From 70c1354a4a96698758a88c032866288f79de6f5a Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Sat, 24 Aug 2024 08:16:37 -0400 Subject: Initial commit --- .../java/jp/plusplus/fbs/render/RendererBook.class | Bin 0 -> 5652 bytes .../java/jp/plusplus/fbs/render/RendererBook.java | 120 +++++++++++++++ .../plusplus/fbs/render/RendererGameOverlay.class | Bin 0 -> 8398 bytes .../plusplus/fbs/render/RendererGameOverlay.java | 159 +++++++++++++++++++ .../plusplus/fbs/render/TessellatorWrapper.class | Bin 0 -> 4379 bytes .../jp/plusplus/fbs/render/TessellatorWrapper.java | 168 +++++++++++++++++++++ 6 files changed, 447 insertions(+) create mode 100644 src/main/java/jp/plusplus/fbs/render/RendererBook.class create mode 100644 src/main/java/jp/plusplus/fbs/render/RendererBook.java create mode 100644 src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.class create mode 100644 src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.java create mode 100644 src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.class create mode 100644 src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java (limited to 'src/main/java/jp/plusplus/fbs/render') diff --git a/src/main/java/jp/plusplus/fbs/render/RendererBook.class b/src/main/java/jp/plusplus/fbs/render/RendererBook.class new file mode 100644 index 0000000..40256a1 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/render/RendererBook.class differ diff --git a/src/main/java/jp/plusplus/fbs/render/RendererBook.java b/src/main/java/jp/plusplus/fbs/render/RendererBook.java new file mode 100644 index 0000000..a0fea62 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/render/RendererBook.java @@ -0,0 +1,120 @@ +package jp.plusplus.fbs.render; + +import jp.plusplus.fbs.FBS; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Timer; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; + +/** + * Createdby pluslus_Fon 2015/06/07. + */ +public class RendererBook implements IItemRenderer { + protected static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + EnumAction act=item.getItemUseAction(); + if(act!= FBS.actionDecode && act!=FBS.actionSpell) return false; + return type==ItemRenderType.EQUIPPED_FIRST_PERSON; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if(type==ItemRenderType.EQUIPPED_FIRST_PERSON) { + EntityPlayer ep = FBS.proxy.getEntityPlayerInstance(); + + if (ep.isUsingItem()) { + float tick = FBS.proxy.getRenderPartialTicks(); + float f1 = 1.0f; + float f2 = ep.prevRotationPitch + (ep.rotationPitch - ep.prevRotationPitch) * tick; + float f5; + float f6; + float f7; + + //--------------------------------- + float f13 = 0.8F; + + f6 = (float) ep.getItemInUseCount() - tick + 1.0F; + f7 = 1.0F - f6 / (float) item.getMaxItemUseDuration(); + float f8 = 1.0F - f7; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + float f9 = 1.0F - f8; + GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float) Math.PI) * 0.1F) * (float) ((double) f7 > 0.2D ? 1 : 0), 0.0F); + GL11.glTranslatef(f9 * 0.6F, -f9 * 0.4F, 0.0F); + GL11.glRotatef(f9 * 45.0f, -f9 * 45.0f, f9 * 45.0f, 0.0F); + GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F); + } + + IIcon icon = item.getIconIndex(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625f); + for (int x = 1; x < item.getItem().getRenderPasses(item.getItemDamage()); x++) { + int k1 = item.getItem().getColorFromItemStack(item, x); + float f10 = (float) (k1 >> 16 & 255) / 255.0F; + float f11 = (float) (k1 >> 8 & 255) / 255.0F; + float f12 = (float) (k1 & 255) / 255.0F; + GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F); + icon = item.getItem().getIcon(item, x); + ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625f); + } + + if (item.hasEffect(0)) { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + Tessellator tessellator=Tessellator.instance; + + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + } +} diff --git a/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.class b/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.class new file mode 100644 index 0000000..611260d Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.class differ diff --git a/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.java b/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.java new file mode 100644 index 0000000..b5a731c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/render/RendererGameOverlay.java @@ -0,0 +1,159 @@ +package jp.plusplus.fbs.render; + +import com.mojang.realmsclient.gui.ChatFormatting; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import jp.plusplus.fbs.FBS; +import jp.plusplus.fbs.RecipeBladeSpice; +import jp.plusplus.fbs.Registry; +import jp.plusplus.fbs.alchemy.characteristic.CharacteristicBase; +import jp.plusplus.fbs.exprop.FBSEntityProperties; +import jp.plusplus.fbs.item.ItemBookSorcery; +import jp.plusplus.fbs.spirit.ISpiritTool; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.client.GuiIngameForge; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import java.util.ArrayList; +import java.util.List; + +/** + * Createdby pluslus_Fon 2015/06/05. + */ +public class RendererGameOverlay { + public static final ResourceLocation icons = new ResourceLocation(FBS.MODID+":textures/gui/san.png"); + public static Minecraft mc = FMLClientHandler.instance().getClient(); + + @SideOnly(Side.CLIENT) + private static int Count = 0; + @SideOnly(Side.CLIENT) + public static boolean renderHUD = false; + @SideOnly(Side.CLIENT) + public static boolean renderAria=false; + + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Pre event) { + if (event.type == RenderGameOverlayEvent.ElementType.FOOD && mc.playerController.shouldDrawHUD()) { + renderHUD = true; + } + if(event.type==RenderGameOverlayEvent.ElementType.HOTBAR) renderAria=true; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Post event) { + int width = event.resolution.getScaledWidth(); + int height = event.resolution.getScaledHeight(); + + if (renderHUD) { + renderHUD = false; + + mc.mcProfiler.startSection(FBS.MODID+"-san"); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(icons); + + int x=width/2-91; + int y=height - GuiIngameForge.left_height; + GuiIngameForge.left_height += 10; + + //san + drawTexturedModalRect(x, y, 0, 0, 24, 8); + if(mc.thePlayer!=null){ + FBSEntityProperties fbsep=FBSEntityProperties.get(mc.thePlayer); + int s=fbsep.getSanity(); + int ms=fbsep.get(mc.thePlayer).getMaxSanity(); + + for(int i=0;i==0 || s>0;i++){ + drawTexturedModalRect(x+24+8*(2-i), y, 8 * (s%10), 8, 8, 8); + s/=10; + } + drawTexturedModalRect(x+24+8*3, y, 24, 0, 8, 8); + for(int i=0;i==0 || ms>0;i++){ + drawTexturedModalRect(x+24+8*(5-i), y, 8 * (ms%10), 8, 8, 8); + ms/=10; + } + } + mc.mcProfiler.endSection(); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(Gui.icons); + } + + if(renderAria){ + renderAria = false; + + mc.mcProfiler.startSection(FBS.MODID+"-aria"); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(icons); + + //詠唱時間の描画 + if(mc.thePlayer.isUsingItem()){ + ItemStack itemStack=mc.thePlayer.getCurrentEquippedItem(); + if(itemStack!=null && itemStack.getItem() instanceof ItemBookSorcery){ + int baseX=width/2-33; + int baseY=height/2+9; + int w=64-(int)(64.f*mc.thePlayer.getItemInUseCount()/itemStack.getMaxItemUseDuration()); + + drawTexturedModalRect(baseX, baseY, 88, 0, 66, 4); + if(w>0) drawTexturedModalRect(baseX+1, baseY+1, 89, 4, w, 2); + } + } + mc.mcProfiler.endSection(); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(Gui.icons); + } + } + + + @SubscribeEvent + public void onItemTooltipEvent(ItemTooltipEvent event) { + ItemStack itemStack = event.itemStack; + List toolTip = event.toolTip; + + //使用することでSAN値が増減するアイテム + Registry.ItemSanity isan=Registry.GetItemSanity(event.itemStack); + if(isan!=null){ + if(isan.max>0) toolTip.add(ChatFormatting.BLUE+StatCollector.translateToLocalFormatted("info.fbs.sanity.add", isan.trial, isan.max)); + else if(isan.max<0) toolTip.add(ChatFormatting.RED+StatCollector.translateToLocalFormatted("info.fbs.sanity.lose", isan.trial, -isan.max)); + } + + //精霊武器 + if(itemStack.getItem() instanceof ISpiritTool){ + + } + + //剣と刃薬 + if(itemStack.getItem() instanceof ItemSword){ + NBTTagCompound nbt=itemStack.getTagCompound(); + if(nbt!=null && nbt.hasKey(RecipeBladeSpice.AMOUNT)){ + toolTip.add("[Blade Spice "+nbt.getInteger(RecipeBladeSpice.AMOUNT)+"]"); + + ArrayList cbs=RecipeBladeSpice.getCharacteristics(itemStack); + for(CharacteristicBase cb : cbs){ + toolTip.add(cb.getNameColor()+"-"+cb.getLocalizedName()+":"+cb.getLocalizedEffectValue()); + } + } + } + } + + public static void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6){ + float zLevel = -90.0F; + + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1)); + tessellator.addVertexWithUV((par1 + par5), (par2 + par6), zLevel, ((par3 + par5) * f), ((par4 + par6) * f1)); + tessellator.addVertexWithUV((par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1)); + tessellator.addVertexWithUV((par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1)); + tessellator.draw(); + } +} diff --git a/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.class b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.class new file mode 100644 index 0000000..fb6a808 Binary files /dev/null and b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.class differ diff --git a/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java new file mode 100644 index 0000000..c9937e4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java @@ -0,0 +1,168 @@ +package jp.plusplus.fbs.render; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; + +/** + * Created by plusplus_F on 2015/06/28. + * なんで!!!てってれーたーには!!!!面描画メソッドが!!!!用意されてないんですか!!!!!1111 + */ +public class TessellatorWrapper { + private static Tessellator tessellator=Tessellator.instance; + private static boolean isBlockRender; + + public static void SetBlockRender(boolean flag){ + isBlockRender=flag; + } + + public static void DrawXPos(float bx, float by, float bz, float my, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16*bz); + float maxU=icon.getInterpolatedU(16*mz); + float minV=icon.getInterpolatedV(16*my); + float maxV=icon.getInterpolatedV(16*by); + + if(isBlockRender){ + tessellator.setNormal(1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.draw(); + } + } + public static void DrawXNeg(float bx, float by, float bz, float my, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bz); + float maxU=icon.getInterpolatedU(16 * mz); + float minV=icon.getInterpolatedV(16 * my); + float maxV=icon.getInterpolatedV(16 * by); + + if(isBlockRender){ + tessellator.setNormal(-1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.draw(); + } + } + + public static void DrawYPos(float bx, float by, float bz, float mx, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * bz); + float maxV=icon.getInterpolatedV(16 * mz); + + if(isBlockRender){ + tessellator.setNormal(0.0f, 1.0f, 0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f, 1.0f, 0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.draw(); + } + } + public static void DrawYNeg(float bx, float by, float bz, float mx, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * bz); + float maxV=icon.getInterpolatedV(16 * mz); + + if(isBlockRender){ + tessellator.setNormal(0.0f,-1.0f,0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f,-1.0f,0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.draw(); + } + } + + public static void DrawZPos(float bx, float by, float bz, float mx, float my, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * by); + float maxV=icon.getInterpolatedV(16 * my); + + if(isBlockRender){ + tessellator.setNormal(0.0f,0.0f,1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f,0.0f,1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.draw(); + } + } + public static void DrawZNeg(float bx, float by, float bz, float mx, float my, IIcon icon){ + float minU=icon.getInterpolatedU(16*bx); + float maxU=icon.getInterpolatedU(16*mx); + float minV=icon.getInterpolatedV(16 * by); + float maxV=icon.getInterpolatedV(16*my); + + if(isBlockRender){ + tessellator.setNormal(0.0f, 0.0f, -1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f, 0.0f, -1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.draw(); + } + } + + public static void DrawAllFaces(float bx, float by, float bz, float mx, float my, float mz, IIcon icon) { + DrawYNeg(bx, by, bz, mx, mz, icon); + DrawYPos(bx, my, bz, mx, mz, icon); + DrawZNeg(bx, by, bz, mx, my, icon); + DrawZPos(bx, by, mz, mx, my, icon); + DrawXNeg(bx, by, bz, my, mz, icon); + DrawXPos(mx, by, bz, my, mz, icon); + } + +} -- cgit v1.2.3