From 586ad18463883cc70b7f3adbcc8c2a774120788d Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Sat, 5 Oct 2024 03:52:55 -0500 Subject: [PATCH] Trophy improvements -Added redstone signal requirement -Hydra moves mouth like the Ender Dragon head -Start yeti trophy (WIP) --- .../TileEntityTFTrophyRenderer.java | 689 ++++++++++-------- .../tileentity/TileEntityTFTrophy.java | 39 +- 2 files changed, 396 insertions(+), 332 deletions(-) diff --git a/src/main/java/twilightforest/client/renderer/tileentity/TileEntityTFTrophyRenderer.java b/src/main/java/twilightforest/client/renderer/tileentity/TileEntityTFTrophyRenderer.java index 11090a5bab..efe1f7b548 100644 --- a/src/main/java/twilightforest/client/renderer/tileentity/TileEntityTFTrophyRenderer.java +++ b/src/main/java/twilightforest/client/renderer/tileentity/TileEntityTFTrophyRenderer.java @@ -11,6 +11,7 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.common.MinecraftForge; @@ -27,381 +28,408 @@ import javax.annotation.Nullable; +// TODO: Alpha yeti trophy public class TileEntityTFTrophyRenderer extends TileEntitySpecialRenderer { + public static class DummyTile extends TileEntityTFTrophy { + } - public static class DummyTile extends TileEntityTFTrophy {} + private final ModelTFHydraHead hydraHeadModel = new ModelTFHydraHead(); + private static final ResourceLocation textureLocHydra = TwilightForestMod.getModelTexture("hydra4.png"); - private final ModelTFHydraHead hydraHeadModel = new ModelTFHydraHead(); - private static final ResourceLocation textureLocHydra = TwilightForestMod.getModelTexture("hydra4.png"); + private final ModelTFNaga nagaHeadModel = new ModelTFNaga(); + private static final ResourceLocation textureLocNaga = TwilightForestMod.getModelTexture("nagahead.png"); - private final ModelTFNaga nagaHeadModel = new ModelTFNaga(); - private static final ResourceLocation textureLocNaga = TwilightForestMod.getModelTexture("nagahead.png"); + private final ModelTFLich lichModel = new ModelTFLich(); + private static final ResourceLocation textureLocLich = TwilightForestMod.getModelTexture("twilightlich64.png"); + + private final ModelTFTowerBoss urGhastModel = new ModelTFTowerBoss(); + private static final ResourceLocation textureLocUrGhast = TwilightForestMod.getModelTexture("towerboss.png"); + + private final ModelTFSnowQueen snowQueenModel = new ModelTFSnowQueen(); + private static final ResourceLocation textureLocSnowQueen = TwilightForestMod.getModelTexture("snowqueen.png"); - private final ModelTFLich lichModel = new ModelTFLich(); - private static final ResourceLocation textureLocLich = TwilightForestMod.getModelTexture("twilightlich64.png"); - - private final ModelTFTowerBoss urGhastModel = new ModelTFTowerBoss(); - private static final ResourceLocation textureLocUrGhast = TwilightForestMod.getModelTexture("towerboss.png"); + private final ModelTFMinoshroom minoshroomModel = new ModelTFMinoshroom(); + private static final ResourceLocation textureLocMinoshroom = TwilightForestMod.getModelTexture("minoshroomtaur.png"); - private final ModelTFSnowQueen snowQueenModel = new ModelTFSnowQueen(); - private static final ResourceLocation textureLocSnowQueen = TwilightForestMod.getModelTexture("snowqueen.png"); + private final ModelTFKnightPhantom2 knightPhantomModel = new ModelTFKnightPhantom2(); + private static final ResourceLocation textureLocKnightPhantom = TwilightForestMod.getModelTexture("phantomskeleton.png"); + private final ModelTFPhantomArmor knightPhantomArmorModel = new ModelTFPhantomArmor(EntityEquipmentSlot.HEAD, 0.5F); + private static final ResourceLocation textureLocKnightPhantomArmor = new ResourceLocation(TwilightForestMod.ARMOR_DIR + "phantom_1.png"); + + private final ModelTFQuestRam questRamModel = new ModelTFQuestRam(); + private static final ResourceLocation textureLocQuestRam = TwilightForestMod.getModelTexture("questram.png"); + private static final ResourceLocation textureLocQuestRamLines = TwilightForestMod.getModelTexture("questram_lines.png"); + + private final ModelTFYetiAlpha eliteYetiModel = new ModelTFYetiAlpha(); + private static final ResourceLocation textureLocEliteYeti = TwilightForestMod.getModelTexture("yetialpha.png"); + + /*private final ModelTFKobold finalKoboldModel = new ModelTFKobold(); + private static final ResourceLocation textureLocFinalKobold = TwilightForestMod.getModelTexture("kobold.png");*/ + + private final ModelResourceLocation itemModelLocation; + + public TileEntityTFTrophyRenderer() { + this.itemModelLocation = null; + } + + public TileEntityTFTrophyRenderer(ModelResourceLocation itemModelLocation) { + this.itemModelLocation = itemModelLocation; + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onModelBake(ModelBakeEvent event) { + event.getModelRegistry().putObject(itemModelLocation, new BakedModel()); + } + + private class BakedModel extends BuiltInItemModel { + + BakedModel() { + super("minecraft:blocks/soul_sand"); + } + + @Override + protected void setItemStack(ItemStack stack) { + TileEntityTFTrophyRenderer.this.stack = stack; + } + + @Override + protected void setTransform(ItemCameraTransforms.TransformType transform) { + TileEntityTFTrophyRenderer.this.transform = transform; + } + } + + private ItemStack stack = ItemStack.EMPTY; + private ItemCameraTransforms.TransformType transform = ItemCameraTransforms.TransformType.NONE; + + @Override + public void render(@Nullable TileEntityTFTrophy trophy, double x, double y, double z, float partialTime, int destroyStage, float alpha) { + GlStateManager.pushMatrix(); + GlStateManager.disableCull(); + + if (trophy == null) { + if (transform == ItemCameraTransforms.TransformType.GUI) { + String modelName = BossVariant.getVariant(stack.getMetadata()).getTrophyType().getModelName(); + ModelResourceLocation trophyModelLocation = new ModelResourceLocation(TwilightForestMod.ID + ":" + modelName, "inventory"); + IBakedModel trophyModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(trophyModelLocation); + + GlStateManager.disableLighting(); + GlStateManager.translate(0.5F, 0.5F, -1.5F); + Minecraft.getMinecraft().getRenderItem().renderItem(stack, ForgeHooksClient.handleCameraTransforms(trophyModel, transform, false)); + GlStateManager.enableLighting(); + GlStateManager.translate(-0.5F, 0.0F, 1.5F); + + //if (variant == BossVariant.QUEST_RAM) + // GlStateManager.translate(0.0F,0.0625F,0.0F); + + GlStateManager.rotate(30, 1F, 0F, 0F); + + } else if (transform == ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND + || transform == ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) { + GlStateManager.scale(0.5F, 0.5F, 0.5F); + GlStateManager.rotate(45, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(45, 0.0F, 1.0F, 0.0F); + GlStateManager.translate(0.40625F, 1.171875F, 0.0F); + + } else if (transform == ItemCameraTransforms.TransformType.GROUND) { + GlStateManager.translate(0.25F, 0.3F, 0.25F); + GlStateManager.scale(0.5F, 0.5F, 0.5F); + + } else if (transform == ItemCameraTransforms.TransformType.HEAD) { + if (BossVariant.getVariant(stack.getMetadata()) == BossVariant.QUEST_RAM) { + GlStateManager.scale(3F, 3F, 3F); + GlStateManager.translate(-0.33F, -0.13F, -0.33F); + } else { + GlStateManager.scale(2.0F, 2.0F, 2.0F); + GlStateManager.translate(-0.25F, 0.0F, -0.25F); + } + } + } + + //int meta = trophy != null ? trophy.getBlockMetadata() & 7 : stack.getMetadata() & 7; + + float rotation = trophy != null ? (float) (trophy.getSkullRotation() * 360) / 16.0F : 0.0F; + boolean onGround = true; + + // wall mounted? + if (trophy != null && trophy.getBlockMetadata() != 1) { + switch (trophy.getBlockMetadata() & 7) { + case 2: + onGround = false; + break; + case 3: + onGround = false; + rotation = 180.0F; + break; + case 4: + onGround = false; + rotation = 270.0F; + break; + case 5: + default: + onGround = false; + rotation = 90.0F; + } + } else if (trophy == null && transform == ItemCameraTransforms.TransformType.GUI) { + rotation = TFConfig.rotateTrophyHeadsGui ? TFClientEvents.rotationTicker : 135; + } + + GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); + + switch (BossVariant.getVariant(trophy != null ? trophy.getSkullType() : stack.getMetadata())) { + case HYDRA: + if (trophy == null) { + GlStateManager.translate(0.0F, -0.25F, transform == ItemCameraTransforms.TransformType.HEAD ? -0.125F : 0.0F); + } + renderHydraHead(trophy, rotation, onGround && trophy != null, partialTime); + break; + case NAGA: + renderNagaHead(rotation, onGround); + break; + case LICH: + renderLichHead(rotation, onGround); + break; + case UR_GHAST: + if (trophy == null) GlStateManager.translate(0.0F, -0.5F, 0.0F); + renderUrGhastHead(trophy, rotation, onGround, partialTime); + break; + case SNOW_QUEEN: + renderSnowQueenHead(rotation, onGround); + break; + case MINOSHROOM: + renderMinoshroomHead(rotation, onGround); + break; + case KNIGHT_PHANTOM: + renderKnightPhantomHead(rotation, onGround); + break; + case QUEST_RAM: + renderQuestRamHead(rotation, onGround); + break; + case FINAL_BOSS: + renderWroughtnautHead(rotation, onGround); + break; + case ELITE_YETI: + renderEliteYetiHead(rotation, onGround); + break; + default: + break; + } + + GlStateManager.enableCull(); + GlStateManager.popMatrix(); + } + + /** + * Render a hydra head + */ + private void renderHydraHead(@Nullable TileEntityTFTrophy trophy, float rotation, boolean onGround, float partialTicks) { + GlStateManager.scale(0.25f, 0.25f, 0.25f); + + this.bindTexture(textureLocHydra); + + GlStateManager.scale(1f, -1f, -1f); + + // we seem to be getting a 180-degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); + + GlStateManager.translate(0.0F, 1.0F, 1.5F); + + // open mouth + if (onGround) { + hydraHeadModel.openMouthForTrophy(0.0F); + } else if (trophy != null) { + float ageInTicks = trophy.ticksExisted; + + if (trophy.shouldAnimate()) { + ageInTicks += partialTicks; + } - private final ModelTFMinoshroom minoshroomModel = new ModelTFMinoshroom(); - private static final ResourceLocation textureLocMinoshroom = TwilightForestMod.getModelTexture("minoshroomtaur.png"); + hydraHeadModel.openMouthForTrophy(MathHelper.sin(ageInTicks) / 4 + 0.25F); + } - private final ModelTFKnightPhantom2 knightPhantomModel = new ModelTFKnightPhantom2(); - private static final ResourceLocation textureLocKnightPhantom = TwilightForestMod.getModelTexture("phantomskeleton.png"); - private final ModelTFPhantomArmor knightPhantomArmorModel = new ModelTFPhantomArmor(EntityEquipmentSlot.HEAD, 0.5F); - private static final ResourceLocation textureLocKnightPhantomArmor = new ResourceLocation(TwilightForestMod.ARMOR_DIR + "phantom_1.png"); - - private final ModelTFQuestRam questRamModel = new ModelTFQuestRam(); - private static final ResourceLocation textureLocQuestRam = TwilightForestMod.getModelTexture("questram.png"); - private static final ResourceLocation textureLocQuestRamLines = TwilightForestMod.getModelTexture("questram_lines.png"); - - private final ModelTFKobold finalKoboldModel = new ModelTFKobold(); - private static final ResourceLocation textureLocFinalKobold = TwilightForestMod.getModelTexture("kobold.png"); - - private final ModelResourceLocation itemModelLocation; - - public TileEntityTFTrophyRenderer() { - this.itemModelLocation = null; - } - - public TileEntityTFTrophyRenderer(ModelResourceLocation itemModelLocation) { - this.itemModelLocation = itemModelLocation; - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onModelBake(ModelBakeEvent event) { - event.getModelRegistry().putObject(itemModelLocation, new BakedModel()); - } - - private class BakedModel extends BuiltInItemModel { - - BakedModel() { - super("minecraft:blocks/soul_sand"); - } - - @Override - protected void setItemStack(ItemStack stack) { - TileEntityTFTrophyRenderer.this.stack = stack; - } - - @Override - protected void setTransform(ItemCameraTransforms.TransformType transform) { - TileEntityTFTrophyRenderer.this.transform = transform; - } - } - - private ItemStack stack = ItemStack.EMPTY; - private ItemCameraTransforms.TransformType transform = ItemCameraTransforms.TransformType.NONE; - - @Override - public void render(@Nullable TileEntityTFTrophy trophy, double x, double y, double z, float partialTime, int destroyStage, float alpha) { - GlStateManager.pushMatrix(); - GlStateManager.disableCull(); - - if (trophy == null) { - if (transform == ItemCameraTransforms.TransformType.GUI) { - String modelName = BossVariant.getVariant(stack.getMetadata()).getTrophyType().getModelName(); - ModelResourceLocation trophyModelLocation = new ModelResourceLocation(TwilightForestMod.ID + ":" + modelName, "inventory"); - IBakedModel trophyModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(trophyModelLocation); - - GlStateManager.disableLighting(); - GlStateManager.translate(0.5F, 0.5F, -1.5F); - Minecraft.getMinecraft().getRenderItem().renderItem(stack, ForgeHooksClient.handleCameraTransforms(trophyModel, transform, false)); - GlStateManager.enableLighting(); - GlStateManager.translate(-0.5F, 0.0F, 1.5F); - - //if (variant == BossVariant.QUEST_RAM) - // GlStateManager.translate(0.0F,0.0625F,0.0F); - - GlStateManager.rotate(30, 1F, 0F, 0F); - - } else if (transform == ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND - || transform == ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) { - GlStateManager.scale(0.5F, 0.5F, 0.5F); - GlStateManager.rotate(45, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate(45, 0.0F, 1.0F, 0.0F); - GlStateManager.translate(0.40625F, 1.171875F, 0.0F); - - } else if (transform == ItemCameraTransforms.TransformType.GROUND) { - GlStateManager.translate(0.25F, 0.3F, 0.25F); - GlStateManager.scale(0.5F, 0.5F, 0.5F); - - } else if (transform == ItemCameraTransforms.TransformType.HEAD) { - if (BossVariant.getVariant(stack.getMetadata()) == BossVariant.QUEST_RAM) { - GlStateManager.scale(3F, 3F, 3F); - GlStateManager.translate(-0.33F, -0.13F, -0.33F); - } else { - GlStateManager.scale(2.0F, 2.0F, 2.0F); - GlStateManager.translate(-0.25F, 0.0F, -0.25F); - } - } - } - - //int meta = trophy != null ? trophy.getBlockMetadata() & 7 : stack.getMetadata() & 7; - - float rotation = trophy != null ? (float) (trophy.getSkullRotation() * 360) / 16.0F : 0.0F; - boolean onGround = true; - - // wall mounted? - if (trophy != null && trophy.getBlockMetadata() != 1) { - switch (trophy.getBlockMetadata() & 7) { - case 2: - onGround = false; - break; - case 3: - onGround = false; - rotation = 180.0F; - break; - case 4: - onGround = false; - rotation = 270.0F; - break; - case 5: - default: - onGround = false; - rotation = 90.0F; - } - } else if (trophy == null && transform == ItemCameraTransforms.TransformType.GUI) { - rotation = TFConfig.rotateTrophyHeadsGui ? TFClientEvents.rotationTicker : 135; - } - - GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); - - switch (BossVariant.getVariant(trophy != null ? trophy.getSkullType() : stack.getMetadata())) { - case HYDRA: - if (trophy == null) { - GlStateManager.translate(0.0F, -0.25F, transform == ItemCameraTransforms.TransformType.HEAD ? -0.125F : 0.0F); - } - renderHydraHead(rotation, onGround && trophy != null); - break; - case NAGA: - renderNagaHead(rotation, onGround); - break; - case LICH: - renderLichHead(rotation, onGround); - break; - case UR_GHAST: - if (trophy == null) GlStateManager.translate(0.0F, -0.5F, 0.0F); - renderUrGhastHead(trophy, rotation, onGround, partialTime); - break; - case SNOW_QUEEN: - renderSnowQueenHead(rotation, onGround); - break; - case MINOSHROOM: - renderMinoshroomHead(rotation, onGround); - break; - case KNIGHT_PHANTOM: - renderKnightPhantomHead(rotation, onGround); - break; - case QUEST_RAM: - renderQuestRamHead(rotation, onGround); - break; - case FINAL_BOSS: - renderWroughtnautHead(rotation, onGround); - break; - default: - break; - } - - GlStateManager.enableCull(); - GlStateManager.popMatrix(); - } - - /** - * Render a hydra head - */ - private void renderHydraHead(float rotation, boolean onGround) { - GlStateManager.scale(0.25f, 0.25f, 0.25f); - - this.bindTexture(textureLocHydra); + // render the hydra head + hydraHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); + } - GlStateManager.scale(1f, -1f, -1f); + private void renderNagaHead(float rotation, boolean onGround) { + GlStateManager.translate(0, -0.125F, 0); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + GlStateManager.scale(0.25f, 0.25f, 0.25f); - GlStateManager.translate(0, onGround ? 1F : -0F, 1.5F); + this.bindTexture(textureLocNaga); - // open mouth? - hydraHeadModel.openMouthForTrophy(onGround ? 0F : 0.25F); + GlStateManager.scale(1f, -1f, -1f); - // render the hydra head - hydraHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); - } + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - private void renderNagaHead(float rotation, boolean onGround) { - GlStateManager.translate(0, -0.125F, 0); + GlStateManager.translate(0, onGround ? 1F : -0F, onGround ? 0F : 1F); - GlStateManager.scale(0.25f, 0.25f, 0.25f); + // render the naga head + nagaHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); + } - this.bindTexture(textureLocNaga); - GlStateManager.scale(1f, -1f, -1f); + private void renderLichHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + //GlStateManager.scale(0.5f, 0.5f, 0.5f); - GlStateManager.translate(0, onGround ? 1F : -0F, onGround ? 0F : 1F); + this.bindTexture(textureLocLich); - // render the naga head - nagaHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); - } + GlStateManager.scale(1f, -1f, -1f); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - private void renderLichHead(float rotation, boolean onGround) { - GlStateManager.translate(0, 1, 0); + GlStateManager.translate(0, onGround ? 1.75F : 1.5F, onGround ? 0F : 0.24F); - //GlStateManager.scale(0.5f, 0.5f, 0.5f); + // render the lich head + lichModel.bipedHead.render(0.0625F); + lichModel.bipedHeadwear.render(0.0625F); + } - this.bindTexture(textureLocLich); - GlStateManager.scale(1f, -1f, -1f); + private void renderUrGhastHead(@Nullable TileEntityTFTrophy trophy, float rotation, boolean onGround, float partialTime) { + GlStateManager.translate(0, 1, 0); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + GlStateManager.scale(0.5f, 0.5f, 0.5f); - GlStateManager.translate(0, onGround ? 1.75F : 1.5F, onGround ? 0F : 0.24F); + this.bindTexture(textureLocUrGhast); - // render the lich head - lichModel.bipedHead.render(0.0625F); - lichModel.bipedHeadwear.render(0.0625F); - } + GlStateManager.scale(1f, -1f, -1f); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - private void renderUrGhastHead(@Nullable TileEntityTFTrophy trophy, float rotation, boolean onGround, float partialTime) { - GlStateManager.translate(0, 1, 0); + GlStateManager.translate(0, 1F, 0F); - GlStateManager.scale(0.5f, 0.5f, 0.5f); + // render the head + float ageInTicks = 0F; - this.bindTexture(textureLocUrGhast); + if (trophy != null) { + ageInTicks = trophy.ticksExisted; - GlStateManager.scale(1f, -1f, -1f); + if (trophy.shouldAnimate()) { + ageInTicks += partialTime; + } + } - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + urGhastModel.render(null, 0.0F, 0, ageInTicks, 0, 0.0F, 0.0625F); + } - GlStateManager.translate(0, 1F, 0F); + private void renderSnowQueenHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); - // render the head - urGhastModel.render(null, 0.0F, 0, trophy != null ? trophy.ticksExisted + partialTime : TFClientEvents.sineTicker + partialTime, 0, 0.0F, 0.0625F); - } + //GlStateManager.scale(0.5f, 0.5f, 0.5f); - private void renderSnowQueenHead(float rotation, boolean onGround) { - GlStateManager.translate(0, 1, 0); + this.bindTexture(textureLocSnowQueen); - //GlStateManager.scale(0.5f, 0.5f, 0.5f); + GlStateManager.scale(1f, -1f, -1f); - this.bindTexture(textureLocSnowQueen); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - GlStateManager.scale(1f, -1f, -1f); + GlStateManager.translate(0, onGround ? 1.5F : 1.25F, onGround ? 0F : 0.24F); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + // render the head + snowQueenModel.bipedHead.render(0.0625F); + snowQueenModel.bipedHeadwear.render(0.0625F); + } - GlStateManager.translate(0, onGround ? 1.5F : 1.25F, onGround ? 0F : 0.24F); + private void renderMinoshroomHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); - // render the head - snowQueenModel.bipedHead.render(0.0625F); - snowQueenModel.bipedHeadwear.render(0.0625F); - } + //GlStateManager.scale(0.5f, 0.5f, 0.5f); - private void renderMinoshroomHead(float rotation, boolean onGround) { - GlStateManager.translate(0, 1, 0); + this.bindTexture(textureLocMinoshroom); - //GlStateManager.scale(0.5f, 0.5f, 0.5f); + GlStateManager.scale(1f, -1f, -1f); - this.bindTexture(textureLocMinoshroom); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - GlStateManager.scale(1f, -1f, -1f); + GlStateManager.translate(0, onGround ? 1.875F : 1.625F, onGround ? 0.5625F : 0.8125F); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + // render the head + minoshroomModel.bipedHead.render(0.0625F); + } - GlStateManager.translate(0, onGround ? 1.875F : 1.625F, onGround ? 0.5625F : 0.8125F); + private void renderKnightPhantomHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); - // render the head - minoshroomModel.bipedHead.render(0.0625F); - } + GlStateManager.scale(1f, -1f, -1f); - private void renderKnightPhantomHead(float rotation, boolean onGround) { - GlStateManager.translate(0, 1, 0); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - GlStateManager.scale(1f, -1f, -1f); + GlStateManager.translate(0, onGround ? 1.5F : 1.25F, onGround ? 0.0F : 0.25F); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - GlStateManager.translate(0, onGround ? 1.5F : 1.25F, onGround ? 0.0F : 0.25F); + // render the head + this.bindTexture(textureLocKnightPhantomArmor); + knightPhantomArmorModel.bipedHead.render(0.0625F); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + GlStateManager.color(1.0F, 1.0F, 1.0F, 0.75F); - // render the head - this.bindTexture(textureLocKnightPhantomArmor); - knightPhantomArmorModel.bipedHead.render(0.0625F); + this.bindTexture(textureLocKnightPhantom); + knightPhantomModel.bipedHead.render(0.0625F); + } - GlStateManager.color(1.0F, 1.0F, 1.0F, 0.75F); + private void renderQuestRamHead(float rotation, boolean onGround) { + if (transform == ItemCameraTransforms.TransformType.GUI) + GlStateManager.scale(0.55f, 0.55f, 0.55f); + else if (stack.isEmpty()) + GlStateManager.scale(0.65f, 0.65f, 0.65f); + else + GlStateManager.scale(0.5f, 0.5f, 0.5f); - this.bindTexture(textureLocKnightPhantom); - knightPhantomModel.bipedHead.render(0.0625F); - } + if (transform == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND + || transform == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND) { + GlStateManager.translate(0.0F, 0.5F, 0.0F); + } - private void renderQuestRamHead(float rotation, boolean onGround) { - if (transform == ItemCameraTransforms.TransformType.GUI) - GlStateManager.scale(0.55f, 0.55f, 0.55f); - else if (stack.isEmpty()) - GlStateManager.scale(0.65f, 0.65f, 0.65f); - else - GlStateManager.scale(0.5f, 0.5f, 0.5f); + this.bindTexture(textureLocQuestRam); - if (transform == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND - || transform == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND) { - GlStateManager.translate(0.0F, 0.5F, 0.0F); - } + GlStateManager.scale(1f, -1f, -1f); - this.bindTexture(textureLocQuestRam); + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - GlStateManager.scale(1f, -1f, -1f); + GlStateManager.translate(0F, onGround ? 1.30F : 1.03F, onGround ? 0.765625F : 1.085F); - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + // render the head + questRamModel.head.render(0.0625F); - GlStateManager.translate(0F, onGround ? 1.30F : 1.03F, onGround ? 0.765625F : 1.085F); + GlStateManager.disableLighting(); + this.bindTexture(textureLocQuestRamLines); + float var4 = 1.0F; + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GlStateManager.scale(1.025f, 1.025f, 1.025f); + char var5 = 61680; + int var6 = var5 % 65536; + int var7 = var5 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) var6, (float) var7); + GlStateManager.color(1.0F, 1.0F, 1.0F, var4); + questRamModel.head.render(0.0625F); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + GlStateManager.enableLighting(); + } - // render the head - questRamModel.head.render(0.0625F); - - GlStateManager.disableLighting(); - this.bindTexture(textureLocQuestRamLines); - float var4 = 1.0F; - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - GlStateManager.scale(1.025f, 1.025f, 1.025f); - char var5 = 61680; - int var6 = var5 % 65536; - int var7 = var5 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) var6, (float) var7); - GlStateManager.color(1.0F, 1.0F, 1.0F, var4); - questRamModel.head.render(0.0625F); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - GlStateManager.enableLighting(); - } - - private void renderFinalKoboldHead(float rotation, boolean onGround) { + /*private void renderFinalKoboldHead(float rotation, boolean onGround) { GlStateManager.translate(0, 1, 0); this.bindTexture(textureLocFinalKobold); @@ -416,22 +444,39 @@ private void renderFinalKoboldHead(float rotation, boolean onGround) { // render the head finalKoboldModel.bipedHead.render(0.0625F); - } + }*/ - private void renderWroughtnautHead(float rotation, boolean onGround) { - GlStateManager.translate(0, 1, 0); + private void renderWroughtnautHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); - this.bindTexture(new ResourceLocation("mowziesmobs", "textures/entity/wroughtnaut.png")); + this.bindTexture(new ResourceLocation("mowziesmobs", "textures/entity/wroughtnaut.png")); - GlStateManager.scale(1f, -1f, -1f); + GlStateManager.scale(1f, -1f, -1f); - // we seem to be getting a 180 degree rotation here - GlStateManager.rotate(rotation, 0F, 1F, 0F); - GlStateManager.rotate(180F, 0F, 1F, 0F); + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); - GlStateManager.translate(0, onGround ? 1.35F : 1.25F, onGround ? 0F : 0.3F); + GlStateManager.translate(0, onGround ? 1.35F : 1.25F, onGround ? 0F : 0.3F); - // render the head - new ModelWroughtnaut().head.render(0.0625F); - } + // render the head + new ModelWroughtnaut().head.render(0.0625F); + } + + private void renderEliteYetiHead(float rotation, boolean onGround) { + GlStateManager.translate(0, 1, 0); + + this.bindTexture(textureLocEliteYeti); + + GlStateManager.scale(1f, -1f, -1f); + + // we seem to be getting a 180 degree rotation here + GlStateManager.rotate(rotation, 0F, 1F, 0F); + GlStateManager.rotate(180F, 0F, 1F, 0F); + + GlStateManager.translate(0, onGround ? 1.35F : 1.25F, onGround ? 0F : 0.3F); + + // render the head + eliteYetiModel.bipedHead.render(0.0625F); + } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFTrophy.java b/src/main/java/twilightforest/tileentity/TileEntityTFTrophy.java index 6d6541a39b..2fa93d5818 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFTrophy.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFTrophy.java @@ -1,22 +1,41 @@ package twilightforest.tileentity; +import javax.annotation.ParametersAreNonnullByDefault; + import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import twilightforest.enums.BossVariant; public class TileEntityTFTrophy extends TileEntitySkull { - public int ticksExisted; + public int ticksExisted; + private boolean shouldAnimate; + + @Override + public void update() { + super.update(); + + if (this.world.isRemote) { + BossVariant variant = BossVariant.getVariant(this.getSkullType()); + + if (variant == BossVariant.HYDRA || variant == BossVariant.UR_GHAST) { + if (this.world.isBlockPowered(this.getPos())) { + this.shouldAnimate = true; + this.ticksExisted++; + } else this.shouldAnimate = false; + } + } + } - @Override - public void update() { - super.update(); - this.ticksExisted++; - } + public boolean shouldAnimate() { + return shouldAnimate; + } - @Override - public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { - return oldState.getBlock() != newState.getBlock(); - } + @Override + @ParametersAreNonnullByDefault + public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { + return oldState.getBlock() != newState.getBlock(); + } }