diff --git a/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineAbstract.java b/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineAbstract.java index 26cbe596..14ed69a4 100755 --- a/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineAbstract.java +++ b/src/main/java/de/katzenpapst/amunra/tile/TileEntityMothershipEngineAbstract.java @@ -123,7 +123,7 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { /** * Calculates tank capacity based on the boosters - * + * * @return */ abstract protected int getTankCapacity(); @@ -321,36 +321,15 @@ protected void processFluids() { if (canister != null && this.isItemFuel(canister)) { // attempt to drain it into the tank - FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(canister); - // int spaceForFluid = this.fuelTank.getCapacity() - - /* - * if (this.fuelTank.getFluid() == null || this.fuelTank.getFluid().amount + liquid.amount <= - * this.fuelTank.getCapacity()) { - */ final int fluidAmount = this.fuelTank.getFluid() == null ? 0 : this.fuelTank.getFluid().amount; final int spaceForFluid = this.fuelTank.getCapacity() - fluidAmount; // attempt to drain as much as we have space - if (canister.getItem() instanceof IFluidContainerItem) { - // try to do - final FluidStack drained = ((IFluidContainerItem) canister.getItem()) - .drain(canister, spaceForFluid, true); + if (canister.getItem() instanceof IFluidContainerItem fluidCanister) { + // try to drain as much as we have space for + final FluidStack drained = fluidCanister.drain(canister, spaceForFluid, true); if (drained != null && drained.amount > 0) { - // this.fuelTank.fill(new FluidStack(this.fuel, drained.amount), true); - // check how much fluid remains in there - // getFluidForFilledItem doesn't work on IFluidContainerItem - liquid = ((IFluidContainerItem) canister.getItem()).getFluid(canister); - // liquid = FluidContainerRegistry.getFluidForFilledItem(canister); - if (liquid == null || liquid.amount == 0) { - // this should replace the container with it's empty version - final ItemStack canisterNew = FluidContainerRegistry.drainFluidContainer(canister); - if (canisterNew != null) { - this.containingItems[0] = canisterNew; - } - } - // if(((IFluidContainerItem)canister.getItem()).) - // FluidContainerRegistry.get } } else { // attempt to drain it all at once @@ -358,34 +337,15 @@ protected void processFluids() { if (spaceForFluid >= capacity) { // now drain it - this.fuelTank.fill(new FluidStack(this.fuel, capacity), true); final ItemStack canisterNew = FluidContainerRegistry.drainFluidContainer(canister); if (canisterNew != null) { + this.fuelTank.fill(new FluidStack(this.fuel, capacity), true); this.containingItems[0] = canisterNew; } } } - // } } - /* - * if (this.containingItems[0].getItem() instanceof ItemCanisterGeneric) { if (this.containingItems[0].getItem() - * == GCItems.fuelCanister) { int originalDamage = this.containingItems[0].getItemDamage(); int used = - * this.fuelTank.fill(new FluidStack(GalacticraftCore.fluidFuel, ItemCanisterGeneric.EMPTY - originalDamage), - * true); if (originalDamage + used == ItemCanisterGeneric.EMPTY) this.containingItems[0] = new - * ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY); else this.containingItems[0] = new - * ItemStack(GCItems.fuelCanister, 1, originalDamage + used); } } else { final FluidStack liquid = - * FluidContainerRegistry.getFluidForFilledItem(this.containingItems[0]); if (liquid != null) { boolean isFuel = - * FluidUtil.testFuel(FluidRegistry.getFluidName(liquid)); if (isFuel) { if (this.fuelTank.getFluid() == null || - * this.fuelTank.getFluid().amount + liquid.amount <= this.fuelTank.getCapacity()) { this.fuelTank.fill(new - * FluidStack(GalacticraftCore.fluidFuel, liquid.amount), true); if - * (FluidContainerRegistry.isBucket(this.containingItems[0]) && - * FluidContainerRegistry.isFilledContainer(this.containingItems[0])) { final int amount = - * this.containingItems[0].stackSize; if (amount > 1) { this.fuelTank.fill(new - * FluidStack(GalacticraftCore.fluidFuel, (amount - 1) * FluidContainerRegistry.BUCKET_VOLUME), true); } - * this.containingItems[0] = new ItemStack(Items.bucket, amount); } else { this.containingItems[0].stackSize--; - * if (this.containingItems[0].stackSize == 0) { this.containingItems[0] = null; } } } } } } - */ } @Override @@ -878,7 +838,7 @@ public void beginTransit(final long duration) { /** * This should return how much fuel units are consumed per AU travelled, in millibuckets - * + * * @return */ // abstract public int getFuelUsagePerAU();