use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class CoordTrackUpgradeHandler method onPlayerInteract.
@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event) {
if (event.action == Action.RIGHT_CLICK_BLOCK && isListeningToCoordTrackerSetting) {
isListeningToCoordTrackerSetting = false;
ForgeDirection dir = ForgeDirection.getOrientation(event.face);
reset();
ItemStack stack = event.entityPlayer.getCurrentArmor(3);
if (stack != null) {
NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "CoordTracker");
tag.setInteger("dimID", event.entity.worldObj.provider.dimensionId);
tag.setInteger("x", event.x + dir.offsetX);
tag.setInteger("y", event.y + dir.offsetY);
tag.setInteger("z", event.z + dir.offsetZ);
}
NetworkHandler.sendToServer(new PacketCoordTrackUpdate(event.entity.worldObj, event.x + dir.offsetX, event.y + dir.offsetY, event.z + dir.offsetZ));
}
return false;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class ModelUniversalSensor method renderModel.
public void renderModel(float size, float dishRotation, boolean[] sidesConnected) {
Base1.render(size);
Base2.render(size);
GL11.glPushMatrix();
GL11.glRotatef(dishRotation, 0, 1, 0);
Dish1.render(size);
Dish2.render(size);
Dish3.render(size);
Dish4.render(size);
Dish5.render(size);
Dish6.render(size);
GL11.glPopMatrix();
ForgeDirection d = ForgeDirection.EAST;
for (int i = 0; i < 4; i++) {
d = d.getRotation(ForgeDirection.UP);
if (sidesConnected[d.ordinal()]) {
TubeConnection.rotateAngleY = (float) (i * Math.PI / 2);
TubeConnection.render(size);
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class ModelKeroseneLamp method renderStatic.
@Override
public void renderStatic(float size, TileEntity te) {
ForgeDirection sideConnected = ForgeDirection.DOWN;
if (te != null) {
sideConnected = ((TileEntityKeroseneLamp) te).getSideConnected();
}
Tank.render(size);
Holder1.render(size);
Holder2.render(size);
Base.render(size);
Top.render(size);
if (sideConnected != ForgeDirection.DOWN) {
Support1.render(size);
if (sideConnected != ForgeDirection.UP) {
SupportSide.rotateAngleY = 0;
ForgeDirection rotation = ((TileEntityKeroseneLamp) te).getRotation();
if (rotation != ForgeDirection.UP && rotation != ForgeDirection.DOWN) {
while (sideConnected != rotation.getOpposite()) {
sideConnected = sideConnected.getRotation(ForgeDirection.DOWN);
SupportSide.rotateAngleY += Math.toRadians(90);
}
}
SupportSide2.rotateAngleY = SupportSide.rotateAngleY;
SupportSide.render(size);
SupportSide2.render(size);
}
}
if (te != null) {
FluidTankInfo info = ((TileEntityKeroseneLamp) te).getTankInfo(null)[0];
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(-3 / 16F + 0.01F, 23 / 16F - percentageFull * 2.999F / 16F, -3 / 16F + 0.01F, 3 / 16F - 0.01F, 22.99F / 16F, 3 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, te.getWorldObj());
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class LogisticsManager method getRequestedAmount.
public static int getRequestedAmount(SemiBlockLogistics requester, ItemStack providingStack) {
TileEntity te = requester.getTileEntity();
if (!(te instanceof IInventory))
return 0;
int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.stackSize;
if (requestedAmount == 0)
return 0;
providingStack = providingStack.copy();
providingStack.stackSize = requestedAmount;
ItemStack remainder = providingStack.copy();
remainder.stackSize += requester.getIncomingItems(providingStack);
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
remainder = IOHelper.insert(te, remainder, d, true);
if (remainder == null)
break;
}
if (remainder != null)
providingStack.stackSize -= remainder.stackSize;
if (providingStack.stackSize <= 0)
return 0;
return providingStack.stackSize;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class LogisticsManager method tryProvide.
//curAI = new DroneAILiquidImport(drone, new FakeWidgetLogistics(provider.getPos(), providingStack));
// transportingFluid = new FluidStackWrapper(providingStack);
private void tryProvide(SemiBlockLogistics provider, SemiBlockLogistics requester, PriorityQueue<LogisticsTask> tasks) {
IInventory providingInventory = IOHelper.getInventoryForTE(provider.getTileEntity());
if (providingInventory != null) {
if (requester instanceof IProvidingInventoryListener)
((IProvidingInventoryListener) requester).notify(provider.getTileEntity());
for (int i = 0; i < providingInventory.getSizeInventory(); i++) {
ItemStack providingStack = providingInventory.getStackInSlot(i);
if (providingStack != null && (!(provider instanceof ISpecificProvider) || ((ISpecificProvider) provider).canProvide(providingStack)) && IOHelper.canExtractItemFromInventory(providingInventory, providingStack, i, 0)) {
int requestedAmount = getRequestedAmount(requester, providingStack);
if (requestedAmount > 0) {
ItemStack stack = providingStack.copy();
stack.stackSize = requestedAmount;
tasks.add(new LogisticsTask(provider, requester, stack));
}
}
}
}
if (provider.getTileEntity() instanceof IFluidHandler) {
IFluidHandler providingTank = (IFluidHandler) provider.getTileEntity();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
FluidStack providingStack = providingTank.drain(d, 16000, false);
if (providingStack != null && (!(provider instanceof ISpecificProvider) || ((ISpecificProvider) provider).canProvide(providingStack)) && providingTank.canDrain(d, providingStack.getFluid())) {
int requestedAmount = getRequestedAmount(requester, providingStack);
if (requestedAmount > 0) {
FluidStack stack = providingStack.copy();
stack.amount = requestedAmount;
tasks.add(new LogisticsTask(provider, requester, new FluidStackWrapper(stack)));
}
}
}
}
}
Aggregations