use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class ProgWidgetPressureCondition method getEvaluator.
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {
@Override
protected boolean evaluate(ChunkPosition pos) {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (te instanceof IPneumaticMachine) {
IAirHandler airHandler = ((IPneumaticMachine) te).getAirHandler();
float pressure = Float.MIN_VALUE;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (getSides()[d.ordinal()]) {
pressure = Math.max(airHandler.getPressure(d), pressure);
}
}
return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? pressure == ((ICondition) widget).getRequiredCount() : pressure >= ((ICondition) widget).getRequiredCount();
}
return false;
}
};
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class DroneInteractRFImport method doInteract.
@Override
public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate) {
IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone);
if (droneEnergy.getEnergyStored() == droneEnergy.getMaxEnergyStored()) {
interactHandler.abort();
return false;
} else {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (te instanceof IEnergyProvider) {
IEnergyProvider provider = (IEnergyProvider) te;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (interactHandler.getSides()[d.ordinal()]) {
int transferedEnergy = droneEnergy.receiveEnergy(provider.extractEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true);
if (transferedEnergy > 0) {
if (!simulate) {
interactHandler.decreaseCount(transferedEnergy);
droneEnergy.receiveEnergy(transferedEnergy, false);
provider.extractEnergy(d, transferedEnergy, false);
}
return true;
}
}
}
}
return false;
}
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class WailaHeatHandler method getNBTData.
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te instanceof IHeatExchanger) {
Set<IHeatExchangerLogic> heatExchangers = new HashSet<IHeatExchangerLogic>();
IHeatExchangerLogic logic = null;
boolean isMultisided = true;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (logic != null) {
if (heatExchangers.contains(logic)) {
isMultisided = false;
break;
} else {
heatExchangers.add(logic);
}
}
}
if (isMultisided) {
NBTTagList tagList = new NBTTagList();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
logic = ((IHeatExchanger) te).getHeatExchangerLogic(d);
if (logic != null) {
NBTTagCompound heatTag = new NBTTagCompound();
heatTag.setByte("side", (byte) d.ordinal());
heatTag.setInteger("temp", (int) logic.getTemperature());
tagList.appendTag(heatTag);
}
}
tag.setTag("heat", tagList);
} else if (logic != null) {
tag.setInteger("temp", (int) logic.getTemperature());
}
}
return tag;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class TileEntityAssemblyDrill method updateEntity.
@Override
public void updateEntity() {
oldDrillRotation = drillRotation;
super.updateEntity();
if (isDrillOn) {
drillSpeed = Math.min(drillSpeed + TileEntityConstants.ASSEMBLY_DRILL_ACCELERATION * speed, TileEntityConstants.ASSEMBLY_DRILL_MAX_SPEED);
} else {
drillSpeed = Math.max(drillSpeed - TileEntityConstants.ASSEMBLY_DRILL_ACCELERATION, 0);
}
drillRotation += drillSpeed;
while (drillRotation >= 360) {
drillRotation -= 360;
}
if (!worldObj.isRemote && drillStep > 0) {
ForgeDirection[] platformDirection = getPlatformDirection();
if (platformDirection == null)
drillStep = 1;
switch(drillStep) {
case 1:
slowMode = false;
gotoHomePosition();
break;
case 2:
hoverOverNeighbour(platformDirection[0], platformDirection[1]);
break;
case 3:
isDrillOn = true;
break;
case 4:
slowMode = true;
gotoNeighbour(platformDirection[0], platformDirection[1]);
break;
case 5:
hoverOverNeighbour(platformDirection[0], platformDirection[1]);
isDrillOn = false;
TileEntity te = getTileEntityForCurrentDirection();
if (te instanceof TileEntityAssemblyPlatform) {
TileEntityAssemblyPlatform platform = (TileEntityAssemblyPlatform) te;
platform.hasDrilledStack = true;
ItemStack output = getDrilledOutputForItem(platform.getHeldStack());
if (output != null) {
platform.setHeldStack(output);
}
}
break;
case 6:
slowMode = false;
gotoHomePosition();
break;
}
if (isDoneInternal()) {
drillStep++;
if (drillStep > 6)
drillStep = 0;
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class TileEntityBase method autoExportLiquid.
public void autoExportLiquid() {
FluidStack extractedStack = ((IFluidHandler) this).drain(ForgeDirection.UNKNOWN, Integer.MAX_VALUE, false);
if (extractedStack != null) {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getTileCache()[d.ordinal()].getTileEntity();
if (te instanceof IFluidHandler) {
if (((IFluidHandler) te).canFill(d.getOpposite(), extractedStack.getFluid())) {
int filledAmount = ((IFluidHandler) te).fill(d.getOpposite(), extractedStack, true);
((IFluidHandler) this).drain(ForgeDirection.UNKNOWN, filledAmount, true);
extractedStack.amount -= filledAmount;
if (extractedStack.amount <= 0)
break;
}
}
}
}
}
Aggregations