mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-28 05:58:33 +01:00
Compare commits
No commits in common. "ad981047d7d7459b36860e1fd8658d4f277187c4" and "4914c5f3c00ac559cc0f6ddd85a4b4e6c4bda6f2" have entirely different histories.
ad981047d7
...
4914c5f3c0
15 changed files with 130 additions and 113 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -13,7 +13,6 @@
|
||||||
/bin/
|
/bin/
|
||||||
/run/
|
/run/
|
||||||
/logs
|
/logs
|
||||||
/runs
|
|
||||||
|
|
||||||
*.classpath
|
*.classpath
|
||||||
*.project
|
*.project
|
||||||
|
@ -21,4 +20,4 @@
|
||||||
*.launch
|
*.launch
|
||||||
.settings/org.eclipse.jdt.core.prefs
|
.settings/org.eclipse.jdt.core.prefs
|
||||||
*.prefs
|
*.prefs
|
||||||
.cache
|
.cache
|
13
build.gradle
13
build.gradle
|
@ -47,12 +47,6 @@ runs {
|
||||||
systemProperty 'forge.logging.console.level', 'info'
|
systemProperty 'forge.logging.console.level', 'info'
|
||||||
|
|
||||||
modSource project.sourceSets.main
|
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 {
|
client {
|
||||||
|
@ -94,14 +88,15 @@ dependencies {
|
||||||
|
|
||||||
implementation "org.jgrapht:jgrapht-core:${jgt_version}"
|
implementation "org.jgrapht:jgrapht-core:${jgt_version}"
|
||||||
jarJar(group: "org.jgrapht", name: "jgrapht-core", version: "[${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.jheaps", name: "jheaps", version: "[${jheaps_version}]")
|
||||||
jarJar(group: "org.apfloat", name: "apfloat", version: "[${apfloat_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
|
// 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
|
// 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}-common-api:${jei_version}"
|
||||||
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
|
compileOnly "mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"
|
||||||
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
|
runtimeOnly "mezz.jei:jei-${minecraft_version}-forge:${jei_version}"
|
||||||
|
|
||||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||||
|
@ -153,4 +148,4 @@ publishing {
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
}
|
}
|
|
@ -10,13 +10,13 @@ neogradle.subsystems.parchment.mappingsVersion=2023.12.31
|
||||||
minecraft_version=1.20.4
|
minecraft_version=1.20.4
|
||||||
minecraft_version_range=[1.20.4,1.21)
|
minecraft_version_range=[1.20.4,1.21)
|
||||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||||
neo_version=20.4.195
|
neo_version=20.4.80-beta
|
||||||
# The Neo version range can use any version of Neo as bounds
|
# The Neo version range can use any version of Neo as bounds
|
||||||
neo_version_range=[20.4,)
|
neo_version_range=[20.4,)
|
||||||
# The loader version range can only use the major version of FML as bounds
|
# The loader version range can only use the major version of FML as bounds
|
||||||
loader_version_range=[2,)
|
loader_version_range=[2,)
|
||||||
|
|
||||||
jei_version=17.3.0.49
|
jei_version=17.3.0.48
|
||||||
jgt_version=1.5.2
|
jgt_version=1.5.2
|
||||||
jheaps_version=0.14
|
jheaps_version=0.14
|
||||||
apfloat_version=1.10.1
|
apfloat_version=1.10.1
|
||||||
|
@ -32,7 +32,7 @@ mod_name=PrettyPipes
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.16.0
|
mod_version=1.15.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package de.ellpeck.prettypipes;
|
package de.ellpeck.prettypipes;
|
||||||
|
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
|
|
||||||
@Mod(PrettyPipes.ID)
|
@Mod(PrettyPipes.ID)
|
||||||
public final class PrettyPipes {
|
public final class PrettyPipes {
|
||||||
|
|
||||||
public static final String ID = "prettypipes";
|
public static final String ID = "prettypipes";
|
||||||
|
|
||||||
|
public PrettyPipes(IEventBus eventBus) {
|
||||||
|
if (FMLEnvironment.dist == Dist.CLIENT)
|
||||||
|
eventBus.addListener(Registry.Client::setup);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import de.ellpeck.prettypipes.entities.PipeFrameRenderer;
|
||||||
import de.ellpeck.prettypipes.items.*;
|
import de.ellpeck.prettypipes.items.*;
|
||||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||||
import de.ellpeck.prettypipes.misc.ModuleClearingRecipe;
|
import de.ellpeck.prettypipes.misc.ModuleClearingRecipe;
|
||||||
import de.ellpeck.prettypipes.packets.*;
|
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||||
|
@ -66,25 +65,23 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.Mod.EventBusSubscriber;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.common.Mod.EventBusSubscriber.Bus;
|
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
|
||||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
|
||||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
|
||||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@EventBusSubscriber(bus = Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public final class Registry {
|
public final class Registry {
|
||||||
|
|
||||||
|
// TODO use saved data for pipe networks
|
||||||
|
/*public static BlockCapability<PipeNetwork, Void> pipeNetworkCapability = CapabilityManager.get(new CapabilityToken<>() {
|
||||||
|
});*/
|
||||||
public static BlockCapability<IPipeConnectable, Direction> pipeConnectableCapability = BlockCapability.createSided(new ResourceLocation(PrettyPipes.ID, "pipe_connectable"), IPipeConnectable.class);
|
public static BlockCapability<IPipeConnectable, Direction> pipeConnectableCapability = BlockCapability.createSided(new ResourceLocation(PrettyPipes.ID, "pipe_connectable"), IPipeConnectable.class);
|
||||||
|
|
||||||
public static Item wrenchItem;
|
public static Item wrenchItem;
|
||||||
|
@ -196,27 +193,6 @@ public final class Registry {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
|
|
||||||
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.pipeBlockEntity, (e, d) -> e);
|
|
||||||
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.pressurizerBlockEntity, (e, d) -> e);
|
|
||||||
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.itemTerminalBlockEntity, (e, d) -> e);
|
|
||||||
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.craftingTerminalBlockEntity, (e, d) -> e);
|
|
||||||
|
|
||||||
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, Registry.pressurizerBlockEntity, (e, d) -> e.storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerPayloads(final RegisterPayloadHandlerEvent event) {
|
|
||||||
var registrar = event.registrar(PrettyPipes.ID);
|
|
||||||
registrar.play(PacketItemEnterPipe.ID, PacketItemEnterPipe::new, PacketItemEnterPipe::onMessage);
|
|
||||||
registrar.play(PacketButton.ID, PacketButton::new, PacketButton::onMessage);
|
|
||||||
registrar.play(PacketCraftingModuleTransfer.ID, PacketCraftingModuleTransfer::new, PacketCraftingModuleTransfer::onMessage);
|
|
||||||
registrar.play(PacketGhostSlot.ID, PacketGhostSlot::new, PacketGhostSlot::onMessage);
|
|
||||||
registrar.play(PacketNetworkItems.ID, PacketNetworkItems::new, PacketNetworkItems::onMessage);
|
|
||||||
registrar.play(PacketRequest.ID, PacketRequest::new, PacketRequest::onMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) {
|
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) {
|
||||||
var type = (MenuType<T>) IMenuTypeExtension.create((windowId, inv, data) -> {
|
var type = (MenuType<T>) IMenuTypeExtension.create((windowId, inv, data) -> {
|
||||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level(), data.readBlockPos());
|
var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level(), data.readBlockPos());
|
||||||
|
@ -233,10 +209,8 @@ public final class Registry {
|
||||||
helper.register(new ResourceLocation(PrettyPipes.ID, tier.name().toLowerCase(Locale.ROOT) + "_" + name), item.apply(name, tier));
|
helper.register(new ResourceLocation(PrettyPipes.ID, tier.name().toLowerCase(Locale.ROOT) + "_" + name), item.apply(name, tier));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusSubscriber(bus = Bus.MOD, value = Dist.CLIENT)
|
|
||||||
public static final class Client {
|
public static final class Client {
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void setup(FMLClientSetupEvent event) {
|
public static void setup(FMLClientSetupEvent event) {
|
||||||
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
||||||
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
||||||
|
|
|
@ -84,22 +84,17 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderGuiPre(ScreenEvent.Render.Pre event) {
|
public void onRenderGui(ScreenEvent.Render 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();
|
var screen = event.getScreen();
|
||||||
if (!(screen instanceof ItemTerminalGui terminal))
|
if (!(screen instanceof ItemTerminalGui terminal))
|
||||||
return;
|
return;
|
||||||
var sync = PlayerPrefs.get().syncJei;
|
var sync = PlayerPrefs.get().syncJei;
|
||||||
if (this.jeiSyncButton.isHovered())
|
if (event instanceof ScreenEvent.Render.Post) {
|
||||||
event.getGuiGraphics().renderTooltip(terminal.getMinecraft().font, Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -127,5 +122,4 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
filter.setFilterText(terminalText);
|
filter.setFilterText(terminalText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package de.ellpeck.prettypipes.misc;
|
package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
|
import de.ellpeck.prettypipes.packets.*;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||||
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -16,6 +21,16 @@ import java.nio.file.Paths;
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public final class Events {
|
public final class Events {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onWorldCaps(RegisterCapabilitiesEvent event) {
|
||||||
|
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.pipeBlockEntity, (e, d) -> e);
|
||||||
|
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.pressurizerBlockEntity, (e, d) -> e);
|
||||||
|
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.itemTerminalBlockEntity, (e, d) -> e);
|
||||||
|
event.registerBlockEntity(Registry.pipeConnectableCapability, Registry.craftingTerminalBlockEntity, (e, d) -> e);
|
||||||
|
|
||||||
|
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, Registry.pressurizerBlockEntity, (e, d) -> e.storage);
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarting(ServerStartingEvent event) {
|
public static void onServerStarting(ServerStartingEvent event) {
|
||||||
event.getServer().getCommands().getDispatcher().register(Commands.literal(PrettyPipes.ID).requires(s -> s.hasPermission(2))
|
event.getServer().getCommands().getDispatcher().register(Commands.literal(PrettyPipes.ID).requires(s -> s.hasPermission(2))
|
||||||
|
@ -46,4 +61,15 @@ public final class Events {
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onPayloadRegister(final RegisterPayloadHandlerEvent event) {
|
||||||
|
var registrar = event.registrar(PrettyPipes.ID);
|
||||||
|
registrar.play(PacketItemEnterPipe.ID, PacketItemEnterPipe::new, PacketItemEnterPipe::onMessage);
|
||||||
|
registrar.play(PacketButton.ID, PacketButton::new, PacketButton::onMessage);
|
||||||
|
registrar.play(PacketCraftingModuleTransfer.ID, PacketCraftingModuleTransfer::new, PacketCraftingModuleTransfer::onMessage);
|
||||||
|
registrar.play(PacketGhostSlot.ID, PacketGhostSlot::new, PacketGhostSlot::onMessage);
|
||||||
|
registrar.play(PacketNetworkItems.ID, PacketNetworkItems::new, PacketNetworkItems::onMessage);
|
||||||
|
registrar.play(PacketRequest.ID, PacketRequest::new, PacketRequest::onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,16 +61,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
|
|
||||||
public PipeNetwork(CompoundTag nbt) {
|
public PipeNetwork(CompoundTag nbt) {
|
||||||
this();
|
this();
|
||||||
var nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
|
this.load(nbt);
|
||||||
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
|
@Override
|
||||||
|
@ -121,6 +112,23 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
return nbt;
|
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) {
|
public void addNode(BlockPos pos, BlockState state) {
|
||||||
if (!this.isNode(pos)) {
|
if (!this.isNode(pos)) {
|
||||||
this.graph.addVertex(pos);
|
this.graph.addVertex(pos);
|
||||||
|
@ -517,13 +525,11 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startProfile(String name) {
|
public void startProfile(String name) {
|
||||||
if (this.level != null)
|
this.level.getProfiler().push(() -> PrettyPipes.ID + ":pipe_network_" + name);
|
||||||
this.level.getProfiler().push(() -> PrettyPipes.ID + ":pipe_network_" + name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endProfile() {
|
public void endProfile() {
|
||||||
if (this.level != null)
|
this.level.getProfiler().pop();
|
||||||
this.level.getProfiler().pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PipeNetwork get(Level level) {
|
public static PipeNetwork get(Level level) {
|
||||||
|
|
|
@ -206,10 +206,10 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
var opposite = direction.getOpposite();
|
var opposite = direction.getOpposite();
|
||||||
var tile = world.getBlockEntity(offset);
|
var tile = world.getBlockEntity(offset);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
var connectable = world.getCapability(Registry.pipeConnectableCapability, offset, tile.getBlockState(), tile, opposite);
|
var connectable = world.getCapability(Registry.pipeConnectableCapability, pos, state, tile, opposite);
|
||||||
if (connectable != null)
|
if (connectable != null)
|
||||||
return connectable.getConnectionType(pos, direction);
|
return connectable.getConnectionType(pos, direction);
|
||||||
var handler = world.getCapability(Capabilities.ItemHandler.BLOCK, offset, tile.getBlockState(), tile, opposite);
|
var handler = world.getCapability(Capabilities.ItemHandler.BLOCK, pos, state, tile, opposite);
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
return ConnectionType.CONNECTED;
|
return ConnectionType.CONNECTED;
|
||||||
}
|
}
|
||||||
|
@ -268,11 +268,6 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
var network = PipeNetwork.get(worldIn);
|
var network = PipeNetwork.get(worldIn);
|
||||||
network.removeNode(pos);
|
network.removeNode(pos);
|
||||||
network.onPipeChanged(pos, state);
|
network.onPipeChanged(pos, state);
|
||||||
if (worldIn.getBlockEntity(pos) instanceof PipeBlockEntity pipe) {
|
|
||||||
pipe.getItems().clear();
|
|
||||||
for (var lock : pipe.craftIngredientRequests)
|
|
||||||
network.resolveNetworkLock(lock);
|
|
||||||
}
|
|
||||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.Lazy;
|
import net.neoforged.neoforge.common.util.Lazy;
|
||||||
|
@ -388,6 +391,15 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
this.getItems().clear();
|
||||||
|
var network = PipeNetwork.get(this.level);
|
||||||
|
for (var lock : this.craftIngredientRequests)
|
||||||
|
network.resolveNetworkLock(lock);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return Component.translatable("container." + PrettyPipes.ID + ".pipe");
|
return Component.translatable("container." + PrettyPipes.ID + ".pipe");
|
||||||
|
@ -399,6 +411,14 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
return new MainPipeContainer(Registry.pipeContainer, window, player, PipeBlockEntity.this.worldPosition);
|
return new MainPipeContainer(Registry.pipeContainer, window, player, PipeBlockEntity.this.worldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO render bounding box?
|
||||||
|
/* @Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public AABB getRenderBoundingBox() {
|
||||||
|
// our render bounding box should always be the full block in case we're covered
|
||||||
|
return new AABB(this.worldPosition);
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
||||||
var state = this.level.getBlockState(pipePos.relative(direction));
|
var state = this.level.getBlockState(pipePos.relative(direction));
|
||||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.neoforged.neoforge.client.model.data.ModelData;
|
import net.neoforged.neoforge.client.model.data.ModelData;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -42,10 +41,5 @@ public class PipeRenderer implements BlockEntityRenderer<PipeBlockEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AABB getRenderBoundingBox(PipeBlockEntity blockEntity) {
|
|
||||||
// our render bounding box should always be the full block in case we're covered
|
|
||||||
return new AABB(blockEntity.getBlockPos());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,15 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
|
||||||
super.render(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);
|
this.renderTooltip(graphics, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||||
this.renderTooltip(graphics, mouseX, mouseY);
|
this.renderTooltip(graphics, mouseX, mouseY);
|
||||||
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)
|
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)
|
||||||
|
|
|
@ -266,6 +266,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.renderBackground(graphics, mouseX, mouseY, partialTicks);
|
||||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||||
for (var widget : this.renderables) {
|
for (var widget : this.renderables) {
|
||||||
if (widget instanceof ItemTerminalWidget terminal)
|
if (widget instanceof ItemTerminalWidget terminal)
|
||||||
|
|
|
@ -4,22 +4,22 @@
|
||||||
# Note that there are a couple of TOML lists in this file.
|
# Note that there are a couple of TOML lists in this file.
|
||||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
modLoader = "javafml" #mandatory
|
modLoader="javafml" #mandatory
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the the FML version. This is currently 47.
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
loaderVersion = "${loader_version_range}" #mandatory
|
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||||
license = "${mod_license}"
|
license="${mod_license}"
|
||||||
# A URL to refer people to when problems occur with this mod
|
# A URL to refer people to when problems occur with this mod
|
||||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
[[mods]] #mandatory
|
[[mods]] #mandatory
|
||||||
# The modid of the mod
|
# The modid of the mod
|
||||||
modId = "${mod_id}" #mandatory
|
modId="${mod_id}" #mandatory
|
||||||
# The version number of the mod
|
# The version number of the mod
|
||||||
version = "${mod_version}" #mandatory
|
version="${mod_version}" #mandatory
|
||||||
# A display name for the mod
|
# A display name for the mod
|
||||||
displayName = "${mod_name}" #mandatory
|
displayName="${mod_name}" #mandatory
|
||||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||||
|
@ -29,7 +29,7 @@ displayName = "${mod_name}" #mandatory
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
#credits="" #optional
|
#credits="" #optional
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
authors = "${mod_authors}" #optional
|
authors="${mod_authors}" #optional
|
||||||
# Display Test controls the display for your mod in the server connection screen
|
# Display Test controls the display for your mod in the server connection screen
|
||||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||||
|
@ -39,33 +39,29 @@ authors = "${mod_authors}" #optional
|
||||||
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
||||||
|
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description = '''${mod_description}'''
|
description='''${mod_description}'''
|
||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.${ mod_id }]] #optional
|
[[dependencies.${mod_id}]] #optional
|
||||||
# the modid of the dependency
|
# the modid of the dependency
|
||||||
modId = "neoforge" #mandatory
|
modId="forge" #mandatory
|
||||||
# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive).
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
# 'required' requires the mod to exist, 'optional' does not
|
mandatory=true #mandatory
|
||||||
# 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning
|
|
||||||
type = "required" #mandatory
|
|
||||||
# Optional field describing why the dependency is required or why it is incompatible
|
|
||||||
# reason="..."
|
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange = "${neo_version_range}" #mandatory
|
versionRange="${forge_version_range}" #mandatory
|
||||||
# An ordering relationship for the dependency.
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||||
# BEFORE - This mod is loaded BEFORE the dependency
|
# BEFORE - This mod is loaded BEFORE the dependency
|
||||||
# AFTER - This mod is loaded AFTER the dependency
|
# AFTER - This mod is loaded AFTER the dependency
|
||||||
ordering = "NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||||
side = "BOTH"
|
side="BOTH"
|
||||||
# Here's another dependency
|
# Here's another dependency
|
||||||
[[dependencies.${ mod_id }]]
|
[[dependencies.${mod_id}]]
|
||||||
modId = "minecraft"
|
modId="minecraft"
|
||||||
type = "required"
|
mandatory=true
|
||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange = "${minecraft_version_range}"
|
versionRange="${minecraft_version_range}"
|
||||||
ordering = "NONE"
|
ordering="NONE"
|
||||||
side = "BOTH"
|
side="BOTH"
|
||||||
|
|
||||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
||||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||||
|
|
Loading…
Reference in a new issue