Search in sources :

Example 1 with TileJar

use of com.teamwizardry.wizardry.common.tile.TileJar in project Wizardry by TeamWizardry.

the class BlockJar method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (ItemNBTHelper.getBoolean(stack, Constants.NBT.FAIRY_INSIDE, false)) {
        TileEntity entity = worldIn.getTileEntity(pos);
        if (entity != null && entity instanceof TileJar) {
            TileJar jar = (TileJar) entity;
            jar.color = new Color(ItemNBTHelper.getInt(stack, Constants.NBT.FAIRY_COLOR, 0xFFFFFF));
            jar.age = ItemNBTHelper.getInt(stack, Constants.NBT.FAIRY_AGE, 0);
            jar.hasFairy = true;
            jar.markDirty();
            worldIn.checkLight(pos);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileJar(com.teamwizardry.wizardry.common.tile.TileJar)

Example 2 with TileJar

use of com.teamwizardry.wizardry.common.tile.TileJar in project Wizardry by TeamWizardry.

the class BlockJar method getPickBlock.

@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
    ItemStack stack = new ItemStack(this);
    TileEntity entity = world.getTileEntity(pos);
    if (entity != null && entity instanceof TileJar) {
        TileJar jar = (TileJar) entity;
        if (jar.color == null)
            return stack;
        ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_COLOR, jar.color.getRGB());
        ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_AGE, jar.age);
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileJar(com.teamwizardry.wizardry.common.tile.TileJar) ItemStack(net.minecraft.item.ItemStack)

Example 3 with TileJar

use of com.teamwizardry.wizardry.common.tile.TileJar in project Wizardry by TeamWizardry.

the class BlockJar method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        TileEntity tile = worldIn.getTileEntity(pos);
        if (tile != null && tile instanceof TileJar) {
            TileJar jar = (TileJar) tile;
            if (playerIn.isSneaking() && jar.hasFairy) {
                EntityFairy entity = new EntityFairy(worldIn, jar.color, jar.age);
                entity.setPosition(playerIn.posX, playerIn.posY, playerIn.posZ);
                worldIn.spawnEntity(entity);
                jar.hasFairy = false;
                jar.markDirty();
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileJar(com.teamwizardry.wizardry.common.tile.TileJar) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy)

Aggregations

TileJar (com.teamwizardry.wizardry.common.tile.TileJar)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EntityFairy (com.teamwizardry.wizardry.common.entity.EntityFairy)1 ItemStack (net.minecraft.item.ItemStack)1