Skip to content

Commit

Permalink
add infinite water cover
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Aug 13, 2021
1 parent 664bd32 commit d4b0dfa
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/render/Textures.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public class Textures {
public static final SimpleOverlayRenderer DETECTOR_ITEM = new SimpleOverlayRenderer("cover/overlay_item_detector");
public static final SimpleOverlayRenderer CRAFTING = new SimpleOverlayRenderer("cover/overlay_crafting");
public static final SimpleOverlayRenderer SOLAR_PANEL = new SimpleOverlayRenderer("cover/overlay_solar_panel");
public static final SimpleOverlayRenderer INFINITE_WATER = new SimpleOverlayRenderer("cover/overlay_infinite_water");
public static final SimpleOverlayRenderer ROCK_CRUSHER_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_rock_crusher");
public static final SimpleOverlayRenderer ROCK_CRUSHER_ACTIVE_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_rock_crusher_active");
public static final SimpleOverlayRenderer PIPE_OUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_pipe_out");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gregtech/common/covers/CoverBehaviors.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void init() {
registerBehavior(51, new ResourceLocation(GTValues.MODID, "fluid_detector"), MetaItems.COVER_FLUID_DETECTOR, CoverDetectorFluid::new);
registerBehavior(52, new ResourceLocation(GTValues.MODID, "item_detector"), MetaItems.COVER_ITEM_DETECTOR, CoverDetectorItem::new);
registerBehavior(53, new ResourceLocation(GTValues.MODID, "crafting_table"), MetaItems.COVER_CRAFTING, CoverCraftingTable::new);
registerBehavior(54, new ResourceLocation(GTValues.MODID, "infinite_water"), MetaItems.COVER_INFINITE_WATER, CoverInfiniteWater::new);

for (int i = 0; i < COVERS_PER_ITEM; i++) {
int throughput = (int) (Math.pow(4, i) * 1280);
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/gregtech/common/covers/CoverInfiniteWater.java
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);
}
}
}
1 change: 1 addition & 0 deletions src/main/java/gregtech/common/items/MetaItem1.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public void registerSubItems() {
COVER_CRAFTING = addItem(307, "cover.crafting");
COVER_DRAIN = addItem(308, "cover.drain");
COVER_SHUTTER = addItem(309, "cover.shutter");
COVER_INFINITE_WATER = addItem(310, "cover.infinite_water");
COVER_FACADE = addItem(330, "cover.facade").addComponents(new FacadeItem()).disableModelLoading();

// Solar Panels: ID 331-346
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gregtech/common/items/MetaItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ private MetaItems() {
public static MetaItem<?>.MetaValueItem COVER_SCREEN;
public static MetaItem<?>.MetaValueItem COVER_CRAFTING;
public static MetaItem<?>.MetaValueItem COVER_DRAIN;
public static MetaItem<?>.MetaValueItem COVER_INFINITE_WATER;

public static MetaItem<?>.MetaValueItem COVER_SOLAR_PANEL;
public static MetaItem<?>.MetaValueItem COVER_SOLAR_PANEL_ULV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,14 @@ private static void registerAssemblerRecipes() {
.EUt(16).duration(50)
.buildAndRegister();

ASSEMBLER_RECIPES.recipeBuilder()
.input(ELECTRIC_PUMP_HV, 2)
.inputs(new ItemStack(Items.CAULDRON))
.input(circuit, MarkerMaterials.Tier.Advanced)
.output(COVER_INFINITE_WATER)
.EUt(480).duration(200)
.buildAndRegister();

RecipeMaps.ASSEMBLER_RECIPES.recipeBuilder().EUt(16).input(OrePrefix.plate, Materials.WroughtIron, 8).outputs(MetaBlocks.MACHINE_CASING.getItemVariant(MachineCasingType.ULV)).circuitMeta(8).duration(25).buildAndRegister();
RecipeMaps.ASSEMBLER_RECIPES.recipeBuilder().EUt(16).input(OrePrefix.plate, Materials.Steel, 8).outputs(MetaBlocks.MACHINE_CASING.getItemVariant(MachineCasingType.LV)).circuitMeta(8).duration(50).buildAndRegister();
RecipeMaps.ASSEMBLER_RECIPES.recipeBuilder().EUt(16).input(OrePrefix.plate, Materials.Aluminium, 8).outputs(MetaBlocks.MACHINE_CASING.getItemVariant(MachineCasingType.MV)).circuitMeta(8).duration(50).buildAndRegister();
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ metaitem.cover.solar.panel.ulv.tooltip=8 Volt Solar Panel
metaitem.cover.solar.panel.lv.name=Solar Panel (LV)
metaitem.cover.solar.panel.lv.tooltip=Low Voltage Solar Panel

metaitem.cover.infinite_water.name=Infinite Water Cover
metaitem.cover.infinite_water.tooltip=Creates 64 Buckets of Water every second (as Cover)

metaitem.gelled_toluene.name=Gelled Toluene
metaitem.gelled_toluene.tooltip=Raw Explosive

Expand Down
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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation":{
"frametime":2
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d4b0dfa

Please sign in to comment.