Skip to content

Commit

Permalink
Re-Register Water als a Fluid Coolant and Allow Interacting with Tank…
Browse files Browse the repository at this point in the history
…s from UI
  • Loading branch information
shartte committed Jul 21, 2024
1 parent f4d7cf9 commit a866cf4
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 123 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ minecraft_version=1.21
cloth_config_version=15.0.127

rei_version=16.0.729
emi_version=1.1.7+1.21
neoforge_version=21.0.22-beta
emi_version=1.1.10+1.21
neoforge_version=21.0.113-beta
curios_version=7.0.0-beta.3+1.20.4

# Switch between none, emi and rei
runtime_itemlist_mod=rei
runtime_itemlist_mod=emi

#########################################################
# Parchment #
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginManagement {
maven { url "https://maven.architectury.dev/" }
}
plugins {
id 'net.neoforged.moddev' version '0.1.105'
id 'net.neoforged.moddev' version '1.0.13'
id "me.shedaniel.unified-publishing" version "0.1.+"
id 'com.diffplug.spotless' version '6.25.0'
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/owmii/powah/Powah.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.material.Fluids;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
Expand Down Expand Up @@ -80,6 +81,7 @@ public Powah(IEventBus modEventBus) {

modEventBus.addListener((FMLCommonSetupEvent event) -> {
// TODO: move to config
PowahAPI.registerCoolant(BuiltInRegistries.FLUID.getKey(Fluids.WATER), 1);
PowahAPI.registerSolidCoolant(Blocks.SNOW_BLOCK, 48, -3);
PowahAPI.registerSolidCoolant(Items.SNOWBALL, 12, -3);
PowahAPI.registerSolidCoolant(Blocks.ICE, 48, -5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.InventoryMenu;
import owmii.powah.api.PowahAPI;
import owmii.powah.block.magmator.MagmatorTile;
import owmii.powah.client.ClientUtils;
import owmii.powah.client.screen.Textures;
import owmii.powah.inventory.MagmatorContainer;
import owmii.powah.lib.client.screen.container.AbstractEnergyScreen;
import owmii.powah.lib.client.util.Draw;
import owmii.powah.lib.client.util.Text;
import owmii.powah.lib.logistics.energy.Energy;
import owmii.powah.util.Ticker;
Expand All @@ -28,6 +25,18 @@ public MagmatorScreen(MagmatorContainer container, Inventory inv, Component titl
if (this.te.isBurning()) {
this.heat.setTicks(20);
}
addTankArea(
te::getTank,
157,
5,
14,
65,
"info.lollipop.fluid",
(content, lines) -> {
lines.add(Component.translatable("info.lollipop.Gain").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.translatable("info.lollipop.fe.per.mb", PowahAPI.getMagmaticFluidHeat(content.getFluid()), "100")
.withStyle(ChatFormatting.DARK_GRAY)));
});
}

@Override
Expand All @@ -47,22 +56,6 @@ protected void drawBackground(GuiGraphics guiGraphics, float partialTicks, int m
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.heat.subSized());
Textures.MAGMATOR_BUFFER.draw(guiGraphics, this.leftPos + 83, this.topPos + 29);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

var tank = this.te.getTank();
if (!tank.isEmpty()) {
var fluidStack = tank.getFluid();
var sprite = ClientUtils.getStillTexture(fluidStack);
if (sprite != null) {
int color = ClientUtils.getFluidColor(fluidStack);
float red = (color >> 16 & 0xFF) / 255.0F;
float green = (color >> 8 & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
RenderSystem.setShaderColor(red, green, blue, 1.0F);
bindTexture(InventoryMenu.BLOCK_ATLAS);
Draw.gaugeV(sprite, this.leftPos + 157, this.topPos + 5, 14, 65, (int) tank.getCapacity(), (int) tank.getFluidAmount());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
}
}

@Override
Expand All @@ -83,23 +76,5 @@ protected void renderTooltip(GuiGraphics gui, int mouseX, int mouseY) {
.withStyle(ChatFormatting.DARK_GRAY)));
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}

var tank = this.te.getTank();
if (isMouseOver(mouseX - 157, mouseY - 5, 14, 65)) {
List<Component> list = new ArrayList<>();
if (!tank.isEmpty()) {
list.add(Component.translatable("info.lollipop.fluid").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(tank.getFluid().getDisplayName().plainCopy().withStyle(ChatFormatting.GOLD)));
list.add(Component.translatable("info.lollipop.stored").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Util.formatTankContent(tank)));
list.add(Component.translatable("info.lollipop.Gain").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.translatable("info.lollipop.fe.per.mb", PowahAPI.getMagmaticFluidHeat(tank.getFluid().getFluid()), "100")
.withStyle(ChatFormatting.DARK_GRAY)));
} else {
list.add(Component.translatable("info.lollipop.fluid").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal("---").withStyle(ChatFormatting.DARK_GRAY)));
}
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package owmii.powah.client.screen.container;

import com.mojang.blaze3d.systems.RenderSystem;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.InventoryMenu;
import owmii.powah.api.PowahAPI;
import owmii.powah.block.reactor.ReactorTile;
import owmii.powah.client.ClientUtils;
import owmii.powah.client.screen.Textures;
import owmii.powah.inventory.ReactorContainer;
import owmii.powah.lib.client.screen.container.AbstractEnergyScreen;
import owmii.powah.lib.client.screen.widget.IconButton;
import owmii.powah.lib.client.util.Draw;
import owmii.powah.lib.client.util.Text;
import owmii.powah.lib.logistics.energy.Energy;
import owmii.powah.network.Network;
Expand All @@ -27,6 +23,14 @@ public class ReactorScreen extends AbstractEnergyScreen<ReactorTile, ReactorCont

public ReactorScreen(ReactorContainer container, Inventory inv, Component title) {
super(container, inv, title, Textures.REACTOR);

addTankArea(te::getTank, 157, 5, 14, 65, "info.lollipop.coolant", (content, lines) -> {
lines.add(Component.translatable("info.lollipop.temperature").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component
.translatable("info.lollipop.temperature.c",
"" + ChatFormatting.AQUA + PowahAPI.getCoolant(content.getFluid()))
.withStyle(ChatFormatting.DARK_GRAY)));
});
}

@Override
Expand Down Expand Up @@ -60,22 +64,6 @@ protected void drawBackground(GuiGraphics guiGraphics, float partialTicks, int m
Textures.REACTOR_GAUGE_TEMP.drawScalableH(guiGraphics, this.te.temp.subSized(), this.leftPos + 114, this.topPos + 28);

Textures.REACTOR_GEN_MODE_BG.draw(guiGraphics, this.modeButton.getX() - 4, this.modeButton.getY() - 4);

var tank = this.te.getTank();
if (!tank.isEmpty()) {
var fluidStack = tank.getFluid();
var sprite = ClientUtils.getStillTexture(fluidStack);
if (sprite != null) {
int color = ClientUtils.getFluidColor(fluidStack);
float red = (color >> 16 & 0xFF) / 255.0F;
float green = (color >> 8 & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
RenderSystem.setShaderColor(red, green, blue, 1.0F);
bindTexture(InventoryMenu.BLOCK_ATLAS);
Draw.gaugeV(sprite, this.leftPos + 157, this.topPos + 5, 14, 65, (int) tank.getCapacity(), (int) tank.getFluidAmount());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
}
}

@Override
Expand Down Expand Up @@ -159,25 +147,5 @@ protected void renderTooltip(GuiGraphics gui, int mouseX, int mouseY) {
list.add(Component.literal("" + ChatFormatting.AQUA + this.te.solidCoolantTemp + " C"));
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}

var tank = this.te.getTank();
if (isMouseOver(mouseX - 157, mouseY - 5, 14, 65)) {
List<Component> list = new ArrayList<>();
if (!tank.isEmpty()) {
list.add(Component.translatable("info.lollipop.coolant").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(tank.getFluid().getDisplayName().plainCopy().withStyle(ChatFormatting.AQUA)));
list.add(Component.translatable("info.lollipop.stored").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Util.formatTankContent(tank)));
list.add(Component.translatable("info.lollipop.temperature").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component
.translatable("info.lollipop.temperature.c",
"" + ChatFormatting.AQUA + PowahAPI.getCoolant(tank.getFluid().getFluid()))
.withStyle(ChatFormatting.DARK_GRAY)));
} else {
list.add(Component.translatable("info.lollipop.fluid").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal("---").withStyle(ChatFormatting.DARK_GRAY)));
}
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
package owmii.powah.client.screen.container;

import com.mojang.blaze3d.systems.RenderSystem;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.InventoryMenu;
import owmii.powah.api.PowahAPI;
import owmii.powah.block.thermo.ThermoTile;
import owmii.powah.client.ClientUtils;
import owmii.powah.client.screen.Textures;
import owmii.powah.inventory.ThermoContainer;
import owmii.powah.lib.client.screen.container.AbstractEnergyScreen;
import owmii.powah.lib.client.util.Draw;
import owmii.powah.lib.client.util.Text;
import owmii.powah.lib.logistics.energy.Energy;
import owmii.powah.util.Util;

public class ThermoScreen extends AbstractEnergyScreen<ThermoTile, ThermoContainer> {
public ThermoScreen(ThermoContainer container, Inventory inv, Component title) {
super(container, inv, title, Textures.THERMO);

addTankArea(te::getTank, 157, 5, 14, 65, "info.lollipop.coolant", (content, lines) -> {
lines.add(Component.translatable("info.lollipop.temperature").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component
.translatable("info.lollipop.temperature.c",
"" + ChatFormatting.AQUA + PowahAPI.getCoolant(content.getFluid()))
.withStyle(ChatFormatting.DARK_GRAY)));
});
}

@Override
protected void drawBackground(GuiGraphics gui, float partialTicks, int mouseX, int mouseY) {
super.drawBackground(gui, partialTicks, mouseX, mouseY);
Textures.THERMO_GAUGE.drawScalableH(gui, this.te.getEnergy().subSized(), this.leftPos + 5, this.topPos + 5);

var tank = this.te.getTank();
if (!tank.isEmpty()) {
var fluidStack = tank.getFluid();
var sprite = ClientUtils.getStillTexture(fluidStack);
if (sprite != null) {
int color = ClientUtils.getFluidColor(fluidStack);
float red = (color >> 16 & 0xFF) / 255.0F;
float green = (color >> 8 & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
RenderSystem.setShaderColor(red, green, blue, 1.0F);
bindTexture(InventoryMenu.BLOCK_ATLAS);
Draw.gaugeV(sprite, this.leftPos + 157, this.topPos + 5, 14, 65, (int) tank.getCapacity(), (int) tank.getFluidAmount());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
}

long percent = this.te.getGeneration() > 0 ? (100 * this.te.generating) / this.te.getGeneration() : 0;
gui.drawString(font, percent + "%" + " (" + this.te.generating + " FE/t)", this.leftPos + 34, this.topPos + 10, 5592405, false);
}
Expand All @@ -67,25 +55,5 @@ protected void renderTooltip(GuiGraphics gui, int mouseX, int mouseY) {
.withStyle(ChatFormatting.DARK_GRAY)));
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}

var tank = this.te.getTank();
if (isMouseOver(mouseX - 157, mouseY - 5, 14, 65)) {
List<Component> list = new ArrayList<>();
if (!tank.isEmpty()) {
list.add(Component.translatable("info.lollipop.coolant").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(tank.getFluid().getDisplayName().plainCopy().withStyle(ChatFormatting.AQUA)));
list.add(Component.translatable("info.lollipop.stored").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Util.formatTankContent(tank)));
list.add(Component.translatable("info.lollipop.temperature").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component
.translatable("info.lollipop.temperature.c",
"" + ChatFormatting.AQUA + PowahAPI.getCoolant(tank.getFluid().getFluid()))
.withStyle(ChatFormatting.DARK_GRAY)));
} else {
list.add(Component.translatable("info.lollipop.fluid").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal("---").withStyle(ChatFormatting.DARK_GRAY)));
}
gui.renderComponentTooltip(font, list, mouseX, mouseY);
}
}
}
Loading

0 comments on commit a866cf4

Please sign in to comment.