Search in sources :

Example 1 with TileEntitySkinnable

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);
}
Also used : TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 2 with TileEntitySkinnable

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);
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 3 with TileEntitySkinnable

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));
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 4 with TileEntitySkinnable

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockSkinnable(riskyken.armourersWorkshop.common.blocks.BlockSkinnable) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Block(net.minecraft.block.Block) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 5 with TileEntitySkinnable

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;
}
Also used : BlockSkinnable(riskyken.armourersWorkshop.common.blocks.BlockSkinnable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ArrayList(java.util.ArrayList) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Aggregations

TileEntitySkinnable (riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)6 Block (net.minecraft.block.Block)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)2 BlockSkinnable (riskyken.armourersWorkshop.common.blocks.BlockSkinnable)2 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)2 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 ModItemBlock (riskyken.armourersWorkshop.common.items.block.ModItemBlock)1 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)1