From d1d851f8ede2008eaa28b89f36a36774d4d02d96 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:42:22 +0200 Subject: [PATCH] Adjust altar rendering --- .../emt/harkenscythe/blocks/HSBloodAltar.java | 14 ++++---- .../emt/harkenscythe/blocks/HSSoulAltar.java | 14 ++++---- .../client/renderers/RenderHSBloodAltar.java | 19 +++++++---- .../client/renderers/RenderHSSoulAltar.java | 19 +++++++---- .../mod/emt/harkenscythe/init/HSRegistry.java | 2 -- .../tileentities/HSTileEntityBloodAltar.java | 33 +++++++++++-------- .../tileentities/HSTileEntitySoulAltar.java | 33 +++++++++++-------- 7 files changed, 80 insertions(+), 54 deletions(-) diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java index 1a269f1..c13f631 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java @@ -63,10 +63,10 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En { if (altar.isValidRecipe()) { - Item item = altar.getItemStack().getItem(); - int requiredBloods = HSAltarRecipes.getRequiredBlood(altar.getItemStack().getItem()); + Item item = altar.getInputStack().getItem(); + int requiredBloods = HSAltarRecipes.getRequiredBlood(altar.getInputStack().getItem()); altar.decreaseCrucibleLevel(requiredBloods / 10); - altar.getItemStack().shrink(1); + altar.getInputStack().shrink(1); if (!player.world.isRemote) player.world.spawnEntity(new EntityItem(player.world, altar.getPos().getX() + 0.5D, altar.getPos().getY() + 1.5D, altar.getPos().getZ() + 0.5D, new ItemStack(HSAltarRecipes.getOutputBlood(item)))); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), HSSoundEvents.BLOCK_BLOOD_ALTAR_ENCHANT, SoundCategory.BLOCKS, 0.8F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); @@ -81,10 +81,10 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En } else if (!heldItem.isEmpty()) { - ItemStack altarItem = altar.getItemStack(); + ItemStack altarItem = altar.getInputStack(); if (altarItem.isEmpty()) { - altar.setItemStack(heldItem.splitStack(1)); + altar.setInputStack(heldItem.splitStack(1)); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); return true; } @@ -98,12 +98,12 @@ else if (altarItem.getMaxStackSize() > altarItem.getCount() && ItemStack.areItem } else { - ItemStack itemStack = altar.getItemStack(); + ItemStack itemStack = altar.getInputStack(); if (!itemStack.isEmpty()) { player.addItemStackToInventory(itemStack); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); - altar.setItemStack(ItemStack.EMPTY); + altar.setInputStack(ItemStack.EMPTY); return true; } } diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java index 37f88da..b5989da 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java @@ -63,10 +63,10 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En { if (altar.isValidRecipe()) { - Item item = altar.getItemStack().getItem(); - int requiredSouls = HSAltarRecipes.getRequiredSouls(altar.getItemStack().getItem()); + Item item = altar.getInputStack().getItem(); + int requiredSouls = HSAltarRecipes.getRequiredSouls(altar.getInputStack().getItem()); altar.decreaseCrucibleLevel(requiredSouls / 10); - altar.getItemStack().shrink(1); + altar.getInputStack().shrink(1); if (!player.world.isRemote) player.world.spawnEntity(new EntityItem(player.world, altar.getPos().getX() + 0.5D, altar.getPos().getY() + 1.5D, altar.getPos().getZ() + 0.5D, new ItemStack(HSAltarRecipes.getOutputSoul(item)))); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), HSSoundEvents.BLOCK_SOUL_ALTAR_ENCHANT, SoundCategory.BLOCKS, 0.8F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); @@ -81,10 +81,10 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En } else if (!heldItem.isEmpty()) { - ItemStack altarItem = altar.getItemStack(); + ItemStack altarItem = altar.getInputStack(); if (altarItem.isEmpty()) { - altar.setItemStack(heldItem.splitStack(1)); + altar.setInputStack(heldItem.splitStack(1)); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); return true; } @@ -98,12 +98,12 @@ else if (altarItem.getMaxStackSize() > altarItem.getCount() && ItemStack.areItem } else { - ItemStack itemStack = altar.getItemStack(); + ItemStack itemStack = altar.getInputStack(); if (!itemStack.isEmpty()) { player.addItemStackToInventory(itemStack); player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); - altar.setItemStack(ItemStack.EMPTY); + altar.setInputStack(ItemStack.EMPTY); return true; } } diff --git a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSBloodAltar.java b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSBloodAltar.java index 6e15a3e..59c177c 100644 --- a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSBloodAltar.java +++ b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSBloodAltar.java @@ -41,14 +41,23 @@ public void render(HSTileEntityBloodAltar te, double x, double y, double z, floa RenderHelper.enableStandardItemLighting(); GlStateManager.pushAttrib(); - ItemStack stack = te.getItemStack(); + ItemStack stack = te.getInputStack(); if (!stack.isEmpty()) { + // Display input item GlStateManager.pushMatrix(); GlStateManager.translate(0.25, 1.75, 0.25); GlStateManager.rotate(timeD, 0, 1, 0); + GlStateManager.scale(0.8, 0.8, 0.8); renderItem.renderItem(stack, ItemCameraTransforms.TransformType.FIXED); GlStateManager.popMatrix(); + + // Display blood essence + GlStateManager.pushMatrix(); + GlStateManager.translate(0.3, 0.25, -0.25); + GlStateManager.scale(0.5, 0.5, 0.5); + renderItem.renderItem(te.getEssenceStack(), ItemCameraTransforms.TransformType.FIXED); + GlStateManager.popMatrix(); } RenderHelper.disableStandardItemLighting(); @@ -110,11 +119,9 @@ public void render(HSTileEntityBloodAltar te, double x, double y, double z, floa int textColor = te.isValidRecipe() ? 0x00FF00 : 0xFFFFFF; // Display blood count - String bloodText = "Blood: " + te.getBloodCount(); + String bloodText = "x " + te.getBloodCount(); GlStateManager.pushMatrix(); - GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); + GlStateManager.translate(x + 0.5, y + 0.25, z - 0.01); GlStateManager.scale(-0.025f, -0.025f, 0.025f); GlStateManager.disableLighting(); Minecraft.getMinecraft().fontRenderer.drawString(bloodText, -Minecraft.getMinecraft().fontRenderer.getStringWidth(bloodText) / 2, 0, textColor); @@ -124,7 +131,7 @@ public void render(HSTileEntityBloodAltar te, double x, double y, double z, floa // Display input stack count String stackText = String.valueOf(stack.getCount()); GlStateManager.pushMatrix(); - GlStateManager.translate(x + 0.5, y + 2.7, z + 0.5); + GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); GlStateManager.scale(-0.025f, -0.025f, 0.025f); diff --git a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoulAltar.java b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoulAltar.java index 74e9148..fc65e84 100644 --- a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoulAltar.java +++ b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoulAltar.java @@ -41,14 +41,23 @@ public void render(HSTileEntitySoulAltar te, double x, double y, double z, float RenderHelper.enableStandardItemLighting(); GlStateManager.pushAttrib(); - ItemStack stack = te.getItemStack(); + ItemStack stack = te.getInputStack(); if (!stack.isEmpty()) { + // Display input item GlStateManager.pushMatrix(); GlStateManager.translate(0.25, 1.75, 0.25); GlStateManager.rotate(timeD, 0, 1, 0); + GlStateManager.scale(0.8, 0.8, 0.8); renderItem.renderItem(stack, ItemCameraTransforms.TransformType.FIXED); GlStateManager.popMatrix(); + + // Display soul essence + GlStateManager.pushMatrix(); + GlStateManager.translate(0.3, 0.25, -0.25); + GlStateManager.scale(0.5, 0.5, 0.5); + renderItem.renderItem(te.getEssenceStack(), ItemCameraTransforms.TransformType.FIXED); + GlStateManager.popMatrix(); } RenderHelper.disableStandardItemLighting(); @@ -110,11 +119,9 @@ public void render(HSTileEntitySoulAltar te, double x, double y, double z, float int textColor = te.isValidRecipe() ? 0x00FF00 : 0xFFFFFF; // Display soul count - String soulsText = "Souls: " + te.getSoulCount(); + String soulsText = "x " + te.getSoulCount(); GlStateManager.pushMatrix(); - GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); + GlStateManager.translate(x + 0.5, y + 0.25, z - 0.01); GlStateManager.scale(-0.025f, -0.025f, 0.025f); GlStateManager.disableLighting(); Minecraft.getMinecraft().fontRenderer.drawString(soulsText, -Minecraft.getMinecraft().fontRenderer.getStringWidth(soulsText) / 2, 0, textColor); @@ -124,7 +131,7 @@ public void render(HSTileEntitySoulAltar te, double x, double y, double z, float // Display input stack count String stackText = String.valueOf(stack.getCount()); GlStateManager.pushMatrix(); - GlStateManager.translate(x + 0.5, y + 2.7, z + 0.5); + GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); GlStateManager.scale(-0.025f, -0.025f, 0.025f); diff --git a/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java b/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java index 4060067..a47aaeb 100644 --- a/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java +++ b/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java @@ -14,10 +14,8 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.init.PotionTypes; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionUtils; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; diff --git a/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntityBloodAltar.java b/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntityBloodAltar.java index ebf5bf4..e3ba848 100644 --- a/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntityBloodAltar.java +++ b/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntityBloodAltar.java @@ -5,6 +5,7 @@ import java.util.Random; import mod.emt.harkenscythe.blocks.HSBloodCrucible; import mod.emt.harkenscythe.init.HSAltarRecipes; +import mod.emt.harkenscythe.init.HSItems; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -22,6 +23,7 @@ public class HSTileEntityBloodAltar extends TileEntity implements ITickable { private static final Random rand = new Random(); private static final int RADIUS = 4; + private final ItemStack essenceStack = new ItemStack(HSItems.blood_essence); public int tickCount; public float pageFlip; public float pageFlipPrev; @@ -34,7 +36,12 @@ public class HSTileEntityBloodAltar extends TileEntity implements ITickable public float tRot; private int bloodCount; private boolean validRecipe; - private ItemStack itemStack = ItemStack.EMPTY; + private ItemStack inputStack = ItemStack.EMPTY; + + public ItemStack getEssenceStack() + { + return essenceStack; + } public int getBloodCount() { @@ -46,25 +53,25 @@ public boolean isValidRecipe() return validRecipe; } - public ItemStack getItemStack() + public ItemStack getInputStack() { - return itemStack; + return inputStack; } - public void setItemStack(ItemStack itemStack) + public void setInputStack(ItemStack inputStack) { - this.itemStack = itemStack; + this.inputStack = inputStack; markDirty(); } public void dropItem() { - if (!world.isRemote && !itemStack.isEmpty()) + if (!world.isRemote && !inputStack.isEmpty()) { BlockPos pos = getPos(); - EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), itemStack); + EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), inputStack); world.spawnEntity(entityItem); - setItemStack(ItemStack.EMPTY); + setInputStack(ItemStack.EMPTY); } } @@ -74,7 +81,7 @@ public void readFromNBT(NBTTagCompound compound) super.readFromNBT(compound); if (compound.hasKey("Item")) { - itemStack = new ItemStack(compound.getCompoundTag("Item")); + inputStack = new ItemStack(compound.getCompoundTag("Item")); } } @@ -82,10 +89,10 @@ public void readFromNBT(NBTTagCompound compound) public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - if (!itemStack.isEmpty()) + if (!inputStack.isEmpty()) { NBTTagCompound itemTag = new NBTTagCompound(); - itemStack.writeToNBT(itemTag); + inputStack.writeToNBT(itemTag); compound.setTag("Item", itemTag); } return compound; @@ -188,7 +195,7 @@ public void update() this.flipA += (f - this.flipA) * 0.9F; this.pageFlip += this.flipA; - if (this.world.getWorldTime() % 20 == 19 && !this.getItemStack().isEmpty()) + if (!this.getInputStack().isEmpty()) { updateBloodCount(); updateRecipe(); @@ -202,7 +209,7 @@ public void updateBloodCount() public void updateRecipe() { - this.validRecipe = HSAltarRecipes.isValidInputBlood(this.getItemStack().getItem()) && HSAltarRecipes.getRequiredBlood(this.getItemStack().getItem()) <= this.bloodCount; + this.validRecipe = HSAltarRecipes.isValidInputBlood(this.getInputStack().getItem()) && HSAltarRecipes.getRequiredBlood(this.getInputStack().getItem()) <= this.bloodCount; } public int scanCrucibleLevels() diff --git a/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntitySoulAltar.java b/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntitySoulAltar.java index 1f51110..d95b494 100644 --- a/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntitySoulAltar.java +++ b/src/main/java/mod/emt/harkenscythe/tileentities/HSTileEntitySoulAltar.java @@ -5,6 +5,7 @@ import java.util.Random; import mod.emt.harkenscythe.blocks.HSSoulCrucible; import mod.emt.harkenscythe.init.HSAltarRecipes; +import mod.emt.harkenscythe.init.HSItems; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -22,6 +23,7 @@ public class HSTileEntitySoulAltar extends TileEntity implements ITickable { private static final Random rand = new Random(); private static final int RADIUS = 4; + private final ItemStack essenceStack = new ItemStack(HSItems.soul_essence); public int tickCount; public float pageFlip; public float pageFlipPrev; @@ -34,7 +36,12 @@ public class HSTileEntitySoulAltar extends TileEntity implements ITickable public float tRot; private int soulCount; private boolean validRecipe; - private ItemStack itemStack = ItemStack.EMPTY; + private ItemStack inputStack = ItemStack.EMPTY; + + public ItemStack getEssenceStack() + { + return essenceStack; + } public int getSoulCount() { @@ -46,25 +53,25 @@ public boolean isValidRecipe() return validRecipe; } - public ItemStack getItemStack() + public ItemStack getInputStack() { - return itemStack; + return inputStack; } - public void setItemStack(ItemStack itemStack) + public void setInputStack(ItemStack inputStack) { - this.itemStack = itemStack; + this.inputStack = inputStack; markDirty(); } public void dropItem() { - if (!world.isRemote && !itemStack.isEmpty()) + if (!world.isRemote && !inputStack.isEmpty()) { BlockPos pos = getPos(); - EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), itemStack); + EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), inputStack); world.spawnEntity(entityItem); - setItemStack(ItemStack.EMPTY); + setInputStack(ItemStack.EMPTY); } } @@ -74,7 +81,7 @@ public void readFromNBT(NBTTagCompound compound) super.readFromNBT(compound); if (compound.hasKey("Item")) { - itemStack = new ItemStack(compound.getCompoundTag("Item")); + inputStack = new ItemStack(compound.getCompoundTag("Item")); } } @@ -82,10 +89,10 @@ public void readFromNBT(NBTTagCompound compound) public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - if (!itemStack.isEmpty()) + if (!inputStack.isEmpty()) { NBTTagCompound itemTag = new NBTTagCompound(); - itemStack.writeToNBT(itemTag); + inputStack.writeToNBT(itemTag); compound.setTag("Item", itemTag); } return compound; @@ -188,7 +195,7 @@ public void update() this.flipA += (f - this.flipA) * 0.9F; this.pageFlip += this.flipA; - if (this.world.getWorldTime() % 20 == 19 && !this.getItemStack().isEmpty()) + if (!this.getInputStack().isEmpty()) { updateSoulCount(); updateRecipe(); @@ -202,7 +209,7 @@ public void updateSoulCount() public void updateRecipe() { - this.validRecipe = HSAltarRecipes.isValidInputSoul(this.getItemStack().getItem()) && HSAltarRecipes.getRequiredSouls(this.getItemStack().getItem()) <= this.soulCount; + this.validRecipe = HSAltarRecipes.isValidInputSoul(this.getInputStack().getItem()) && HSAltarRecipes.getRequiredSouls(this.getInputStack().getItem()) <= this.soulCount; } public int scanCrucibleLevels()