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