From f8ff74b36b4ed2d3716b980b515559f3af5b5326 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 18 Oct 2018 13:34:37 +0200 Subject: [PATCH] start of infusion --- .../java/de/ellpeck/naturesaura/Helper.java | 32 +++++++++ .../blocks/BlockContainerImpl.java | 24 +++++++ .../naturesaura/blocks/BlockNatureAltar.java | 10 +++ .../naturesaura/blocks/BlockWoodStand.java | 43 +----------- .../blocks/tiles/ItemStackHandlerNA.java | 62 ++++++++++++++++++ .../blocks/tiles/TileEntityImpl.java | 31 ++++++++- .../blocks/tiles/TileEntityNatureAltar.java | 30 ++++++++- .../blocks/tiles/TileEntityWoodStand.java | 24 +++++-- .../tiles/render/RenderNatureAltar.java | 26 ++++++++ .../blocks/tiles/render/RenderWoodStand.java | 2 +- .../naturesaura/events/TerrainGenEvents.java | 10 +-- .../ellpeck/naturesaura/items/ModItems.java | 1 + .../naturesaura/proxy/ClientProxy.java | 3 + .../naturesaura/recipes/AltarRecipe.java | 37 +++++++++++ .../naturesaura/recipes/ModRecipes.java | 2 + .../naturesaura/recipes/TreeRitualRecipe.java | 3 +- .../assets/naturesaura/lang/en_US.lang | 1 + .../naturesaura/models/item/infused_iron.json | 6 ++ .../textures/items/infused_iron.png | Bin 0 -> 634 bytes 19 files changed, 293 insertions(+), 54 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java create mode 100644 src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java create mode 100644 src/main/resources/assets/naturesaura/models/item/infused_iron.json create mode 100644 src/main/resources/assets/naturesaura/textures/items/infused_iron.png diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index eb1df604..130f3d1f 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -1,16 +1,20 @@ package de.ellpeck.naturesaura; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.IItemHandlerModifiable; import java.util.ArrayList; import java.util.List; @@ -73,4 +77,32 @@ public final class Helper { GlStateManager.popMatrix(); } } + + public static boolean putStackOnTile(EntityPlayer player, EnumHand hand, BlockPos pos, int slot) { + TileEntity tile = player.world.getTileEntity(pos); + if (tile instanceof TileEntityImpl) { + IItemHandlerModifiable handler = ((TileEntityImpl) tile).getItemHandler(null); + if (handler != null) { + ItemStack handStack = player.getHeldItem(hand); + if (!handStack.isEmpty()) { + ItemStack remain = handler.insertItem(slot, handStack, player.world.isRemote); + if (!ItemStack.areItemStacksEqual(remain, handStack)) { + if (!player.world.isRemote) { + player.setHeldItem(hand, remain); + } + return true; + } + } + + if (!handler.getStackInSlot(slot).isEmpty()) { + if (!player.world.isRemote) { + player.addItemStackToInventory(handler.getStackInSlot(slot)); + handler.setStackInSlot(slot, ItemStack.EMPTY); + } + return true; + } + } + } + return false; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index 514420e3..2595dbd6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -1,21 +1,25 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.items.IItemHandler; import javax.annotation.Nullable; import java.util.Collections; @@ -81,4 +85,24 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, IMod public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } + + @Override + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + if (!worldIn.isRemote) { + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileEntityImpl) { + IItemHandler handler = ((TileEntityImpl) tile).getItemHandler(null); + if (handler != null) { + for (int i = 0; i < handler.getSlots(); i++) { + ItemStack stack = handler.getStackInSlot(i); + if (!stack.isEmpty()) { + EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack); + worldIn.spawnEntity(item); + } + } + } + } + } + super.breakBlock(worldIn, pos, state); + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index 04edf46b..975a67ca 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -1,11 +1,16 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockNatureAltar extends BlockContainerImpl { @@ -17,6 +22,11 @@ public class BlockNatureAltar extends BlockContainerImpl { this.setHarvestLevel("pickaxe", 1); } + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + return Helper.putStackOnTile(playerIn, hand, pos, 0); + } + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUND_BOX; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index f417a2e8..cc6ee302 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -1,12 +1,12 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -28,46 +28,7 @@ public class BlockWoodStand extends BlockContainerImpl { @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityWoodStand) { - TileEntityWoodStand stand = (TileEntityWoodStand) tile; - if (stand.stack.isEmpty()) { - ItemStack handStack = playerIn.getHeldItem(hand); - if (!handStack.isEmpty()) { - if (!worldIn.isRemote) { - ItemStack copy = handStack.copy(); - copy.setCount(1); - stand.stack = copy; - handStack.shrink(1); - stand.sendToClients(); - } - return true; - } - } else { - if (!worldIn.isRemote) { - playerIn.addItemStackToInventory(stand.stack); - stand.stack = ItemStack.EMPTY; - stand.sendToClients(); - } - return true; - } - } - return false; - } - - @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { - if (!worldIn.isRemote) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityWoodStand) { - TileEntityWoodStand stand = (TileEntityWoodStand) tile; - if (!stand.stack.isEmpty()) { - EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stand.stack); - worldIn.spawnEntity(item); - } - } - } - super.breakBlock(worldIn, pos, state); + return Helper.putStackOnTile(playerIn, hand, pos, 0); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java new file mode 100644 index 00000000..d12db094 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java @@ -0,0 +1,62 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.ItemStackHandler; + +import javax.annotation.Nonnull; + +public class ItemStackHandlerNA extends ItemStackHandler { + + private final TileEntityImpl tile; + private final boolean sendToClients; + + public ItemStackHandlerNA(int size) { + this(size, null, false); + } + + public ItemStackHandlerNA(int size, TileEntityImpl tile, boolean sendToClients) { + super(size); + this.tile = tile; + this.sendToClients = sendToClients; + } + + @Override + protected void onContentsChanged(int slot) { + if (this.sendToClients && !this.tile.getWorld().isRemote) { + this.tile.sendToClients(); + } + } + + protected boolean canInsert(ItemStack stack, int slot) { + return true; + } + + protected boolean canExtract(ItemStack stack, int slot, int amount) { + return true; + } + + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return this.canInsert(stack, slot); + } + + @Nonnull + @Override + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if (this.canInsert(stack, slot)) { + return super.insertItem(slot, stack, simulate); + } else { + return stack; + } + } + + @Nonnull + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (this.canExtract(this.getStackInSlot(slot), slot, amount)) { + return super.extractItem(slot, amount, simulate); + } else { + return ItemStack.EMPTY; + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index ff183c1b..a35c1689 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -1,15 +1,21 @@ package de.ellpeck.naturesaura.blocks.tiles; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.server.management.PlayerChunkMapEntry; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; + +import javax.annotation.Nullable; public class TileEntityImpl extends TileEntity { @Override @@ -68,4 +74,27 @@ public class TileEntityImpl extends TileEntity { entry.sendPacket(this.getUpdatePacket()); } } + + public IItemHandlerModifiable getItemHandler(EnumFacing facing) { + return null; + } + + @Override + public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return this.getItemHandler(facing) != null; + } else { + return super.hasCapability(capability, facing); + } + } + + @Nullable + @Override + public T getCapability(Capability capability, @Nullable EnumFacing facing) { + if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return (T) this.getItemHandler(facing); + } else { + return super.getCapability(capability, facing); + } + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index 42c0f57d..78ca6da9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -7,14 +7,19 @@ import de.ellpeck.naturesaura.aura.IAuraContainer; import de.ellpeck.naturesaura.aura.IAuraContainerProvider; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; +import de.ellpeck.naturesaura.recipes.AltarRecipe; import net.minecraft.block.BlockStoneBrick; import net.minecraft.block.BlockStoneBrick.EnumType; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.ItemStackHandler; import java.util.ArrayList; import java.util.List; @@ -55,7 +60,6 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, new BlockPos(-2, 0, 2) }; private static final BlockPos[] CHISELED_POSITIONS = new BlockPos[]{ - new BlockPos(0, -1, 0), new BlockPos(1, -1, 1), new BlockPos(-1, -1, 1), new BlockPos(-1, -1, -1), @@ -88,6 +92,23 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, new BlockPos(1, -1, 3), }; + public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { + @Override + public int getSlotLimit(int slot) { + return 1; + } + + @Override + protected boolean canInsert(ItemStack stack, int slot) { + return AltarRecipe.forInput(stack) != null; + } + + @Override + protected boolean canExtract(ItemStack stack, int slot, int amount) { + return AltarRecipe.forInput(stack) == null; + } + }; + private final List cachedProviders = new ArrayList<>(); private final BasicAuraContainer container = new BasicAuraContainer(5000); public boolean structureFine; @@ -182,6 +203,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, @Override public void writeNBT(NBTTagCompound compound, boolean syncing) { super.writeNBT(compound, syncing); + compound.setTag("items", this.items.serializeNBT()); compound.setBoolean("fine", this.structureFine); this.container.writeNBT(compound); } @@ -189,6 +211,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, @Override public void readNBT(NBTTagCompound compound, boolean syncing) { super.readNBT(compound, syncing); + this.items.deserializeNBT(compound.getCompoundTag("items")); this.structureFine = compound.getBoolean("fine"); this.container.readNBT(compound); } @@ -202,4 +225,9 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, public boolean isArtificial() { return true; } + + @Override + public IItemHandlerModifiable getItemHandler(EnumFacing facing) { + return this.items; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index cd22e3fa..1d214885 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -17,6 +17,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.ItemStackHandler; import java.util.HashMap; import java.util.Map; @@ -41,7 +43,13 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { new BlockPos(1, 0, -2), new BlockPos(-1, 0, -2) }; - public ItemStack stack = ItemStack.EMPTY; + + public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; private BlockPos ritualPos; private Map involvedStands; @@ -102,7 +110,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { for (BlockPos pos : this.involvedStands.keySet()) { TileEntityWoodStand stand = (TileEntityWoodStand) this.world.getTileEntity(pos); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1)); - stand.stack = ItemStack.EMPTY; + stand.items.setStackInSlot(0, ItemStack.EMPTY); stand.sendToClients(); } } @@ -146,7 +154,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { } for (Map.Entry entry : this.involvedStands.entrySet()) { TileEntity tile = this.world.getTileEntity(entry.getKey()); - if (!(tile instanceof TileEntityWoodStand) || (this.timer < this.totalTime / 2 && !((TileEntityWoodStand) tile).stack.isItemEqual(entry.getValue()))) { + if (!(tile instanceof TileEntityWoodStand) + || (this.timer < this.totalTime / 2 && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isItemEqual(entry.getValue()))) { return false; } } @@ -156,7 +165,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { @Override public void writeNBT(NBTTagCompound compound, boolean syncing) { super.writeNBT(compound, syncing); - compound.setTag("item", this.stack.writeToNBT(new NBTTagCompound())); + compound.setTag("items", this.items.serializeNBT()); if (!syncing) { if (this.ritualPos != null && this.involvedStands != null && this.output != null && this.totalTime > 0) { @@ -180,7 +189,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { @Override public void readNBT(NBTTagCompound compound, boolean syncing) { super.readNBT(compound, syncing); - this.stack = new ItemStack(compound.getCompoundTag("item")); + this.items.deserializeNBT(compound.getCompoundTag("items")); if (!syncing) { if (compound.hasKey("ritual_pos") && compound.hasKey("stands") && compound.hasKey("output") && compound.hasKey("total_time")) { @@ -201,4 +210,9 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { } } } + + @Override + public IItemHandlerModifiable getItemHandler(EnumFacing facing) { + return this.items; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java new file mode 100644 index 00000000..8da95160 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java @@ -0,0 +1,26 @@ +package de.ellpeck.naturesaura.blocks.tiles.render; + +import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class RenderNatureAltar extends TileEntitySpecialRenderer { + @Override + public void render(TileEntityNatureAltar tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + ItemStack stack = tile.items.getStackInSlot(0); + if (!stack.isEmpty()) { + GlStateManager.pushMatrix(); + float time = tile.getWorld().getTotalWorldTime() + partialTicks; + float bob = (float) Math.sin(time / 10F) * 0.1F; + GlStateManager.translate(x + 0.5F, y + 1.2F + bob, z + 0.5F); + GlStateManager.rotate((time * 3) % 360, 0F, 1F, 0F); + float scale = stack.getItem() instanceof ItemBlock ? 0.75F : 0.5F; + GlStateManager.scale(scale, scale, scale); + Helper.renderItemInWorld(stack); + GlStateManager.popMatrix(); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java index 78ab3aef..ca91c007 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; public class RenderWoodStand extends TileEntitySpecialRenderer { @Override public void render(TileEntityWoodStand tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - ItemStack stack = tile.stack; + ItemStack stack = tile.items.getStackInSlot(0); if (!stack.isEmpty()) { GlStateManager.pushMatrix(); if (stack.getItem() instanceof ItemBlock) { diff --git a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java index 35c0b5f0..d3e4520f 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java @@ -29,8 +29,9 @@ public class TerrainGenEvents { for (TileEntity tile : tileEntities) { if (tile instanceof TileEntityWoodStand) { TileEntityWoodStand stand = (TileEntityWoodStand) tile; - if (!stand.stack.isEmpty()) { - usableItems.add(stand.stack); + ItemStack stack = stand.items.getStackInSlot(0); + if (!stack.isEmpty()) { + usableItems.add(stack); stands.add(stand); } } @@ -46,9 +47,10 @@ public class TerrainGenEvents { TileEntityWoodStand toPick = null; for (TileEntityWoodStand stand : stands) { - int index = Helper.getItemIndex(stillRequired, stand.stack); + ItemStack stack = stand.items.getStackInSlot(0); + int index = Helper.getItemIndex(stillRequired, stack); if (index >= 0) { - actuallyInvolved.put(stand.getPos(), stand.stack); + actuallyInvolved.put(stand.getPos(), stack); stillRequired.remove(index); if (toPick == null) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 9f106d65..db47957c 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -7,4 +7,5 @@ public final class ModItems { public static final Item EYE = new ItemEye(); public static final Item GOLD_FIBER = new ItemGoldFiber(); public static final Item GOLD_LEAF = new ItemImpl("gold_leaf"); + public static final Item INFUSED_IRON = new ItemImpl("infused_iron"); } diff --git a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java index c2d5ff6b..8fb4327d 100644 --- a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java @@ -1,6 +1,8 @@ package de.ellpeck.naturesaura.proxy; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; +import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand; import de.ellpeck.naturesaura.events.ClientEvents; import de.ellpeck.naturesaura.particles.ParticleHandler; @@ -33,6 +35,7 @@ public class ClientProxy implements IProxy { @Override public void init(FMLInitializationEvent event) { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWoodStand.class, new RenderWoodStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNatureAltar.class, new RenderNatureAltar()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java new file mode 100644 index 00000000..55d7f492 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java @@ -0,0 +1,37 @@ +package de.ellpeck.naturesaura.recipes; + +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class AltarRecipe { + + public static final List RECIPES = new ArrayList<>(); + + public final ItemStack input; + public final ItemStack output; + public final int aura; + public final int time; + + public AltarRecipe(ItemStack input, ItemStack output, int aura, int time) { + this.input = input; + this.output = output; + this.aura = aura; + this.time = time; + } + + public static AltarRecipe forInput(ItemStack input) { + for (AltarRecipe recipe : RECIPES) { + if (recipe.input.isItemEqual(input)) { + return recipe; + } + } + return null; + } + + public AltarRecipe add() { + RECIPES.add(this); + return this; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 74a3c72b..3a74e82c 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -20,5 +20,7 @@ public final class ModRecipes { new ItemStack(Blocks.STONE), new ItemStack(ModItems.GOLD_LEAF), new ItemStack(Items.DIAMOND)).add(); + + new AltarRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), 100, 30).add(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java index 2cdc0b99..a044fa41 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java @@ -35,7 +35,8 @@ public class TreeRitualRecipe { } } - public void add() { + public TreeRitualRecipe add() { RECIPES.add(this); + return this; } } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 1b423807..1428de36 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -13,5 +13,6 @@ tile.naturesaura.wood_stand.name=Wooden Stand item.naturesaura.eye.name=Environmental Eye item.naturesaura.gold_fiber.name=Brilliant Fiber item.naturesaura.gold_leaf.name=Gold Leaf +item.naturesaura.infused_iron.name=Infused Iron container.naturesaura.tree_ritual.name=Tree Infusion \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/infused_iron.json b/src/main/resources/assets/naturesaura/models/item/infused_iron.json new file mode 100644 index 00000000..c488643c --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/infused_iron.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/infused_iron" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/items/infused_iron.png b/src/main/resources/assets/naturesaura/textures/items/infused_iron.png new file mode 100644 index 0000000000000000000000000000000000000000..179850a823393e600fd2bc5cdb6f08e0ca78eb67 GIT binary patch literal 634 zcmV-=0)_pFP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y9E-_;&oJ#-z0qaRbK~y+TZIjzm(?Ar))7$h#OPe-HTX^&V zNN-8nrWZ;DL@pzs|Cuj>cmYNcyf9WBeQ|Jx(Ld}X-+{#?`pqQUoU_0EcF&#~O4)2y z#zZ0^V=|ePQ5Rz>PYDwT(&@B}N-Ca8rDUYYs7Dlc`yW)^n1;Dxfw4>`a~+MOZ%IkT zob@X5OGOkP*yvu2;hzt2XEX&#Mv5DYrtX_4ESCi8{a!-<&$7USixqg^2B;slB}e#X z0eh_?!P2TDlY?IiX#X6c`J;#KdG!5#L16bdfd6TL#%WiMBQPC{+m5&qR#0OSA~+k$ zWbb1i;g>P;YbDrQRTS1O6gM5v*sva!(L4!J+9_Xc@pA-B`Ut)bQ9tRRyfcH`stIR% z8vcg?YH!=99R!$vdhrmcgbrZz#E|( zA-dgN%>N5Tx@l#-Em;)RvU-Q|Hy6=kx7s-_-BCe0aBD|Q#Q%YmK8bnV{jUt;64f~F UYlO9eEdT%j07*qoM6N<$f~WHoF8}}l literal 0 HcmV?d00001