use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class AmadronOfferManager method tryRestockCustomOffers.
public void tryRestockCustomOffers() {
for (AmadronOffer offer : allOffers) {
if (offer instanceof AmadronOfferCustom) {
AmadronOfferCustom custom = (AmadronOfferCustom) offer;
TileEntity input = custom.getProvidingTileEntity();
TileEntity output = custom.getReturningTileEntity();
int possiblePickups = ContainerAmadron.capShoppingAmount(custom.invert(), 50, input instanceof IInventory ? (IInventory) input : null, output instanceof IInventory ? (IInventory) output : null, input instanceof IFluidHandler ? (IFluidHandler) input : null, output instanceof IFluidHandler ? (IFluidHandler) output : null, null);
if (possiblePickups > 0) {
ChunkPosition pos = new ChunkPosition(input.xCoord, input.yCoord, input.zCoord);
EntityDrone drone = ContainerAmadron.retrieveOrderItems(custom, possiblePickups, input.getWorldObj(), pos, input.getWorldObj(), pos);
if (drone != null) {
drone.setHandlingOffer(custom.copy(), possiblePickups, null, "Restock");
}
}
custom.invert();
custom.payout();
}
}
}
use of net.minecraft.tileentity.TileEntity 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.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class WailaPneumaticHandler method addTipToMachine.
public static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
NBTTagCompound tCompound = accessor.getNBTData();
TileEntity te = accessor.getTileEntity();
if (te instanceof IPneumaticMachine) {
addTipToMachine(currenttip, (IPneumaticMachine) te, tCompound.getFloat("pressure"));
}
}
use of net.minecraft.tileentity.TileEntity 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.minecraft.tileentity.TileEntity 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