Search in sources :

Example 16 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockMannequin method getPickBlock.

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
    ItemStack stack = new ItemStack(ModBlocks.mannequin, 1);
    int meta = world.getBlockMetadata(x, y, z);
    int yOffset = 0;
    if (meta == 1) {
        yOffset = -1;
    }
    TileEntity te = world.getTileEntity(x, y + yOffset, z);
    if (te != null && te instanceof TileEntityMannequin) {
        TileEntityMannequin teMan = (TileEntityMannequin) te;
        if (teMan.getGameProfile() != null) {
            NBTTagCompound profileTag = new NBTTagCompound();
            NBTUtil.func_152460_a(profileTag, teMan.getGameProfile());
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setTag(TAG_OWNER, profileTag);
        }
        if (!StringUtils.isNullOrEmpty(teMan.getImageUrl())) {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setString(TAG_IMAGE_URL, teMan.getImageUrl());
        }
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 17 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockMannequin method rotateBlock.

@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
    if (world.isRemote) {
        return false;
    }
    int meta = world.getBlockMetadata(x, y, z);
    int yOffset = 0;
    if (meta == 1) {
        yOffset = -1;
    }
    TileEntity te = world.getTileEntity(x, y + yOffset, z);
    if (te != null && te instanceof TileEntityMannequin) {
        int rotation = ((TileEntityMannequin) te).getRotation();
        rotation++;
        if (rotation > 15) {
            rotation = 0;
        }
        ((TileEntityMannequin) te).setRotation(rotation);
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 18 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockMannequin method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xHit, float yHit, float zHit) {
    if (!player.canPlayerEdit(x, y, z, side, player.getCurrentEquippedItem())) {
        return false;
    }
    if (!world.isRemote) {
        if (player.inventory.getCurrentItem() != null) {
            if (player.inventory.getCurrentItem().getItem() == ModItems.mannequinTool) {
                return false;
            }
            if (player.inventory.getCurrentItem().getItem() == ModItems.paintbrush) {
                return false;
            }
        }
        int meta = world.getBlockMetadata(x, y, z);
        int yOffset = 0;
        if (meta == 1) {
            yOffset = -1;
        }
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem() == Items.name_tag) {
            TileEntity te = world.getTileEntity(x, y + yOffset, z);
            ;
            if (te != null && te instanceof TileEntityMannequin) {
                if (stack.getItem() == Items.name_tag) {
                    ((TileEntityMannequin) te).setOwner(player.getCurrentEquippedItem());
                }
            }
        } else {
            FMLNetworkHandler.openGui(player, ArmourersWorkshop.instance, LibGuiIds.MANNEQUIN, world, x, y + yOffset, z);
        }
    }
    if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == ModItems.mannequinTool) {
        return false;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ItemStack(net.minecraft.item.ItemStack) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 19 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockMannequin method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
    if (!world.isRemote) {
        TileEntityMannequin te = getMannequinTileEntity(world, x, y, z);
        if (te != null && te.getDropItems()) {
            ItemStack dropStack = te.getDropStack();
            UtilItems.spawnItemInWorld(world, x, y, z, dropStack);
            BlockUtils.dropInventoryBlocks(world, x, y, z);
        }
    }
    super.breakBlock(world, x, y, z, block, metadata);
}
Also used : TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityMannequin (riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)19 TileEntity (net.minecraft.tileentity.TileEntity)14 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 Block (net.minecraft.block.Block)3 GameProfile (com.mojang.authlib.GameProfile)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 EntityFX (net.minecraft.client.particle.EntityFX)2 EntitySpellParticleFX (net.minecraft.client.particle.EntitySpellParticleFX)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Container (net.minecraft.inventory.Container)2 Contributor (riskyken.armourersWorkshop.common.Contributors.Contributor)2 ContainerMannequin (riskyken.armourersWorkshop.common.inventory.ContainerMannequin)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)1 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)1 BipedRotations (riskyken.armourersWorkshop.common.data.BipedRotations)1 ItemBlockMannequin (riskyken.armourersWorkshop.common.items.block.ItemBlockMannequin)1