some fixes

This commit is contained in:
Ell 2024-03-07 18:21:05 +01:00
parent f908fa6c39
commit cca0f12f1a
8 changed files with 37 additions and 43 deletions

View file

@ -47,6 +47,12 @@ runs {
systemProperty 'forge.logging.console.level', 'info'
modSource project.sourceSets.main
dependencies {
runtime "org.jgrapht:jgrapht-core:${jgt_version}"
runtime "org.jheaps:jheaps:${jheaps_version}"
runtime "org.apfloat:apfloat:${apfloat_version}"
}
}
client {
@ -88,15 +94,14 @@ dependencies {
implementation "org.jgrapht:jgrapht-core:${jgt_version}"
jarJar(group: "org.jgrapht", name: "jgrapht-core", version: "[${jgt_version}]")
// for some reason jgrapht dependencies aren't auto-included in the metadata and i can't figure out how to make that happen
jarJar(group: "org.jheaps", name: "jheaps", version: "[${jheaps_version}]")
jarJar(group: "org.apfloat", name: "apfloat", version: "[${apfloat_version}]")
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
compileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"
compileOnly "mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"
runtimeOnly "mezz.jei:jei-${minecraft_version}-forge:${jei_version}"
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar

View file

@ -10,13 +10,13 @@ neogradle.subsystems.parchment.mappingsVersion=2023.12.31
minecraft_version=1.20.4
minecraft_version_range=[1.20.4,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.4.80-beta
neo_version=20.4.195
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.4,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[2,)
jei_version=17.3.0.48
jei_version=17.3.0.49
jgt_version=1.5.2
jheaps_version=0.14
apfloat_version=1.10.1

View file

@ -84,17 +84,22 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
}
@SubscribeEvent
public void onRenderGui(ScreenEvent.Render event) {
public void onRenderGuiPre(ScreenEvent.Render.Pre event) {
var screen = event.getScreen();
if (!(screen instanceof ItemTerminalGui))
return;
var sync = PlayerPrefs.get().syncJei;
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
}
@SubscribeEvent
public void onRenderGuiPost(ScreenEvent.Render.Post event) {
var screen = event.getScreen();
if (!(screen instanceof ItemTerminalGui terminal))
return;
var sync = PlayerPrefs.get().syncJei;
if (event instanceof ScreenEvent.Render.Post) {
if (this.jeiSyncButton.isHovered())
event.getGuiGraphics().renderTooltip(terminal.getMinecraft().font, Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
} else if (event instanceof ScreenEvent.Render.Pre) {
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
}
if (this.jeiSyncButton.isHovered())
event.getGuiGraphics().renderTooltip(terminal.getMinecraft().font, Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
}
@SubscribeEvent
@ -122,4 +127,5 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
filter.setFilterText(terminalText);
}
}
}

View file

@ -39,6 +39,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
// TODO it appears that this doesn't save properly yet :(
public class PipeNetwork extends SavedData implements GraphListener<BlockPos, NetworkEdge> {
private static final Factory<PipeNetwork> FACTORY = new Factory<>(PipeNetwork::new, PipeNetwork::new);
@ -61,7 +62,16 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
public PipeNetwork(CompoundTag nbt) {
this();
this.load(nbt);
var nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
for (var i = 0; i < nodes.size(); i++)
this.graph.addVertex(NbtUtils.readBlockPos(nodes.getCompound(i)));
var edges = nbt.getList("edges", Tag.TAG_COMPOUND);
for (var i = 0; i < edges.size(); i++)
this.addEdge(new NetworkEdge(edges.getCompound(i)));
for (var item : Utility.deserializeAll(nbt.getList("items", Tag.TAG_COMPOUND), IPipeItem::load))
this.pipeItems.put(item.getCurrentPipe(), item);
for (var lock : Utility.deserializeAll(nbt.getList("locks", Tag.TAG_COMPOUND), NetworkLock::new))
this.createNetworkLock(lock);
}
@Override
@ -112,23 +122,6 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
return nbt;
}
public void load(CompoundTag nbt) {
this.graph.removeAllVertices(new ArrayList<>(this.graph.vertexSet()));
this.pipeItems.clear();
this.networkLocks.clear();
var nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
for (var i = 0; i < nodes.size(); i++)
this.graph.addVertex(NbtUtils.readBlockPos(nodes.getCompound(i)));
var edges = nbt.getList("edges", Tag.TAG_COMPOUND);
for (var i = 0; i < edges.size(); i++)
this.addEdge(new NetworkEdge(edges.getCompound(i)));
for (var item : Utility.deserializeAll(nbt.getList("items", Tag.TAG_COMPOUND), IPipeItem::load))
this.pipeItems.put(item.getCurrentPipe(), item);
for (var lock : Utility.deserializeAll(nbt.getList("locks", Tag.TAG_COMPOUND), NetworkLock::new))
this.createNetworkLock(lock);
}
public void addNode(BlockPos pos, BlockState state) {
if (!this.isNode(pos)) {
this.graph.addVertex(pos);

View file

@ -206,10 +206,10 @@ public class PipeBlock extends BaseEntityBlock {
var opposite = direction.getOpposite();
var tile = world.getBlockEntity(offset);
if (tile != null) {
var connectable = world.getCapability(Registry.pipeConnectableCapability, pos, state, tile, opposite);
var connectable = world.getCapability(Registry.pipeConnectableCapability, offset, tile.getBlockState(), tile, opposite);
if (connectable != null)
return connectable.getConnectionType(pos, direction);
var handler = world.getCapability(Capabilities.ItemHandler.BLOCK, pos, state, tile, opposite);
var handler = world.getCapability(Capabilities.ItemHandler.BLOCK, offset, tile.getBlockState(), tile, opposite);
if (handler != null)
return ConnectionType.CONNECTED;
}

View file

@ -54,15 +54,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
super.render(graphics, mouseX, mouseY, partialTicks);
for (var widget : this.renderables) {
// TODO render widget tooltips?
/* if (widget instanceof AbstractWidget abstractWidget) {
if (abstractWidget.isHoveredOrFocused())
abstractWidget.renderToolTip(matrix, mouseX, mouseY);
}*/
}
this.renderTooltip(graphics, mouseX, mouseY);
}

View file

@ -19,7 +19,6 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
super.render(graphics, mouseX, mouseY, partialTicks);
this.renderTooltip(graphics, mouseX, mouseY);
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)

View file

@ -266,7 +266,6 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
super.render(graphics, mouseX, mouseY, partialTicks);
for (var widget : this.renderables) {
if (widget instanceof ItemTerminalWidget terminal)