Search in sources :

Example 1 with BlockType

use of crazypants.enderio.machines.machine.teleport.telepad.render.BlockType in project EnderIO by SleepyTrousers.

the class BlockTelePad method getSelectedBoundingBox.

@Deprecated
@Override
@Nonnull
public AxisAlignedBB getSelectedBoundingBox(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos) {
    if (bs.getBlock() == this) {
        BlockType bt = bs.getValue(BLOCK_TYPE);
        if (bt != BlockType.SINGLE) {
            BlockPos masterLoc = bt.getLocationOfMaster(pos);
            AxisAlignedBB res = new AxisAlignedBB(masterLoc.south().south().west(), masterLoc.north().east().east().up());
            return res;
        }
    }
    return super.getSelectedBoundingBox(bs, world, pos);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockType(crazypants.enderio.machines.machine.teleport.telepad.render.BlockType) BlockPos(net.minecraft.util.math.BlockPos) Nonnull(javax.annotation.Nonnull)

Example 2 with BlockType

use of crazypants.enderio.machines.machine.teleport.telepad.render.BlockType in project EnderIO by SleepyTrousers.

the class BlockTelePad method getStateForPlacement.

@Override
@Deprecated
@Nonnull
public IBlockState getStateForPlacement(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @Nonnull EntityLivingBase placer) {
    BlockPos swCorner = findSouthWestCorner(worldIn, pos);
    BlockPos masterPos = getMasterPosForNewMB(worldIn, swCorner, pos);
    if (masterPos == null) {
        return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
    }
    BlockType myType = null;
    for (BlockType bt : BlockType.values()) {
        BlockPos test = bt.getLocationOfMaster(pos);
        if (test != null && test.equals(masterPos)) {
            myType = bt;
        }
    }
    if (myType == null) {
        return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
    }
    if (!worldIn.isRemote) {
        updateMultiBlock(worldIn, masterPos, pos, true);
    }
    return getStateFromMeta(myType.ordinal());
}
Also used : BlockType(crazypants.enderio.machines.machine.teleport.telepad.render.BlockType) BlockPos(net.minecraft.util.math.BlockPos) Nonnull(javax.annotation.Nonnull)

Example 3 with BlockType

use of crazypants.enderio.machines.machine.teleport.telepad.render.BlockType in project EnderIO by SleepyTrousers.

the class BlockTelePad method breakBlock.

@Override
public void breakBlock(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
    if (state.getBlock() == this) {
        BlockType type = state.getValue(BLOCK_TYPE);
        if (type != BlockType.SINGLE) {
            BlockPos masterPos = type.getLocationOfMaster(pos);
            updateMultiBlock(worldIn, masterPos, pos, false);
        }
    }
}
Also used : BlockType(crazypants.enderio.machines.machine.teleport.telepad.render.BlockType) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with BlockType

use of crazypants.enderio.machines.machine.teleport.telepad.render.BlockType in project EnderIO by SleepyTrousers.

the class BlockTelePad method openGui.

@Override
protected boolean openGui(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer entityPlayer, @Nonnull EnumFacing side) {
    BlockType type = world.getBlockState(pos).getValue(BLOCK_TYPE);
    BlockPos masterPos = type.getLocationOfMaster(pos);
    if (masterPos != null) {
        TileTelePad tp = getTileEntity(world, masterPos);
        if (tp != null) {
            if (tp.canBlockBeAccessed(entityPlayer)) {
                return openGui(world, masterPos, entityPlayer, side, GUI_ID_TELEPAD);
            } else {
                sendPrivateStatusMessage(world, entityPlayer, tp.getOwner());
                return false;
            }
        }
    }
    entityPlayer.sendStatusMessage(Lang.STATUS_TELEPAD_UNFORMED.toChatServer(), true);
    return false;
}
Also used : BlockType(crazypants.enderio.machines.machine.teleport.telepad.render.BlockType) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with BlockType

use of crazypants.enderio.machines.machine.teleport.telepad.render.BlockType in project EnderIO by SleepyTrousers.

the class BlockTelePad method updateMultiBlock.

private void updateMultiBlock(World world, BlockPos masterPos, BlockPos ignorePos, boolean form) {
    for (BlockType type : BlockType.values()) {
        if (type != BlockType.SINGLE) {
            Vec3i offset = type.getOffsetFromMaster();
            BlockPos targetPos = new BlockPos(masterPos.getX() + offset.getX(), masterPos.getY() + offset.getY(), masterPos.getZ() + offset.getZ());
            if (!targetPos.equals(ignorePos)) {
                BlockType setToType = BlockType.SINGLE;
                if (form) {
                    setToType = type;
                }
                world.setBlockState(targetPos, getDefaultState().withProperty(BLOCK_TYPE, setToType), 3);
            }
        }
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockType(crazypants.enderio.machines.machine.teleport.telepad.render.BlockType) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockType (crazypants.enderio.machines.machine.teleport.telepad.render.BlockType)5 BlockPos (net.minecraft.util.math.BlockPos)5 Nonnull (javax.annotation.Nonnull)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 Vec3i (net.minecraft.util.math.Vec3i)1