use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.
the class MultiTileEntityJuicer method readFromNBT2.
@Override
public void readFromNBT2(NBTTagCompound aNBT) {
super.readFromNBT2(aNBT);
if (aNBT.hasKey(NBT_RECIPEMAP))
mRecipes = RecipeMap.RECIPE_MAPS.get(aNBT.getString(NBT_RECIPEMAP));
mTanks = new FluidTankGT[mRecipes.mOutputFluidCount];
for (int i = 0; i < mTanks.length; i++) mTanks[i] = new FluidTankGT(1000000).readFromNBT(aNBT, NBT_TANK + "." + i);
}
use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.
the class MultiTileEntityMixingBowl method onTick2.
@Override
public void onTick2(long aTimer, boolean aIsServerSide) {
if (aIsServerSide) {
if (SERVER_TIME % 600 == 10 && worldObj.isRaining() && getRainOffset(0, 1, 0)) {
BiomeGenBase tBiome = getBiome();
if (tBiome.rainfall > 0 && tBiome.temperature >= 0.2) {
Block tInFront = getBlockAtSide(SIDE_TOP);
if (!(tInFront instanceof BlockLiquid) && !(tInFront instanceof IFluidBlock) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR_OPPOSITES[SIDE_TOP]) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR[SIDE_TOP])) {
FluidStack tWater = FL.Water.make((long) Math.max(1, tBiome.rainfall * 200) * (worldObj.isThundering() ? 2 : 1));
if (tWater != null) {
IFluidTank tTank = getFluidTankFillable2(SIDE_TOP, tWater);
if (tTank != null)
tTank.fill(tWater, T);
}
}
}
}
boolean tBreak = F;
mDisplay = 0;
for (FluidTankGT tTank : mTanksOutput) if (tTank.has()) {
mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
tBreak = T;
break;
}
if (!tBreak) {
for (FluidTankGT tTank : mTanksInput) if (tTank.has()) {
mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
tBreak = T;
break;
}
if (!tBreak) {
ItemStack tStack;
for (int i = 0; i < 7; i++) if (ST.valid(tStack = slot(6 - i))) {
OreDictItemData tData = OM.data_(tStack);
if (tData == null || tData.mMaterial == null) {
mDisplay = -1;
} else {
mDisplay = tData.mMaterial.mMaterial.mID;
}
tBreak = T;
break;
}
}
}
}
}
use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.
the class MultiTileEntityMixingBowl method readFromNBT2.
@Override
public void readFromNBT2(NBTTagCompound aNBT) {
super.readFromNBT2(aNBT);
if (aNBT.hasKey(NBT_RECIPEMAP))
mRecipes = RecipeMap.RECIPE_MAPS.get(aNBT.getString(NBT_RECIPEMAP));
int tCapacity = 1000;
if (aNBT.hasKey(NBT_TANK_CAPACITY))
tCapacity = UT.Code.bindInt(aNBT.getLong(NBT_TANK_CAPACITY));
mTanksInput = new FluidTankGT[mRecipes.mInputFluidCount];
for (int i = 0; i < mTanksInput.length; i++) mTanksInput[i] = new FluidTankGT(tCapacity).readFromNBT(aNBT, NBT_TANK + ".in." + i);
mTanksOutput = new FluidTankGT[mRecipes.mOutputFluidCount];
for (int i = 0; i < mTanksOutput.length; i++) mTanksOutput[i] = new FluidTankGT(tCapacity).readFromNBT(aNBT, NBT_TANK + ".out." + i);
}
use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.
the class MultiTileEntityMixingBowl method onBlockActivated3.
@Override
public boolean onBlockActivated3(EntityPlayer aPlayer, byte aSide, float aHitX, float aHitY, float aHitZ) {
if (isServerSide()) {
ItemStack aStack = aPlayer.getCurrentEquippedItem();
if (SIDES_TOP[aSide]) {
float[] tCoords = UT.Code.getFacingCoordsClicked(aSide, aHitX, aHitY, aHitZ);
if (tCoords[0] <= PX_P[2] && tCoords[1] <= PX_P[2])
return T;
if (!UT.Entities.isPlayer(aPlayer))
return T;
if (ToolsGT.contains(TOOL_mixer, aStack))
return F;
ItemStack[] tInputItems = ST.array(slot(0), slot(1), slot(2), slot(3), slot(4), slot(5));
Recipe tRecipe = mRecipes.findRecipe(this, mLastRecipe, F, V[1], NI, mTanksInput, tInputItems);
if (tRecipe != null) {
if (tRecipe.mCanBeBuffered)
mLastRecipe = tRecipe;
if (canOutput(tRecipe) && tRecipe.isRecipeInputEqual(T, F, mTanksInput, tInputItems)) {
ItemStack[] tOutputItems = tRecipe.getOutputs();
FluidStack[] tOutputFluids = tRecipe.getFluidOutputs();
for (int i = 0; i < mRecipes.mOutputItemsCount && i < tOutputItems.length; i++) addStackToSlot(i + 6, tOutputItems[i]);
for (int i = 0; i < mTanksOutput.length && i < tOutputFluids.length; i++) mTanksOutput[i].fill(tOutputFluids[i], T);
aPlayer.addExhaustion(tRecipe.getAbsoluteTotalPower() / 250.0F);
removeAllDroppableNullStacks();
return T;
}
}
}
if (UT.Inventories.addStackToPlayerInventory(aPlayer, slot(6), T)) {
slotKill(6);
return T;
}
ItemStack tStack = ST.container(ST.amount(1, aStack), T);
FluidStack tFluid = FL.getFluid(ST.amount(1, aStack), T);
if (aStack != null && tFluid != null && FL.fillAll_(this, SIDE_ANY, tFluid, T)) {
aStack.stackSize--;
UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
updateInventory();
updateAdjacentInventories();
return T;
}
if (SIDES_TOP[aSide] && aHitX > PX_P[2] && aHitX < PX_N[2] && aHitZ > PX_P[2] && aHitZ < PX_N[2]) {
if (aStack != null)
for (byte i = 0; i < 6; i++) {
if (ST.move(aPlayer.inventory, this, aPlayer.inventory.currentItem, i) > 0)
return T;
}
if (aStack != null)
for (FluidTankGT tTank : mTanksOutput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
aStack.stackSize--;
UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
return T;
}
if (aStack != null)
for (FluidTankGT tTank : mTanksInput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
aStack.stackSize--;
UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
return T;
}
} else {
if (aStack != null)
for (FluidTankGT tTank : mTanksOutput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
aStack.stackSize--;
UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
return T;
}
if (aStack != null)
for (FluidTankGT tTank : mTanksInput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
aStack.stackSize--;
UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
return T;
}
if (aStack != null)
for (byte i = 0; i < 6; i++) {
if (ST.move(aPlayer.inventory, this, aPlayer.inventory.currentItem, i) > 0)
return T;
}
}
if (!slotHas(6))
for (int i = 0; i < 6; i++) if (UT.Inventories.addStackToPlayerInventory(aPlayer, slot(i), T)) {
slotKill(i);
return T;
}
} else {
if (SIDES_TOP[aSide]) {
float[] tCoords = UT.Code.getFacingCoordsClicked(aSide, aHitX, aHitY, aHitZ);
if (tCoords[0] <= PX_P[2] && tCoords[1] <= PX_P[2]) {
mRecipes.openNEI();
return T;
}
if (mDisplay != 0) {
if (mDisplay < -1) {
UT.Sounds.play(SFX.MC_LIQUID_WATER, 5, 1.0F, 1.0F, getCoords());
} else {
UT.Sounds.play(SFX.MC_DIG_SAND, 5, 1.0F, 1.0F, getCoords());
}
}
}
}
return T;
}
use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.
the class MultiTileEntityBathingPot method onToolClick2.
@Override
public long onToolClick2(String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, byte aSide, float aHitX, float aHitY, float aHitZ) {
long rReturn = super.onToolClick2(aTool, aRemainingDurability, aQuality, aPlayer, aChatReturn, aPlayerInventory, aSneaking, aStack, aSide, aHitX, aHitY, aHitZ);
if (rReturn > 0 || isClientSide())
return rReturn;
if (aTool.equals(TOOL_plunger)) {
updateInventory();
for (FluidTankGT tTank : mTanksOutput) {
long rAmount = GarbageGT.trash(tTank, 1000);
if (rAmount > 0)
return rAmount;
}
for (FluidTankGT tTank : mTanksInput) {
long rAmount = GarbageGT.trash(tTank, 1000);
if (rAmount > 0)
return rAmount;
}
updateAdjacentInventories();
}
if (aTool.equals(TOOL_magnifyingglass)) {
if (aChatReturn != null) {
boolean temp = T;
for (FluidTankGT tTank : mTanksInput) if (!tTank.isEmpty()) {
temp = F;
aChatReturn.add("Input: " + tTank.content());
}
for (FluidTankGT tTank : mTanksOutput) if (!tTank.isEmpty()) {
temp = F;
aChatReturn.add("Output: " + tTank.content());
}
if (temp)
aChatReturn.add("Contains no Fluids");
}
return mTanksInput.length + mTanksOutput.length;
}
return 0;
}
Aggregations