Search in sources :

Example 6 with TileEntitySkinnable

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

the class BlockSkinnable method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xHit, float yHit, float zHit) {
    Skin skin = getSkin(world, x, y, z);
    TileEntitySkinnable te = getTileEntity(world, x, y, z);
    if (te == null) {
        return false;
    }
    TileEntitySkinnable parentTe = te.getParent();
    if (parentTe == null) {
        return false;
    }
    if (parentTe.hasLinkedBlock()) {
        BlockLocation loc = parentTe.getLinkedBlock();
        Block block = world.getBlock(loc.x, loc.y, loc.z);
        if (!(block instanceof BlockSkinnable)) {
            return block.onBlockActivated(world, loc.x, loc.y, loc.z, player, side, xHit, yHit, zHit);
        }
    }
    if (skin == null) {
        return false;
    }
    if (SkinProperties.PROP_BLOCK_SEAT.getValue(skin.getProperties())) {
        return sitOnSeat(world, parentTe.xCoord, parentTe.yCoord, parentTe.zCoord, player, skin);
    }
    if (SkinProperties.PROP_BLOCK_BED.getValue(skin.getProperties())) {
    // return sleepInBed(world, parentTe.xCoord, parentTe.yCoord, parentTe.zCoord, player, skin, te.getRotation(), te);
    }
    if (SkinProperties.PROP_BLOCK_INVENTORY.getValue(skin.getProperties()) | SkinProperties.PROP_BLOCK_ENDER_INVENTORY.getValue(skin.getProperties())) {
        if (!world.isRemote) {
            FMLNetworkHandler.openGui(player, ArmourersWorkshop.instance, LibGuiIds.SKINNABLE, world, parentTe.xCoord, parentTe.yCoord, parentTe.zCoord);
        }
        return true;
    }
    return false;
}
Also used : ModItemBlock(riskyken.armourersWorkshop.common.items.block.ModItemBlock) Block(net.minecraft.block.Block) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) 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