Search in sources :

Example 1 with TileEntityManualChopper

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChopper(se.gory_moon.horsepower.tileentity.TileEntityChopper) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityManualChopper(se.gory_moon.horsepower.tileentity.TileEntityManualChopper)

Example 2 with TileEntityManualChopper

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);
}
Also used : ItemStack(net.minecraft.item.ItemStack) TileEntityManualChopper(se.gory_moon.horsepower.tileentity.TileEntityManualChopper) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Aggregations

TileEntityManualChopper (se.gory_moon.horsepower.tileentity.TileEntityManualChopper)2 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1 TileEntityChopper (se.gory_moon.horsepower.tileentity.TileEntityChopper)1