Search in sources :

Example 21 with EnumFacing

use of net.minecraft.util.EnumFacing in project NetherEx by LogicTechCorp.

the class PigtificateVillage method getFenceGateInfo.

public VillageFenceGateInfo getFenceGateInfo(BlockPos pos) {
    VillageFenceGateInfo fenceGateInfo = null;
    int i = Integer.MAX_VALUE;
    for (VillageFenceGateInfo fenceGateInfo1 : villageFenceGateInfoList) {
        int j = fenceGateInfo1.getDistanceToFenceGateBlockSq(pos);
        if (j > 256) {
            j = j * 1000;
        } else {
            j = fenceGateInfo1.getFenceGateOpeningRestrictionCounter();
        }
        if (j < i) {
            BlockPos blockpos = fenceGateInfo1.getFenceGateBlockPos();
            EnumFacing enumfacing = fenceGateInfo1.getInsideDirection();
            if (world.getBlockState(blockpos.offset(enumfacing, 1)).getBlock().blocksMovement(world, blockpos.offset(enumfacing, 1)) && world.getBlockState(blockpos.offset(enumfacing, -1)).getBlock().blocksMovement(world, blockpos.offset(enumfacing, -1)) && world.getBlockState(blockpos.up().offset(enumfacing, 1)).getBlock().blocksMovement(world, blockpos.up().offset(enumfacing, 1)) && world.getBlockState(blockpos.up().offset(enumfacing, -1)).getBlock().blocksMovement(world, blockpos.up().offset(enumfacing, -1))) {
                fenceGateInfo = fenceGateInfo1;
                i = j;
            }
        }
    }
    return fenceGateInfo;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 22 with EnumFacing

use of net.minecraft.util.EnumFacing in project NetherEx by LogicTechCorp.

the class PigtificateVillageCollection method getOutside.

private EnumFacing getOutside(BlockPos fenceGatePos) {
    IBlockState fenceGateState = world.getBlockState(fenceGatePos);
    IBlockState stairState = world.getBlockState(fenceGatePos.up(2));
    if (fenceGateState.getBlock() instanceof BlockFenceGate && stairState.getBlock() instanceof BlockStairs) {
        EnumFacing fenceGateFacing = fenceGateState.getValue(BlockFenceGate.FACING);
        EnumFacing stairFacing = stairState.getValue(BlockStairs.FACING);
        if (stairFacing == fenceGateFacing || stairFacing == fenceGateFacing.getOpposite()) {
            return stairFacing;
        }
        return null;
    } else {
        return null;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) EnumFacing(net.minecraft.util.EnumFacing) BlockStairs(net.minecraft.block.BlockStairs)

Example 23 with EnumFacing

use of net.minecraft.util.EnumFacing in project NetherEx by LogicTechCorp.

the class PigtificateVillageCollection method addFenceGatesAround.

private void addFenceGatesAround(BlockPos central) {
    for (int l = -16; l < 16; ++l) {
        for (int i1 = -4; i1 < 4; ++i1) {
            for (int j1 = -16; j1 < 16; ++j1) {
                BlockPos blockpos = central.add(l, i1, j1);
                EnumFacing outside = getOutside(blockpos);
                if (outside != null) {
                    VillageFenceGateInfo villagefenceGateinfo = checkFenceGateExistence(blockpos);
                    if (villagefenceGateinfo == null) {
                        addToNewFenceGatesList(blockpos, outside);
                    } else {
                        villagefenceGateinfo.setLastActivityTimestamp(tickCounter);
                    }
                }
            }
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos)

Example 24 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityArcFurnace method getAdvancedSelectionBounds.

@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
    if (pos % 15 == 7)
        return null;
    EnumFacing fl = facing;
    EnumFacing fw = facing.rotateY();
    if (mirrored)
        fw = fw.getOpposite();
    if (pos == 0) {
        List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        float minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .125f;
        float maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .25f;
        float minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .125f;
        float maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .25f;
        list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .75f;
        maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .875f;
        minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .75f;
        maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .875f;
        list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        return list;
    } else if (pos >= 46 && pos <= 48) {
        float minX = fl == EnumFacing.WEST ? .25f : 0;
        float maxX = fl == EnumFacing.EAST ? .75f : 1;
        float minZ = fl == EnumFacing.NORTH ? .25f : 0;
        float maxZ = fl == EnumFacing.SOUTH ? .75f : 1;
        List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        minX = fl == EnumFacing.WEST ? 0 : fl == EnumFacing.EAST ? .75f : .25f;
        maxX = fl == EnumFacing.EAST ? 1 : fl == EnumFacing.WEST ? .25f : .75f;
        minZ = fl == EnumFacing.NORTH ? 0 : fl == EnumFacing.SOUTH ? .75f : .25f;
        maxZ = fl == EnumFacing.SOUTH ? 1 : fl == EnumFacing.NORTH ? .25f : .75f;
        list.add(new AxisAlignedBB(minX, .25f, minZ, maxX, .75, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        return list;
    } else if (pos % 25 >= 10 && (pos % 5 == 0 || pos % 5 == 4)) {
        List<AxisAlignedBB> list = pos < 25 ? Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ())) : new ArrayList(2);
        if (pos % 5 == 4)
            fw = fw.getOpposite();
        float minX = fw == EnumFacing.EAST ? .5f : 0;
        float maxX = fw == EnumFacing.WEST ? .5f : 1;
        float minZ = fw == EnumFacing.SOUTH ? .5f : 0;
        float maxZ = fw == EnumFacing.NORTH ? .5f : 1;
        if (pos % 25 / 5 != 3)
            list.add(new AxisAlignedBB(minX, pos < 25 ? .5 : 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        if (pos < 25) {
            minX = fw == EnumFacing.EAST ? .125f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .375f : -1.625f;
            maxX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .875f : fl == EnumFacing.WEST ? .625f : 2.625f;
            minZ = fw == EnumFacing.SOUTH ? .125f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .375f : -1.625f;
            maxZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .875f : fl == EnumFacing.NORTH ? .625f : 2.625f;
            AxisAlignedBB aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            list.add(aabb);
            minX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .375f : .375f;
            maxX = fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.WEST ? .625f : .625f;
            minZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .375f : .375f;
            maxZ = fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.NORTH ? .625f : .625f;
            aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            list.add(aabb);
            minX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? 2.375f : -1.625f;
            maxX = fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.WEST ? -1.375f : 2.625f;
            minZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? 2.375f : -1.625f;
            maxZ = fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.NORTH ? -1.375f : 2.625f;
            aabb = new AxisAlignedBB(minX, .6875, minZ, maxX, .9375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            list.add(aabb);
        } else if (pos < 50) {
            minX = fw == EnumFacing.EAST ? .125f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .375f : -1.625f;
            maxX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .875f : fl == EnumFacing.WEST ? .625f : 2.625f;
            minZ = fw == EnumFacing.SOUTH ? .125f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .375f : -1.625f;
            maxZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .875f : fl == EnumFacing.NORTH ? .625f : 2.625f;
            AxisAlignedBB aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            list.add(aabb);
            minX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .375f : .375f;
            maxX = fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.WEST ? .625f : .625f;
            minZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .375f : .375f;
            maxZ = fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.NORTH ? .625f : .625f;
            aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            if (pos % 5 == 0)
                aabb = aabb.offset(0, .6875, 0);
            list.add(aabb);
            if (pos % 5 == 0) {
                minX = fw == EnumFacing.EAST ? .125f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .375f : .375f;
                maxX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .875f : fl == EnumFacing.WEST ? .625f : .625f;
                minZ = fw == EnumFacing.SOUTH ? .125f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .375f : .375f;
                maxZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .875f : fl == EnumFacing.NORTH ? .625f : .625f;
                aabb = new AxisAlignedBB(minX, .375, minZ, maxX, 1.0625, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
                aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
                list.add(aabb);
            }
            minX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? 2.375f : -1.625f;
            maxX = fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? .625f : fl == EnumFacing.WEST ? -1.375f : 2.625f;
            minZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? 2.375f : -1.625f;
            maxZ = fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? .625f : fl == EnumFacing.NORTH ? -1.375f : 2.625f;
            aabb = new AxisAlignedBB(minX, .125, minZ, maxX, .375, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ());
            aabb = aabb.offset(-fl.getFrontOffsetX() * (pos % 25 - 10) / 5, 0, -fl.getFrontOffsetZ() * (pos % 25 - 10) / 5);
            list.add(aabb);
        } else if (pos == 60 || pos == 64) {
            minX = fw == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .5f : .25f;
            maxX = fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? .625f : .75f;
            minZ = fw == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .5f : .25f;
            maxZ = fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? .625f : .75f;
            list.add(new AxisAlignedBB(minX, .25, minZ, maxX, .75, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        }
        return list;
    }
    return null;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 25 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class BlockIEFluidConcrete method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    if (!isSourceBlock(world, pos) && ForgeEventFactory.canCreateFluidSource(world, pos, state, false)) {
        int adjacentSourceBlocks = (isSourceBlock(world, pos.north()) ? 1 : 0) + (isSourceBlock(world, pos.south()) ? 1 : 0) + (isSourceBlock(world, pos.east()) ? 1 : 0) + (isSourceBlock(world, pos.west()) ? 1 : 0);
        if (adjacentSourceBlocks >= 2 && (world.getBlockState(pos.up(densityDir)).getMaterial().isSolid() || isSourceBlock(world, pos.up(densityDir))))
            world.setBlockState(pos, state.withProperty(LEVEL, 0));
    }
    int level = state.getValue(LEVEL);
    int timer = state.getValue(IEProperties.INT_16);
    int quantaRemaining = quantaPerBlock - level;
    int expQuanta = -101;
    if (timer >= Math.min(14, quantaRemaining)) {
        IBlockState solidState;
        if (level >= 14)
            solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_SHEET.getMeta());
        else if (level >= 10)
            solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_QUARTER.getMeta());
        else if (level >= 6)
            solidState = IEContent.blockStoneDecorationSlabs.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE.getMeta());
        else if (level >= 2)
            solidState = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CONCRETE_THREEQUARTER.getMeta());
        else
            solidState = IEContent.blockStoneDecoration.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE.getMeta());
        world.setBlockState(pos, solidState);
        for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)))) living.addPotionEffect(new PotionEffect(IEPotions.concreteFeet, Integer.MAX_VALUE));
        return;
    } else {
        state = state.withProperty(IEProperties.INT_16, Math.min(15, timer + 1));
        world.setBlockState(pos, state);
    }
    // check adjacent block levels if non-source
    if (quantaRemaining < quantaPerBlock) {
        if (world.getBlockState(pos.add(0, -densityDir, 0)).getBlock() == this || world.getBlockState(pos.add(-1, -densityDir, 0)).getBlock() == this || world.getBlockState(pos.add(1, -densityDir, 0)).getBlock() == this || world.getBlockState(pos.add(0, -densityDir, -1)).getBlock() == this || world.getBlockState(pos.add(0, -densityDir, 1)).getBlock() == this) {
            expQuanta = quantaPerBlock - 1;
        } else {
            int maxQuanta = -100;
            maxQuanta = getLargerQuanta(world, pos.add(-1, 0, 0), maxQuanta);
            maxQuanta = getLargerQuanta(world, pos.add(1, 0, 0), maxQuanta);
            maxQuanta = getLargerQuanta(world, pos.add(0, 0, -1), maxQuanta);
            maxQuanta = getLargerQuanta(world, pos.add(0, 0, 1), maxQuanta);
            expQuanta = maxQuanta - 1;
        }
        int total = level;
        int blocks = 1;
        for (EnumFacing f : EnumFacing.HORIZONTALS) {
            IBlockState otherState = world.getBlockState(pos.offset(f));
            if (otherState.getBlock() == this) {
                blocks++;
                total += otherState.getValue(LEVEL);
            }
        }
        int newEvenQuanta = (int) Math.ceil(total / (float) blocks);
        for (EnumFacing f : EnumFacing.HORIZONTALS) {
            IBlockState otherState = world.getBlockState(pos.offset(f));
            if (otherState.getBlock() == this)
                world.setBlockState(pos.offset(f), otherState.withProperty(LEVEL, newEvenQuanta));
        }
        // decay calculation
        if (expQuanta != quantaRemaining) {
            quantaRemaining = expQuanta;
            if (expQuanta <= 0)
                world.setBlockToAir(pos);
            else {
                world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), 2);
                world.scheduleUpdate(pos, this, tickRate);
                world.notifyNeighborsOfStateChange(pos, this);
            }
        }
    } else // This is a "source" block, set meta to zero, and send a server only update
    if (quantaRemaining >= quantaPerBlock)
        world.setBlockState(pos, this.getDefaultState(), 2);
    // Flow vertically if possible
    if (canDisplace(world, pos.up(densityDir))) {
        flowIntoBlockRet(world, pos.up(densityDir), 1, timer);
        return;
    }
    // Flow outward if possible
    int flowMeta = quantaPerBlock - quantaRemaining + 1;
    if (flowMeta >= quantaPerBlock) {
        world.setBlockState(pos, state.withProperty(IEProperties.INT_16, Math.min(15, timer + 1)));
        world.scheduleUpdate(pos, this, tickRate);
        return;
    }
    if (isSourceBlock(world, pos) || !isFlowingVertically(world, pos)) {
        if (world.getBlockState(pos.down(densityDir)).getBlock() == this)
            flowMeta = 1;
        boolean[] flowTo = getOptimalFlowDirections(world, pos);
        boolean hasFlown = false;
        if (flowTo[0])
            hasFlown |= flowIntoBlockRet(world, pos.add(-1, 0, 0), flowMeta, timer);
        if (flowTo[1])
            hasFlown |= flowIntoBlockRet(world, pos.add(1, 0, 0), flowMeta, timer);
        if (flowTo[2])
            hasFlown |= flowIntoBlockRet(world, pos.add(0, 0, -1), flowMeta, timer);
        if (flowTo[3])
            hasFlown |= flowIntoBlockRet(world, pos.add(0, 0, 1), flowMeta, timer);
        if (!hasFlown) {
            world.setBlockState(pos, state.withProperty(IEProperties.INT_16, Math.min(15, timer + 1)));
            world.scheduleUpdate(pos, this, tickRate);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EnumFacing(net.minecraft.util.EnumFacing) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)260 BlockPos (net.minecraft.util.math.BlockPos)94 TileEntity (net.minecraft.tileentity.TileEntity)64 IBlockState (net.minecraft.block.state.IBlockState)57 Block (net.minecraft.block.Block)35 ItemStack (net.minecraft.item.ItemStack)24 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)23 Vec3d (net.minecraft.util.math.Vec3d)16 ArrayList (java.util.ArrayList)15 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)10 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 World (net.minecraft.world.World)9 Tessellator (net.minecraft.client.renderer.Tessellator)8 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)8 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 List (java.util.List)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)6 Nonnull (javax.annotation.Nonnull)5