Search in sources :

Example 26 with EnumFacing

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

the class BlockConveyor method onIEBlockPlacedBy.

@Override
public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack) {
    super.onIEBlockPlacedBy(world, pos, state, side, hitX, hitY, hitZ, placer, stack);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityConveyorBelt && !(tile instanceof TileEntityConveyorVertical)) {
        TileEntityConveyorBelt conveyor = (TileEntityConveyorBelt) tile;
        EnumFacing f = conveyor.facing;
        ResourceLocation rl = new ResourceLocation(ItemNBTHelper.getString(stack, "conveyorType"));
        IConveyorBelt subType = ConveyorHandler.getConveyor(rl, conveyor);
        conveyor.setConveyorSubtype(subType);
        tile = world.getTileEntity(pos.offset(f));
        TileEntity tileUp = world.getTileEntity(pos.offset(f).add(0, 1, 0));
        if (subType != null && (!(tile instanceof IConveyorTile) || ((IConveyorTile) tile).getFacing() == f.getOpposite()) && tileUp instanceof IConveyorTile && ((IConveyorTile) tileUp).getFacing() != f.getOpposite() && world.isAirBlock(pos.add(0, 1, 0)))
            subType.setConveyorDirection(ConveyorDirection.UP);
        tile = world.getTileEntity(pos.offset(f.getOpposite()).add(0, 1, 0));
    //			if(tile instanceof TileEntityConveyorBelt&&!(tile instanceof TileEntityConveyorVertical) && ((TileEntityConveyorBelt)tile).facing==f)
    //				conveyor.transportDown = true;
    //			if(conveyor.transportUp && conveyor.transportDown)
    //				conveyor.transportDown = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) ResourceLocation(net.minecraft.util.ResourceLocation) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 27 with EnumFacing

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

the class BlockIETileProvider method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof IConfigurableSides && Utils.isHammer(heldItem) && !world.isRemote) {
        int iSide = player.isSneaking() ? side.getOpposite().ordinal() : side.ordinal();
        if (((IConfigurableSides) tile).toggleSide(iSide, player))
            return true;
    }
    if (tile instanceof IDirectionalTile && Utils.isHammer(heldItem) && ((IDirectionalTile) tile).canHammerRotate(side, hitX, hitY, hitZ, player) && !world.isRemote) {
        EnumFacing f = ((IDirectionalTile) tile).getFacing();
        int limit = ((IDirectionalTile) tile).getFacingLimitation();
        if (limit == 0)
            f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length];
        else if (limit == 1)
            f = player.isSneaking() ? f.rotateAround(side.getAxis()).getOpposite() : f.rotateAround(side.getAxis());
        else if (limit == 2 || limit == 5)
            f = player.isSneaking() ? f.rotateYCCW() : f.rotateY();
        ((IDirectionalTile) tile).setFacing(f);
        tile.markDirty();
        world.notifyBlockUpdate(pos, state, state, 3);
        world.addBlockEvent(tile.getPos(), tile.getBlockType(), 255, 0);
        return true;
    }
    if (tile instanceof IHammerInteraction && Utils.isHammer(heldItem) && !world.isRemote) {
        boolean b = ((IHammerInteraction) tile).hammerUseSide(side, player, hitX, hitY, hitZ);
        if (b)
            return b;
    }
    if (tile instanceof IPlayerInteraction) {
        boolean b = ((IPlayerInteraction) tile).interact(side, player, hand, heldItem, hitX, hitY, hitZ);
        if (b)
            return b;
    }
    if (tile instanceof IGuiTile && hand == EnumHand.MAIN_HAND && !player.isSneaking()) {
        TileEntity master = ((IGuiTile) tile).getGuiMaster();
        if (!world.isRemote && master != null && ((IGuiTile) master).canOpenGui(player))
            CommonProxy.openGuiForTile(player, (TileEntity & IGuiTile) master);
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing)

Example 28 with EnumFacing

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

the class TileEntitySqueezer method getAdvancedSelectionBounds.

@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
    EnumFacing fl = facing;
    EnumFacing fw = facing.rotateY();
    if (mirrored)
        fw = fw.getOpposite();
    if (pos == 2) {
        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;
    }
    if (pos == 3 || pos == 4 || pos == 6 || pos == 7) {
        List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        if (pos > 5)
            fl = fl.getOpposite();
        if (pos % 3 == 1)
            fw = fw.getOpposite();
        float minX = fl == EnumFacing.WEST ? .6875f : fl == EnumFacing.EAST ? .0625f : fw == EnumFacing.EAST ? .0625f : .6875f;
        float maxX = fl == EnumFacing.EAST ? .3125f : fl == EnumFacing.WEST ? .9375f : fw == EnumFacing.EAST ? .3125f : .9375f;
        float minZ = fl == EnumFacing.NORTH ? .6875f : fl == EnumFacing.SOUTH ? .0625f : fw == EnumFacing.SOUTH ? .0625f : .6875f;
        float maxZ = fl == EnumFacing.SOUTH ? .3125f : fl == EnumFacing.NORTH ? .9375f : fw == EnumFacing.SOUTH ? .3125f : .9375f;
        list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        if (pos == 4) {
            minX = fl == EnumFacing.WEST ? .375f : fl == EnumFacing.EAST ? .625f : fw == EnumFacing.WEST ? -.125f : 0;
            maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .625f : fw == EnumFacing.EAST ? 1.125f : 1;
            minZ = fl == EnumFacing.NORTH ? .375f : fl == EnumFacing.SOUTH ? .625f : fw == EnumFacing.NORTH ? -.125f : 0;
            maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .625f : fw == EnumFacing.SOUTH ? 1.125f : 1;
            list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
            minX = fl == EnumFacing.WEST ? -.125f : fl == EnumFacing.EAST ? .625f : fw == EnumFacing.WEST ? -.125f : .875f;
            maxX = fl == EnumFacing.EAST ? 1.125f : fl == EnumFacing.WEST ? .375f : fw == EnumFacing.EAST ? 1.125f : .125f;
            minZ = fl == EnumFacing.NORTH ? -.125f : fl == EnumFacing.SOUTH ? .625f : fw == EnumFacing.NORTH ? -.125f : .875f;
            maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? .375f : fw == EnumFacing.SOUTH ? 1.125f : .125f;
            list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
            minX = fl == EnumFacing.WEST ? -.125f : fl == EnumFacing.EAST ? .875f : fw == EnumFacing.WEST ? -.125f : .875f;
            maxX = fl == EnumFacing.EAST ? 1.125f : fl == EnumFacing.WEST ? .125f : fw == EnumFacing.EAST ? 1.125f : .125f;
            minZ = fl == EnumFacing.NORTH ? -.125f : fl == EnumFacing.SOUTH ? .875f : fw == EnumFacing.NORTH ? -.125f : .875f;
            maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? .125f : fw == EnumFacing.SOUTH ? 1.125f : .125f;
            list.add(new AxisAlignedBB(minX, .75f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        }
        return list;
    }
    if ((pos == 12 || pos == 13 || pos == 15 || pos == 16) || (pos == 21 || pos == 22 || pos == 24 || pos == 25)) {
        List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(2);
        if (pos < 18)
            list.add(new AxisAlignedBB(0, 0, 0, 1, .125f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        if (pos % 9 > 5)
            fl = fl.getOpposite();
        if (pos % 3 == 1)
            fw = fw.getOpposite();
        float minY = pos < 18 ? .125f : -.875f;
        float maxY = pos < 18 ? 1.125f : .125f;
        float minX = fl == EnumFacing.WEST ? .84375f : fl == EnumFacing.EAST ? 0f : fw == EnumFacing.EAST ? 0f : .84375f;
        float maxX = fl == EnumFacing.EAST ? .15625f : fl == EnumFacing.WEST ? 1f : fw == EnumFacing.EAST ? .15625f : 1;
        float minZ = fl == EnumFacing.NORTH ? .84375f : fl == EnumFacing.SOUTH ? 0f : fw == EnumFacing.SOUTH ? 0f : .84375f;
        float maxZ = fl == EnumFacing.SOUTH ? .15625f : fl == EnumFacing.NORTH ? 1f : fw == EnumFacing.SOUTH ? .15625f : 1;
        list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        minX = fl == EnumFacing.WEST ? 0f : fl == EnumFacing.EAST ? .15625f : fw == EnumFacing.EAST ? .0625f : .8125f;
        maxX = fl == EnumFacing.EAST ? 1f : fl == EnumFacing.WEST ? .84375f : fw == EnumFacing.EAST ? .1875f : .9375f;
        minZ = fl == EnumFacing.NORTH ? 0f : fl == EnumFacing.SOUTH ? .15625f : fw == EnumFacing.SOUTH ? .0625f : .8125f;
        maxZ = fl == EnumFacing.SOUTH ? 1f : fl == EnumFacing.NORTH ? .84375f : fw == EnumFacing.SOUTH ? .1875f : .9375f;
        list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        minX = fl == EnumFacing.WEST ? .8125f : fl == EnumFacing.EAST ? .0625f : fw == EnumFacing.EAST ? .15625f : 0f;
        maxX = fl == EnumFacing.EAST ? .1875f : fl == EnumFacing.WEST ? .9375f : fw == EnumFacing.EAST ? 1f : .84375f;
        minZ = fl == EnumFacing.NORTH ? .8125f : fl == EnumFacing.SOUTH ? .0625f : fw == EnumFacing.SOUTH ? .15625f : 0f;
        maxZ = fl == EnumFacing.SOUTH ? .1875f : fl == EnumFacing.NORTH ? .9375f : fw == EnumFacing.SOUTH ? 1f : .84375f;
        list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
        if (pos > 18) {
            minX = fl == EnumFacing.WEST ? -.25f : fl == EnumFacing.EAST ? 1.25f : fw == EnumFacing.EAST ? .75f : -.25f;
            maxX = fl == EnumFacing.EAST ? .75f : fl == EnumFacing.WEST ? .25f : fw == EnumFacing.EAST ? 1.25f : .25f;
            minZ = fl == EnumFacing.NORTH ? -.25f : fl == EnumFacing.SOUTH ? 1.25f : fw == EnumFacing.SOUTH ? .75f : -.25f;
            maxZ = fl == EnumFacing.SOUTH ? .75f : fl == EnumFacing.NORTH ? .25f : fw == EnumFacing.SOUTH ? 1.25f : .25f;
            list.add(new AxisAlignedBB(minX, .375f, minZ, maxX, .9375f, 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)

Example 29 with EnumFacing

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

the class TileEntitySheetmetalTank method update.

@Override
public void update() {
    if (pos == 4 && !worldObj.isRemote && worldObj.isBlockIndirectlyGettingPowered(getPos()) > 0)
        for (int i = 0; i < 6; i++) if (i != 1 && tank.getFluidAmount() > 0) {
            EnumFacing f = EnumFacing.getFront(i);
            int outSize = Math.min(144, tank.getFluidAmount());
            FluidStack out = new FluidStack(tank.getFluid().getFluid(), outSize);
            BlockPos outputPos = getPos().offset(f);
            IFluidHandler output = FluidUtil.getFluidHandler(worldObj, outputPos, f.getOpposite());
            if (output != null) {
                int accepted = output.fill(out, false);
                if (accepted > 0) {
                    int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true);
                    this.tank.drain(drained, true);
                    this.markContainingBlockForUpdate(null);
                    updateComparatorValuesPart2();
                }
            }
        }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) IComparatorOverride(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IComparatorOverride)

Example 30 with EnumFacing

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

the class TileEntityThermoelectricGen method update.

@Override
public void update() {
    if (!worldObj.isRemote) {
        int energy = 0;
        for (EnumFacing fd : new EnumFacing[] { EnumFacing.DOWN, EnumFacing.NORTH, EnumFacing.WEST }) if (!worldObj.isAirBlock(getPos().offset(fd)) && !worldObj.isAirBlock(getPos().offset(fd.getOpposite()))) {
            int temp0 = getTemperature(getPos().offset(fd));
            int temp1 = getTemperature(getPos().offset(fd.getOpposite()));
            if (temp0 > -1 && temp1 > -1) {
                int diff = Math.abs(temp0 - temp1);
                energy += (int) (Math.sqrt(diff) / 2 * IEConfig.Machines.thermoelectric_output);
            }
        }
        outputEnergy(energy);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

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