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;
}
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;
}
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;
}
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);
}
Aggregations