From 63b488200b5c6c945890fbb8631bc9200a057436 Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Thu, 11 May 2023 22:00:57 +0200 Subject: [PATCH] Make Jet Engine fuel configurable --- .../java/de/katzenpapst/amunra/AmunRa.java | 3 ++ .../katzenpapst/amunra/config/ARConfig.java | 5 ++++ .../tile/TileEntityMothershipEngineJet.java | 28 ++++--------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/main/java/de/katzenpapst/amunra/AmunRa.java b/src/main/java/de/katzenpapst/amunra/AmunRa.java index 0b340d54..b1ccea98 100755 --- a/src/main/java/de/katzenpapst/amunra/AmunRa.java +++ b/src/main/java/de/katzenpapst/amunra/AmunRa.java @@ -13,6 +13,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fluids.FluidRegistry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -270,6 +271,8 @@ public void postInit(final FMLPostInitializationEvent event) { NetworkRegistry.INSTANCE.registerGuiHandler(AmunRa.instance, new GuiHandler()); FMLCommonHandler.instance().bus().register(new TickHandlerServer()); + TileEntityMothershipEngineJet.jetFuel = FluidRegistry.getFluid(config.validEngineFuel); + // failsafes this.doCompatibilityChecks(); diff --git a/src/main/java/de/katzenpapst/amunra/config/ARConfig.java b/src/main/java/de/katzenpapst/amunra/config/ARConfig.java index e05606c0..580fc6c8 100755 --- a/src/main/java/de/katzenpapst/amunra/config/ARConfig.java +++ b/src/main/java/de/katzenpapst/amunra/config/ARConfig.java @@ -51,6 +51,8 @@ public class ARConfig { // bodies which motherships cannot orbit public Set mothershipBodiesNoOrbit; + public String validEngineFuel; + // *** sky rendering and related *** // bodies not to render public Set bodiesNoRender; @@ -194,6 +196,9 @@ public void processConfig(final Configuration config) { emptySet, "Bodies which should not be orbitable by motherships"); + this.validEngineFuel = config + .getString("validEngineFuels", "motherships", "fuel", "These fluids can be used by Jet Engines"); + // mothershipUserRestriction = config.getBoolean("restrictMothershipToOwner", "mothership", true, "If true, only // the one who built the mothership will be able to use it. If false, anyone can"); diff --git a/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineJet.java b/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineJet.java index df872982..e0cae1fe 100755 --- a/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineJet.java +++ b/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineJet.java @@ -5,7 +5,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; @@ -16,8 +15,6 @@ import de.katzenpapst.amunra.mothership.fueldisplay.MothershipFuelRequirements; import de.katzenpapst.amunra.proxy.ARSidedProxy.ParticleType; import micdoodle8.mods.galacticraft.api.vector.Vector3; -import micdoodle8.mods.galacticraft.core.GalacticraftCore; -import micdoodle8.mods.galacticraft.core.util.FluidUtil; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; /** @@ -33,12 +30,13 @@ public class TileEntityMothershipEngineJet extends TileEntityMothershipEngineAbs // protected final MothershipFuel fuelType; protected MothershipFuelDisplay fuelType = null; + public static Fluid jetFuel; public TileEntityMothershipEngineJet() { this.boosterBlock = ARBlocks.blockMsEngineRocketBooster; this.containingItems = new ItemStack[1]; - this.fuel = GalacticraftCore.fluidFuel; + this.fuel = jetFuel; this.fuelType = new MothershipFuelDisplayFluid(this.fuel); } @@ -49,20 +47,14 @@ public boolean shouldUseEnergy() { @Override public void beginTransit(final long duration) { - final MothershipFuelRequirements reqs = this.getFuelRequirements(duration); - final int fuelReq = reqs.get(this.fuelType); - this.fuelTank.drain(fuelReq, true); - super.beginTransit(duration); - } @Override protected boolean isItemFuel(final ItemStack itemstack) { - FluidStack containedFluid = null; if (itemstack.getItem() instanceof IFluidContainerItem itemContainer) { containedFluid = itemContainer.getFluid(itemstack); @@ -71,12 +63,8 @@ protected boolean isItemFuel(final ItemStack itemstack) { containedFluid = FluidContainerRegistry.getFluidForFilledItem(itemstack); } if (containedFluid != null) { - if (containedFluid.getFluid() == this.fuel) { - return true; - } - return FluidUtil.testFuel(FluidRegistry.getFluidName(containedFluid)); + return this.fuel == containedFluid.getFluid(); } - return false; } @@ -96,7 +84,6 @@ protected void startSound() { @Override protected void spawnParticles() { - final Vector3 particleStart = this.getExhaustPosition(1); final Vector3 particleDirection = this.getExhaustDirection().scale(5); @@ -113,13 +100,10 @@ protected void spawnParticles() { @Override public boolean canFill(final ForgeDirection from, final Fluid fluid) { - - // here, fluid is fuel - if (!FluidUtil.testFuel(FluidRegistry.getFluidName(fluid))) { - return false; + if (this.fuel == fluid) { + return super.canFill(from, fluid); } - - return super.canFill(from, fluid); + return false; } @Override