aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bartworks/common/tileentities/multis
diff options
context:
space:
mode:
authorNotAPenguin <michiel.vandeginste@gmail.com>2024-09-02 23:17:17 +0200
committerGitHub <noreply@github.com>2024-09-02 23:17:17 +0200
commit1b820de08a05070909a267e17f033fcf58ac8710 (patch)
tree02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/bartworks/common/tileentities/multis
parentafd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff)
downloadGT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip
The Great Renaming (#3014)
* move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names
Diffstat (limited to 'src/main/java/bartworks/common/tileentities/multis')
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java834
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTECircuitAssemblyLine.java672
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEDeepEarthHeatingPump.java336
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java565
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java619
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTELESU.java590
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java363
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEThoriumHighTempReactor.java416
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java637
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaBlastFurnace.java430
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaChemicalReactor.java278
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java446
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaOilCracker.java465
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaVacuumFreezer.java533
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MegaMultiBlockBase.java212
15 files changed, 7396 insertions, 0 deletions
diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java
new file mode 100644
index 0000000000..b982c0d886
--- /dev/null
+++ b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java
@@ -0,0 +1,834 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial
+ * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package bartworks.common.tileentities.multis;
+
+import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS;
+import static bartworks.util.BWUtil.ofGlassTiered;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
+import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER;
+import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE;
+import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW;
+import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW;
+import static gregtech.api.util.GTStructureUtility.ofHatchAdder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import javax.annotation.Nullable;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import org.jetbrains.annotations.NotNull;
+
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+
+import bartworks.API.SideReference;
+import bartworks.API.recipe.BartWorksRecipeMaps;
+import bartworks.MainMod;
+import bartworks.common.configs.ConfigHandler;
+import bartworks.common.items.ItemLabParts;
+import bartworks.common.loaders.FluidLoader;
+import bartworks.common.net.RendererPacket;
+import bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch;
+import bartworks.util.BWUtil;
+import bartworks.util.BioCulture;
+import bartworks.util.Coords;
+import bartworks.util.MathUtils;
+import bartworks.util.ResultWrongSievert;
+import gregtech.api.GregTechAPI;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.logic.ProcessingLogic;
+import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase;
+import gregtech.api.metatileentity.implementations.MTEHatchInput;
+import gregtech.api.metatileentity.implementations.MTEHatchOutput;
+import gregtech.api.recipe.RecipeMap;
+import gregtech.api.recipe.check.CheckRecipeResult;
+import gregtech.api.recipe.check.CheckRecipeResultRegistry;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GTRecipe;
+import gregtech.api.util.GTUtility;
+import gregtech.api.util.MultiblockTooltipBuilder;
+import gregtech.api.util.ParallelHelper;
+
+public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> {
+
+ public static final HashMap<Coords, Integer> staticColorMap = new HashMap<>();
+
+ private static final byte TIMERDIVIDER = 20;
+
+ private final HashSet<EntityPlayerMP> playerMPHashSet = new HashSet<>();
+ private final ArrayList<GT_MetaTileEntity_RadioHatch> mRadHatches = new ArrayList<>();
+ private int height = 1;
+ private Fluid mFluid = FluidRegistry.LAVA;
+ private BioCulture mCulture;
+ private ItemStack mStack;
+ private boolean needsVisualUpdate = true;
+ private byte mGlassTier;
+ private int mSievert;
+ private int mNeededSievert;
+ private int mCasing = 0;
+ private int mExpectedMultiplier = 0;
+ private int mTimes = 0;
+ private boolean isVisibleFluid = false;
+
+ public MTEBioVat(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public MTEBioVat(String aName) {
+ super(aName);
+ }
+
+ private static final int CASING_INDEX = 49;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition<MTEBioVat> STRUCTURE_DEFINITION = StructureDefinition.<MTEBioVat>builder()
+ .addShape(
+ STRUCTURE_PIECE_MAIN,
+ transpose(
+ new String[][] { { "ccccc", "ccccc", "ccccc", "ccccc", "ccccc" },
+ { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" }, { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" },
+ { "cc~cc", "ccccc", "ccccc", "ccccc", "ccccc" }, }))
+ .addElement(
+ 'c',
+ ofChain(
+ ofHatchAdder(MTEBioVat::addMaintenanceToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(MTEBioVat::addOutputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(MTEBioVat::addInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(MTEBioVat::addRadiationInputToMachineList, CASING_INDEX, 1),
+ ofHatchAdder(MTEBioVat::addEnergyInputToMachineList, CASING_INDEX, 1),
+ onElementPass(e -> e.mCasing++, ofBlock(GregTechAPI.sBlockCasings4, 1))))
+ .addElement('a', ofChain(isAir(), ofBlockAnyMeta(FluidLoader.bioFluidBlock)))
+ .addElement(
+ 'g',
+ ofGlassTiered((byte) 1, (byte) 127, (byte) 0, (te, v) -> te.mGlassTier = v, te -> te.mGlassTier, 1))
+ .build();
+
+ @Override
+ public IStructureDefinition<MTEBioVat> getStructureDefinition() {
+ return STRUCTURE_DEFINITION;
+ }
+
+ @Override
+ protected IAlignmentLimits getInitialAlignmentLimits() {
+ return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped();
+ }
+
+ @Override
+ protected MultiblockTooltipBuilder createTooltip() {
+ MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
+ tt.addMachineType("Bacterial Vat")
+ .addInfo("Controller block for the Bacterial Vat")
+ .addInfo("For maximum efficiency boost keep the Output Hatch always half filled!")
+ .addSeparator()
+ .beginStructureBlock(5, 4, 5, false)
+ .addController("Front bottom center")
+ .addCasingInfoMin("Clean Stainless Steel Casings", 19, false)
+ .addOtherStructurePart("Glass", "Hollow two middle layers", 2)
+ .addStructureInfo("The glass can be any glass, i.e. Tinkers Construct Clear Glass")
+ .addStructureInfo("Some Recipes need more advanced Glass Types")
+ .addMaintenanceHatch("Any casing", 1)
+ .addOtherStructurePart("Radio Hatch", "Any casing", 1)
+ .addInputBus("Any casing", 1)
+ .addOutputBus("Any casing", 1)
+ .addInputHatch("Any casing", 1)
+ .addOutputHatch("Any casing", 1)
+ .addEnergyHatch("Any casing", 1)
+ .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS);
+ return tt;
+ }
+
+ public static int[] specialValueUnpack(int aSpecialValue) {
+ int[] ret = new int[4];
+ ret[0] = aSpecialValue & 0xF; // = glass tier
+ ret[1] = aSpecialValue >>> 4 & 0b11; // = special value
+ ret[2] = aSpecialValue >>> 6 & 0b1; // boolean exact svt | 1 = true | 0 = false
+ ret[3] = aSpecialValue >>> 7 & Integer.MAX_VALUE; // = sievert
+ return ret;
+ }
+
+ private int getInputCapacity() {
+ return this.mInputHatches.stream()
+ .mapToInt(MTEHatchInput::getCapacity)
+ .sum();
+ }
+
+ private int getOutputCapacity() {
+ return this.mOutputHatches.stream()
+ .mapToInt(MTEHatchOutput::getCapacity)
+ .sum();
+ }
+
+ @Override
+ public int getCapacity() {
+ int ret = 0;
+ ret += this.getInputCapacity();
+ // ret += getOutputCapacity();
+ return ret;
+ }
+
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ return super.fill(resource, doFill);
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack itemStack) {
+ return true;
+ }
+
+ @Override
+ public RecipeMap<?> getRecipeMap() {
+ return BartWorksRecipeMaps.bacterialVatRecipes;
+ }
+
+ /**
+ * Calculates the expected output multiplier based on the output hatch
+ *
+ * @param recipeFluidOutput the recipe fluid output
+ * @param needEqual if the recipeFluidOutput should be equal to the fluid in the output hatch
+ * @return the expected output multiplier
+ */
+ private int getExpectedMultiplier(@Nullable FluidStack recipeFluidOutput, boolean needEqual) {
+ FluidStack storedFluidOutputs = this.getStoredFluidOutputs();
+ if (storedFluidOutputs == null) return 1;
+ if (!needEqual || storedFluidOutputs.isFluidEqual(recipeFluidOutput)) {
+ return this.calcMod(storedFluidOutputs.amount) + 1;
+ }
+ return 1;
+ }
+
+ private int calcMod(double x) {
+ double y = this.getOutputCapacity() / 2D, z = ConfigHandler.bioVatMaxParallelBonus;
+
+ int ret = MathUtils.ceilInt((-1D / y * Math.pow(x - y, 2D) + y) / y * z);
+ return MathUtils.clamp(1, ret, ConfigHandler.bioVatMaxParallelBonus);
+ }
+
+ @Override
+ protected ProcessingLogic createProcessingLogic() {
+ return new ProcessingLogic() {
+
+ @NotNull
+ @Override
+ protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) {
+ if (!BWUtil.areStacksEqualOrNull((ItemStack) recipe.mSpecialItems, MTEBioVat.this.getControllerSlot()))
+ return CheckRecipeResultRegistry.NO_RECIPE;
+ int[] conditions = MTEBioVat.specialValueUnpack(recipe.mSpecialValue);
+ MTEBioVat.this.mNeededSievert = conditions[3];
+
+ if (MTEBioVat.this.mGlassTier < conditions[0]) {
+ return CheckRecipeResultRegistry.insufficientMachineTier(conditions[0]);
+ }
+
+ if (conditions[2] == 0) {
+ if (MTEBioVat.this.mSievert < MTEBioVat.this.mNeededSievert) {
+ return ResultWrongSievert.insufficientSievert(MTEBioVat.this.mNeededSievert);
+ }
+ } else if (MTEBioVat.this.mSievert != conditions[3]) {
+ return ResultWrongSievert.wrongSievert(conditions[3]);
+ }
+
+ return CheckRecipeResultRegistry.SUCCESSFUL;
+ }
+
+ @NotNull
+ @Override
+ protected ParallelHelper createParallelHelper(@NotNull GTRecipe recipe) {
+ return super.createParallelHelper(recipeWithMultiplier(recipe, inputFluids));
+ }
+ };
+ }
+
+ protected GTRecipe recipeWithMultiplier(GTRecipe recipe, FluidStack[] fluidInputs) {
+ GTRecipe tRecipe = recipe.copy();
+ int multiplier = getExpectedMultiplier(recipe.getFluidOutput(0), true);
+ mExpectedMultiplier = multiplier;
+ // Calculate max multiplier limited by input fluids
+ long fluidAmount = 0;
+ for (FluidStack fluid : fluidInputs) {
+ if (recipe.mFluidInputs[0].isFluidEqual(fluid)) {
+ fluidAmount += fluid.amount;
+ }
+ }
+ multiplier = (int) Math.min(multiplier, fluidAmount / recipe.mFluidInputs[0].amount);
+ // In case multiplier is 0
+ multiplier = Math.max(multiplier, 1);
+ mTimes = multiplier;
+ tRecipe.mFluidInputs[0].amount *= multiplier;
+ tRecipe.mFluidOutputs[0].amount *= multiplier;
+ return tRecipe;
+ }
+
+ @Override
+ protected void setupProcessingLogic(ProcessingLogic logic) {
+ super.setupProcessingLogic(logic);
+ logic.setSpecialSlotItem(this.getControllerSlot());
+ }
+
+ public FluidStack getStoredFluidOutputs() {
+ // Only one output Hatch
+ assert this.mOutputHatches.size() == 1;
+ return this.mOutputHatches.get(0)
+ .getFluid();
+ }
+
+ private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int CasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch)) {
+ return false;
+ } else {
+ ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex);
+ return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity);
+ }
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) {
+ this.mRadHatches.clear();
+ this.mGlassTier = 0;
+ this.mCasing = 0;
+
+ if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0)) return false;
+
+ return this.mCasing >= 19 && this.mRadHatches.size() <= 1
+ && this.mOutputHatches.size() == 1
+ && this.mMaintenanceHatches.size() == 1
+ && this.mInputHatches.size() > 0
+ && this.mEnergyHatches.size() > 0;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack itemStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack itemStack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack itemStack) {
+ return 0;
+ }
+
+ private void sendAllRequiredRendererPackets() {
+ int height = this.reCalculateHeight();
+ if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) {
+ for (int x = -1; x < 2; x++) for (int y = 1; y < height; y++)
+ for (int z = -1; z < 2; z++) this.sendPackagesOrRenewRenderer(x, y, z, this.mCulture);
+ }
+ }
+
+ private void sendPackagesOrRenewRenderer(int x, int y, int z, BioCulture lCulture) {
+ int xDir = this.getXDir();
+ int zDir = this.getZDir();
+
+ MTEBioVat.staticColorMap.remove(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId));
+ MTEBioVat.staticColorMap.put(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId),
+ lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB());
+
+ if (SideReference.Side.Server) {
+ MainMod.BW_Network_instance.sendPacketToAllPlayersInRange(
+ this.getBaseMetaTileEntity()
+ .getWorld(),
+ new RendererPacket(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId),
+ lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(),
+ true),
+ this.getBaseMetaTileEntity()
+ .getXCoord(),
+ this.getBaseMetaTileEntity()
+ .getZCoord());
+ MainMod.BW_Network_instance.sendPacketToAllPlayersInRange(
+ this.getBaseMetaTileEntity()
+ .getWorld(),
+ new RendererPacket(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId),
+ lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(),
+ false),
+ this.getBaseMetaTileEntity()
+ .getXCoord(),
+ this.getBaseMetaTileEntity()
+ .getZCoord());
+ }
+ this.needsVisualUpdate = true;
+ }
+
+ private void check_Chunk() {
+ World aWorld = this.getBaseMetaTileEntity()
+ .getWorld();
+ if (!aWorld.isRemote) {
+
+ for (Object tObject : aWorld.playerEntities) {
+ if (!(tObject instanceof EntityPlayerMP tPlayer)) {
+ break;
+ }
+ Chunk tChunk = aWorld.getChunkFromBlockCoords(
+ this.getBaseMetaTileEntity()
+ .getXCoord(),
+ this.getBaseMetaTileEntity()
+ .getZCoord());
+ if (tPlayer.getServerForPlayer()
+ .getPlayerManager()
+ .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) {
+ if (!this.playerMPHashSet.contains(tPlayer)) {
+ this.playerMPHashSet.add(tPlayer);
+ this.sendAllRequiredRendererPackets();
+ }
+ } else {
+ this.playerMPHashSet.remove(tPlayer);
+ }
+ }
+ }
+ }
+
+ private void placeFluid() {
+ this.isVisibleFluid = true;
+ int xDir = this.getXDir();
+ int zDir = this.getZDir();
+ this.height = this.reCalculateHeight();
+ if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) for (int x = -1; x < 2; x++) {
+ for (int y = 0; y < this.height; y++) {
+ for (int z = -1; z < 2; z++) {
+ if (this.getBaseMetaTileEntity()
+ .getWorld()
+ .getBlock(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord())
+ .equals(Blocks.air))
+ this.getBaseMetaTileEntity()
+ .getWorld()
+ .setBlock(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ FluidLoader.bioFluidBlock);
+ }
+ }
+ }
+ }
+
+ private void removeFluid(int xDir, int zDir) {
+ this.isVisibleFluid = false;
+
+ for (int x = -1; x < 2; x++) {
+ for (int y = 1; y < 3; y++) {
+ for (int z = -1; z < 2; z++) {
+ if (this.getBaseMetaTileEntity()
+ .getWorld()
+ .getBlock(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord())
+ .equals(FluidLoader.bioFluidBlock))
+ this.getBaseMetaTileEntity()
+ .getWorld()
+ .setBlockToAir(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord());
+ MTEBioVat.staticColorMap.remove(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord()),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId);
+ }
+ }
+ }
+ }
+
+ private int reCalculateFluidAmmount() {
+ return this.getStoredFluids()
+ .stream()
+ .mapToInt(fluidStack -> fluidStack.amount)
+ .sum();
+ }
+
+ private int reCalculateHeight() {
+ return this.reCalculateFluidAmmount() > this.getCapacity() / 4 - 1
+ ? this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2
+ : 1;
+ }
+
+ public void doAllVisualThings() {
+ if (this.getBaseMetaTileEntity()
+ .isServerSide()) {
+ if (this.mMachine) {
+ ItemStack aStack = this.mInventory[1];
+ BioCulture lCulture = null;
+ int xDir = this.getXDir();
+ int zDir = this.getZDir();
+
+ if (this.getBaseMetaTileEntity()
+ .getTimer() % 200 == 0) {
+ this.check_Chunk();
+ }
+
+ if (this.needsVisualUpdate && this.getBaseMetaTileEntity()
+ .getTimer() % MTEBioVat.TIMERDIVIDER == 0) {
+ for (int x = -1; x < 2; x++)
+ for (int y = 1; y < 3; y++) for (int z = -1; z < 2; z++) this.getBaseMetaTileEntity()
+ .getWorld()
+ .setBlockToAir(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord());
+ }
+
+ this.height = this.reCalculateHeight();
+ if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) {
+ if (!BWUtil.areStacksEqualOrNull(aStack, this.mStack)
+ || this.needsVisualUpdate && this.getBaseMetaTileEntity()
+ .getTimer() % MTEBioVat.TIMERDIVIDER == 1) {
+ for (int x = -1; x < 2; x++) {
+ for (int y = 1; y < this.height; y++) {
+ for (int z = -1; z < 2; z++) {
+ if (aStack == null
+ || aStack.getItem() instanceof ItemLabParts && aStack.getItemDamage() == 0) {
+ if (this.mCulture == null || aStack == null
+ || aStack.getTagCompound() == null
+ || this.mCulture.getID() != aStack.getTagCompound()
+ .getInteger("ID")) {
+ lCulture = aStack == null || aStack.getTagCompound() == null ? null
+ : BioCulture.getBioCulture(
+ aStack.getTagCompound()
+ .getString("Name"));
+ this.sendPackagesOrRenewRenderer(x, y, z, lCulture);
+ }
+ }
+ }
+ }
+ }
+ this.mStack = aStack;
+ this.mCulture = lCulture;
+ }
+ if (this.needsVisualUpdate && this.getBaseMetaTileEntity()
+ .getTimer() % MTEBioVat.TIMERDIVIDER == 1) {
+ if (this.getBaseMetaTileEntity()
+ .isClientSide()) new Throwable().printStackTrace();
+ this.placeFluid();
+ this.needsVisualUpdate = false;
+ }
+ }
+ } else {
+ this.onRemoval();
+ }
+ }
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (this.height != this.reCalculateHeight()) this.needsVisualUpdate = true;
+ this.doAllVisualThings();
+ if (this.getBaseMetaTileEntity()
+ .isServerSide() && this.mRadHatches.size() == 1) {
+ this.mSievert = this.mRadHatches.get(0)
+ .getSievert();
+ if (this.getBaseMetaTileEntity()
+ .isActive() && this.mNeededSievert > this.mSievert) this.mOutputFluids = null;
+ }
+ if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime <= 0) {
+ this.mTimes = 0;
+ this.mMaxProgresstime = 0;
+ }
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setInteger("mFluidHeight", this.height);
+ if (this.mCulture != null && !this.mCulture.getName()
+ .isEmpty()) aNBT.setString("mCulture", this.mCulture.getName());
+ else if ((this.mCulture == null || this.mCulture.getName()
+ .isEmpty()) && !aNBT.getString("mCulture")
+ .isEmpty()) {
+ aNBT.removeTag("mCulture");
+ }
+ if (this.mFluid != null) aNBT.setString("mFluid", this.mFluid.getName());
+ aNBT.setInteger("mSievert", this.mSievert);
+ aNBT.setInteger("mNeededSievert", this.mNeededSievert);
+ aNBT.setBoolean("isVisibleFluid", this.isVisibleFluid);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void onRemoval() {
+ if (this.isVisibleFluid) {
+ int xDir = this.getXDir();
+ int zDir = this.getZDir();
+ this.removeFluid(xDir, zDir);
+ this.sendRenderPackets(xDir, zDir);
+ } else if (this.getBaseMetaTileEntity()
+ .getWorld()
+ .getWorldTime() % 20 == 7) {
+ this.sendRenderPackets();
+ }
+
+ super.onRemoval();
+ }
+
+ private int getXDir() {
+ return this.getBaseMetaTileEntity()
+ .getBackFacing().offsetX * 2;
+ }
+
+ private int getZDir() {
+ return this.getBaseMetaTileEntity()
+ .getBackFacing().offsetZ * 2;
+ }
+
+ private void sendRenderPackets() {
+ int xDir = this.getXDir();
+ int zDir = this.getZDir();
+ this.sendRenderPackets(xDir, zDir);
+ }
+
+ private void sendRenderPackets(int xDir, int zDir) {
+ if (SideReference.Side.Server) {
+ for (int x = -1; x < 2; x++) {
+ for (int y = 1; y < 3; y++) {
+ for (int z = -1; z < 2; z++) {
+ MainMod.BW_Network_instance.sendPacketToAllPlayersInRange(
+ this.getBaseMetaTileEntity()
+ .getWorld(),
+ new RendererPacket(
+ new Coords(
+ xDir + x
+ + this.getBaseMetaTileEntity()
+ .getXCoord(),
+ y + this.getBaseMetaTileEntity()
+ .getYCoord(),
+ zDir + z
+ + this.getBaseMetaTileEntity()
+ .getZCoord(),
+ this.getBaseMetaTileEntity()
+ .getWorld().provider.dimensionId),
+ this.mCulture == null ? BioCulture.NULLCULTURE.getColorRGB()
+ : this.mCulture.getColorRGB(),