use of binnie.design.blocks.DesignBlock in project Binnie by ForestryMC.
the class ModuleCarpentry method getCarpentryPanel.
public static DesignBlock getCarpentryPanel(final IDesignSystem system, final int meta) {
final DesignBlock block = DesignHelper.getDesignBlock(system, meta);
block.setPanel();
return block;
}
use of binnie.design.blocks.DesignBlock in project Binnie by ForestryMC.
the class BlockCarpentryPanel method onNeighborChange.
@Override
public void onNeighborChange(IBlockAccess blockAccess, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(blockAccess, pos, neighbor);
World world = (World) blockAccess;
final DesignBlock block = this.getCarpentryBlock(blockAccess, pos);
if (!DesignHelper.isValidPanelPlacement(blockAccess, pos, block.getFacing())) {
NonNullList<ItemStack> drops = NonNullList.create();
BlockMetadata.getDrops(drops, this, blockAccess, pos);
for (ItemStack stack : drops) {
spawnAsEntity(world, pos, stack);
}
world.setBlockToAir(pos);
}
}
use of binnie.design.blocks.DesignBlock in project Binnie by ForestryMC.
the class BlockCarpentryPanel method getPlacedMeta.
@Override
public int getPlacedMeta(ItemStack item, World world, BlockPos pos, EnumFacing clickedBlock) {
final DesignBlock block = ModuleCarpentry.getCarpentryPanel(this.getDesignSystem(), TileEntityMetadata.getItemDamage(item));
EnumFacing facing = clickedBlock;
boolean valid = true;
if (!DesignHelper.isValidPanelPlacement(world, pos, facing)) {
valid = false;
for (EnumFacing direction : EnumFacing.VALUES) {
if (DesignHelper.isValidPanelPlacement(world, pos, direction)) {
facing = direction;
valid = true;
break;
}
}
}
if (!valid) {
return -1;
}
block.setFacing(facing);
return block.getBlockMetadata(this.getDesignSystem());
}
use of binnie.design.blocks.DesignBlock in project Binnie by ForestryMC.
the class DesignHelper method getDesignBlock.
public static DesignBlock getDesignBlock(final IDesignSystem system, final int meta) {
final int plankID1 = meta & 0xFF;
final int plankID2 = meta >> 8 & 0xFF;
final int tile = meta >> 16 & 0x3FF;
final int rotation = meta >> 26 & 0x3;
final int axis = meta >> 28 & 0x7;
final IDesignMaterial type1 = system.getMaterial(plankID1);
final IDesignMaterial type2 = system.getMaterial(plankID2);
final IDesign type3 = Design.getDesignManager().getDesign(tile);
return new DesignBlock(system, type1, type2, type3, rotation, EnumFacing.VALUES[axis]);
}
Aggregations