use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable in project Armourers-Workshop by RiskyKen.
the class BlockSkinnable method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntitySkinnable te = getTileEntity(world, x, y, z);
if (te != null && te.getInventory() != null) {
BlockUtils.dropInventoryBlocks(world, te.getInventory(), x, y, z);
}
super.breakBlock(world, x, y, z, block, meta);
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable in project Armourers-Workshop by RiskyKen.
the class BlockSkinnable method setBlockBoundsBasedOnState.
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntitySkinnable te = getTileEntity(world, x, y, z);
if (te != null) {
ForgeDirection dir = getFacingDirection(world, x, y, z);
if (dir == ForgeDirection.NORTH) {
te.setBoundsOnBlock(this, 1, 0, 0);
return;
}
if (dir == ForgeDirection.EAST) {
te.setBoundsOnBlock(this, 0, 0, 1);
return;
}
if (dir == ForgeDirection.SOUTH) {
te.setBoundsOnBlock(this, 1, 0, 2);
return;
}
if (dir == ForgeDirection.WEST) {
te.setBoundsOnBlock(this, 2, 0, 1);
return;
}
}
setBlockBounds(0, 0, 0, 1, 1, 1);
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable in project Armourers-Workshop by RiskyKen.
the class BlockSkinnable method dropSkin.
private void dropSkin(World world, int x, int y, int z, boolean isCreativeMode) {
TileEntitySkinnable te = getTileEntity(world, x, y, z);
if (te != null) {
SkinPointer skinPointer = te.getSkinPointer();
if (skinPointer != null) {
if (!isCreativeMode) {
ItemStack skinStack = new ItemStack(ModItems.equipmentSkin, 1);
SkinNBTHelper.addSkinDataToStack(skinStack, skinPointer);
UtilItems.spawnItemInWorld(world, x, y, z, skinStack);
}
te.killChildren(world);
} else {
ModLogger.log(Level.WARN, String.format("Block skin at x:%d y:%d z:%d had no skin data.", x, y, z));
}
}
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable in project Armourers-Workshop by RiskyKen.
the class ItemLinkingTool method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return false;
}
if (!world.isRemote) {
if (!hasLinkLocation(stack)) {
Block block = world.getBlock(x, y, z);
if (!(block instanceof BlockSkinnable)) {
setLinkLocation(stack, new BlockLocation(x, y, z));
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.start", (Object) null));
return true;
} else {
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.linkedToSkinnable", (Object) null));
return true;
}
} else {
BlockLocation loc = getLinkLocation(stack);
Block block = world.getBlock(x, y, z);
if (block instanceof BlockSkinnable) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntitySkinnable) {
((TileEntitySkinnable) te).getParent().setLinkedBlock(loc);
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.finish", (Object) null));
removeLinkLocation(stack);
return true;
}
}
}
removeLinkLocation(stack);
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.fail", (Object) null));
}
return true;
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable in project Armourers-Workshop by RiskyKen.
the class ItemSkin method placeSkinAtLocation.
private boolean placeSkinAtLocation(World world, EntityPlayer player, int side, ItemStack stack, int x, int y, int z, SkinPointer skinPointer) {
if (!canPlaceSkinAtLocation(world, player, side, stack, x, y, z, skinPointer)) {
return false;
}
ForgeDirection dir = UtilPlayer.getDirectionSide(player).getOpposite();
Skin skin = SkinUtils.getSkinDetectSide(stack, false, true);
if (skin == null) {
return false;
}
BlockSkinnable targetBlock = (BlockSkinnable) ModBlocks.skinnable;
if (SkinProperties.PROP_BLOCK_GLOWING.getValue(skin.getProperties())) {
targetBlock = (BlockSkinnable) ModBlocks.skinnableGlowing;
}
int meta = targetBlock.convertDirectionToMetadata(dir);
boolean multiblock = SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skin.getProperties());
ArrayList<BlockLocation> relatedBlocks = new ArrayList<BlockLocation>();
if (multiblock) {
if (!canPlaceChildren(world, player, side, stack, x, y, z, skin, skinPointer, relatedBlocks)) {
return false;
}
placeChildren(world, player, side, x, y, z, skin, skinPointer, relatedBlocks);
}
world.setBlock(x, y, z, targetBlock, meta, 2);
world.setTileEntity(x, y, z, ((ITileEntityProvider) targetBlock).createNewTileEntity(world, 0));
TileEntitySkinnable te = (TileEntitySkinnable) world.getTileEntity(x, y, z);
te.setSkinPointer(skin, skinPointer);
targetBlock.onBlockPlacedBy(world, x, y, z, player, stack);
targetBlock.onPostBlockPlaced(world, x, y, z, meta);
te.setRelatedBlocks(relatedBlocks);
// targetBlock.setFacingDirection(world, x, y, z, dir);
stack.stackSize--;
world.playSoundEffect((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, "dig.stone", 1, 1);
return true;
}
Aggregations