-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from ferriarnus/fluid-rewrite
Rewrite our Fluid handling
- Loading branch information
Showing
17 changed files
with
325 additions
and
312 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
33 changes: 33 additions & 0 deletions
33
src/machines/java/com/enderio/machines/common/attachment/IFluidTankUser.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,33 @@ | ||
package com.enderio.machines.common.attachment; | ||
|
||
import com.enderio.machines.common.MachineNBTKeys; | ||
import com.enderio.machines.common.blockentity.base.MachineBlockEntity; | ||
import com.enderio.machines.common.io.fluid.MachineFluidHandler; | ||
import com.enderio.machines.common.io.fluid.MachineTankLayout; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.neoforged.neoforge.capabilities.ICapabilityProvider; | ||
import net.neoforged.neoforge.fluids.capability.IFluidHandler; | ||
|
||
public interface IFluidTankUser { | ||
|
||
MachineTankLayout getTankLayout(); | ||
MachineFluidHandler getFluidHandler(); | ||
MachineFluidHandler createFluidHandler(); | ||
|
||
default void saveTank(CompoundTag pTag) { | ||
pTag.put(MachineNBTKeys.FLUIDS, getFluidHandler().serializeNBT()); | ||
} | ||
|
||
default void loadTank(CompoundTag pTag) { | ||
getFluidHandler().deserializeNBT(pTag.getCompound(MachineNBTKeys.FLUIDS)); | ||
} | ||
|
||
ICapabilityProvider<MachineBlockEntity, Direction, IFluidHandler> FLUID_HANDLER_PROVIDER = | ||
(be, side) ->{ | ||
if (be instanceof IFluidTankUser user) { | ||
return user.getFluidHandler().getForSide(side); | ||
} | ||
return null; | ||
}; | ||
} |
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
Oops, something went wrong.