diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java index 5a91467d..88e7d4cc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java @@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -21,10 +23,12 @@ public class BlockDecayedLeaves extends BlockImpl { this.setSoundType(SoundType.PLANT); } + @Override public boolean isOpaqueCube(IBlockState state) { return false; } + @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT_MIPPED; @@ -36,4 +40,9 @@ public class BlockDecayedLeaves extends BlockImpl { worldIn.setBlockToAir(pos); } } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return Items.AIR; + } } 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 78ca6da9..1edaec6d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -7,6 +7,7 @@ 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.packet.PacketParticles; import de.ellpeck.naturesaura.recipes.AltarRecipe; import net.minecraft.block.BlockStoneBrick; import net.minecraft.block.BlockStoneBrick.EnumType; @@ -113,6 +114,9 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, private final BasicAuraContainer container = new BasicAuraContainer(5000); public boolean structureFine; + private AltarRecipe currentRecipe; + private int timer; + private int lastAura; @Override @@ -160,6 +164,33 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, this.cachedProviders.remove(index); } } + + ItemStack stack = this.items.getStackInSlot(0); + if (this.currentRecipe == null) { + if (!stack.isEmpty()) { + this.currentRecipe = AltarRecipe.forInput(stack); + } + } else { + if (stack.isEmpty() || !stack.isItemEqual(this.currentRecipe.input)) { + this.currentRecipe = null; + } else { + int req = this.currentRecipe.aura / this.currentRecipe.time; + if (this.container.getStoredAura() >= req) { + this.container.drainAura(req, false); + + if (this.timer % 4 == 0) { + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4)); + } + + this.timer++; + if (this.timer >= this.currentRecipe.time) { + this.items.setStackInSlot(0, this.currentRecipe.output.copy()); + this.currentRecipe = null; + this.timer = 0; + } + } + } + } } if (this.world.getTotalWorldTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) { @@ -206,6 +237,13 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, compound.setTag("items", this.items.serializeNBT()); compound.setBoolean("fine", this.structureFine); this.container.writeNBT(compound); + + if (!syncing) { + if (this.currentRecipe != null) { + compound.setTag("recipe_input", this.currentRecipe.input.serializeNBT()); + compound.setInteger("timer", this.timer); + } + } } @Override @@ -214,6 +252,13 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, this.items.deserializeNBT(compound.getCompoundTag("items")); this.structureFine = compound.getBoolean("fine"); this.container.readNBT(compound); + + if (!syncing) { + if (compound.hasKey("recipe_input")) { + this.currentRecipe = AltarRecipe.forInput(new ItemStack(compound.getCompoundTag("recipe_input"))); + this.timer = compound.getInteger("timer"); + } + } } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index d4800424..66ffa864 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -57,12 +57,12 @@ public class PacketParticles implements IMessage { World world = Minecraft.getMinecraft().world; if (world != null) { switch (message.type) { - case 0: + case 0: // Tree ritual: Gold powder BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); for (BlockPos offset : TileEntityWoodStand.GOLD_POWDER_POSITIONS) { BlockPos dustPos = pos.add(offset); IBlockState state = world.getBlockState(dustPos); - AxisAlignedBB box = state.getBlock().getBoundingBox(state, world, dustPos); + AxisAlignedBB box = state.getBoundingBox(world, dustPos); NaturesAura.proxy.spawnMagicParticle(world, dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(), dustPos.getY() + 0.1F, @@ -73,7 +73,7 @@ public class PacketParticles implements IMessage { 0xf4cb42, 2F, 100, 0F, false, true); } break; - case 1: + case 1: // Tree ritual: Consuming item for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) { NaturesAura.proxy.spawnMagicParticle(world, message.posX + 0.5F, message.posY + 1.25F, message.posZ + 0.5F, @@ -81,7 +81,7 @@ public class PacketParticles implements IMessage { 0x89cc37, 1.5F, 50, 0F, false, true); } break; - case 2: + case 2: // Tree ritual: Tree disappearing for (int i = world.rand.nextInt(5) + 3; i >= 0; i--) { NaturesAura.proxy.spawnMagicParticle(world, message.posX + world.rand.nextFloat(), message.posY + world.rand.nextFloat(), message.posZ + world.rand.nextFloat(), @@ -89,7 +89,7 @@ public class PacketParticles implements IMessage { 0x33FF33, 1F, 100, 0F, false, true); } break; - case 3: + case 3: // Tree ritual: Spawn result item for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) { NaturesAura.proxy.spawnMagicParticle(world, message.posX, message.posY, message.posZ, @@ -97,6 +97,15 @@ public class PacketParticles implements IMessage { 0x89cc37, 2F, 200, 0F, true, true); } break; + case 4: // Nature altar: Conversion + for (int i = world.rand.nextInt(5) + 2; i >= 0; i--) { + NaturesAura.proxy.spawnMagicParticle(world, + message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posY + 0.9F + 0.25F * world.rand.nextFloat(), + message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, + world.rand.nextGaussian() * 0.01F, world.rand.nextFloat() * 0.01F, world.rand.nextGaussian() * 0.01F, + 0x00FF00, world.rand.nextFloat() * 1.5F + 0.75F, 40, 0F, false, true); + } } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 3a74e82c..c48260a9 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -21,6 +21,6 @@ public final class ModRecipes { 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(); + new AltarRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), 200, 30).add(); } }