Skip to content

Commit

Permalink
Merge pull request #11 from GTNewHorizons/dev
Browse files Browse the repository at this point in the history
Make Jet Engine fuel configurable
  • Loading branch information
Dream-Master authored May 11, 2023
2 parents cde6ac5 + 63b4882 commit 7542aff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/main/java/de/katzenpapst/amunra/AmunRa.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/de/katzenpapst/amunra/config/ARConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class ARConfig {
// bodies which motherships cannot orbit
public Set<String> mothershipBodiesNoOrbit;

public String validEngineFuel;

// *** sky rendering and related ***
// bodies not to render
public Set<String> bodiesNoRender;
Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

/**
Expand All @@ -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);
}

Expand All @@ -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);
Expand All @@ -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;
}

Expand All @@ -96,7 +84,6 @@ protected void startSound() {

@Override
protected void spawnParticles() {

final Vector3 particleStart = this.getExhaustPosition(1);
final Vector3 particleDirection = this.getExhaustDirection().scale(5);

Expand All @@ -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
Expand Down

0 comments on commit 7542aff

Please sign in to comment.