Search in sources :

Example 76 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class LogisticsManager method getRequestedAmount.

public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
    if (requestedAmount == 0)
        return 0;
    providingStack = providingStack.copy();
    providingStack.amount = requestedAmount;
    FluidStack remainder = providingStack.copy();
    remainder.amount += requester.getIncomingFluid(remainder.getFluid());
    TileEntity te = requester.getTileEntity();
    if (te instanceof IFluidHandler) {
        IFluidHandler fluidHandler = (IFluidHandler) te;
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            int fluidFilled = fluidHandler.fill(d, remainder, false);
            if (fluidFilled > 0) {
                remainder.amount -= fluidFilled;
                break;
            }
        }
    }
    providingStack.amount -= remainder.amount;
    if (providingStack.amount <= 0)
        return 0;
    return providingStack.amount;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISpecificRequester(pneumaticCraft.common.semiblock.ISpecificRequester) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 77 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockAphorismTile method setBlockBoundsBasedOnState.

@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int par2, int par3, int par4) {
    ForgeDirection dir = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(par2, par3, par4));
    setBlockBounds(dir.offsetX <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetY <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetZ <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetX >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS, dir.offsetY >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS, dir.offsetZ >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS);
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 78 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockHeatSink method setBlockBoundsBasedOnState.

@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int par2, int par3, int par4) {
    ForgeDirection dir = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(par2, par3, par4));
    setBlockBounds(dir.offsetX <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetY <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetX >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetY >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS);
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 79 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockOmnidirectionalHopper method collisionRayTrace.

@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityOmnidirectionalHopper) {
        ForgeDirection o = ((TileEntityOmnidirectionalHopper) te).getDirection();
        boolean isColliding = false;
        setBlockBounds(o.offsetX == 1 ? 10 / 16F : 0, o.offsetY == 1 ? 10 / 16F : 0, o.offsetZ == 1 ? 10 / 16F : 0, o.offsetX == -1 ? 6 / 16F : 1, o.offsetY == -1 ? 6 / 16F : 1, o.offsetZ == -1 ? 6 / 16F : 1);
        if (super.collisionRayTrace(world, x, y, z, origin, direction) != null)
            isColliding = true;
        setBlockBounds(4 / 16F, 4 / 16F, 4 / 16F, 12 / 16F, 12 / 16F, 12 / 16F);
        if (super.collisionRayTrace(world, x, y, z, origin, direction) != null)
            isColliding = true;
        setBlockBounds(0, 0, 0, 1, 1, 1);
        return isColliding ? super.collisionRayTrace(world, x, y, z, origin, direction) : null;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityOmnidirectionalHopper(pneumaticCraft.common.tileentity.TileEntityOmnidirectionalHopper) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 80 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockElevatorCaller method collisionRayTrace.

@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
    setBlockBounds(0, 0, 0, 1, 1, 1);
    MovingObjectPosition rayTrace = super.collisionRayTrace(world, x, y, z, origin, direction);
    ForgeDirection orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) & 7).getOpposite();
    if (rayTrace != null && rayTrace.sideHit == orientation.ordinal()) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntityElevatorCaller) {
            TileEntityElevatorCaller caller = (TileEntityElevatorCaller) te;
            for (TileEntityElevatorCaller.ElevatorButton button : caller.getFloors()) {
                float startX = 0, startZ = 0, endX = 0, endZ = 0;
                switch(orientation) {
                    case NORTH:
                        startZ = 0F;
                        endZ = 0.01F;
                        endX = 1 - (float) button.posX;
                        startX = 1 - ((float) button.posX + (float) button.width);
                        break;
                    case SOUTH:
                        startZ = 0.99F;
                        endZ = 1F;
                        startX = (float) button.posX;
                        endX = (float) button.posX + (float) button.width;
                        break;
                    case WEST:
                        startX = 0F;
                        endX = 0.01F;
                        startZ = (float) button.posX;
                        endZ = (float) button.posX + (float) button.width;
                        break;
                    case EAST:
                        startX = 0.99F;
                        endX = 1F;
                        endZ = 1 - (float) button.posX;
                        startZ = 1 - ((float) button.posX + (float) button.width);
                        break;
                }
                setBlockBounds(startX, 1 - (float) (button.posY + button.height), startZ, endX, 1 - (float) button.posY, endZ);
                MovingObjectPosition buttonTrace = super.collisionRayTrace(world, x, y, z, origin, direction);
                if (buttonTrace != null) {
                    if (startX > 0.01F && startX < 0.98F)
                        startX += 0.01F;
                    if (startZ > 0.01F && startZ < 0.98F)
                        startZ += 0.01F;
                    if (endX > 0.02F && endX < 0.99F)
                        endX -= 0.01F;
                    if (endZ > 0.02F && endZ < 0.99F)
                        endZ -= 0.01F;
                    setBlockBounds(startX, 1.01F - (float) (button.posY + button.height), startZ, endX, 0.99F - (float) button.posY, endZ);
                    buttonTrace.subHit = button.floorNumber;
                    return buttonTrace;
                }
            }
        }
    }
    setBlockBounds(0, 0, 0, 1, 1, 1);
    return rayTrace;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileEntityElevatorCaller(pneumaticCraft.common.tileentity.TileEntityElevatorCaller)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)242 TileEntity (net.minecraft.tileentity.TileEntity)80 ItemStack (net.minecraft.item.ItemStack)47 ArrayList (java.util.ArrayList)29 Block (net.minecraft.block.Block)28 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)24 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)21 IInventory (net.minecraft.inventory.IInventory)19 FluidStack (net.minecraftforge.fluids.FluidStack)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)17 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)16 HashMap (java.util.HashMap)12 Pair (logisticspipes.utils.tuples.Pair)11 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)10 World (net.minecraft.world.World)10 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8