179
CHANGELOG-old.md
179
CHANGELOG-old.md
@@ -1,184 +1,5 @@
|
||||
# Refined Storage Changelog
|
||||
|
||||
### 1.9.18
|
||||
|
||||
- Fixed potential Pattern crash when loading Minecraft.
|
||||
|
||||
### 1.9.17
|
||||
- Added more slots to the Pattern Grid (Darkere)
|
||||
- Combined Fluid and Item View in the Pattern Grid (Darkere)
|
||||
- Fixed Relay not working (Darkere)
|
||||
- Fixed Wireless Transmitter only working upright (Darkere)
|
||||
- Fixed Portable Grid not opening when pointing at a block (Darkere)
|
||||
- Fixed being able to circumvent locked slots by scrolling (Darkere)
|
||||
- Processing patterns now use the order of items/fluids specified in the pattern (Darkere, necauqua)
|
||||
- Fixed multiple bugs related to transferring recipes into the crafting grid (Darkere)
|
||||
- Fixed autocrafting task getting stuck if two tasks fulfilled each others requirements (Darkere)
|
||||
- Fixed fluid autocrafting breaking when using 2 stacks of the same fluid in a pattern (Darkere)
|
||||
- Amount specifying screen is now limited to valid values (Darkere)
|
||||
|
||||
### 1.9.16
|
||||
|
||||
- Added Covers for all cable types! (Buuz135)
|
||||
- Improved JEI integration to pick the best option when transferring items (Darkere)
|
||||
- Fixed an issue where too many items in a grid would kick the player (Darkere)
|
||||
- Fixed an issue where the portable grid does not open from Inventory anymore after some use (Darkere)
|
||||
- Fixed craftable view in grids not showing items that were already in storage (BlueAgent)
|
||||
- Fixed Wireless Crafting Monitor not working as Curio (Darkere)
|
||||
- Fixed wrong slot being locked in some cases when opening Wireless Item (Darkere)
|
||||
- Slightly sped up External Storage item look up (necauqua)
|
||||
- Fixed extraction from Storage Monitor not respecting maximum stack size (Darkere)
|
||||
- Added Polish translation (joker876)
|
||||
- Added Italian translation (maicol07)
|
||||
- Addons can now override how Crafters insert items (Darkere)
|
||||
|
||||
### 1.9.15
|
||||
|
||||
- Fixed Refined Storage Addons compatibility (Darkere)
|
||||
|
||||
### 1.9.14
|
||||
|
||||
- Implemented Curios support (Darkere)
|
||||
|
||||
### 1.9.13
|
||||
|
||||
- Fixed count on Storage Monitor having Z fighting (tivec)
|
||||
- Fixed items on Storage Monitor not being flat (raoulvdberge)
|
||||
- Removed experimental pipeline nagging message (raoulvdberge)
|
||||
- Fixed crash when using an External Storage on a fluid inventory (jeremiahwinsley)
|
||||
- Added some performance improvements for autocrafting (necauqua, Darkere)
|
||||
- Fixed a memory leak in the pattern cache (necauqua)
|
||||
- Fixed Detector crashing when dyed (Darkere)
|
||||
- Fixed autocrafting being stuck after clicking "Start" (necauqua)
|
||||
- Fixed Crafting Monitor not being able to show hours (Darkere)
|
||||
- Fixed capacity rendering of infinite storages (Darkere)
|
||||
- Fixed wrong alignment for the JEI request autocrafting tooltip (Darkere)
|
||||
- Fixed mobs getting stuck in Refined Storage cables (Darkere)
|
||||
- Fixed dismantling storage blocks ignoring stack size (Darkere)
|
||||
- Fixed Ice and Fire banners breaking with Refined Storage (Darkere, necauqua)
|
||||
- Fixed empty keybinding causing GL errors (Darkere)
|
||||
- Fixed some parts of the Japanese translation (akihironagai)
|
||||
- Fixed rendering issue on blocks when using OptiFine (ylou)
|
||||
|
||||
### 1.9.12
|
||||
|
||||
- Fixed some issues when using the Grid when it's offline (Darkere)
|
||||
- Fixed crafting events not being fired in some cases in the Grid (Darkere)
|
||||
- Fixed not being able to set fluid filter slot output quantity (Darkere)
|
||||
- Fixed mod id search not working for Industrial Foregoing (Darkere)
|
||||
- Fixed fluid autocrafting duplicating fluids (Darkere)
|
||||
- Fixed some Grid crashes (ScoreUnder)
|
||||
- Fixed constructor not using compare mode correctly in some cases (ScoreUnder)
|
||||
- Fixed duplication bug in the Interface (Darkere)
|
||||
|
||||
### 1.9.11
|
||||
|
||||
- Fixed disks and network devices not loading when they did not previously exist
|
||||
|
||||
If you are affected by this please go to the world/data/ folder and remove the ".temp" ending from the files before
|
||||
launching.
|
||||
|
||||
### 1.9.10
|
||||
|
||||
- Improve performance of the Grid view (ScoreUnder)
|
||||
- Fixed Disk Manipulator model glitches (Darkere)
|
||||
- Improve performance of the Disk Manipulator (Darkere)
|
||||
- Fixed being unable to set quantity in output slots of the Pattern Grid (Darkere)
|
||||
- Fixed External Storage in fluid mode losing track of fluids sometimes (Darkere)
|
||||
- Added code to avoid / minimize data corruption issues caused by Minecraft (Darkere)
|
||||
- Fixed processing autocrafting orders stealing items from each other (Darkere)
|
||||
- Fixed Constructor in fluid mode voiding fluid source blocks in front of it (Darkere)
|
||||
- Update Japanese translation (alyxferrari)
|
||||
- Fixed crash when recoloring blocks that have no rotation component (Darkere)
|
||||
- Fixed reloading resource packs breaking Refined Storage textures (Darkere)
|
||||
|
||||
### 1.9.9
|
||||
|
||||
- Fixed Refined Storage sidebuttons displaying over the JEI bookmark pagination buttons (raoulvdberge)
|
||||
- Fixed issue where Crafters may fail to recognize an inventory/tank for some patterns (Darkere)
|
||||
- Fixed issue where the Crafter Manager can crash on invalid patterns (raoulvdberge)
|
||||
- Fixed issue where alternatives in the Pattern Grid weren't being saved properly (raoulvdberge)
|
||||
- Fixed not being able to change the Exporter filter slot count with regulator mode without closing and re-opening the
|
||||
container (raoulvdberge)
|
||||
|
||||
### 1.9.8
|
||||
|
||||
- Fixed server crash when scrolling in Grid (Darkere)
|
||||
- Fixed various issues with Grid interactions working without power (Darkere)
|
||||
- Fixed changing rotation not updating blocks (Darkere)
|
||||
- Added a JEI synchronized (two-way) search box mode to the Grid (ScoreUnder)
|
||||
- Added a nag message when a player joins the world that asks the player to enable the experimental Forge lighting
|
||||
pipeline to ensure correct rendering (raoulvdberge)
|
||||
|
||||
### 1.9.7
|
||||
|
||||
- Added functionality to move items in the Grid with shift/ctrl + scrolling (Darkere)
|
||||
- Changed JEI transfer error mechanics (raoulvdberge)
|
||||
- Fixed crash when opening Controller GUI (Darkere)
|
||||
- Fixed dye being consumed without effect in some cases (Darkere)
|
||||
- Fixed deadlock caused by Portable Grid (Darkere)
|
||||
- Fixed custom tooltips not working in the Grid (Darkere)
|
||||
|
||||
### 1.9.6
|
||||
|
||||
- Port to Minecraft 1.16.3 (raoulvdberge)
|
||||
- Added colored block variants (Darkere)
|
||||
- Added functionality to show missing items in the JEI transfer screen (Darkere)
|
||||
- Added functionality to request missing items from autocrafting in the JEI transfer screen (Darkere)
|
||||
- Added client config option to remember the Grid search query (raoulvdberge)
|
||||
- Fixed Portable Grid losing enchantments when placing and breaking (raoulvdberge)
|
||||
|
||||
### 1.9.5
|
||||
|
||||
- Re-added the `/refinedstorage disk create <player> <id>` command (raoulvdberge)
|
||||
- Added the `/refinedstorage disk list` command (raoulvdberge)
|
||||
- Added the `/refinedstorage disk list <player>` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network list <dimension>` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network get <dimension> <pos>` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting list` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting get <id>` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting cancel` command (raoulvdberge)
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting cancel <id>` command (raoulvdberge)
|
||||
- Added JEI ghost ingredient dragging support (raoulvdberge)
|
||||
- Fixed text field not being focused in amount specifying screens (raoulvdberge)
|
||||
|
||||
### 1.9.4
|
||||
|
||||
- Fixed JEI recipes/usages keys not working in Grids (raoulvdberge)
|
||||
|
||||
### 1.9.3
|
||||
|
||||
- Port to Minecraft 1.16.2 (raoulvdberge)
|
||||
- Fixed duplication bug with the Constructor (Darkere)
|
||||
- Updated Japanese translation (a2y4)
|
||||
- Updated Taiwanese translation (ForFunPenguin)
|
||||
- Refactored autocrafting code (raoulvdberge)
|
||||
|
||||
### 1.9.2b
|
||||
|
||||
Fixed duplication bug with the Constructor (Darkere, raoulvdberge)
|
||||
|
||||
### 1.9.2
|
||||
|
||||
- Fixed crash with Forge version 67 (Darkere)
|
||||
- Fixed cases where Refined Storage unwillingly acts like a chunkloader (raoulvdberge)
|
||||
- Fixed Network Transmitters being able to connect to any network device (raoulvdberge)
|
||||
- Fixed Crafting Tweaks buttons being in the wrong position after changing the size configuration of the Grid (
|
||||
raoulvdberge)
|
||||
- Networks that are in a chunk that isn't loaded will no longer work, they will turn off. Chunkload the Controller to
|
||||
maintain a functioning network over long distances (Darkere/raoulvdberge)
|
||||
- Re-added interdimensional networks with the Network Transmitter and Network Receiver (raoulvdberge)
|
||||
- Re-added MouseTweaks integration (raoulvdberge)
|
||||
|
||||
### 1.9.1
|
||||
|
||||
- Fixed server crash (raoulvdberge)
|
||||
|
||||
### 1.9
|
||||
|
||||
- Port to Minecraft 1.16 (raoulvdberge)
|
||||
- Fixed wrench requiring shift click to rotate blocks (raoulvdberge)
|
||||
|
||||
### 1.8.8
|
||||
|
||||
- Fixed duplication bug and weird behavior in the Crafting Grid matrix (Darkere)
|
||||
|
281
CHANGELOG.md
281
CHANGELOG.md
@@ -7,6 +7,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Available items indicator in JEI now updates while JEI is open
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed chained crafters not taking over the name of the root crafter.
|
||||
- Fixed lag when opening JEI in large system
|
||||
|
||||
## [v1.11.1] - 2022-10-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed not using Forge silicon tag for recipes.
|
||||
@@ -106,3 +117,273 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
- Ported to Minecraft 1.18.1.
|
||||
- Focused side buttons now display their tooltip properly.
|
||||
- Improved performance of retrieving patterns by [@metalshark](https://github.com/metalshark).
|
||||
|
||||
## [v1.9.18] - 2022-05-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed potential Pattern crash when loading Minecraft.
|
||||
|
||||
## [v1.9.17] - 2022-01-30
|
||||
|
||||
### Added
|
||||
|
||||
- More slots for the Pattern Grid.
|
||||
|
||||
### Changed
|
||||
|
||||
- Combined fluid and item view in the Pattern Grid.
|
||||
- Processing patterns now use the order of items/fluids specified in the pattern.
|
||||
- Amount specifying screen is now limited to valid values.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Relay not working.
|
||||
- Fixed Wireless Transmitter only working upright.
|
||||
- Fixed Portable Grid not opening when pointing at a block.
|
||||
- Fixed being able to circumvent locked slots by scrolling.
|
||||
- Fixed multiple bugs related to transferring recipes into the crafting grid.
|
||||
- Fixed autocrafting task getting stuck if two tasks fulfilled each others requirements.
|
||||
- Fixed fluid autocrafting breaking when using 2 stacks of the same fluid in a pattern.
|
||||
|
||||
## [v1.9.16] - 2021-11-16
|
||||
|
||||
### Added
|
||||
|
||||
- Added Covers for all cable types.
|
||||
- Added Polish translation.
|
||||
- Added Italian translation.
|
||||
- Addons can now override how crafters insert items.
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved JEI integration to pick the best option when transferring items.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue where too many items in a grid would kick the player.
|
||||
- Fixed an issue where the portable grid does not open from Inventory anymore after some use.
|
||||
- Fixed craftable view in grids not showing items that were already in storage.
|
||||
- Fixed Wireless Crafting Monitor not working as Curio.
|
||||
- Fixed wrong slot being locked in some cases when opening a wireless item.
|
||||
- Slightly sped up External Storage item look up.
|
||||
- Fixed extraction from Storage Monitor not respecting maximum stack size.
|
||||
|
||||
## [v1.9.15] - 2021-07-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Refined Storage Addons compatibility.
|
||||
|
||||
## [v1.9.14] - 2021-07-25
|
||||
|
||||
### Added
|
||||
|
||||
- Implemented Curios support.
|
||||
|
||||
## [v1.9.13] - 2021-06-14
|
||||
|
||||
### Added
|
||||
|
||||
- Added some performance improvements for autocrafting.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed count on Storage Monitor having Z fighting.
|
||||
- Fixed items on Storage Monitor not being flat.
|
||||
- Fixed crash when using an External Storage on a fluid inventory.
|
||||
- Fixed a memory leak in the pattern cache.
|
||||
- Fixed Detector crashing when dyed.
|
||||
- Fixed autocrafting being stuck after clicking "Start".
|
||||
- Fixed Crafting Monitor not being able to show hours.
|
||||
- Fixed capacity rendering of infinite storages.
|
||||
- Fixed wrong alignment for the JEI request autocrafting tooltip.
|
||||
- Fixed mobs getting stuck in Refined Storage cables.
|
||||
- Fixed dismantling storage blocks ignoring stack size.
|
||||
- Fixed Ice and Fire banners breaking with Refined Storage. necauqua)
|
||||
- Fixed empty keybinding causing GL errors.
|
||||
- Fixed some parts of the Japanese translation.
|
||||
- Fixed rendering issue on blocks when using OptiFine.
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed experimental pipeline nagging message.
|
||||
|
||||
## [v1.9.12] - 2021-02-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed some issues when using the Grid when it's offline.
|
||||
- Fixed crafting events not being fired in some cases in the Grid.
|
||||
- Fixed not being able to set fluid filter slot output quantity.
|
||||
- Fixed mod id search not working for Industrial Foregoing.
|
||||
- Fixed fluid autocrafting duplicating fluids.
|
||||
- Fixed some Grid crashes.
|
||||
- Fixed constructor not using compare mode correctly in some cases.
|
||||
- Fixed duplication bug in the Interface.
|
||||
|
||||
## [v1.9.11] - 2021-01-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed disks and network devices not loading when they did not previously exist
|
||||
- If you are affected by this please go to the world/data/ folder and remove the ".temp" ending from the files
|
||||
before
|
||||
launching.
|
||||
|
||||
## [v1.9.10] - 2021-01-02
|
||||
|
||||
### Changed
|
||||
|
||||
- Update Japanese translation.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Improve performance of the Grid view.
|
||||
- Fixed Disk Manipulator model glitches.
|
||||
- Improve performance of the Disk Manipulator.
|
||||
- Fixed being unable to set quantity in output slots of the Pattern Grid.
|
||||
- Fixed External Storage in fluid mode losing track of fluids sometimes.
|
||||
- Added code to avoid / minimize data corruption issues caused by Minecraft.
|
||||
- Fixed processing autocrafting orders stealing items from each other.
|
||||
- Fixed Constructor in fluid mode voiding fluid source blocks in front of it.
|
||||
- Fixed crash when recoloring blocks that have no rotation component.
|
||||
- Fixed reloading resource packs breaking Refined Storage textures.
|
||||
|
||||
## [v1.9.9] - 2020-11-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Refined Storage sidebuttons displaying over the JEI bookmark pagination buttons.
|
||||
- Fixed issue where Crafters may fail to recognize an inventory/tank for some patterns.
|
||||
- Fixed issue where the Crafter Manager can crash on invalid patterns.
|
||||
- Fixed issue where alternatives in the Pattern Grid weren't being saved properly.
|
||||
- Fixed not being able to change the Exporter filter slot count with regulator mode without closing and re-opening the
|
||||
container.
|
||||
|
||||
## [v1.9.8] - 2020-10-24
|
||||
|
||||
### Added
|
||||
|
||||
- Added a JEI synchronized (two-way) search box mode to the Grid.
|
||||
- Added a nag message when a player joins the world that asks the player to enable the experimental Forge lighting
|
||||
pipeline to ensure correct rendering.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed server crash when scrolling in Grid.
|
||||
- Fixed various issues with Grid interactions working without power.
|
||||
- Fixed changing rotation not updating blocks.
|
||||
|
||||
## [v1.9.7] - 2020-10-04
|
||||
|
||||
### Added
|
||||
|
||||
- Added functionality to move items in the Grid with shift/ctrl + scrolling.
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed JEI transfer error mechanics.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed crash when opening Controller GUI.
|
||||
- Fixed dye being consumed without effect in some cases.
|
||||
- Fixed deadlock caused by Portable Grid.
|
||||
- Fixed custom tooltips not working in the Grid.
|
||||
|
||||
## [v1.9.6] - 2020-09-25
|
||||
|
||||
### Added
|
||||
|
||||
- Port to Minecraft 1.16.3.
|
||||
- Added colored block variants.
|
||||
- Added functionality to show missing items in the JEI transfer screen.
|
||||
- Added functionality to request missing items from autocrafting in the JEI transfer screen.
|
||||
- Added client config option to remember the Grid search query.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Portable Grid losing enchantments when placing and breaking.
|
||||
|
||||
## [v1.9.5] - 2020-09-06
|
||||
|
||||
### Added
|
||||
|
||||
- Re-added the `/refinedstorage disk create <player> <id>` command.
|
||||
- Added the `/refinedstorage disk list` command.
|
||||
- Added the `/refinedstorage disk list <player>` command.
|
||||
- Added the `/refinedstorage network list <dimension>` command.
|
||||
- Added the `/refinedstorage network get <dimension> <pos>` command.
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting list` command.
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting get <id>` command.
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting cancel` command.
|
||||
- Added the `/refinedstorage network get <dimension> <pos> autocrafting cancel <id>` command.
|
||||
- Added JEI ghost ingredient dragging support.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed text field not being focused in amount specifying screens.
|
||||
|
||||
## [v1.9.4] - 2020-08-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed JEI recipes/usages keys not working in Grids.
|
||||
|
||||
## [v1.9.3-beta] - 2020-08-24
|
||||
|
||||
### Added
|
||||
|
||||
- Port to Minecraft 1.16.2.
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Japanese translation.
|
||||
- Updated Taiwanese translation.
|
||||
- Refactored autocrafting code.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed duplication bug with the Constructor.
|
||||
|
||||
## [v1.9.2b-beta] - 2020-09-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed duplication bug with the Constructor.
|
||||
|
||||
## [v1.9.2-beta] - 2020-07-17
|
||||
|
||||
### Added
|
||||
|
||||
- Re-added interdimensional networks with the Network Transmitter and Network Receiver.
|
||||
- Re-added MouseTweaks integration.
|
||||
|
||||
### Changed
|
||||
|
||||
- Networks that are in a chunk that isn't loaded will no longer work, they will turn off. Chunkload the Controller to
|
||||
maintain a functioning network over long distances.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed crash with Forge version 67.
|
||||
- Fixed cases where Refined Storage unwillingly acts like a chunkloader.
|
||||
- Fixed Network Transmitters being able to connect to any network device.
|
||||
- Fixed Crafting Tweaks buttons being in the wrong position after changing the size configuration of the Grid.
|
||||
|
||||
## [v1.9.1-beta] - 2020-07-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed server crash.
|
||||
|
||||
## [v1.9.0-beta] - 2020-07-14
|
||||
|
||||
### Added
|
||||
|
||||
- Port to Minecraft 1.16.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed wrench requiring shift click to rotate blocks.
|
||||
|
@@ -33,7 +33,7 @@ apply plugin: 'maven-publish'
|
||||
|
||||
group = 'com.refinedmods'
|
||||
archivesBaseName = 'refinedstorage'
|
||||
version = '1.11.1'
|
||||
version = '1.11.2'
|
||||
|
||||
if (System.getenv('GITHUB_SHA') != null) {
|
||||
version += '+' + System.getenv('GITHUB_SHA').substring(0, 7)
|
||||
|
@@ -86,11 +86,23 @@ public interface ICraftingPatternContainer {
|
||||
|
||||
/**
|
||||
* The name of this container for categorizing in the Crafting Manager GUI.
|
||||
* Will return the name of the root container if we're in a chained scenario.
|
||||
*
|
||||
* @return the name of this container
|
||||
*/
|
||||
Component getName();
|
||||
|
||||
/**
|
||||
* The custom name of this container, as set in an anvil for example.
|
||||
* Can be null.
|
||||
*
|
||||
* @return the name of this container
|
||||
*/
|
||||
@Nullable
|
||||
default Component getCustomName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the position of this container
|
||||
*/
|
||||
|
@@ -15,6 +15,7 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
@@ -40,7 +41,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null).ifPresent(fluidHandler -> {
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
FluidStack extracted = network.extractFluid(stack, FluidType.BUCKET_VOLUME, Action.PERFORM);
|
||||
|
@@ -19,6 +19,7 @@ import com.refinedmods.refinedstorage.network.grid.GridCraftingStartResponseMess
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -174,7 +175,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
||||
Optional<IItemHandler> playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).resolve();
|
||||
Optional<IItemHandler> playerInventory = player.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).resolve();
|
||||
if (playerInventory.isPresent()) {
|
||||
if (preferredSlot != -1) {
|
||||
ItemStack remainder = playerInventory.get().insertItem(preferredSlot, took, true);
|
||||
|
@@ -10,9 +10,9 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
if (!bucket.isEmpty()) {
|
||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
bucket.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null).ifPresent(fluidHandler -> {
|
||||
portableGrid.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, FluidType.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
@@ -10,6 +10,7 @@ import com.refinedmods.refinedstorage.blockentity.grid.portable.IPortableGrid;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -93,7 +94,7 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
||||
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
IItemHandler playerInventory = player.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).orElse(null);
|
||||
if (playerInventory != null) {
|
||||
if (preferredSlot != -1) {
|
||||
ItemStack remainder = playerInventory.insertItem(preferredSlot, took, true);
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
@@ -39,7 +40,7 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.SERVER_CONFIG.getWirelessCraftingMonitor().getUseEnergy() &&
|
||||
((WirelessCraftingMonitorItem) stack.getItem()).getType() != WirelessCraftingMonitorItem.Type.CREATIVE &&
|
||||
@@ -73,7 +74,7 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.SERVER_CONFIG.getWirelessCraftingMonitor().getUseEnergy() && ((WirelessCraftingMonitorItem) stack.getItem()).getType() != WirelessCraftingMonitorItem.Type.CREATIVE) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> {
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
|
@@ -14,6 +14,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class WirelessFluidGridNetworkItem implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.SERVER_CONFIG.getWirelessFluidGrid().getUseEnergy() &&
|
||||
((WirelessFluidGridItem) stack.getItem()).getType() != WirelessFluidGridItem.Type.CREATIVE &&
|
||||
@@ -64,7 +65,7 @@ public class WirelessFluidGridNetworkItem implements INetworkItem {
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.SERVER_CONFIG.getWirelessFluidGrid().getUseEnergy() && ((WirelessFluidGridItem) stack.getItem()).getType() != WirelessFluidGridItem.Type.CREATIVE) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> {
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
|
@@ -14,7 +14,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class WirelessGridNetworkItem implements INetworkItem {
|
||||
@@ -37,7 +37,7 @@ public class WirelessGridNetworkItem implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.SERVER_CONFIG.getWirelessGrid().getUseEnergy() &&
|
||||
((WirelessGridItem) stack.getItem()).getType() != WirelessGridItem.Type.CREATIVE &&
|
||||
@@ -64,7 +64,7 @@ public class WirelessGridNetworkItem implements INetworkItem {
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.SERVER_CONFIG.getWirelessGrid().getUseEnergy() && ((WirelessGridItem) stack.getItem()).getType() != WirelessGridItem.Type.CREATIVE) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> {
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
|
@@ -297,10 +297,20 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
return patternsInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Component getCustomName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getName() {
|
||||
if (displayName != null) {
|
||||
return displayName;
|
||||
ICraftingPatternContainer root = getRootContainer();
|
||||
if (root != null) {
|
||||
Component displayNameOfRoot = root.getCustomName();
|
||||
if (displayNameOfRoot != null) {
|
||||
return displayNameOfRoot;
|
||||
}
|
||||
}
|
||||
|
||||
BlockEntity facing = getConnectedBlockEntity();
|
||||
|
@@ -18,13 +18,18 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final String NBT_OWNER = "Owner";
|
||||
private static final String NBT_VERSION = "Version";
|
||||
private static final int CURRENT_VERSION = 1;
|
||||
@@ -256,8 +261,15 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
if (direction == null) {
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BaseBlock) {
|
||||
direction = state.getValue(((BaseBlock) state.getBlock()).getDirection().getProperty());
|
||||
if (state.getBlock() instanceof BaseBlock baseBlock) {
|
||||
DirectionProperty property = baseBlock.getDirection().getProperty();
|
||||
|
||||
if (state.hasProperty(property)) {
|
||||
direction = state.getValue(property);
|
||||
} else {
|
||||
LOGGER.warn("Node @ {} has no direction! Consider recreating the block", pos);
|
||||
return Direction.NORTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,9 +24,9 @@ import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -218,7 +218,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
boolean shift = player.isCrouching();
|
||||
if (shift) {
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null).ifPresent(fluidHandler -> {
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
fluidHandler.fill(network.extractFluid(stack, FluidType.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
@@ -32,7 +32,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -64,11 +64,11 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
super.setPlacedBy(level, pos, state, entity, stack);
|
||||
|
||||
if (!level.isClientSide) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromStack -> {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyFromStack -> {
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
|
||||
if (blockEntity != null) {
|
||||
blockEntity.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromBlockEntity -> energyFromBlockEntity.receiveEnergy(energyFromStack.getEnergyStored(), false));
|
||||
blockEntity.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyFromBlockEntity -> energyFromBlockEntity.receiveEnergy(energyFromStack.getEnergyStored(), false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -22,9 +22,11 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -32,6 +34,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNodeProxy<RootNetworkNode>, IRedstoneConfigurable {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ControllerBlockEntity> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ControllerBlockEntity> ENERGY_USAGE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNetwork().getEnergyUsage());
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ControllerBlockEntity> ENERGY_STORED = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNetwork().getEnergyStorage().getEnergyStored());
|
||||
@@ -94,10 +98,14 @@ public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNo
|
||||
return dummyNetwork;
|
||||
}
|
||||
|
||||
INetwork network = API.instance().getNetworkManager((ServerLevel) level).getNetwork(worldPosition);
|
||||
INetworkManager manager = API.instance().getNetworkManager((ServerLevel) level);
|
||||
INetwork network = manager.getNetwork(worldPosition);
|
||||
|
||||
if (network == null) {
|
||||
throw new IllegalStateException("No network present at " + worldPosition);
|
||||
LOGGER.warn("Expected a network @ {} but couldn't find it, creating a new one...", worldPosition);
|
||||
network = new Network(level, worldPosition, type);
|
||||
manager.setNetwork(worldPosition, network);
|
||||
manager.markForSaving();
|
||||
}
|
||||
|
||||
return network;
|
||||
@@ -158,7 +166,7 @@ public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNo
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
if (cap == ForgeCapabilities.ENERGY) {
|
||||
return energyProxyCap.cast();
|
||||
}
|
||||
|
||||
|
@@ -11,8 +11,8 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -43,7 +43,7 @@ public class CrafterBlockEntity extends NetworkNodeBlockEntity<CrafterNetworkNod
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && direction != null && !direction.equals(this.getNode().getDirection())) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER && direction != null && !direction.equals(this.getNode().getDirection())) {
|
||||
return patternsCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -21,8 +21,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -140,7 +140,7 @@ public class DiskDriveBlockEntity extends NetworkNodeBlockEntity<DiskDriveNetwor
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER) {
|
||||
return diskCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -21,8 +21,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -98,7 +98,7 @@ public class DiskManipulatorBlockEntity extends NetworkNodeBlockEntity<DiskManip
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER) {
|
||||
return diskCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -10,11 +10,10 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -40,9 +39,9 @@ public class FluidInterfaceBlockEntity extends NetworkNodeBlockEntity<FluidInter
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER) {
|
||||
return inCapability.cast();
|
||||
} else if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
} else if (cap == ForgeCapabilities.FLUID_HANDLER) {
|
||||
return tankCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -34,7 +35,7 @@ public class InterfaceBlockEntity extends NetworkNodeBlockEntity<InterfaceNetwor
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER) {
|
||||
return itemsCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -62,16 +62,26 @@ public abstract class NetworkNodeBlockEntity<N extends NetworkNode> extends Base
|
||||
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager((ServerLevel) level);
|
||||
|
||||
INetworkNode node = manager.getNode(worldPosition);
|
||||
try {
|
||||
INetworkNode node = manager.getNode(worldPosition);
|
||||
|
||||
if (node == null) {
|
||||
LOGGER.warn("Expected a node @ {} but couldn't find it, creating a new one...", worldPosition);
|
||||
node = createNode(level, worldPosition);
|
||||
manager.setNode(worldPosition, node);
|
||||
manager.markForSaving();
|
||||
if (node == null) {
|
||||
LOGGER.warn("Expected a node @ {} but couldn't find it, creating a new one...", worldPosition);
|
||||
node = createAndSetNode(manager);
|
||||
}
|
||||
|
||||
return (N) node;
|
||||
} catch (ClassCastException e) {
|
||||
LOGGER.warn("Node @ {} got desynced with it's block entity container, recreating", worldPosition, e);
|
||||
return (N) createAndSetNode(manager);
|
||||
}
|
||||
}
|
||||
|
||||
return (N) node;
|
||||
private INetworkNode createAndSetNode(INetworkNodeManager manager) {
|
||||
INetworkNode node = createNode(level, worldPosition);
|
||||
manager.setNode(worldPosition, node);
|
||||
manager.markForSaving();
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,6 +12,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -51,7 +52,7 @@ public class NetworkTransmitterBlockEntity extends NetworkNodeBlockEntity<Networ
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER) {
|
||||
return networkCardCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -131,7 +132,7 @@ public class GridBlockEntity extends NetworkNodeBlockEntity<GridNetworkNode> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && type == GridType.PATTERN) {
|
||||
if (cap == ForgeCapabilities.ITEM_HANDLER && type == GridType.PATTERN) {
|
||||
return diskCapability.cast();
|
||||
}
|
||||
|
||||
|
@@ -42,14 +42,13 @@ import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.inventory.ResultContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
@@ -132,7 +131,9 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
|
||||
public void onOpen() {
|
||||
drainEnergy(RS.SERVER_CONFIG.getPortableGrid().getOpenUsage());
|
||||
} private final BaseItemHandler disk = new BaseItemHandler(1)
|
||||
}
|
||||
|
||||
private final BaseItemHandler disk = new BaseItemHandler(1)
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(((handler, slot, reading) -> {
|
||||
if (player != null && !player.level.isClientSide) {
|
||||
@@ -189,7 +190,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null)
|
||||
stack.getCapability(ForgeCapabilities.ENERGY, null)
|
||||
.ifPresent(energyStorage -> energyStorage.extractEnergy(energy, false));
|
||||
}
|
||||
}
|
||||
@@ -197,7 +198,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
@Override
|
||||
public int getEnergy() {
|
||||
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() && ((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE) {
|
||||
return stack.getCapability(CapabilityEnergy.ENERGY, null)
|
||||
return stack.getCapability(ForgeCapabilities.ENERGY, null)
|
||||
.map(IEnergyStorage::getEnergyStored)
|
||||
.orElse(RS.SERVER_CONFIG.getPortableGrid().getCapacity());
|
||||
}
|
||||
@@ -449,7 +450,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
public boolean isGridActive() {
|
||||
if (RS.SERVER_CONFIG.getPortableGrid().getUseEnergy() &&
|
||||
((PortableGridBlockItem) stack.getItem()).getType() != PortableGridBlockItem.Type.CREATIVE &&
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).orElse(null).getEnergyStored() <= RS.SERVER_CONFIG.getPortableGrid().getOpenUsage()) {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).orElse(null).getEnergyStored() <= RS.SERVER_CONFIG.getPortableGrid().getOpenUsage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -510,6 +511,4 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -65,8 +65,8 @@ import net.minecraft.world.inventory.ResultContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -244,7 +244,7 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
this.tabPage = WirelessGridItem.getTabPage(stack);
|
||||
this.size = WirelessGridItem.getSize(stack);
|
||||
|
||||
this.energyStorage = createEnergyStorage(stack.getCapability(CapabilityEnergy.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0));
|
||||
this.energyStorage = createEnergyStorage(stack.getCapability(ForgeCapabilities.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0));
|
||||
|
||||
if (stack.hasTag()) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
@@ -291,7 +291,7 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
stack.getTag().put(NBT_ENCHANTMENTS, enchants);
|
||||
}
|
||||
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(itemEnergy -> itemEnergy.receiveEnergy(energyStorage.getEnergyStored(), false));
|
||||
stack.getCapability(ForgeCapabilities.ENERGY, null).ifPresent(itemEnergy -> itemEnergy.receiveEnergy(energyStorage.getEnergyStored(), false));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
StackUtils.writeItems(filter, i, stack.getTag());
|
||||
@@ -748,7 +748,7 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
if (cap == ForgeCapabilities.ENERGY) {
|
||||
return energyStorageCap.cast();
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,9 @@ import com.refinedmods.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||
import com.refinedmods.refinedstorage.api.storage.cache.IStorageCache;
|
||||
import com.refinedmods.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.BaseBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.IPortableGrid;
|
||||
import com.refinedmods.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.refinedmods.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import com.refinedmods.refinedstorage.container.slot.grid.CraftingGridSlot;
|
||||
@@ -17,9 +20,6 @@ import com.refinedmods.refinedstorage.container.slot.legacy.LegacyBaseSlot;
|
||||
import com.refinedmods.refinedstorage.container.slot.legacy.LegacyDisabledSlot;
|
||||
import com.refinedmods.refinedstorage.container.slot.legacy.LegacyFilterSlot;
|
||||
import com.refinedmods.refinedstorage.screen.IScreenInfoProvider;
|
||||
import com.refinedmods.refinedstorage.blockentity.BaseBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.IPortableGrid;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@@ -8,8 +8,6 @@ import com.refinedmods.refinedstorage.network.grid.GridCraftingPreviewRequestMes
|
||||
import com.refinedmods.refinedstorage.network.grid.GridProcessingTransferMessage;
|
||||
import com.refinedmods.refinedstorage.network.grid.GridTransferMessage;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.stack.IGridStack;
|
||||
import com.refinedmods.refinedstorage.screen.grid.stack.ItemGridStack;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
|
||||
@@ -20,14 +18,16 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridContainerMenu, Object> {
|
||||
@@ -58,26 +58,38 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
|
||||
@Override
|
||||
public @Nullable IRecipeTransferError transferRecipe(GridContainerMenu container, Object recipe, IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) {
|
||||
if (!(container.getScreenInfoProvider() instanceof GridScreen)) {
|
||||
if (!(container.getScreenInfoProvider() instanceof GridScreen gridScreen)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//When JEI is open the screen no longer ticks and doesn't run Actions. However, we do still want to run the actions that update the grid to keep the stored items up to date
|
||||
gridScreen.runActions();
|
||||
|
||||
Ingredient.IngredientList ingredientList = new Ingredient.IngredientList();
|
||||
for (IRecipeSlotView slotView : recipeSlots.getSlotViews(RecipeIngredientRole.INPUT)) {
|
||||
Optional<ItemStack> firstStack = slotView.getIngredients(VanillaTypes.ITEM_STACK).findAny();
|
||||
ingredientList.add(new Ingredient(slotView, firstStack.map(ItemStack::getCount).orElse(0)));
|
||||
}
|
||||
|
||||
IngredientTracker tracker = IngredientTracker.getTracker(container);
|
||||
tracker.updateAvailability(ingredientList, container, player);
|
||||
|
||||
GridType type = container.getGrid().getGridType();
|
||||
|
||||
if (type == GridType.CRAFTING) {
|
||||
return transferRecipeForCraftingGrid(container, recipe, recipeSlots, player, doTransfer);
|
||||
return transferRecipeForCraftingGrid(container, recipe, recipeSlots, player, doTransfer, ingredientList);
|
||||
} else if (type == GridType.PATTERN) {
|
||||
return transferRecipeForPatternGrid(container, recipe, recipeSlots, player, doTransfer);
|
||||
return transferRecipeForPatternGrid(container, recipe, recipeSlots, player, doTransfer, ingredientList);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private RecipeTransferCraftingGridError transferRecipeForCraftingGrid(GridContainerMenu container, Object recipe, IRecipeSlotsView recipeLayout, Player player, boolean doTransfer) {
|
||||
IngredientTracker tracker = createTracker(container, recipeLayout, player, doTransfer);
|
||||
private RecipeTransferCraftingGridError transferRecipeForCraftingGrid(GridContainerMenu container, Object recipe, IRecipeSlotsView recipeLayout, Player player, boolean doTransfer, Ingredient.IngredientList ingredientList) {
|
||||
|
||||
if (doTransfer) {
|
||||
if (tracker.hasMissingButAutocraftingAvailable() && Screen.hasControlDown()) {
|
||||
tracker.createCraftingRequests().forEach((id, count) -> RS.NETWORK_HANDLER.sendToServer(
|
||||
if (ingredientList.hasMissingButAutocraftingAvailable() && Screen.hasControlDown()) {
|
||||
ingredientList.createCraftingRequests().forEach((id, count) -> RS.NETWORK_HANDLER.sendToServer(
|
||||
new GridCraftingPreviewRequestMessage(
|
||||
id,
|
||||
count,
|
||||
@@ -86,79 +98,38 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
)
|
||||
));
|
||||
} else {
|
||||
moveItems(container, recipe, recipeLayout, tracker);
|
||||
moveItems(container, recipe, recipeLayout, player);
|
||||
}
|
||||
} else {
|
||||
if (tracker.hasMissing()) {
|
||||
return new RecipeTransferCraftingGridError(tracker);
|
||||
if (ingredientList.hasMissing()) {
|
||||
return new RecipeTransferCraftingGridError(ingredientList);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IRecipeTransferError transferRecipeForPatternGrid(GridContainerMenu container, Object recipe, IRecipeSlotsView recipeLayout, Player player, boolean doTransfer) {
|
||||
IngredientTracker tracker = createTracker(container, recipeLayout, player, doTransfer);
|
||||
|
||||
private IRecipeTransferError transferRecipeForPatternGrid(GridContainerMenu container, Object recipe, IRecipeSlotsView recipeLayout, Player player, boolean doTransfer, Ingredient.IngredientList ingredientList) {
|
||||
if (doTransfer) {
|
||||
moveItems(container, recipe, recipeLayout, tracker);
|
||||
moveItems(container, recipe, recipeLayout, player);
|
||||
} else {
|
||||
if (tracker.isAutocraftingAvailable()) {
|
||||
return new RecipeTransferPatternGridError(tracker);
|
||||
if (ingredientList.isAutocraftingAvailable()) {
|
||||
return new RecipeTransferPatternGridError(ingredientList);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IngredientTracker createTracker(GridContainerMenu container, IRecipeSlotsView recipeLayout, Player player, boolean doTransfer) {
|
||||
IngredientTracker tracker = new IngredientTracker(recipeLayout, doTransfer);
|
||||
|
||||
// Using IGridView#getStacks will return a *filtered* list of items in the view,
|
||||
// which will cause problems - especially if the user uses JEI synchronised searching.
|
||||
// Instead, we will use IGridView#getAllStacks which provides an unordered view of all GridStacks.
|
||||
Collection<IGridStack> gridStacks = ((GridScreen) container.getScreenInfoProvider()).getView().getAllStacks();
|
||||
|
||||
// Check grid
|
||||
if (container.getGrid().isGridActive()) {
|
||||
for (IGridStack gridStack : gridStacks) {
|
||||
if (gridStack instanceof ItemGridStack) {
|
||||
tracker.addAvailableStack(((ItemGridStack) gridStack).getStack(), gridStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check inventory
|
||||
for (int inventorySlot = 0; inventorySlot < player.getInventory().getContainerSize(); inventorySlot++) {
|
||||
if (!player.getInventory().getItem(inventorySlot).isEmpty()) {
|
||||
tracker.addAvailableStack(player.getInventory().getItem(inventorySlot), null);
|
||||
}
|
||||
}
|
||||
|
||||
// Check grid crafting slots
|
||||
if (container.getGrid().getGridType().equals(GridType.CRAFTING)) {
|
||||
CraftingContainer craftingMatrix = container.getGrid().getCraftingMatrix();
|
||||
if (craftingMatrix != null) {
|
||||
for (int matrixSlot = 0; matrixSlot < craftingMatrix.getContainerSize(); matrixSlot++) {
|
||||
if (!craftingMatrix.getItem(matrixSlot).isEmpty()) {
|
||||
tracker.addAvailableStack(craftingMatrix.getItem(matrixSlot), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
public boolean hasTransferredRecently() {
|
||||
return System.currentTimeMillis() - lastTransferTimeMs <= TRANSFER_SCROLLBAR_DELAY_MS;
|
||||
}
|
||||
|
||||
private void moveItems(GridContainerMenu gridContainer, Object recipe, IRecipeSlotsView recipeLayout, IngredientTracker tracker) {
|
||||
private void moveItems(GridContainerMenu gridContainer, Object recipe, IRecipeSlotsView recipeLayout, Player player) {
|
||||
this.lastTransferTimeMs = System.currentTimeMillis();
|
||||
|
||||
if (gridContainer.getGrid().getGridType() == GridType.PATTERN && !(recipe instanceof CraftingRecipe)) {
|
||||
moveForProcessing(recipeLayout, tracker);
|
||||
moveForProcessing(recipeLayout, gridContainer, player);
|
||||
} else {
|
||||
move(recipeLayout);
|
||||
}
|
||||
@@ -185,7 +156,7 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
RS.NETWORK_HANDLER.sendToServer(new GridTransferMessage(inputs));
|
||||
}
|
||||
|
||||
private void moveForProcessing(IRecipeSlotsView recipeLayout, IngredientTracker tracker) {
|
||||
private void moveForProcessing(IRecipeSlotsView recipeLayout, GridContainerMenu gridContainer, Player player) {
|
||||
List<ItemStack> inputs = new LinkedList<>();
|
||||
List<ItemStack> outputs = new LinkedList<>();
|
||||
|
||||
@@ -194,13 +165,13 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
|
||||
List<IRecipeSlotView> inputSlots = recipeLayout.getSlotViews(RecipeIngredientRole.INPUT);
|
||||
for (IRecipeSlotView view : inputSlots) {
|
||||
handleItemIngredient(inputs, view, tracker);
|
||||
handleItemIngredient(inputs, view, gridContainer, player);
|
||||
handleFluidIngredient(fluidInputs, view);
|
||||
}
|
||||
|
||||
List<IRecipeSlotView> outputSlots = recipeLayout.getSlotViews(RecipeIngredientRole.OUTPUT);
|
||||
for (IRecipeSlotView view : outputSlots) {
|
||||
handleItemIngredient(outputs, view, tracker);
|
||||
handleItemIngredient(outputs, view, gridContainer, player);
|
||||
handleFluidIngredient(fluidOutputs, view);
|
||||
}
|
||||
|
||||
@@ -213,9 +184,9 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
}
|
||||
}
|
||||
|
||||
private void handleItemIngredient(List<ItemStack> list, IRecipeSlotView slotView, IngredientTracker tracker) {
|
||||
private void handleItemIngredient(List<ItemStack> list, IRecipeSlotView slotView, GridContainerMenu gridContainer, Player player) {
|
||||
if (slotView != null && slotView.getIngredients(VanillaTypes.ITEM_STACK).findAny().isPresent()) {
|
||||
ItemStack stack = tracker.findBestMatch(slotView.getIngredients(VanillaTypes.ITEM_STACK).toList());
|
||||
ItemStack stack = IngredientTracker.getTracker(gridContainer).findBestMatch(gridContainer, player, slotView.getIngredients(VanillaTypes.ITEM_STACK).toList());
|
||||
|
||||
if (stack.isEmpty() && slotView.getDisplayedIngredient(VanillaTypes.ITEM_STACK).isPresent()) {
|
||||
stack = slotView.getDisplayedIngredient(VanillaTypes.ITEM_STACK).get();
|
||||
|
@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.integration.jei;
|
||||
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
class Ingredient {
|
||||
private final IRecipeSlotView slotView;
|
||||
@@ -16,7 +16,7 @@ class Ingredient {
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return getMissingAmount() == 0;
|
||||
return getMissingAmount() <= 0;
|
||||
}
|
||||
|
||||
public int getMissingAmount() {
|
||||
@@ -42,4 +42,36 @@ class Ingredient {
|
||||
public void fulfill(int amount) {
|
||||
fulfilled += amount;
|
||||
}
|
||||
|
||||
static class IngredientList {
|
||||
List<Ingredient> ingredients = new ArrayList<>();
|
||||
|
||||
void add(Ingredient ingredient) {
|
||||
ingredients.add(ingredient);
|
||||
}
|
||||
|
||||
public boolean hasMissing() {
|
||||
return ingredients.stream().anyMatch(ingredient -> !ingredient.isAvailable());
|
||||
}
|
||||
|
||||
public boolean hasMissingButAutocraftingAvailable() {
|
||||
return ingredients.stream().anyMatch(ingredient -> !ingredient.isAvailable() && ingredient.isCraftable());
|
||||
}
|
||||
|
||||
public boolean isAutocraftingAvailable() {
|
||||
return ingredients.stream().anyMatch(Ingredient::isCraftable);
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> createCraftingRequests() {
|
||||
Map<UUID, Integer> toRequest = new HashMap<>();
|
||||
|
||||
for (Ingredient ingredient : ingredients) {
|
||||
if (!ingredient.isAvailable() && ingredient.isCraftable()) {
|
||||
toRequest.merge(ingredient.getCraftStackId(), ingredient.getMissingAmount(), Integer::sum);
|
||||
}
|
||||
}
|
||||
|
||||
return toRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,124 +2,214 @@ package com.refinedmods.refinedstorage.integration.jei;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.GridType;
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.container.GridContainerMenu;
|
||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.stack.IGridStack;
|
||||
import com.refinedmods.refinedstorage.screen.grid.stack.ItemGridStack;
|
||||
import com.refinedmods.refinedstorage.screen.grid.view.IGridView;
|
||||
import com.refinedmods.refinedstorage.util.ItemStackKey;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class IngredientTracker {
|
||||
private final List<Ingredient> ingredients = new ArrayList<>();
|
||||
private final Map<ResourceLocation, Integer> storedItems = new HashMap<>();
|
||||
private boolean doTransfer;
|
||||
|
||||
public IngredientTracker(IRecipeSlotsView recipeLayout, boolean doTransfer) {
|
||||
for (IRecipeSlotView slotView : recipeLayout.getSlotViews(RecipeIngredientRole.INPUT)) {
|
||||
Optional<ItemStack> optionalItemStack = slotView.getIngredients(VanillaTypes.ITEM_STACK).findAny();
|
||||
private static IngredientTracker INSTANCE;
|
||||
|
||||
optionalItemStack.ifPresent(stack -> ingredients.add(new Ingredient(slotView, stack.getCount())));
|
||||
private final Map<ItemStackKey, Integer> storedItems = new HashMap<>();
|
||||
private final Map<ItemStackKey, Integer> patternItems = new HashMap<>();
|
||||
private final Map<ItemStackKey, UUID> craftableItems = new HashMap<>();
|
||||
|
||||
public static IngredientTracker getTracker(GridContainerMenu gridContainer) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new IngredientTracker(gridContainer);
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void invalidate() {
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public IngredientTracker(GridContainerMenu gridContainer) {
|
||||
|
||||
// Using IGridView#getStacks will return a *filtered* list of items in the view,
|
||||
// which will cause problems - especially if the user uses JEI synchronised searching.
|
||||
// Instead, we will use IGridView#getAllStacks which provides an unordered view of all GridStacks.
|
||||
IGridView view = ((GridScreen) gridContainer.getScreenInfoProvider()).getView();
|
||||
|
||||
//Existing stacks are synced by the fact that they are both referencing the same object. However, new stacks need to be added.
|
||||
view.addDeltaListener((iGridStack -> {
|
||||
if (iGridStack instanceof ItemGridStack stack) {
|
||||
if (stack.isCraftable()) {
|
||||
craftableItems.put(new ItemStackKey(stack.getStack()), stack.getId());
|
||||
} else {
|
||||
addStack(stack.getStack());
|
||||
}
|
||||
|
||||
}
|
||||
}));
|
||||
Collection<IGridStack> gridStacks = view.getAllStacks();
|
||||
|
||||
// Check grid
|
||||
if (gridContainer.getGrid().isGridActive()) {
|
||||
for (IGridStack gridStack : gridStacks) {
|
||||
if (gridStack instanceof ItemGridStack stackInGrid) {
|
||||
|
||||
// for craftables we should easily be able to take the hit from hashing the nbt
|
||||
if (stackInGrid.isCraftable()) {
|
||||
craftableItems.put(new ItemStackKey(stackInGrid.getStack()), gridStack.getId());
|
||||
} else { // for non-craftables we don't hash nbt to avoid the performance hit
|
||||
addStack(stackInGrid.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addStack(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (stack.getItem() instanceof ICraftingPatternProvider) {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(Minecraft.getInstance().level, stack);
|
||||
if (pattern.isValid()) {
|
||||
for (ItemStack outputStack : pattern.getOutputs()) {
|
||||
patternItems.merge(new ItemStackKey(outputStack), 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
storedItems.merge(new ItemStackKey(stack), stack.getCount(), Integer::sum);
|
||||
}
|
||||
|
||||
this.doTransfer = doTransfer;
|
||||
}
|
||||
|
||||
public Collection<Ingredient> getIngredients() {
|
||||
return ingredients;
|
||||
|
||||
public ItemStack findBestMatch(GridContainerMenu gridContainer, Player player, List<ItemStack> list) {
|
||||
ItemStack resultStack = ItemStack.EMPTY;
|
||||
int count = 0;
|
||||
|
||||
|
||||
for (ItemStack listStack : list) {
|
||||
|
||||
//check crafting matrix
|
||||
if (gridContainer.getGrid().getGridType().equals(GridType.CRAFTING)) {
|
||||
CraftingContainer craftingMatrix = gridContainer.getGrid().getCraftingMatrix();
|
||||
if (craftingMatrix != null) {
|
||||
for (int matrixSlot = 0; matrixSlot < craftingMatrix.getContainerSize(); matrixSlot++) {
|
||||
ItemStack stackInSlot = craftingMatrix.getItem(matrixSlot);
|
||||
if (API.instance().getComparer().isEqual(listStack, stackInSlot, IComparer.COMPARE_NBT)) {
|
||||
if (stackInSlot.getCount() > count) {
|
||||
count = stackInSlot.getCount();
|
||||
resultStack = stackInSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check inventory
|
||||
for (int inventorySlot = 0; inventorySlot < player.getInventory().getContainerSize(); inventorySlot++) {
|
||||
ItemStack stackInSlot = player.getInventory().getItem(inventorySlot);
|
||||
if (API.instance().getComparer().isEqual(listStack, stackInSlot, IComparer.COMPARE_NBT)) {
|
||||
if (stackInSlot.getCount() > count) {
|
||||
count = stackInSlot.getCount();
|
||||
resultStack = stackInSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check storage
|
||||
var stored = storedItems.get(new ItemStackKey(listStack));
|
||||
if (stored != null) {
|
||||
if (stored > count) {
|
||||
resultStack = listStack;
|
||||
count = stored;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If the item is not in storage check patterns autocrafting
|
||||
if (count == 0) {
|
||||
for (ItemStack itemStack : list) {
|
||||
ItemStackKey key = new ItemStackKey(itemStack);
|
||||
if (craftableItems.get(key) != null) {
|
||||
resultStack = itemStack;
|
||||
break;
|
||||
} else if (patternItems.get(key) != null) {
|
||||
resultStack = itemStack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultStack;
|
||||
}
|
||||
|
||||
public void addAvailableStack(ItemStack stack, @Nullable IGridStack gridStack) {
|
||||
int available = stack.getCount();
|
||||
if (doTransfer) {
|
||||
if (stack.getItem() instanceof ICraftingPatternProvider) {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(Minecraft.getInstance().level, stack);
|
||||
if (pattern.isValid()) {
|
||||
for (ItemStack outputStack : pattern.getOutputs()) {
|
||||
storedItems.merge(registryName(outputStack.getItem()), outputStack.getCount(), Integer::sum);
|
||||
public void updateAvailability(Ingredient.IngredientList ingredientList, GridContainerMenu gridContainer, Player player) {
|
||||
Map<Integer, Integer> usedMatrixStacks = new HashMap<>();
|
||||
Map<Integer, Integer> usedInventoryStacks = new HashMap<>();
|
||||
Map<ItemStackKey, Integer> usedStoredStacks = new HashMap<>();
|
||||
|
||||
//Gather available Stacks
|
||||
for (Ingredient ingredient : ingredientList.ingredients) {
|
||||
ingredient.getSlotView().getIngredients(VanillaTypes.ITEM_STACK).takeWhile(stack -> !ingredient.isAvailable()).forEach(stack -> {
|
||||
|
||||
ingredient.setCraftStackId(craftableItems.get(new ItemStackKey(stack)));
|
||||
// Check grid crafting slots
|
||||
if (gridContainer.getGrid().getGridType().equals(GridType.CRAFTING)) {
|
||||
CraftingContainer craftingMatrix = gridContainer.getGrid().getCraftingMatrix();
|
||||
if (craftingMatrix != null) {
|
||||
for (int matrixSlot = 0; matrixSlot < craftingMatrix.getContainerSize(); matrixSlot++) {
|
||||
if (checkStack(usedMatrixStacks, ingredient, stack, matrixSlot, craftingMatrix.getItem(matrixSlot))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
storedItems.merge(registryName(stack.getItem()), available, Integer::sum);
|
||||
}
|
||||
}
|
||||
|
||||
for (Ingredient ingredient : ingredients) {
|
||||
if (available == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<ItemStack> match = ingredient
|
||||
.getSlotView()
|
||||
.getIngredients(VanillaTypes.ITEM_STACK)
|
||||
.filter(s -> API.instance().getComparer().isEqual(stack, s, IComparer.COMPARE_NBT))
|
||||
.findFirst();
|
||||
|
||||
if (match.isPresent()) {
|
||||
// Craftables and non-craftables are 2 different gridstacks
|
||||
// As such we need to ignore craftable stacks as they are not actual items
|
||||
if (gridStack != null && gridStack.isCraftable()) {
|
||||
ingredient.setCraftStackId(gridStack.getId());
|
||||
} else if (!ingredient.isAvailable()) {
|
||||
int needed = ingredient.getMissingAmount();
|
||||
int used = Math.min(available, needed);
|
||||
ingredient.fulfill(used);
|
||||
available -= used;
|
||||
//read inventory
|
||||
for (int inventorySlot = 0; inventorySlot < player.getInventory().getContainerSize(); inventorySlot++) {
|
||||
if (checkStack(usedInventoryStacks, ingredient, stack, inventorySlot, player.getInventory().getItem(inventorySlot))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check Stored Stacks
|
||||
ItemStackKey key = new ItemStackKey(stack);
|
||||
Integer stored = storedItems.get(key);
|
||||
if (stored != null) {
|
||||
Integer used = usedStoredStacks.get(key);
|
||||
int amount = Math.min(ingredient.getMissingAmount(), used == null ? stored : stored - used);
|
||||
if (amount > 0) {
|
||||
ingredient.fulfill(amount);
|
||||
usedStoredStacks.put(key, used == null ? amount : used + amount);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMissing() {
|
||||
return ingredients.stream().anyMatch(ingredient -> !ingredient.isAvailable());
|
||||
}
|
||||
|
||||
public boolean hasMissingButAutocraftingAvailable() {
|
||||
return ingredients.stream().anyMatch(ingredient -> !ingredient.isAvailable() && ingredient.isCraftable());
|
||||
}
|
||||
|
||||
public boolean isAutocraftingAvailable() {
|
||||
return ingredients.stream().anyMatch(Ingredient::isCraftable);
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> createCraftingRequests() {
|
||||
Map<UUID, Integer> toRequest = new HashMap<>();
|
||||
|
||||
for (Ingredient ingredient : ingredients) {
|
||||
if (!ingredient.isAvailable() && ingredient.isCraftable()) {
|
||||
toRequest.merge(ingredient.getCraftStackId(), ingredient.getMissingAmount(), Integer::sum);
|
||||
private boolean checkStack(Map<Integer, Integer> usedMatrixStacks, Ingredient ingredient, ItemStack stack, int slot, ItemStack stackInSlot) {
|
||||
if (API.instance().getComparer().isEqual(stack, stackInSlot, IComparer.COMPARE_NBT)) {
|
||||
Integer used = usedMatrixStacks.get(slot);
|
||||
int amount = Math.min(ingredient.getMissingAmount(), used == null ? stackInSlot.getCount() : stackInSlot.getCount() - used);
|
||||
if (amount > 0) {
|
||||
ingredient.fulfill(amount);
|
||||
usedMatrixStacks.put(slot, amount);
|
||||
}
|
||||
return ingredient.isAvailable();
|
||||
}
|
||||
|
||||
return toRequest;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack findBestMatch(List<ItemStack> list) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
int count = 0;
|
||||
|
||||
for (ItemStack itemStack : list) {
|
||||
Integer stored = storedItems.get(registryName(itemStack.getItem()));
|
||||
if (stored != null && stored > count) {
|
||||
stack = itemStack;
|
||||
count = stored;
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
private ResourceLocation registryName(final Item item) {
|
||||
return ForgeRegistries.ITEMS.getKey(item);
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -17,10 +16,11 @@ public class RecipeTransferCraftingGridError implements IRecipeTransferError {
|
||||
protected static final Color AUTOCRAFTING_HIGHLIGHT_COLOR = new Color(0.0f, 0.0f, 1.0f, 0.4f);
|
||||
private static final Color MISSING_HIGHLIGHT_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.4f);
|
||||
private static final boolean HOST_OS_IS_MACOS = System.getProperty("os.name").equals("Mac OS X");
|
||||
protected final IngredientTracker tracker;
|
||||
protected final Ingredient.IngredientList ingredientList;
|
||||
|
||||
public RecipeTransferCraftingGridError(IngredientTracker tracker) {
|
||||
this.tracker = tracker;
|
||||
|
||||
public RecipeTransferCraftingGridError(Ingredient.IngredientList ingredientList) {
|
||||
this.ingredientList = ingredientList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,6 +28,16 @@ public class RecipeTransferCraftingGridError implements IRecipeTransferError {
|
||||
return Type.COSMETIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonHighlightColor() {
|
||||
if (ingredientList.hasMissingButAutocraftingAvailable()) {
|
||||
return AUTOCRAFTING_HIGHLIGHT_COLOR.getRGB();
|
||||
} else if (ingredientList.hasMissing()) {
|
||||
return MISSING_HIGHLIGHT_COLOR.getRGB();
|
||||
}
|
||||
return IRecipeTransferError.super.getButtonHighlightColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(PoseStack poseStack, int mouseX, int mouseY, IRecipeSlotsView recipeSlotsView, int recipeX, int recipeY) {
|
||||
poseStack.translate(recipeX, recipeY, 0);
|
||||
@@ -44,7 +54,7 @@ public class RecipeTransferCraftingGridError implements IRecipeTransferError {
|
||||
boolean craftMessage = false;
|
||||
boolean missingMessage = false;
|
||||
|
||||
for (Ingredient ingredient : tracker.getIngredients()) {
|
||||
for (Ingredient ingredient : ingredientList.ingredients) {
|
||||
if (!ingredient.isAvailable()) {
|
||||
if (ingredient.isCraftable()) {
|
||||
ingredient.getSlotView().drawHighlight(stack, AUTOCRAFTING_HIGHLIGHT_COLOR.getRGB());
|
||||
|
@@ -4,13 +4,12 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeTransferPatternGridError extends RecipeTransferCraftingGridError {
|
||||
public RecipeTransferPatternGridError(IngredientTracker tracker) {
|
||||
super(tracker);
|
||||
public RecipeTransferPatternGridError(Ingredient.IngredientList ingredients) {
|
||||
super(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,7 +19,7 @@ public class RecipeTransferPatternGridError extends RecipeTransferCraftingGridEr
|
||||
|
||||
boolean craftMessage = false;
|
||||
|
||||
for (Ingredient ingredient : tracker.getIngredients()) {
|
||||
for (Ingredient ingredient : ingredientList.ingredients) {
|
||||
if (ingredient.isCraftable()) {
|
||||
ingredient.getSlotView().drawHighlight(stack, AUTOCRAFTING_HIGHLIGHT_COLOR.getRGB());
|
||||
craftMessage = true;
|
||||
|
@@ -4,14 +4,13 @@ import com.refinedmods.refinedstorage.item.capabilityprovider.EnergyCapabilityPr
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -41,7 +40,7 @@ public abstract class EnergyItem extends Item {
|
||||
|
||||
@Override
|
||||
public int getBarWidth(ItemStack stack) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY).orElse(null);
|
||||
if (energy == null) {
|
||||
return 0;
|
||||
}
|
||||
@@ -51,7 +50,7 @@ public abstract class EnergyItem extends Item {
|
||||
|
||||
@Override
|
||||
public int getBarColor(ItemStack stack) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
|
||||
if (energy == null) {
|
||||
return super.getBarColor(stack);
|
||||
}
|
||||
@@ -63,7 +62,7 @@ public abstract class EnergyItem extends Item {
|
||||
super.appendHoverText(stack, level, tooltip, flag);
|
||||
|
||||
if (!creative) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null)
|
||||
stack.getCapability(ForgeCapabilities.ENERGY, null)
|
||||
.ifPresent(energy -> tooltip.add(Component.translatable("misc.refinedstorage.energy_stored", energy.getEnergyStored(), energy.getMaxEnergyStored()).setStyle(Styles.GRAY)));
|
||||
}
|
||||
}
|
||||
|
@@ -5,14 +5,13 @@ import com.refinedmods.refinedstorage.item.capabilityprovider.EnergyCapabilityPr
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -42,7 +41,7 @@ public abstract class EnergyBlockItem extends BaseBlockItem {
|
||||
|
||||
@Override
|
||||
public int getBarWidth(ItemStack stack) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY).orElse(null);
|
||||
if (energy == null) {
|
||||
return 0;
|
||||
}
|
||||
@@ -52,7 +51,7 @@ public abstract class EnergyBlockItem extends BaseBlockItem {
|
||||
|
||||
@Override
|
||||
public int getBarColor(ItemStack stack) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
|
||||
if (energy == null) {
|
||||
return super.getBarColor(stack);
|
||||
}
|
||||
@@ -64,7 +63,7 @@ public abstract class EnergyBlockItem extends BaseBlockItem {
|
||||
super.appendHoverText(stack, level, tooltip, flag);
|
||||
|
||||
if (!creative) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(energy -> tooltip.add(Component.translatable("misc.refinedstorage.energy_stored", energy.getEnergyStored(), energy.getMaxEnergyStored()).setStyle(Styles.GRAY)));
|
||||
stack.getCapability(ForgeCapabilities.ENERGY, null).ifPresent(energy -> tooltip.add(Component.translatable("misc.refinedstorage.energy_stored", energy.getEnergyStored(), energy.getMaxEnergyStored()).setStyle(Styles.GRAY)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ import com.refinedmods.refinedstorage.energy.ItemEnergyStorage;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -22,7 +22,7 @@ public class EnergyCapabilityProvider implements ICapabilityProvider {
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction dire) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
if (cap == ForgeCapabilities.ENERGY) {
|
||||
return capability.cast();
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.item.ItemPropertyFunction;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -14,7 +14,7 @@ import javax.annotation.Nullable;
|
||||
public class ControllerItemPropertyGetter implements ItemPropertyFunction {
|
||||
@Override
|
||||
public float call(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int p) {
|
||||
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY).orElse(null);
|
||||
IEnergyStorage storage = stack.getCapability(ForgeCapabilities.ENERGY).orElse(null);
|
||||
if (storage != null) {
|
||||
return Network.getEnergyType(storage.getEnergyStored(), storage.getMaxEnergyStored()).ordinal();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunct
|
||||
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
|
||||
public class ControllerLootFunction extends LootItemConditionalFunction {
|
||||
protected ControllerLootFunction(LootItemCondition[] conditions) {
|
||||
@@ -30,7 +30,7 @@ public class ControllerLootFunction extends LootItemConditionalFunction {
|
||||
if (blockEntity instanceof ControllerBlockEntity) {
|
||||
INetwork network = ((ControllerBlockEntity) blockEntity).getRemovedNetwork() == null ? ((ControllerBlockEntity) blockEntity).getNetwork() : ((ControllerBlockEntity) blockEntity).getRemovedNetwork();
|
||||
|
||||
itemStack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energy -> energy.receiveEnergy(network.getEnergyStorage().getEnergyStored(), false));
|
||||
itemStack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energy -> energy.receiveEnergy(network.getEnergyStorage().getEnergyStored(), false));
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
|
@@ -73,7 +73,7 @@ public abstract class BaseScreen<T extends AbstractContainerMenu> extends Abstra
|
||||
executeLater(AbstractContainerScreen.class, callback);
|
||||
}
|
||||
|
||||
private void runActions() {
|
||||
public void runActions() {
|
||||
runActions(getClass());
|
||||
runActions(AbstractContainerScreen.class);
|
||||
}
|
||||
|
@@ -10,6 +10,12 @@ import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.apiimpl.render.ElementDrawers;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkNodeBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.IPortableGrid;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.PortableGridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.container.GridContainerMenu;
|
||||
import com.refinedmods.refinedstorage.network.grid.*;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
@@ -24,12 +30,6 @@ import com.refinedmods.refinedstorage.screen.widget.ScrollbarWidget;
|
||||
import com.refinedmods.refinedstorage.screen.widget.SearchWidget;
|
||||
import com.refinedmods.refinedstorage.screen.widget.TabListWidget;
|
||||
import com.refinedmods.refinedstorage.screen.widget.sidebutton.*;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkNodeBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.IPortableGrid;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.PortableGridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import com.refinedmods.refinedstorage.util.TimeUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -658,6 +657,7 @@ public class GridScreen extends BaseScreen<GridContainerMenu> implements IScreen
|
||||
if (!RS.CLIENT_CONFIG.getGrid().getRememberSearchQuery()) {
|
||||
searchQuery = "";
|
||||
}
|
||||
getView().removed();
|
||||
}
|
||||
|
||||
public SearchWidget getSearchField() {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.screen.grid.view;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.integration.jei.IngredientTracker;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.filtering.GridFilterParser;
|
||||
import com.refinedmods.refinedstorage.screen.grid.sorting.IGridSorter;
|
||||
@@ -9,6 +10,7 @@ import com.refinedmods.refinedstorage.screen.grid.stack.IGridStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -22,6 +24,8 @@ public class GridViewImpl implements IGridView {
|
||||
private boolean active = false;
|
||||
private List<IGridStack> stacks = new ArrayList<>();
|
||||
|
||||
private List<Consumer<IGridStack>> deltaListeners = new ArrayList<>();
|
||||
|
||||
public GridViewImpl(GridScreen screen, IGridSorter defaultSorter, List<IGridSorter> sorters) {
|
||||
this.screen = screen;
|
||||
this.defaultSorter = defaultSorter;
|
||||
@@ -73,6 +77,17 @@ public class GridViewImpl implements IGridView {
|
||||
this.screen.updateScrollbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeltaListener(Consumer<IGridStack> listener) {
|
||||
deltaListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
deltaListeners.clear();
|
||||
IngredientTracker.invalidate();
|
||||
}
|
||||
|
||||
private Comparator<IGridStack> getActiveSort() {
|
||||
IGrid grid = screen.getGrid();
|
||||
SortingDirection sortingDirection = grid.getSortingDirection() == IGrid.SORTING_DIRECTION_DESCENDING ? SortingDirection.DESCENDING : SortingDirection.ASCENDING;
|
||||
@@ -153,6 +168,9 @@ public class GridViewImpl implements IGridView {
|
||||
if (craftingStack != null && shouldSort && activeFilters.test(existing)) {
|
||||
stacks.remove(craftingStack);
|
||||
}
|
||||
|
||||
deltaListeners.forEach(consumer -> consumer.accept(stack));
|
||||
|
||||
} else {
|
||||
if (shouldSort) {
|
||||
stacks.remove(existing);
|
||||
|
@@ -6,6 +6,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IGridView {
|
||||
List<IGridStack> getStacks();
|
||||
@@ -24,4 +25,8 @@ public interface IGridView {
|
||||
boolean canCraft();
|
||||
|
||||
void sort();
|
||||
|
||||
void addDeltaListener(Consumer<IGridStack> listener);
|
||||
|
||||
void removed();
|
||||
}
|
||||
|
@@ -17,11 +17,10 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
@@ -47,7 +46,7 @@ public final class LevelUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
IItemHandler handler = blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).orElse(null);
|
||||
IItemHandler handler = blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, side).orElse(null);
|
||||
if (handler == null) {
|
||||
if (side != null && blockEntity instanceof WorldlyContainer) {
|
||||
handler = new SidedInvWrapper((WorldlyContainer) blockEntity, side);
|
||||
@@ -61,7 +60,7 @@ public final class LevelUtils {
|
||||
|
||||
public static IFluidHandler getFluidHandler(@Nullable BlockEntity blockEntity, Direction side) {
|
||||
if (blockEntity != null) {
|
||||
return blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side).orElse(null);
|
||||
return blockEntity.getCapability(ForgeCapabilities.FLUID_HANDLER, side).orElse(null);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -18,9 +18,9 @@ import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -296,7 +296,7 @@ public final class StackUtils {
|
||||
stack = ItemHandlerHelper.copyStackWithSize(stack, 1);
|
||||
}
|
||||
|
||||
IFluidHandlerItem handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).orElse(null);
|
||||
IFluidHandlerItem handler = stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null).orElse(null);
|
||||
if (handler != null) {
|
||||
FluidStack result = handler.drain(FluidType.BUCKET_VOLUME, simulate ? IFluidHandler.FluidAction.SIMULATE : IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"refinedstorage:silicon"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user