Search in sources :

Example 1 with DesignBlock

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;
}
Also used : DesignBlock(binnie.design.blocks.DesignBlock)

Example 2 with DesignBlock

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);
    }
}
Also used : DesignBlock(binnie.design.blocks.DesignBlock) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 3 with DesignBlock

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());
}
Also used : DesignBlock(binnie.design.blocks.DesignBlock) EnumFacing(net.minecraft.util.EnumFacing)

Example 4 with DesignBlock

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]);
}
Also used : DesignBlock(binnie.design.blocks.DesignBlock) IDesign(binnie.design.api.IDesign) IDesignMaterial(binnie.design.api.IDesignMaterial)

Aggregations

DesignBlock (binnie.design.blocks.DesignBlock)4 IDesign (binnie.design.api.IDesign)1 IDesignMaterial (binnie.design.api.IDesignMaterial)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 World (net.minecraft.world.World)1