Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.105'
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
id 'net.neoforged.moddev' version '2.0.140'
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
}

ext.releaseTag = providers.environmentVariable("TAG").orElse("").toString()
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ modrinth_project_id=EuTS81Z3
curse_project_id=250294

# Minecraft/Forge
minecraft_version=1.21.8
minecraft_version_range=[1.21.8,)
neo_version=21.8.47
neo_version_range=[21.8.25,)
minecraft_version=1.21.11
minecraft_version_range=[1.21.11,)
neo_version=21.11.37-beta
neo_version_range=[21.11.0-beta,)
loader_version_range=[4,)
pack_format_number=18
parchment_minecraft_version=1.21.8
parchment_mappings_version=2025.07.20
pack_format_number=94.1
parchment_minecraft_version=1.21.10
parchment_mappings_version=2025.10.12

# Dependencies
top_version=1.21_neo-12.0.3-5
jade_curse_id=6838468
jei_version=24.0.0.2
jade_curse_id=7427066
jei_version=27.4.0.15
patchouli_version=1.21-87-NEOFORGE
ffs_version=21.0.0

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/me/desht/modularrouters/ModularRouters.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.desht.modularrouters.network.NetworkHandler;
import me.desht.modularrouters.util.ModNameCache;
import me.desht.modularrouters.util.WildcardedRLMatcher;
import net.minecraft.resources.Identifier;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
Expand Down Expand Up @@ -53,15 +54,15 @@ private static void registerDeferred(IEventBus modBus) {
}

private void registerCaps(RegisterCapabilitiesEvent event) {
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK,
event.registerBlockEntity(Capabilities.Item.BLOCK,
ModBlockEntities.MODULAR_ROUTER.get(),
(be, side) -> be.getBuffer());

event.registerBlockEntity(Capabilities.FluidHandler.BLOCK,
event.registerBlockEntity(Capabilities.Fluid.BLOCK,
ModBlockEntities.MODULAR_ROUTER.get(),
(be, side) -> be.getFluidHandler());

event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK,
event.registerBlockEntity(Capabilities.Energy.BLOCK,
ModBlockEntities.MODULAR_ROUTER.get(),
(be, side) -> be.getEnergyStorage());
}
Expand Down Expand Up @@ -98,4 +99,8 @@ public static void gatherData(GatherDataEvent.Client event) {
event.createProvider(ModModelProvider::new);
}
}

public static Identifier id(String path) {
return Identifier.fromNamespaceAndPath(MODID, path);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.desht.modularrouters.api.event;

import me.desht.modularrouters.block.tile.ModularRouterBlockEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.inventory.DataSlot;
import net.neoforged.bus.api.Event;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -16,7 +16,7 @@
*/
public class RegisterRouterContainerData extends Event {
private final ModularRouterBlockEntity router;
private final Map<ResourceLocation, DataSlot> data = new HashMap<>();
private final Map<Identifier, DataSlot> data = new HashMap<>();

@ApiStatus.Internal
public RegisterRouterContainerData(ModularRouterBlockEntity router) {
Expand All @@ -29,7 +29,7 @@ public RegisterRouterContainerData(ModularRouterBlockEntity router) {
* @param id the ID of the slot
* @param dataSlot the slot to register
*/
public void register(ResourceLocation id, DataSlot dataSlot) {
public void register(Identifier id, DataSlot dataSlot) {
data.put(id, dataSlot);
}

Expand All @@ -41,7 +41,7 @@ public ModularRouterBlockEntity getRouter() {
}

@ApiStatus.Internal
public Map<ResourceLocation, DataSlot> getData() {
public Map<Identifier, DataSlot> getData() {
return Collections.unmodifiableMap(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean hasAnalogOutputSignal(BlockState state) {
}

@Override
public int getAnalogOutputSignal(BlockState blockState, Level world, BlockPos pos) {
public int getAnalogOutputSignal(BlockState blockState, Level world, BlockPos pos, Direction direction) {
return world.getBlockEntity(pos, ModBlockEntities.MODULAR_ROUTER.get())
.map(router -> ItemHandlerHelper.calcRedstoneFromInventory(router.getBuffer()))
.orElse(0);
Expand Down Expand Up @@ -163,7 +163,7 @@ public InteractionResult useWithoutItem(BlockState state, Level world, BlockPos
PacketDistributor.sendToPlayer(sp, RouterSettingsMessage.forRouter(router));
PacketDistributor.sendToPlayer(sp, RouterUpgradesSyncMessage.forRouter(router));
sp.openMenu(router, pos);
} else if (!router.isPermitted(player) && world.isClientSide) {
} else if (!router.isPermitted(player) && world.isClientSide()) {
player.displayClientMessage(xlate("modularrouters.chatText.security.accessDenied").withStyle(ChatFormatting.RED), false);
player.playSound(ModSounds.ERROR.get(), 1.0f, 1.0f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import me.desht.modularrouters.util.MiscUtil;
import me.desht.modularrouters.util.TranslatableEnum;
import me.desht.modularrouters.util.fake_player.RouterFakePlayer;
import net.minecraft.Util;
import net.minecraft.server.players.NameAndId;
import net.minecraft.util.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.GlobalPos;
Expand Down Expand Up @@ -258,8 +259,8 @@ protected void loadAdditional(ValueInput input) {
active = input.getBooleanOr(NBT_ACTIVE, false);
activeTimer = input.getIntOr(NBT_ACTIVE_TIMER, 0);
ecoMode = input.getBooleanOr(NBT_ECO_MODE, false);
ownerID = input.read(NBT_OWNER_PROFILE, ExtraCodecs.GAME_PROFILE).orElse(DEFAULT_FAKEPLAYER_PROFILE);

var tmpOwnerID = input.read(NBT_OWNER_PROFILE, NameAndId.CODEC).orElse(new NameAndId(DEFAULT_FAKEPLAYER_PROFILE.id(), DEFAULT_FAKEPLAYER_PROFILE.name()));
ownerID = new GameProfile(tmpOwnerID.id(), tmpOwnerID.name());
// TODO extension data

// When restoring, give the counter a random initial value to avoid all saved routers
Expand All @@ -284,7 +285,7 @@ protected void saveAdditional(ValueOutput output) {
if (activeTimer != 0) output.putInt(NBT_ACTIVE_TIMER, activeTimer);
if (ecoMode) output.putBoolean(NBT_ECO_MODE, true);
if (ownerID != null) {
output.store(NBT_OWNER_PROFILE, ExtraCodecs.GAME_PROFILE, ownerID);
output.store(NBT_OWNER_PROFILE, NameAndId.CODEC, new NameAndId(ownerID.id(), ownerID.name()));
}
// TODO extension data
// if (!getExtensionData().isEmpty()) nbt.put(NBT_EXTRA, getExtensionData());
Expand Down Expand Up @@ -526,7 +527,7 @@ private void handleSync(boolean renderUpdate) {
// some tile entity field changed that the client needs to know about
// if on server, sync TE data to client; if on client, possibly mark the TE for re-render
Level level = nonNullLevel();
if (!level.isClientSide) {
if (!level.isClientSide()) {
if (anyPlayerHasThisOpen()) {
blockUpdateNeeded = true;
} else {
Expand Down Expand Up @@ -602,7 +603,7 @@ private void compileModules() {
private void compileUpgrades() {
// if called client-side, always recompile (it's due to an upgrade sync)
Level level = nonNullLevel();
if (level.isClientSide || recompileNeeded.contains(RecompileFlag.UPGRADES)) {
if (level.isClientSide() || recompileNeeded.contains(RecompileFlag.UPGRADES)) {
int prevMufflers = getUpgradeCount(ModItems.MUFFLER_UPGRADE.get());
upgradeCount.clear();
permitted.clear();
Expand All @@ -623,7 +624,7 @@ private void compileUpgrades() {
ConfigHolder.common.router.fluidBaseTransferRate.get() + getUpgradeCount(ModItems.FLUID_UPGRADE.get()) * ConfigHolder.common.router.mBperFluidUpgrade.get());

energyStorage.updateForEnergyUpgrades(getUpgradeCount(ModItems.ENERGY_UPGRADE.get()));
if (!level.isClientSide) {
if (!level.isClientSide()) {
int mufflers = getUpgradeCount(ModItems.MUFFLER_UPGRADE.get());
if (prevMufflers != mufflers) {
level.setBlock(worldPosition, getBlockState().setValue(ModularRouterBlock.ACTIVE, active && mufflers < 3), Block.UPDATE_CLIENTS);
Expand Down Expand Up @@ -947,7 +948,7 @@ public AABB getRenderBoundingBox() {
}

public void addItemBeam(BeamData beamData) {
if (nonNullLevel().isClientSide) {
if (nonNullLevel().isClientSide()) {
beams.add(beamData);
cachedRenderAABB = null;
} else {
Expand Down Expand Up @@ -985,7 +986,7 @@ public IFluidHandlerItem getFluidHandler() {
}

public void sendBlockUpdateIfNeeded() {
if (!level.isClientSide && blockUpdateNeeded && !anyPlayerHasThisOpen()) {
if (!level.isClientSide() && blockUpdateNeeded && !anyPlayerHasThisOpen()) {
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_ALL);
blockUpdateNeeded = false;
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/me/desht/modularrouters/client/KeyBindings.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package me.desht.modularrouters.client;

import com.mojang.blaze3d.platform.InputConstants;
import me.desht.modularrouters.ModularRouters;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.resources.Identifier;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import net.neoforged.neoforge.client.settings.KeyConflictContext;
import org.lwjgl.glfw.GLFW;

public class KeyBindings {
public static KeyMapping.Category CATEGORY = new KeyMapping.Category(ModularRouters.id("key"));

public static KeyMapping keybindConfigure;
public static KeyMapping keybindModuleInfo;

public static void registerKeyBindings(RegisterKeyMappingsEvent event) {
event.registerCategory(CATEGORY);
KeyBindings.keybindConfigure = new KeyMapping("key.modularrouters.configure", KeyConflictContext.GUI,
InputConstants.getKey(GLFW.GLFW_KEY_C, -1), "key.modularrouters.category");
InputConstants.getKey(new KeyEvent(GLFW.GLFW_KEY_C, -1, 0)), CATEGORY);
KeyBindings.keybindModuleInfo = new KeyMapping("key.modularrouters.moduleInfo", KeyConflictContext.GUI,
InputConstants.getKey(GLFW.GLFW_KEY_I, -1), "key.modularrouters.category");
InputConstants.getKey(new KeyEvent(GLFW.GLFW_KEY_I, -1, 0)), CATEGORY);

event.register(KeyBindings.keybindConfigure);
event.register(KeyBindings.keybindModuleInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.MenuAccess;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
Expand All @@ -38,7 +40,7 @@
import static me.desht.modularrouters.util.MiscUtil.RL;

public class ModularRouterScreen extends AbstractContainerScreen<RouterMenu> implements ISendToServer, MenuAccess<RouterMenu> {
private static final ResourceLocation TEXTURE_LOCATION = RL("textures/gui/router.png");
private static final Identifier TEXTURE_LOCATION = RL("textures/gui/router.png");

private static final int LABEL_YPOS = 5;
private static final int MODULE_LABEL_YPOS = 60;
Expand Down Expand Up @@ -107,13 +109,13 @@ protected void renderBg(GuiGraphics graphics, float v, int i, int i1) {
}

@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return KeyBindings.keybindConfigure.getKey().getValue() == keyCode ? handleModuleConfig() : super.keyPressed(keyCode, scanCode, modifiers);
public boolean keyPressed(KeyEvent event) {
return KeyBindings.keybindConfigure.getKey().getValue() == event.key() ? handleModuleConfig() : super.keyPressed(event);
}

@Override
public boolean mouseClicked(double x, double y, int btn) {
return btn == 2 ? handleModuleConfig() : super.mouseClicked(x, y, btn);
public boolean mouseClicked(MouseButtonEvent event, boolean flag) {
return event.button() == 2 ? handleModuleConfig() : super.mouseClicked(event, flag);
}

@Override
Expand All @@ -131,7 +133,7 @@ public void containerTick() {
boolean hasEnergyUpgrade = menu.getRouter().getEnergyCapacity() > 0;
energyWidget.visible = hasEnergyUpgrade;
energyDirButton.visible = hasEnergyUpgrade
&& getMenu().getSlot(RouterMenu.TE_FIRST_SLOT).getItem().getCapability(Capabilities.EnergyStorage.ITEM) != null;
&& getMenu().getSlot(RouterMenu.TE_FIRST_SLOT).getItem().getCapability(Capabilities.Energy.ITEM) != null;

energyWarning.setX(hasEnergyUpgrade ? leftPos - 22 : leftPos + 4);
energyWarning.tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ComponentRenderUtils;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;
Expand Down Expand Up @@ -132,7 +133,7 @@ public Button(int x, int y) {
}

@Override
public void onClick(double mouseX, double mouseY) {
public void onClick(MouseButtonEvent event, boolean flag) {
toggle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.desht.modularrouters.util.MFLocator;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Inventory;
Expand Down Expand Up @@ -46,12 +47,12 @@ boolean closeGUI() {
}

@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if ((keyCode == GLFW.GLFW_KEY_ESCAPE || ClientUtil.isInvKey(keyCode))) {
public boolean keyPressed(KeyEvent event) {
if ((event.key() == GLFW.GLFW_KEY_ESCAPE || ClientUtil.isInvKey(event.key()))) {
// Intercept ESC/E and immediately reopen the previous GUI, if any
if (closeGUI()) return true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(event);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.desht.modularrouters.network.messages.OpenGuiMessage;
import me.desht.modularrouters.util.MFLocator;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
Expand All @@ -26,12 +27,12 @@ public abstract class AbstractFilterScreen extends Screen implements IResyncable
}

@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_ESCAPE || (ClientUtil.isInvKey(keyCode)) /*&& (!hasTextFieldManager() || !getOrCreateTextFieldManager().isFocused())*/) {
public boolean keyPressed(KeyEvent event) {
if (event.key() == GLFW.GLFW_KEY_ESCAPE || (ClientUtil.isInvKey(event.key())) /*&& (!hasTextFieldManager() || !getOrCreateTextFieldManager().isFocused())*/) {
// Intercept ESC/<inv> and immediately reopen the previous GUI, if any
if (closeGUI()) return true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(event);
}

boolean closeGUI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
Expand All @@ -29,7 +29,7 @@
import static me.desht.modularrouters.client.util.ClientUtil.xlate;

public class BulkItemFilterScreen extends AbstractFilterContainerScreen {
private static final ResourceLocation TEXTURE_LOCATION = MiscUtil.RL("textures/gui/bulkitemfilter.png");
private static final Identifier TEXTURE_LOCATION = MiscUtil.RL("textures/gui/bulkitemfilter.png");

private static final int GUI_WIDTH = 176;
private static final int GUI_HEIGHT = 233;
Expand Down
Loading