-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
664bd32
commit d4b0dfa
Showing
11 changed files
with
83 additions
and
0 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
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
57 changes: 57 additions & 0 deletions
57
src/main/java/gregtech/common/covers/CoverInfiniteWater.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,57 @@ | ||
package gregtech.common.covers; | ||
|
||
import codechicken.lib.render.CCRenderState; | ||
import codechicken.lib.render.pipeline.IVertexOperation; | ||
import codechicken.lib.vec.Cuboid6; | ||
import codechicken.lib.vec.Matrix4; | ||
import gregtech.api.cover.CoverBehavior; | ||
import gregtech.api.cover.ICoverable; | ||
import gregtech.api.render.Textures; | ||
import net.minecraft.util.BlockRenderLayer; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.ITickable; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; | ||
import net.minecraftforge.fluids.capability.IFluidHandler; | ||
|
||
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
import static gregtech.api.unification.material.Materials.Lava; | ||
import static gregtech.api.unification.material.Materials.Water; | ||
|
||
public class CoverInfiniteWater extends CoverBehavior implements ITickable { | ||
|
||
private static final int SPEED = 4; | ||
private long timer = 0L; | ||
private final IFluidHandler fluidHandler; | ||
|
||
public CoverInfiniteWater(ICoverable coverHolder, EnumFacing attachedSide) { | ||
super(coverHolder, attachedSide); | ||
fluidHandler = this.coverHolder.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); | ||
} | ||
|
||
@Override | ||
public boolean canAttach() { | ||
return this.coverHolder.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null) != null; | ||
} | ||
|
||
@Override | ||
public void renderCover(CCRenderState ccRenderState, Matrix4 matrix4, IVertexOperation[] iVertexOperations, Cuboid6 cuboid6, BlockRenderLayer blockRenderLayer) { | ||
Textures.INFINITE_WATER.renderSided(attachedSide, cuboid6, ccRenderState, iVertexOperations, matrix4); | ||
} | ||
|
||
@Override | ||
public void update() { | ||
if (timer++ % ((20 * SPEED) / (Math.pow(2, SPEED - 1))) == 0) { | ||
FluidStack fluidStack = fluidHandler.drain(Water.getFluid(Integer.MAX_VALUE), false); | ||
Arrays.stream(fluidHandler.getTankProperties()) | ||
.filter(tank -> Optional.ofNullable(tank.getContents()) | ||
.orElse(Lava.getFluid(1)).isFluidEqual(Water.getFluid(1)) && tank.getCapacity() > 64000) | ||
.findFirst() | ||
.ifPresent($ -> fluidHandler.fill(Water.getFluid(64000), true)); | ||
int amount = fluidStack != null ? Math.max(64000 - fluidStack.amount, 0) : 64000; | ||
fluidHandler.fill(Water.getFluid(amount), true); | ||
} | ||
} | ||
} |
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
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
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/gregtech/models/item/metaitems/cover.infinite_water.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,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "gregtech:items/metaitems/cover.infinite_water" | ||
} | ||
} |
Binary file added
BIN
+7.63 KB
...main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png.mcmeta
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,5 @@ | ||
{ | ||
"animation":{ | ||
"frametime":2 | ||
} | ||
} |
Binary file added
BIN
+10.2 KB
...ain/resources/assets/gregtech/textures/items/metaitems/cover.infinite_water.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.