diff --git a/src/main/java/tconstruct/blocks/slime/SlimeGrass.java b/src/main/java/tconstruct/blocks/slime/SlimeGrass.java index 32f736a0..40c0c85b 100644 --- a/src/main/java/tconstruct/blocks/slime/SlimeGrass.java +++ b/src/main/java/tconstruct/blocks/slime/SlimeGrass.java @@ -141,4 +141,12 @@ public class SlimeGrass extends MantleBlock else return TinkerTools.craftedSoil; } + + @Override + public Item getItemDropped(int metadata, Random random, int p_149650_3_) { + if (metadata == 1) + return Blocks.dirt.getItemDropped(metadata, random, p_149650_3_); + else + return ItemSaddle.getItemFromBlock(TinkerTools.craftedSoil); + } } diff --git a/src/main/java/tconstruct/tools/TinkerToolEvents.java b/src/main/java/tconstruct/tools/TinkerToolEvents.java index c6f311fa..5d8c7307 100644 --- a/src/main/java/tconstruct/tools/TinkerToolEvents.java +++ b/src/main/java/tconstruct/tools/TinkerToolEvents.java @@ -44,6 +44,22 @@ public class TinkerToolEvents AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 1)); } } + + // slab pattern chest + if(item == Item.getItemFromBlock(TinkerTools.craftingSlabWood) && event.crafting.getItemDamage() == 4) { + // copy over NBT + for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { + ItemStack stack = event.craftMatrix.getStackInSlot(i); + if(stack == null) + continue; + // regular pattern chest + if(stack.getItem() == Item.getItemFromBlock(TinkerTools.toolStationWood) && stack.getItemDamage() == 5) + { + event.crafting.setTagCompound(stack.getTagCompound()); + break; + } + } + } } } diff --git a/src/main/java/tconstruct/tools/TinkerTools.java b/src/main/java/tconstruct/tools/TinkerTools.java index 2f9b29ca..de4849ca 100644 --- a/src/main/java/tconstruct/tools/TinkerTools.java +++ b/src/main/java/tconstruct/tools/TinkerTools.java @@ -341,6 +341,10 @@ public class TinkerTools { vanillaToolRecipes(); modIntegration(); + + // Fix for chisels harvetslevel derp + if("chisel".equals(Blocks.stone.getHarvestTool(0))) + Blocks.stone.setHarvestLevel("pickaxe", 0, 0); } private void addPartMapping () diff --git a/src/main/java/tconstruct/tools/blocks/CraftingSlab.java b/src/main/java/tconstruct/tools/blocks/CraftingSlab.java index 5089df15..59dc3d59 100644 --- a/src/main/java/tconstruct/tools/blocks/CraftingSlab.java +++ b/src/main/java/tconstruct/tools/blocks/CraftingSlab.java @@ -7,8 +7,10 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.*; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.world.World; @@ -132,7 +134,22 @@ public class CraftingSlab extends InventorySlab @Override public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) { - if (PHConstruct.freePatterns) + boolean keptInventory = false; + if (stack.hasTagCompound()) + { + NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory"); + TileEntity te = world.getTileEntity(x, y, z); + if (inventory != null && te instanceof PatternChestLogic) + { + PatternChestLogic logic = (PatternChestLogic) te; + logic.readInventoryFromNBT(inventory); + logic.xCoord = x; + logic.yCoord = y; + logic.zCoord = z; + keptInventory = true; + } + } + if (!keptInventory && PHConstruct.freePatterns) { int meta = world.getBlockMetadata(x, y, z); if (meta == 4) @@ -169,4 +186,52 @@ public class CraftingSlab extends InventorySlab return null; } } + + /* Keep pattern chest inventory */ + @Override + public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) + { + player.addExhaustion(0.025F); + + if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 4) + { + ItemStack chest = new ItemStack(this, 1, 4); + NBTTagCompound inventory = new NBTTagCompound(); + PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z); + logic.writeInventoryToNBT(inventory); + NBTTagCompound baseTag = new NBTTagCompound(); + baseTag.setTag("Inventory", inventory); + chest.setTagCompound(baseTag); + + // remove content. This is necessary because otherwise the patterns would also spill into the world + // we don't want to prevent that since that's the intended behaviour for explosions. + for(int i = 0; i < logic.getSizeInventory(); i++) + logic.setInventorySlotContents(i, null); + + //Spawn item + if (!player.capabilities.isCreativeMode || player.isSneaking()) + { + float f = 0.7F; + double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, chest); + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + } + } + } + return world.setBlockToAir(x, y, z); + } + + @Override + public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta) + { + if (meta != 4) + super.harvestBlock(world, player, x, y, z, meta); + //Do nothing + } }