diff --git a/src/main/java/gregtech/api/render/Textures.java b/src/main/java/gregtech/api/render/Textures.java index c8c56a93797..08b27e51472 100644 --- a/src/main/java/gregtech/api/render/Textures.java +++ b/src/main/java/gregtech/api/render/Textures.java @@ -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"); diff --git a/src/main/java/gregtech/common/covers/CoverBehaviors.java b/src/main/java/gregtech/common/covers/CoverBehaviors.java index 16ca5a0922d..23aa96ddc38 100644 --- a/src/main/java/gregtech/common/covers/CoverBehaviors.java +++ b/src/main/java/gregtech/common/covers/CoverBehaviors.java @@ -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); diff --git a/src/main/java/gregtech/common/covers/CoverInfiniteWater.java b/src/main/java/gregtech/common/covers/CoverInfiniteWater.java new file mode 100644 index 00000000000..d8505e6534c --- /dev/null +++ b/src/main/java/gregtech/common/covers/CoverInfiniteWater.java @@ -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); + } + } +} diff --git a/src/main/java/gregtech/common/items/MetaItem1.java b/src/main/java/gregtech/common/items/MetaItem1.java index 972fa117247..7a1ddf197d4 100644 --- a/src/main/java/gregtech/common/items/MetaItem1.java +++ b/src/main/java/gregtech/common/items/MetaItem1.java @@ -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 diff --git a/src/main/java/gregtech/common/items/MetaItems.java b/src/main/java/gregtech/common/items/MetaItems.java index 37b89ed7934..f3d2efce4ab 100644 --- a/src/main/java/gregtech/common/items/MetaItems.java +++ b/src/main/java/gregtech/common/items/MetaItems.java @@ -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; diff --git a/src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java b/src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java index 19d90a750f0..d4b484b10a0 100644 --- a/src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java @@ -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(); diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index 4d5db12af85..2f00262c1e8 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -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 diff --git a/src/main/resources/assets/gregtech/models/item/metaitems/cover.infinite_water.json b/src/main/resources/assets/gregtech/models/item/metaitems/cover.infinite_water.json new file mode 100644 index 00000000000..c0dd2f63af9 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/metaitems/cover.infinite_water.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/metaitems/cover.infinite_water" + } +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png b/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png new file mode 100644 index 00000000000..537d07fc7a8 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png.mcmeta new file mode 100644 index 00000000000..97596ba8176 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/cover/overlay_infinite_water.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":2 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/textures/items/metaitems/cover.infinite_water.png b/src/main/resources/assets/gregtech/textures/items/metaitems/cover.infinite_water.png new file mode 100644 index 00000000000..c5214280d03 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/metaitems/cover.infinite_water.png differ