Skip to content

Commit

Permalink
Adjust altar rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 11, 2024
1 parent a46b975 commit d1d851f
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 54 deletions.
14 changes: 7 additions & 7 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/mod/emt/harkenscythe/init/HSRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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()
{
Expand All @@ -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);
}
}

Expand All @@ -74,18 +81,18 @@ public void readFromNBT(NBTTagCompound compound)
super.readFromNBT(compound);
if (compound.hasKey("Item"))
{
itemStack = new ItemStack(compound.getCompoundTag("Item"));
inputStack = new ItemStack(compound.getCompoundTag("Item"));
}
}

@Override
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;
Expand Down Expand Up @@ -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();
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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()
{
Expand All @@ -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);
}
}

Expand All @@ -74,18 +81,18 @@ public void readFromNBT(NBTTagCompound compound)
super.readFromNBT(compound);
if (compound.hasKey("Item"))
{
itemStack = new ItemStack(compound.getCompoundTag("Item"));
inputStack = new ItemStack(compound.getCompoundTag("Item"));
}
}

@Override
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;
Expand Down Expand Up @@ -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();
Expand All @@ -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()
Expand Down

0 comments on commit d1d851f

Please sign in to comment.