Search in sources :

Example 6 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class BlockPanelLighting method onUseWrench.

@Override
public boolean onUseWrench(World world, BlockPos pos, EntityPlayer entityPlayer, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof TileEntityPanelLight)) {
        return false;
    }
    IBlockState bs = world.getBlockState(pos);
    if (!(bs.getBlock() instanceof BlockPanelLighting)) {
        return false;
    }
    PanelType type = (PanelType) bs.getValue(BlockPanelLighting.TYPE);
    TileEntityPanelLight tilegood = (TileEntityPanelLight) tile;
    int metadata = tilegood.meta;
    if (metadata < 8 && (type == PanelType.LINEAR || type == PanelType.SF) || metadata < 24 && type == PanelType.SFDIAG) {
        tilegood.meta += 8;
        return true;
    }
    int metaDir = ((metadata & 7) + 1) % 6;
    // 0->1 1->2 2->5 3->4 4->0 5->3
    if (// after north
    metaDir == 3) {
        metaDir = 5;
    } else if (metaDir == 0) {
        metaDir = 3;
    } else if (metaDir == 5) {
        metaDir = 0;
    }
    tilegood.meta = metaDir;
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityPanelLight(micdoodle8.mods.galacticraft.core.tile.TileEntityPanelLight)

Example 7 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class BlockPanelLighting method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    int damage = stack.getItemDamage();
    if (damage >= PANELTYPES_LENGTH)
        damage = 0;
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityPanelLight && placer instanceof EntityPlayer) {
        ((TileEntityPanelLight) tile).initialise(damage, EnumFacing.getDirectionFromEntityLiving(pos, placer), (EntityPlayer) placer, worldIn.isRemote, ((BlockPanelLighting) state.getBlock()).superState[damage]);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityPanelLight(micdoodle8.mods.galacticraft.core.tile.TileEntityPanelLight)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)5 BlockPanelLighting (micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)3 TileEntityPanelLight (micdoodle8.mods.galacticraft.core.tile.TileEntityPanelLight)3 TileEntity (net.minecraft.tileentity.TileEntity)3 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)2 EnumBlockBasicMoon (micdoodle8.mods.galacticraft.core.blocks.BlockBasicMoon.EnumBlockBasicMoon)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1