use of se.gory_moon.horsepower.tileentity.TileEntityManualChopper in project HorsePower by GoryMoon.
the class BlockHPChoppingBase method writeDataOntoItemstack.
private void writeDataOntoItemstack(@Nonnull ItemStack item, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean inventorySave) {
// get block data from the block
TileEntity te = world.getTileEntity(pos);
if (te != null && (te instanceof TileEntityChopper || te instanceof TileEntityManualChopper)) {
NBTTagCompound tag = item.hasTagCompound() ? item.getTagCompound() : new NBTTagCompound();
// texture
NBTTagCompound data = te.getTileData().getCompoundTag("textureBlock");
if (!data.hasNoTags()) {
tag.setTag("textureBlock", data);
}
if (!tag.hasNoTags()) {
item.setTagCompound(tag);
}
}
}
use of se.gory_moon.horsepower.tileentity.TileEntityManualChopper in project HorsePower by GoryMoon.
the class BlockChoppingBlock method onBlockClicked.
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer player) {
if (player instanceof FakePlayer || player == null)
return;
TileEntityManualChopper te = getTileEntity(worldIn, pos);
if (te != null) {
ItemStack held = player.getHeldItem(EnumHand.MAIN_HAND);
if (!held.isEmpty() && ((held.getItem().getHarvestLevel(held, "axe", player, null) > -1) || isItemWhitelisted(held))) {
if (te.chop(player, held)) {
player.addExhaustion((float) Configs.general.choppingblockExhaustion);
if (Configs.general.shouldDamageAxe)
held.damageItem(1, player);
}
}
}
super.onBlockClicked(worldIn, pos, player);
}
Aggregations