-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Reservoir Hatch & Adjust model (#1576)
- Loading branch information
Showing
44 changed files
with
194 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
], | ||
"page": "gtceu:parts/buffer_part", | ||
"position": [ | ||
-100, | ||
-50, | ||
100 | ||
], | ||
"section": "gtceu:parts" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
], | ||
"page": "gtceu:parts/diode", | ||
"position": [ | ||
-50, | ||
100 | ||
-250, | ||
150 | ||
], | ||
"section": "gtceu:parts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
], | ||
"page": "gtceu:parts/parallel_hatch", | ||
"position": [ | ||
-200, | ||
-150, | ||
150 | ||
], | ||
"section": "gtceu:parts" | ||
|
15 changes: 15 additions & 0 deletions
15
src/generated/resources/assets/gtceu/compass/nodes/parts/reservoir_hatch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"button_texture": { | ||
"type": "item", | ||
"res": "gtceu:reservoir_hatch" | ||
}, | ||
"items": [ | ||
"gtceu:reservoir_hatch" | ||
], | ||
"page": "gtceu:parts/reservoir_hatch", | ||
"position": [ | ||
-100, | ||
100 | ||
], | ||
"section": "gtceu:parts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
], | ||
"page": "gtceu:parts/rotor_holder", | ||
"position": [ | ||
-250, | ||
-200, | ||
150 | ||
], | ||
"section": "gtceu:parts" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
.../java/com/gregtechceu/gtceu/common/machine/multiblock/part/ReservoirHatchPartMachine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.gregtechceu.gtceu.common.machine.multiblock.part; | ||
|
||
import com.gregtechceu.gtceu.api.GTValues; | ||
import com.gregtechceu.gtceu.api.capability.recipe.IO; | ||
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; | ||
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; | ||
|
||
import com.lowdragmc.lowdraglib.misc.FluidStorage; | ||
import com.lowdragmc.lowdraglib.side.fluid.FluidStack; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.level.material.Fluids; | ||
|
||
import java.util.Collections; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
public class ReservoirHatchPartMachine extends FluidHatchPartMachine { | ||
|
||
protected InfiniteWaterTank waterTank; | ||
|
||
public static final long FLUID_AMOUNT = 2_000_000_000L; | ||
|
||
public ReservoirHatchPartMachine(IMachineBlockEntity holder, Object... args) { | ||
super(holder, GTValues.EV, IO.IN, FLUID_AMOUNT, 1, args); | ||
} | ||
|
||
////////////////////////////////// | ||
// ****** Initialization ****** // | ||
////////////////////////////////// | ||
|
||
@Override | ||
protected NotifiableFluidTank createTank(long initialCapacity, int slots, Object... args) { | ||
this.waterTank = new InfiniteWaterTank(initialCapacity); | ||
// allow both importing and exporting from the tank | ||
return new NotifiableFluidTank(this, Collections.singletonList(waterTank), io, IO.BOTH); | ||
} | ||
|
||
////////////////////////////////// | ||
// ******** Fill Water ******** // | ||
////////////////////////////////// | ||
|
||
@Override | ||
protected void updateTankSubscription() { | ||
if (isWorkingEnabled() && !waterTank.isFull()) { | ||
autoIOSubs = subscribeServerTick(autoIOSubs, this::autoIO); | ||
} else if (autoIOSubs != null) { | ||
autoIOSubs.unsubscribe(); | ||
autoIOSubs = null; | ||
} | ||
} | ||
|
||
@Override | ||
protected void autoIO() { | ||
// replace with refilling water tank | ||
if (getOffsetTimer() % 20 == 0) { | ||
waterTank.refillWater(); | ||
updateTankSubscription(); | ||
} | ||
} | ||
|
||
protected static class InfiniteWaterTank extends FluidStorage { | ||
|
||
private static final CompoundTag EMPTY = new CompoundTag(); | ||
private static final FluidStack WATER = FluidStack.create(Fluids.WATER, Long.MAX_VALUE); | ||
|
||
public InfiniteWaterTank(long capacity) { | ||
super(capacity); | ||
// start with the full amount | ||
setFluid(FluidStack.create(Fluids.WATER, capacity)); | ||
} | ||
|
||
public void refillWater() { | ||
// call super since our overrides don't allow any kind of filling | ||
super.fill(0, WATER, false, true); | ||
} | ||
|
||
public boolean isFull() { | ||
return getFluidAmount() >= capacity; | ||
} | ||
|
||
@Override | ||
public boolean supportsFill(int tank) { | ||
// don't allow external callers to fill this tank | ||
return false; | ||
} | ||
|
||
@Override | ||
public long fill(int tank, FluidStack resource, boolean simulate, boolean notifyChange) { | ||
// don't allow external filling | ||
return 0; | ||
} | ||
|
||
@Override | ||
public CompoundTag serializeNBT() { | ||
// serialization is unnecessary here, we can always recreate it completely full since it would refill anyway | ||
return EMPTY; | ||
} | ||
|
||
@Override | ||
public void deserializeNBT(CompoundTag nbt) {} | ||
|
||
@Override | ||
public FluidStorage copy() { | ||
var storage = new InfiniteWaterTank(capacity); | ||
storage.setFluid(fluid.copy()); | ||
return storage; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/computation_data_hatch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/data_access_hatch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/data_access_hatch_creative.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.input.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.input_16a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.input_4a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.output_16a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/energy_hatch.output_4a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.export.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.export_4x.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.export_9x.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.import.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.import_4x.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/fluid_hatch.import_9x.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/hull.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/item_bus.export.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/item_bus.import.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.source.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.target.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/maintenance.cleaning.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/maintenance.configurable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/gtceu/models/block/machine/part/maintenance.full_auto.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.