Skip to content

Commit

Permalink
Merge pull request #602 from refinedmods/fix/GH-597/relay-model
Browse files Browse the repository at this point in the history
All sorts of bugfixes
  • Loading branch information
raoulvdberge authored Jul 6, 2024
2 parents 416f367 + 6e779a1 commit 250d2df
Show file tree
Hide file tree
Showing 75 changed files with 256 additions and 165 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ out/
/bin/
logs/
.cache/
run/
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Ability to open Portable Grid with a keybinding.

### Fixed

- Fixed Relay model not being able to load correctly.
- Fixed not being able to ghost drag resources from recipe viewers into filter slots on NeoForge.
- Fixed extra dark backgrounds due to drawing background on GUIs twice.

## [2.0.0-milestone.4.2] - 2024-07-06

## [2.0.0-milestone.4.1] - 2024-07-05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
import com.refinedmods.refinedstorage.platform.api.support.network.ConnectionLogic;
import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations;
import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry;
import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier;
Expand Down Expand Up @@ -192,7 +192,7 @@ EnergyStorage asBlockItemEnergyStorage(

SlotReference createInventorySlotReference(Player player, InteractionHand hand);

void useNetworkBoundItem(Player player, Item... items);
void useSlotReferencedItem(Player player, Item... items);

BuiltinPermissions getBuiltinPermissions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
import com.refinedmods.refinedstorage.platform.api.support.network.ConnectionLogic;
import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations;
import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry;
import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier;
Expand Down Expand Up @@ -368,8 +368,8 @@ public SlotReference createInventorySlotReference(final Player player, final Int
}

@Override
public void useNetworkBoundItem(final Player player, final Item... items) {
ensureLoaded().useNetworkBoundItem(player, items);
public void useSlotReferencedItem(final Player player, final Item... items) {
ensureLoaded().useSlotReferencedItem(player, items);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.refinedmods.refinedstorage.platform.api.PlatformApi;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceHandlerItem;

import java.util.List;
import java.util.Optional;
Expand All @@ -22,7 +23,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.1")
public abstract class AbstractNetworkBoundEnergyItem extends AbstractEnergyItem {
public abstract class AbstractNetworkBoundEnergyItem extends AbstractEnergyItem implements SlotReferenceHandlerItem {
protected final NetworkBoundItemHelper networkBoundItemHelper;

protected AbstractNetworkBoundEnergyItem(final Properties properties,
Expand Down Expand Up @@ -56,17 +57,22 @@ public InteractionResultHolder<ItemStack> use(final Level level, final Player pl
final ItemStack stack = player.getItemInHand(hand);
if (player instanceof ServerPlayer serverPlayer && level.getServer() != null) {
final SlotReference slotReference = PlatformApi.INSTANCE.createInventorySlotReference(player, hand);
final NetworkBoundItemSession session = networkBoundItemHelper.openSession(
stack,
serverPlayer,
slotReference
);
use(serverPlayer, slotReference, session);
slotReference.resolve(player).ifPresent(s -> use(serverPlayer, s, slotReference));
}
return InteractionResultHolder.consume(stack);
}

public abstract void use(ServerPlayer player, SlotReference slotReference, NetworkBoundItemSession session);
@Override
public void use(final ServerPlayer player, final ItemStack stack, final SlotReference slotReference) {
final NetworkBoundItemSession session = PlatformApi.INSTANCE.getNetworkBoundItemHelper().openSession(
stack,
player,
slotReference
);
use(player, slotReference, session);
}

protected abstract void use(ServerPlayer player, SlotReference slotReference, NetworkBoundItemSession session);

public boolean isBound(final ItemStack stack) {
return networkBoundItemHelper.isBound(stack);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.refinedmods.refinedstorage.platform.api.support.network.bounditem;

import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;

import java.util.List;
import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.refinedmods.refinedstorage.platform.api.support.network.bounditem;
package com.refinedmods.refinedstorage.platform.api.support.slotreference;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.refinedmods.refinedstorage.platform.api.support.network.bounditem;
package com.refinedmods.refinedstorage.platform.api.support.slotreference;

import com.refinedmods.refinedstorage.platform.api.PlatformApi;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.refinedmods.refinedstorage.platform.api.support.slotreference;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import org.apiguardian.api.API;

@FunctionalInterface
@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.3")
public interface SlotReferenceHandlerItem {
void use(ServerPlayer player, ItemStack stack, SlotReference slotReference);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.refinedmods.refinedstorage.platform.api.support.network.bounditem;
package com.refinedmods.refinedstorage.platform.api.support.slotreference;

import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage.platform.api.support.slotreference;

import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,20 @@ protected static void handleInputEvents() {
}
final KeyMapping openWirelessGrid = KeyMappings.INSTANCE.getOpenWirelessGrid();
while (openWirelessGrid != null && openWirelessGrid.consumeClick()) {
PlatformApi.INSTANCE.useNetworkBoundItem(
PlatformApi.INSTANCE.useSlotReferencedItem(
player,
Items.INSTANCE.getWirelessGrid(),
Items.INSTANCE.getCreativeWirelessGrid()
);
}
final KeyMapping openPortableGrid = KeyMappings.INSTANCE.getOpenPortableGrid();
while (openPortableGrid != null && openPortableGrid.consumeClick()) {
PlatformApi.INSTANCE.useSlotReferencedItem(
player,
Items.INSTANCE.getPortableGrid(),
Items.INSTANCE.getCreativePortableGrid()
);
}
}

protected static void registerDiskModels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@
import com.refinedmods.refinedstorage.platform.common.support.containermenu.SingleAmountData;
import com.refinedmods.refinedstorage.platform.common.support.energy.EnergyLootItemFunction;
import com.refinedmods.refinedstorage.platform.common.support.network.BaseNetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.InventorySlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.common.support.network.component.PlatformStorageNetworkComponent;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceFactory;
import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceContainerData;
import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceTypes;
import com.refinedmods.refinedstorage.platform.common.support.slotreference.InventorySlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.common.upgrade.FortuneUpgradeItem;
import com.refinedmods.refinedstorage.platform.common.upgrade.RangeUpgradeItem;
import com.refinedmods.refinedstorage.platform.common.upgrade.RegulatorUpgradeContainerMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer;
import com.refinedmods.refinedstorage.platform.api.support.network.NetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations;
import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry;
import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier;
Expand All @@ -68,15 +68,15 @@
import com.refinedmods.refinedstorage.platform.common.support.energy.ItemEnergyStorage;
import com.refinedmods.refinedstorage.platform.common.support.network.ConnectionProviderImpl;
import com.refinedmods.refinedstorage.platform.common.support.network.InWorldNetworkNodeContainerImpl;
import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.CompositeSlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.InventorySlotReference;
import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.NetworkBoundItemHelperImpl;
import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.C2SPackets;
import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.S2CPackets;
import com.refinedmods.refinedstorage.platform.common.support.registry.PlatformRegistryImpl;
import com.refinedmods.refinedstorage.platform.common.support.resource.CompositeRecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceFactory;
import com.refinedmods.refinedstorage.platform.common.support.resource.ItemResourceFactory;
import com.refinedmods.refinedstorage.platform.common.support.slotreference.CompositeSlotReferenceProvider;
import com.refinedmods.refinedstorage.platform.common.support.slotreference.InventorySlotReference;
import com.refinedmods.refinedstorage.platform.common.upgrade.BuiltinUpgradeDestinationsImpl;
import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeRegistryImpl;
import com.refinedmods.refinedstorage.platform.common.util.ServerEventQueue;
Expand Down Expand Up @@ -519,9 +519,9 @@ public SlotReference createInventorySlotReference(final Player player, final Int
}

@Override
public void useNetworkBoundItem(final Player player, final Item... items) {
public void useSlotReferencedItem(final Player player, final Item... items) {
final Set<Item> validItems = new HashSet<>(Arrays.asList(items));
slotReferenceProvider.findForUse(player, items[0], validItems).ifPresent(C2SPackets::sendUseNetworkBoundItem);
slotReferenceProvider.findForUse(player, items[0], validItems).ifPresent(C2SPackets::sendUseSlotReferencedItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.MOD_ID;
import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslation;
import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslationKey;

public final class ContentNames {
public static final String MOD_TRANSLATION_KEY = "mod." + MOD_ID;
public static final MutableComponent MOD = Component.translatable(MOD_TRANSLATION_KEY);

public static final MutableComponent CABLE = name("cable");
public static final MutableComponent GRID = name("grid");
public static final MutableComponent CRAFTING_GRID = name("crafting_grid");
Expand All @@ -35,6 +37,14 @@ public final class ContentNames {
public static final MutableComponent RELAY = name("relay");
public static final MutableComponent DISK_INTERFACE = name("disk_interface");

public static final String CLEAR_CRAFTING_MATRIX_TO_NETWORK_TRANSLATION_KEY =
createTranslationKey("key", "clear_crafting_grid_matrix_to_network");
public static final String CLEAR_CRAFTING_MATRIX_TO_INVENTORY_TRANSLATION_KEY =
createTranslationKey("key", "clear_crafting_grid_matrix_to_inventory");
public static final String FOCUS_SEARCH_BAR_TRANSLATION_KEY = createTranslationKey("key", "focus_search_bar");
public static final String OPEN_WIRELESS_GRID_TRANSLATION_KEY = createTranslationKey("key", "open_wireless_grid");
public static final String OPEN_PORTABLE_GRID_TRANSLATION_KEY = createTranslationKey("key", "open_portable_grid");

private ContentNames() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public final class KeyMappings {
private KeyMapping clearCraftingGridMatrixToInventory;
@Nullable
private KeyMapping openWirelessGrid;
@Nullable
private KeyMapping openPortableGrid;

private KeyMappings() {
}
Expand Down Expand Up @@ -54,4 +56,13 @@ public KeyMapping getOpenWirelessGrid() {
public void setOpenWirelessGrid(final KeyMapping openWirelessGrid) {
this.openWirelessGrid = openWirelessGrid;
}

@Nullable
public KeyMapping getOpenPortableGrid() {
return openPortableGrid;
}

public void setOpenPortableGrid(final KeyMapping openPortableGrid) {
this.openPortableGrid = openPortableGrid;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.platform.common.grid;

import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.platform.common.grid;

import com.refinedmods.refinedstorage.platform.api.grid.Grid;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.common.content.Menus;

import net.minecraft.world.entity.player.Inventory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.platform.common.grid;

import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory;

import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.platform.common.grid;

import com.refinedmods.refinedstorage.platform.api.grid.Grid;
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference;
import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference;
import com.refinedmods.refinedstorage.platform.common.content.ContentNames;
import com.refinedmods.refinedstorage.platform.common.support.containermenu.ExtendedMenuProvider;

Expand Down
Loading

0 comments on commit 250d2df

Please sign in to comment.