Porting to 1.18.1

This commit is contained in:
raoulvdberge
2021-12-12 18:08:33 +01:00
parent 8eab8ffecc
commit 293b1a2227
553 changed files with 7289 additions and 8010 deletions

View File

@@ -26,6 +26,7 @@ repositories {
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
version = '1.10.0' version = '1.10.0'
def env = System.getenv() def env = System.getenv()
@@ -35,10 +36,14 @@ if (env.BUILD_NUMBER) {
group = 'com.refinedmods' group = 'com.refinedmods'
archivesBaseName = 'refinedstorage' archivesBaseName = 'refinedstorage'
java.toolchain.languageVersion = JavaLanguageVersion.of(8) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "999"
}
minecraft { minecraft {
mappings channel: 'official', version: '1.16.5' mappings channel: 'official', version: '1.18.1'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs { runs {
@@ -53,12 +58,6 @@ minecraft {
} }
} }
intellijClient {
parent runs.client
ideaModule "${project.name}.main"
environment 'MOD_CLASSES', "${project.file("out/production/resources").canonicalPath};${project.file("out/production/classes").canonicalPath}"
}
server { server {
workingDirectory project.file('run') workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
@@ -96,19 +95,7 @@ processResources {
} }
dependencies { dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.1.31' minecraft 'net.minecraftforge:forge:1.18.1-39.0.0'
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.106:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.106")
compileOnly fg.deobf('curse.maven:mouse-tweaks-60089:3202662')
compileOnly fg.deobf('curse.maven:crafting-tweaks-233071:3330406')
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.2")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.2:api")
/*minecraft 'net.minecraftforge:forge:1.18.1-39.0.0'
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41:api") compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41") runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41")
@@ -118,11 +105,7 @@ dependencies {
compileOnly fg.deobf('curse.maven:crafting-tweaks-233071:3545611') compileOnly fg.deobf('curse.maven:crafting-tweaks-233071:3545611')
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4") runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4:api")*/ compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4:api")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.6.2')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2')
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.16.1'
} }
jar { jar {

View File

@@ -10,10 +10,10 @@ import com.refinedmods.refinedstorage.network.NetworkHandler;
import com.refinedmods.refinedstorage.setup.ClientSetup; import com.refinedmods.refinedstorage.setup.ClientSetup;
import com.refinedmods.refinedstorage.setup.CommonSetup; import com.refinedmods.refinedstorage.setup.CommonSetup;
import com.refinedmods.refinedstorage.setup.ServerSetup; import com.refinedmods.refinedstorage.setup.ServerSetup;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.world.inventory.MenuType;
import net.minecraft.item.ItemGroup; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@@ -28,7 +28,7 @@ public final class RS {
public static final String NAME = "Refined Storage"; public static final String NAME = "Refined Storage";
public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler(); public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler();
public static final ItemGroup MAIN_GROUP = new MainItemGroup(); public static final CreativeModeTab MAIN_GROUP = new MainItemGroup();
public static final ServerConfig SERVER_CONFIG = new ServerConfig(); public static final ServerConfig SERVER_CONFIG = new ServerConfig();
public static final ClientConfig CLIENT_CONFIG = new ClientConfig(); public static final ClientConfig CLIENT_CONFIG = new ClientConfig();
@@ -46,9 +46,10 @@ public final class RS {
RSLootFunctions.register(); RSLootFunctions.register();
FMLJavaModLoadingContext.get().getModEventBus().addListener(commonSetup::onCommonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(commonSetup::onCommonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(TileEntityType.class, commonSetup::onRegisterTiles); FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(BlockEntityType.class, commonSetup::onRegisterTiles);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(IRecipeSerializer.class, commonSetup::onRegisterRecipeSerializers); FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(RecipeSerializer.class, commonSetup::onRegisterRecipeSerializers);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ContainerType.class, commonSetup::onRegisterContainers); FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(MenuType.class, commonSetup::onRegisterContainers);
FMLJavaModLoadingContext.get().getModEventBus().addListener(commonSetup::onRegisterCapabilities);
FMLJavaModLoadingContext.get().getModEventBus().register(new DataGenerators()); FMLJavaModLoadingContext.get().getModEventBus().register(new DataGenerators());
FMLJavaModLoadingContext.get().getModEventBus().register(new CuriosIntegration()); FMLJavaModLoadingContext.get().getModEventBus().register(new CuriosIntegration());

View File

@@ -7,11 +7,11 @@ import com.refinedmods.refinedstorage.apiimpl.storage.ItemStorageType;
import com.refinedmods.refinedstorage.block.*; import com.refinedmods.refinedstorage.block.*;
import com.refinedmods.refinedstorage.item.blockitem.PortableGridBlockItem; import com.refinedmods.refinedstorage.item.blockitem.PortableGridBlockItem;
import com.refinedmods.refinedstorage.util.ColorMap; import com.refinedmods.refinedstorage.util.ColorMap;
import net.minecraft.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
@@ -19,13 +19,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public final class RSBlocks { public final class RSBlocks {
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, RS.ID);
private static final String GRID_SUFFIX = "_grid";
public static final RegistryObject<ImporterBlock> IMPORTER; public static final RegistryObject<ImporterBlock> IMPORTER;
public static final RegistryObject<ExporterBlock> EXPORTER; public static final RegistryObject<ExporterBlock> EXPORTER;
public static final RegistryObject<QuartzEnrichedIronBlock> QUARTZ_ENRICHED_IRON; public static final RegistryObject<QuartzEnrichedIronBlock> QUARTZ_ENRICHED_IRON;
public static final RegistryObject<MachineCasingBlock> MACHINE_CASING; public static final RegistryObject<MachineCasingBlock> MACHINE_CASING;
public static final RegistryObject<CableBlock> CABLE; public static final RegistryObject<CableBlock> CABLE;
@@ -40,7 +35,8 @@ public final class RSBlocks {
public static final RegistryObject<DestructorBlock> DESTRUCTOR; public static final RegistryObject<DestructorBlock> DESTRUCTOR;
public static final RegistryObject<PortableGridBlock> PORTABLE_GRID; public static final RegistryObject<PortableGridBlock> PORTABLE_GRID;
public static final RegistryObject<PortableGridBlock> CREATIVE_PORTABLE_GRID; public static final RegistryObject<PortableGridBlock> CREATIVE_PORTABLE_GRID;
public static final List<RegistryObject<? extends Block>> COLORED_BLOCKS = new ArrayList<>();
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, RS.ID);
public static final ColorMap<CrafterBlock> CRAFTER = new ColorMap<>(BLOCKS); public static final ColorMap<CrafterBlock> CRAFTER = new ColorMap<>(BLOCKS);
public static final ColorMap<RelayBlock> RELAY = new ColorMap<>(BLOCKS); public static final ColorMap<RelayBlock> RELAY = new ColorMap<>(BLOCKS);
public static final ColorMap<NetworkTransmitterBlock> NETWORK_TRANSMITTER = new ColorMap<>(BLOCKS); public static final ColorMap<NetworkTransmitterBlock> NETWORK_TRANSMITTER = new ColorMap<>(BLOCKS);
@@ -57,8 +53,7 @@ public final class RSBlocks {
public static final ColorMap<CrafterManagerBlock> CRAFTER_MANAGER = new ColorMap<>(BLOCKS); public static final ColorMap<CrafterManagerBlock> CRAFTER_MANAGER = new ColorMap<>(BLOCKS);
public static final ColorMap<CraftingMonitorBlock> CRAFTING_MONITOR = new ColorMap<>(BLOCKS); public static final ColorMap<CraftingMonitorBlock> CRAFTING_MONITOR = new ColorMap<>(BLOCKS);
public static final ColorMap<DetectorBlock> DETECTOR = new ColorMap<>(BLOCKS); public static final ColorMap<DetectorBlock> DETECTOR = new ColorMap<>(BLOCKS);
private static final String GRID_SUFFIX = "_grid";
public static final List<RegistryObject<? extends Block>> COLORED_BLOCKS = new ArrayList<>();
static { static {
QUARTZ_ENRICHED_IRON = BLOCKS.register("quartz_enriched_iron_block", QuartzEnrichedIronBlock::new); QUARTZ_ENRICHED_IRON = BLOCKS.register("quartz_enriched_iron_block", QuartzEnrichedIronBlock::new);

View File

@@ -1,59 +1,59 @@
package com.refinedmods.refinedstorage; package com.refinedmods.refinedstorage;
import com.refinedmods.refinedstorage.container.*; import com.refinedmods.refinedstorage.container.*;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.registries.ObjectHolder;
@ObjectHolder(RS.ID) @ObjectHolder(RS.ID)
public final class RSContainers { public final class RSContainers {
@ObjectHolder("controller") @ObjectHolder("controller")
public static final ContainerType<ControllerContainer> CONTROLLER = null; public static final MenuType<ControllerContainer> CONTROLLER = null;
@ObjectHolder("grid") @ObjectHolder("grid")
public static final ContainerType<GridContainer> GRID = null; public static final MenuType<GridContainer> GRID = null;
@ObjectHolder("detector") @ObjectHolder("detector")
public static final ContainerType<DetectorContainer> DETECTOR = null; public static final MenuType<DetectorContainer> DETECTOR = null;
@ObjectHolder("exporter") @ObjectHolder("exporter")
public static final ContainerType<ExporterContainer> EXPORTER = null; public static final MenuType<ExporterContainer> EXPORTER = null;
@ObjectHolder("external_storage") @ObjectHolder("external_storage")
public static final ContainerType<ExternalStorageContainer> EXTERNAL_STORAGE = null; public static final MenuType<ExternalStorageContainer> EXTERNAL_STORAGE = null;
@ObjectHolder("filter") @ObjectHolder("filter")
public static final ContainerType<FilterContainer> FILTER = null; public static final MenuType<FilterContainer> FILTER = null;
@ObjectHolder("importer") @ObjectHolder("importer")
public static final ContainerType<ImporterContainer> IMPORTER = null; public static final MenuType<ImporterContainer> IMPORTER = null;
@ObjectHolder("network_transmitter") @ObjectHolder("network_transmitter")
public static final ContainerType<NetworkTransmitterContainer> NETWORK_TRANSMITTER = null; public static final MenuType<NetworkTransmitterContainer> NETWORK_TRANSMITTER = null;
@ObjectHolder("relay") @ObjectHolder("relay")
public static final ContainerType<RelayContainer> RELAY = null; public static final MenuType<RelayContainer> RELAY = null;
@ObjectHolder("disk_drive") @ObjectHolder("disk_drive")
public static final ContainerType<DiskDriveContainer> DISK_DRIVE = null; public static final MenuType<DiskDriveContainer> DISK_DRIVE = null;
@ObjectHolder("storage_block") @ObjectHolder("storage_block")
public static final ContainerType<StorageContainer> STORAGE_BLOCK = null; public static final MenuType<StorageContainer> STORAGE_BLOCK = null;
@ObjectHolder("fluid_storage_block") @ObjectHolder("fluid_storage_block")
public static final ContainerType<FluidStorageContainer> FLUID_STORAGE_BLOCK = null; public static final MenuType<FluidStorageContainer> FLUID_STORAGE_BLOCK = null;
@ObjectHolder("security_manager") @ObjectHolder("security_manager")
public static final ContainerType<SecurityManagerContainer> SECURITY_MANAGER = null; public static final MenuType<SecurityManagerContainer> SECURITY_MANAGER = null;
@ObjectHolder("interface") @ObjectHolder("interface")
public static final ContainerType<InterfaceContainer> INTERFACE = null; public static final MenuType<InterfaceContainer> INTERFACE = null;
@ObjectHolder("fluid_interface") @ObjectHolder("fluid_interface")
public static final ContainerType<FluidInterfaceContainer> FLUID_INTERFACE = null; public static final MenuType<FluidInterfaceContainer> FLUID_INTERFACE = null;
@ObjectHolder("wireless_transmitter") @ObjectHolder("wireless_transmitter")
public static final ContainerType<WirelessTransmitterContainer> WIRELESS_TRANSMITTER = null; public static final MenuType<WirelessTransmitterContainer> WIRELESS_TRANSMITTER = null;
@ObjectHolder("storage_monitor") @ObjectHolder("storage_monitor")
public static final ContainerType<StorageMonitorContainer> STORAGE_MONITOR = null; public static final MenuType<StorageMonitorContainer> STORAGE_MONITOR = null;
@ObjectHolder("constructor") @ObjectHolder("constructor")
public static final ContainerType<ConstructorContainer> CONSTRUCTOR = null; public static final MenuType<ConstructorContainer> CONSTRUCTOR = null;
@ObjectHolder("destructor") @ObjectHolder("destructor")
public static final ContainerType<DestructorContainer> DESTRUCTOR = null; public static final MenuType<DestructorContainer> DESTRUCTOR = null;
@ObjectHolder("disk_manipulator") @ObjectHolder("disk_manipulator")
public static final ContainerType<DiskManipulatorContainer> DISK_MANIPULATOR = null; public static final MenuType<DiskManipulatorContainer> DISK_MANIPULATOR = null;
@ObjectHolder("crafter") @ObjectHolder("crafter")
public static final ContainerType<CrafterContainer> CRAFTER = null; public static final MenuType<CrafterContainer> CRAFTER = null;
@ObjectHolder("crafter_manager") @ObjectHolder("crafter_manager")
public static final ContainerType<CrafterManagerContainer> CRAFTER_MANAGER = null; public static final MenuType<CrafterManagerContainer> CRAFTER_MANAGER = null;
@ObjectHolder("crafting_monitor") @ObjectHolder("crafting_monitor")
public static final ContainerType<CraftingMonitorContainer> CRAFTING_MONITOR = null; public static final MenuType<CraftingMonitorContainer> CRAFTING_MONITOR = null;
@ObjectHolder("wireless_crafting_monitor") @ObjectHolder("wireless_crafting_monitor")
public static final ContainerType<CraftingMonitorContainer> WIRELESS_CRAFTING_MONITOR = null; public static final MenuType<CraftingMonitorContainer> WIRELESS_CRAFTING_MONITOR = null;
private RSContainers() { private RSContainers() {
} }

View File

@@ -7,16 +7,16 @@ import com.refinedmods.refinedstorage.item.*;
import com.refinedmods.refinedstorage.item.blockitem.*; import com.refinedmods.refinedstorage.item.blockitem.*;
import com.refinedmods.refinedstorage.util.BlockUtils; import com.refinedmods.refinedstorage.util.BlockUtils;
import com.refinedmods.refinedstorage.util.ColorMap; import com.refinedmods.refinedstorage.util.ColorMap;
import net.minecraft.item.BlockItem; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.item.Item; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.BlockItem;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.item.Item;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.*; import java.util.*;
@@ -167,13 +167,13 @@ public final class RSItems {
LATE_REGISTRATION.add(() -> { LATE_REGISTRATION.add(() -> {
RSBlocks.CONTROLLER.forEach((color, block) -> { RSBlocks.CONTROLLER.forEach((color, block) -> {
if (color != ColorMap.DEFAULT_COLOR) { if (color != ColorMap.DEFAULT_COLOR) {
CONTROLLER.put(color, ITEMS.register(RSBlocks.CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId())))); CONTROLLER.put(color, ITEMS.register(RSBlocks.CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CONTROLLER.get(color).get(), color, new TranslatableComponent(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId()))));
} }
}); });
RSBlocks.CREATIVE_CONTROLLER.forEach((color, block) -> { RSBlocks.CREATIVE_CONTROLLER.forEach((color, block) -> {
if (color != ColorMap.DEFAULT_COLOR) { if (color != ColorMap.DEFAULT_COLOR) {
CREATIVE_CONTROLLER.put(color, ITEMS.register(RSBlocks.CREATIVE_CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId())))); CREATIVE_CONTROLLER.put(color, ITEMS.register(RSBlocks.CREATIVE_CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER.get(color).get(), color, new TranslatableComponent(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId()))));
} }
}); });
}); });

View File

@@ -1,54 +1,54 @@
package com.refinedmods.refinedstorage; package com.refinedmods.refinedstorage;
import net.minecraft.client.settings.KeyBinding; import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.KeyMapping;
import net.minecraftforge.client.settings.KeyConflictContext; import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier; import net.minecraftforge.client.settings.KeyModifier;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
public final class RSKeyBindings { public final class RSKeyBindings {
public static final KeyBinding FOCUS_SEARCH_BAR = new KeyBinding( public static final KeyMapping FOCUS_SEARCH_BAR = new KeyMapping(
"key.refinedstorage.focusSearchBar", "key.refinedstorage.focusSearchBar",
KeyConflictContext.GUI, KeyConflictContext.GUI,
InputMappings.Type.KEYSYM, InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_TAB, GLFW.GLFW_KEY_TAB,
RS.NAME RS.NAME
); );
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding( public static final KeyMapping CLEAR_GRID_CRAFTING_MATRIX = new KeyMapping(
"key.refinedstorage.clearGridCraftingMatrix", "key.refinedstorage.clearGridCraftingMatrix",
KeyConflictContext.GUI, KeyConflictContext.GUI,
KeyModifier.CONTROL, KeyModifier.CONTROL,
InputMappings.Type.KEYSYM, InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_X, GLFW.GLFW_KEY_X,
RS.NAME RS.NAME
); );
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding( public static final KeyMapping OPEN_WIRELESS_GRID = new KeyMapping(
"key.refinedstorage.openWirelessGrid", "key.refinedstorage.openWirelessGrid",
KeyConflictContext.IN_GAME, KeyConflictContext.IN_GAME,
InputMappings.UNKNOWN, InputConstants.UNKNOWN,
RS.NAME RS.NAME
); );
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding( public static final KeyMapping OPEN_WIRELESS_FLUID_GRID = new KeyMapping(
"key.refinedstorage.openWirelessFluidGrid", "key.refinedstorage.openWirelessFluidGrid",
KeyConflictContext.IN_GAME, KeyConflictContext.IN_GAME,
InputMappings.UNKNOWN, InputConstants.UNKNOWN,
RS.NAME RS.NAME
); );
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding( public static final KeyMapping OPEN_WIRELESS_CRAFTING_MONITOR = new KeyMapping(
"key.refinedstorage.openWirelessCraftingMonitor", "key.refinedstorage.openWirelessCraftingMonitor",
KeyConflictContext.IN_GAME, KeyConflictContext.IN_GAME,
InputMappings.UNKNOWN, InputConstants.UNKNOWN,
RS.NAME RS.NAME
); );
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding( public static final KeyMapping OPEN_PORTABLE_GRID = new KeyMapping(
"key.refinedstorage.openPortableGrid", "key.refinedstorage.openPortableGrid",
KeyConflictContext.IN_GAME, KeyConflictContext.IN_GAME,
InputMappings.UNKNOWN, InputConstants.UNKNOWN,
RS.NAME RS.NAME
); );

View File

@@ -4,39 +4,39 @@ import com.refinedmods.refinedstorage.loottable.ControllerLootFunction;
import com.refinedmods.refinedstorage.loottable.CrafterLootFunction; import com.refinedmods.refinedstorage.loottable.CrafterLootFunction;
import com.refinedmods.refinedstorage.loottable.PortableGridBlockLootFunction; import com.refinedmods.refinedstorage.loottable.PortableGridBlockLootFunction;
import com.refinedmods.refinedstorage.loottable.StorageBlockLootFunction; import com.refinedmods.refinedstorage.loottable.StorageBlockLootFunction;
import net.minecraft.loot.LootFunctionType; import net.minecraft.core.Registry;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.registry.Registry; import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
public final class RSLootFunctions { public final class RSLootFunctions {
private static LootFunctionType storageBlock; private static LootItemFunctionType storageBlock;
private static LootFunctionType portableGrid; private static LootItemFunctionType portableGrid;
private static LootFunctionType crafter; private static LootItemFunctionType crafter;
private static LootFunctionType controller; private static LootItemFunctionType controller;
private RSLootFunctions() { private RSLootFunctions() {
} }
public static void register() { public static void register() {
storageBlock = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootFunctionType(new StorageBlockLootFunction.Serializer())); storageBlock = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootItemFunctionType(new StorageBlockLootFunction.Serializer()));
portableGrid = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootFunctionType(new PortableGridBlockLootFunction.Serializer())); portableGrid = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootItemFunctionType(new PortableGridBlockLootFunction.Serializer()));
crafter = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "crafter"), new LootFunctionType(new CrafterLootFunction.Serializer())); crafter = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "crafter"), new LootItemFunctionType(new CrafterLootFunction.Serializer()));
controller = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "controller"), new LootFunctionType(new ControllerLootFunction.Serializer())); controller = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "controller"), new LootItemFunctionType(new ControllerLootFunction.Serializer()));
} }
public static LootFunctionType getStorageBlock() { public static LootItemFunctionType getStorageBlock() {
return storageBlock; return storageBlock;
} }
public static LootFunctionType getPortableGrid() { public static LootItemFunctionType getPortableGrid() {
return portableGrid; return portableGrid;
} }
public static LootFunctionType getCrafter() { public static LootItemFunctionType getCrafter() {
return crafter; return crafter;
} }
public static LootFunctionType getController() { public static LootItemFunctionType getController() {
return controller; return controller;
} }
} }

View File

@@ -4,87 +4,87 @@ import com.refinedmods.refinedstorage.tile.*;
import com.refinedmods.refinedstorage.tile.craftingmonitor.CraftingMonitorTile; import com.refinedmods.refinedstorage.tile.craftingmonitor.CraftingMonitorTile;
import com.refinedmods.refinedstorage.tile.grid.GridTile; import com.refinedmods.refinedstorage.tile.grid.GridTile;
import com.refinedmods.refinedstorage.tile.grid.portable.PortableGridTile; import com.refinedmods.refinedstorage.tile.grid.portable.PortableGridTile;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.registries.ObjectHolder;
@ObjectHolder(RS.ID) @ObjectHolder(RS.ID)
public final class RSTiles { public final class RSTiles {
@ObjectHolder("controller") @ObjectHolder("controller")
public static final TileEntityType<ControllerTile> CONTROLLER = null; public static final BlockEntityType<ControllerTile> CONTROLLER = null;
@ObjectHolder("creative_controller") @ObjectHolder("creative_controller")
public static final TileEntityType<ControllerTile> CREATIVE_CONTROLLER = null; public static final BlockEntityType<ControllerTile> CREATIVE_CONTROLLER = null;
@ObjectHolder("detector") @ObjectHolder("detector")
public static final TileEntityType<DetectorTile> DETECTOR = null; public static final BlockEntityType<DetectorTile> DETECTOR = null;
@ObjectHolder("disk_drive") @ObjectHolder("disk_drive")
public static final TileEntityType<DiskDriveTile> DISK_DRIVE = null; public static final BlockEntityType<DiskDriveTile> DISK_DRIVE = null;
@ObjectHolder("exporter") @ObjectHolder("exporter")
public static final TileEntityType<ExporterTile> EXPORTER = null; public static final BlockEntityType<ExporterTile> EXPORTER = null;
@ObjectHolder("external_storage") @ObjectHolder("external_storage")
public static final TileEntityType<ExternalStorageTile> EXTERNAL_STORAGE = null; public static final BlockEntityType<ExternalStorageTile> EXTERNAL_STORAGE = null;
@ObjectHolder("grid") @ObjectHolder("grid")
public static final TileEntityType<GridTile> GRID = null; public static final BlockEntityType<GridTile> GRID = null;
@ObjectHolder("crafting_grid") @ObjectHolder("crafting_grid")
public static final TileEntityType<GridTile> CRAFTING_GRID = null; public static final BlockEntityType<GridTile> CRAFTING_GRID = null;
@ObjectHolder("pattern_grid") @ObjectHolder("pattern_grid")
public static final TileEntityType<GridTile> PATTERN_GRID = null; public static final BlockEntityType<GridTile> PATTERN_GRID = null;
@ObjectHolder("fluid_grid") @ObjectHolder("fluid_grid")
public static final TileEntityType<GridTile> FLUID_GRID = null; public static final BlockEntityType<GridTile> FLUID_GRID = null;
@ObjectHolder("importer") @ObjectHolder("importer")
public static final TileEntityType<ImporterTile> IMPORTER = null; public static final BlockEntityType<ImporterTile> IMPORTER = null;
@ObjectHolder("network_transmitter") @ObjectHolder("network_transmitter")
public static final TileEntityType<NetworkTransmitterTile> NETWORK_TRANSMITTER = null; public static final BlockEntityType<NetworkTransmitterTile> NETWORK_TRANSMITTER = null;
@ObjectHolder("network_receiver") @ObjectHolder("network_receiver")
public static final TileEntityType<NetworkReceiverTile> NETWORK_RECEIVER = null; public static final BlockEntityType<NetworkReceiverTile> NETWORK_RECEIVER = null;
@ObjectHolder("relay") @ObjectHolder("relay")
public static final TileEntityType<RelayTile> RELAY = null; public static final BlockEntityType<RelayTile> RELAY = null;
@ObjectHolder("cable") @ObjectHolder("cable")
public static final TileEntityType<CableTile> CABLE = null; public static final BlockEntityType<CableTile> CABLE = null;
@ObjectHolder("1k_storage_block") @ObjectHolder("1k_storage_block")
public static final TileEntityType<StorageTile> ONE_K_STORAGE_BLOCK = null; public static final BlockEntityType<StorageTile> ONE_K_STORAGE_BLOCK = null;
@ObjectHolder("4k_storage_block") @ObjectHolder("4k_storage_block")
public static final TileEntityType<StorageTile> FOUR_K_STORAGE_BLOCK = null; public static final BlockEntityType<StorageTile> FOUR_K_STORAGE_BLOCK = null;
@ObjectHolder("16k_storage_block") @ObjectHolder("16k_storage_block")
public static final TileEntityType<StorageTile> SIXTEEN_K_STORAGE_BLOCK = null; public static final BlockEntityType<StorageTile> SIXTEEN_K_STORAGE_BLOCK = null;
@ObjectHolder("64k_storage_block") @ObjectHolder("64k_storage_block")
public static final TileEntityType<StorageTile> SIXTY_FOUR_K_STORAGE_BLOCK = null; public static final BlockEntityType<StorageTile> SIXTY_FOUR_K_STORAGE_BLOCK = null;
@ObjectHolder("creative_storage_block") @ObjectHolder("creative_storage_block")
public static final TileEntityType<StorageTile> CREATIVE_STORAGE_BLOCK = null; public static final BlockEntityType<StorageTile> CREATIVE_STORAGE_BLOCK = null;
@ObjectHolder("64k_fluid_storage_block") @ObjectHolder("64k_fluid_storage_block")
public static final TileEntityType<FluidStorageTile> SIXTY_FOUR_K_FLUID_STORAGE_BLOCK = null; public static final BlockEntityType<FluidStorageTile> SIXTY_FOUR_K_FLUID_STORAGE_BLOCK = null;
@ObjectHolder("256k_fluid_storage_block") @ObjectHolder("256k_fluid_storage_block")
public static final TileEntityType<FluidStorageTile> TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK = null; public static final BlockEntityType<FluidStorageTile> TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK = null;
@ObjectHolder("1024k_fluid_storage_block") @ObjectHolder("1024k_fluid_storage_block")
public static final TileEntityType<FluidStorageTile> THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK = null; public static final BlockEntityType<FluidStorageTile> THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK = null;
@ObjectHolder("4096k_fluid_storage_block") @ObjectHolder("4096k_fluid_storage_block")
public static final TileEntityType<FluidStorageTile> FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK = null; public static final BlockEntityType<FluidStorageTile> FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK = null;
@ObjectHolder("creative_fluid_storage_block") @ObjectHolder("creative_fluid_storage_block")
public static final TileEntityType<FluidStorageTile> CREATIVE_FLUID_STORAGE_BLOCK = null; public static final BlockEntityType<FluidStorageTile> CREATIVE_FLUID_STORAGE_BLOCK = null;
@ObjectHolder("security_manager") @ObjectHolder("security_manager")
public static final TileEntityType<SecurityManagerTile> SECURITY_MANAGER = null; public static final BlockEntityType<SecurityManagerTile> SECURITY_MANAGER = null;
@ObjectHolder("interface") @ObjectHolder("interface")
public static final TileEntityType<InterfaceTile> INTERFACE = null; public static final BlockEntityType<InterfaceTile> INTERFACE = null;
@ObjectHolder("fluid_interface") @ObjectHolder("fluid_interface")
public static final TileEntityType<FluidInterfaceTile> FLUID_INTERFACE = null; public static final BlockEntityType<FluidInterfaceTile> FLUID_INTERFACE = null;
@ObjectHolder("wireless_transmitter") @ObjectHolder("wireless_transmitter")
public static final TileEntityType<WirelessTransmitterTile> WIRELESS_TRANSMITTER = null; public static final BlockEntityType<WirelessTransmitterTile> WIRELESS_TRANSMITTER = null;
@ObjectHolder("storage_monitor") @ObjectHolder("storage_monitor")
public static final TileEntityType<StorageMonitorTile> STORAGE_MONITOR = null; public static final BlockEntityType<StorageMonitorTile> STORAGE_MONITOR = null;
@ObjectHolder("constructor") @ObjectHolder("constructor")
public static final TileEntityType<ConstructorTile> CONSTRUCTOR = null; public static final BlockEntityType<ConstructorTile> CONSTRUCTOR = null;
@ObjectHolder("destructor") @ObjectHolder("destructor")
public static final TileEntityType<DestructorTile> DESTRUCTOR = null; public static final BlockEntityType<DestructorTile> DESTRUCTOR = null;
@ObjectHolder("disk_manipulator") @ObjectHolder("disk_manipulator")
public static final TileEntityType<DiskManipulatorTile> DISK_MANIPULATOR = null; public static final BlockEntityType<DiskManipulatorTile> DISK_MANIPULATOR = null;
@ObjectHolder("portable_grid") @ObjectHolder("portable_grid")
public static final TileEntityType<PortableGridTile> PORTABLE_GRID = null; public static final BlockEntityType<PortableGridTile> PORTABLE_GRID = null;
@ObjectHolder("creative_portable_grid") @ObjectHolder("creative_portable_grid")
public static final TileEntityType<PortableGridTile> CREATIVE_PORTABLE_GRID = null; public static final BlockEntityType<PortableGridTile> CREATIVE_PORTABLE_GRID = null;
@ObjectHolder("crafter") @ObjectHolder("crafter")
public static final TileEntityType<CrafterTile> CRAFTER = null; public static final BlockEntityType<CrafterTile> CRAFTER = null;
@ObjectHolder("crafter_manager") @ObjectHolder("crafter_manager")
public static final TileEntityType<CrafterManagerTile> CRAFTER_MANAGER = null; public static final BlockEntityType<CrafterManagerTile> CRAFTER_MANAGER = null;
@ObjectHolder("crafting_monitor") @ObjectHolder("crafting_monitor")
public static final TileEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null; public static final BlockEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null;
private RSTiles() { private RSTiles() {
} }

View File

@@ -22,10 +22,10 @@ import com.refinedmods.refinedstorage.api.storage.tracker.IStorageTrackerManager
import com.refinedmods.refinedstorage.api.util.IComparer; import com.refinedmods.refinedstorage.api.util.IComparer;
import com.refinedmods.refinedstorage.api.util.IQuantityFormatter; import com.refinedmods.refinedstorage.api.util.IQuantityFormatter;
import com.refinedmods.refinedstorage.api.util.IStackList; import com.refinedmods.refinedstorage.api.util.IStackList;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ServerLevel;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -62,7 +62,7 @@ public interface IRSAPI {
* @param world world * @param world world
* @return the network node manager for a given world * @return the network node manager for a given world
*/ */
INetworkNodeManager getNetworkNodeManager(ServerWorld world); INetworkNodeManager getNetworkNodeManager(ServerLevel world);
/** /**
* Gets a network manager for a given world. * Gets a network manager for a given world.
@@ -70,7 +70,7 @@ public interface IRSAPI {
* @param world world * @param world world
* @return the network manager for a given world * @return the network manager for a given world
*/ */
INetworkManager getNetworkManager(ServerWorld world); INetworkManager getNetworkManager(ServerLevel world);
/** /**
* @return the crafting task registry * @return the crafting task registry
@@ -131,7 +131,7 @@ public interface IRSAPI {
* @return the storage disk manager * @return the storage disk manager
*/ */
@Nonnull @Nonnull
IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld); IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld);
/** /**
* @return the storage disk sync manager * @return the storage disk sync manager
@@ -143,7 +143,7 @@ public interface IRSAPI {
* @return the storage tracker manager * @return the storage tracker manager
*/ */
@Nonnull @Nonnull
IStorageTrackerManager getStorageTrackerManager(ServerWorld anyWorld); IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld);
/** /**
* Adds an external storage provider for the given storage type. * Adds an external storage provider for the given storage type.
@@ -166,7 +166,7 @@ public interface IRSAPI {
* @return a storage disk * @return a storage disk
*/ */
@Nonnull @Nonnull
IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity, @Nullable PlayerEntity owner); IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel world, int capacity, @Nullable Player owner);
/** /**
* @param world the world * @param world the world
@@ -175,7 +175,7 @@ public interface IRSAPI {
* @return a fluid storage disk * @return a fluid storage disk
*/ */
@Nonnull @Nonnull
IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity, @Nullable PlayerEntity owner); IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel world, int capacity, @Nullable Player owner);
/** /**
* Creates crafting request info for an item. * Creates crafting request info for an item.
@@ -201,7 +201,7 @@ public interface IRSAPI {
* @param tag the nbt tag * @param tag the nbt tag
* @return the request info * @return the request info
*/ */
ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException; ICraftingRequestInfo createCraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException;
/** /**
* @param renderHandler the render handler to add * @param renderHandler the render handler to add

View File

@@ -3,9 +3,9 @@ package com.refinedmods.refinedstorage.api.autocrafting;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICalculationResult; import com.refinedmods.refinedstorage.api.autocrafting.task.ICalculationResult;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTask; import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTask;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
@@ -34,7 +34,7 @@ public interface ICraftingManager {
/** /**
* @return named crafting pattern containers * @return named crafting pattern containers
*/ */
Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers(); Map<Component, List<IItemHandlerModifiable>> getNamedContainers();
/** /**
* Starts a crafting task. * Starts a crafting task.
@@ -140,13 +140,13 @@ public interface ICraftingManager {
/** /**
* @param tag the tag to read from * @param tag the tag to read from
*/ */
void readFromNbt(CompoundNBT tag); void readFromNbt(CompoundTag tag);
/** /**
* @param tag the tag to write to * @param tag the tag to write to
* @return the written tag * @return the written tag
*/ */
CompoundNBT writeToNbt(CompoundNBT tag); CompoundTag writeToNbt(CompoundTag tag);
/** /**
* @param listener the listener * @param listener the listener

View File

@@ -1,10 +1,10 @@
package com.refinedmods.refinedstorage.api.autocrafting; package com.refinedmods.refinedstorage.api.autocrafting;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry; import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.network.chat.Component;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -33,7 +33,7 @@ public interface ICraftingPattern {
* @return an error message when this pattern is not valid, or null if there's no message * @return an error message when this pattern is not valid, or null if there's no message
*/ */
@Nullable @Nullable
ITextComponent getErrorMessage(); Component getErrorMessage();
/** /**
* @return true if the crafting pattern can be treated as a processing pattern, false otherwise * @return true if the crafting pattern can be treated as a processing pattern, false otherwise

View File

@@ -2,11 +2,11 @@ package com.refinedmods.refinedstorage.api.autocrafting;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import net.minecraft.item.ItemStack; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.TileEntity; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.network.chat.Component;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -62,12 +62,12 @@ public interface ICraftingPatternContainer {
* @return the tile that this container is connected to, or null if no tile is present * @return the tile that this container is connected to, or null if no tile is present
*/ */
@Nullable @Nullable
TileEntity getConnectedTile(); BlockEntity getConnectedTile();
/** /**
* @return the tile that this container is facing * @return the tile that this container is facing
*/ */
TileEntity getFacingTile(); BlockEntity getFacingTile();
/** /**
* @return the direction to the facing tile * @return the direction to the facing tile
@@ -90,7 +90,7 @@ public interface ICraftingPatternContainer {
* *
* @return the name of this container * @return the name of this container
*/ */
ITextComponent getName(); Component getName();
/** /**
* @return the position of this container * @return the position of this container

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.autocrafting; package com.refinedmods.refinedstorage.api.autocrafting;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -19,5 +19,5 @@ public interface ICraftingPatternProvider {
* @return the crafting pattern * @return the crafting pattern
*/ */
@Nonnull @Nonnull
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container); ICraftingPattern create(Level world, ItemStack stack, ICraftingPatternContainer container);
} }

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.autocrafting; package com.refinedmods.refinedstorage.api.autocrafting;
import com.refinedmods.refinedstorage.api.IRSAPI; import com.refinedmods.refinedstorage.api.IRSAPI;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
/** /**
* Defines the behavior of pattern rendering. * Defines the behavior of pattern rendering.

View File

@@ -1,11 +1,11 @@
package com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor; package com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList; import com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.ITextComponent; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -23,7 +23,7 @@ public interface ICraftingMonitorElement {
* @param drawers the drawers that this element can use * @param drawers the drawers that this element can use
*/ */
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers); void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers);
/** /**
* Returns the id for the base of this element, used for sorting in the {@link CraftingMonitorElementList} * Returns the id for the base of this element, used for sorting in the {@link CraftingMonitorElementList}
@@ -42,7 +42,7 @@ public interface ICraftingMonitorElement {
/** /**
* @return the tooltip of this element * @return the tooltip of this element
*/ */
default List<ITextComponent> getTooltip() { default List<Component> getTooltip() {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -51,7 +51,7 @@ public interface ICraftingMonitorElement {
* *
* @param buf the buffer * @param buf the buffer
*/ */
void write(PacketBuffer buf); void write(FriendlyByteBuf buf);
/** /**
* Merge an element into the current element. * Merge an element into the current element.

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor; package com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.function.Function; import java.util.function.Function;
@@ -16,7 +16,7 @@ public interface ICraftingMonitorElementRegistry {
* @param id the id, as specified in {@link ICraftingMonitorElement#getId()} * @param id the id, as specified in {@link ICraftingMonitorElement#getId()}
* @param factory the factory * @param factory the factory
*/ */
void add(ResourceLocation id, Function<PacketBuffer, ICraftingMonitorElement> factory); void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingMonitorElement> factory);
/** /**
* Returns a factory from the registry. * Returns a factory from the registry.
@@ -25,5 +25,5 @@ public interface ICraftingMonitorElementRegistry {
* @return the factory, or null if no factory was found * @return the factory, or null if no factory was found
*/ */
@Nullable @Nullable
Function<PacketBuffer, ICraftingMonitorElement> get(ResourceLocation id); Function<FriendlyByteBuf, ICraftingMonitorElement> get(ResourceLocation id);
} }

View File

@@ -1,9 +1,9 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview; package com.refinedmods.refinedstorage.api.autocrafting.preview;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -18,7 +18,7 @@ public interface ICraftingPreviewElement {
* @param drawers the drawers this element can use * @param drawers the drawers this element can use
*/ */
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers); void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers);
/** /**
* @return true when this crafting preview elements signifies an error that disables starting a task * @return true when this crafting preview elements signifies an error that disables starting a task
@@ -28,7 +28,7 @@ public interface ICraftingPreviewElement {
/** /**
* @param buf buffer to write to * @param buf buffer to write to
*/ */
void write(PacketBuffer buf); void write(FriendlyByteBuf buf);
/** /**
* Returns the id of this element, used for serialization and deserialization over the network. * Returns the id of this element, used for serialization and deserialization over the network.

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview; package com.refinedmods.refinedstorage.api.autocrafting.preview;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.function.Function; import java.util.function.Function;
@@ -16,7 +16,7 @@ public interface ICraftingPreviewElementRegistry {
* @param id the id, as specified in {@link ICraftingPreviewElement#getId()} * @param id the id, as specified in {@link ICraftingPreviewElement#getId()}
* @param factory the factory * @param factory the factory
*/ */
void add(ResourceLocation id, Function<PacketBuffer, ICraftingPreviewElement> factory); void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingPreviewElement> factory);
/** /**
* Returns a factory from the registry. * Returns a factory from the registry.
@@ -25,5 +25,5 @@ public interface ICraftingPreviewElementRegistry {
* @return the factory, or null if no factory was found * @return the factory, or null if no factory was found
*/ */
@Nullable @Nullable
Function<PacketBuffer, ICraftingPreviewElement> get(ResourceLocation id); Function<FriendlyByteBuf, ICraftingPreviewElement> get(ResourceLocation id);
} }

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.autocrafting.task; package com.refinedmods.refinedstorage.api.autocrafting.task;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -25,5 +25,5 @@ public interface ICraftingRequestInfo {
/** /**
* @return the written tag * @return the written tag
*/ */
CompoundNBT writeToNbt(); CompoundTag writeToNbt();
} }

View File

@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.api.autocrafting.task;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;
@@ -63,7 +63,7 @@ public interface ICraftingTask {
* @param tag the tag * @param tag the tag
* @return the written tag * @return the written tag
*/ */
CompoundNBT writeToNbt(CompoundNBT tag); CompoundTag writeToNbt(CompoundTag tag);
/** /**
* @return the elements of this task for display in the crafting monitor * @return the elements of this task for display in the crafting monitor

View File

@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.api.autocrafting.task;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
/** /**
* A factory that creates a crafting task. * A factory that creates a crafting task.
@@ -27,5 +27,5 @@ public interface ICraftingTaskFactory {
* @param tag the tag * @param tag the tag
* @return the crafting task * @return the crafting task
*/ */
ICraftingTask createFromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException; ICraftingTask createFromNbt(INetwork network, CompoundTag tag) throws CraftingTaskReadException;
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.autocrafting.task; package com.refinedmods.refinedstorage.api.autocrafting.task;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@@ -10,10 +10,10 @@ import com.refinedmods.refinedstorage.api.storage.cache.IStorageCache;
import com.refinedmods.refinedstorage.api.storage.tracker.IStorageTracker; import com.refinedmods.refinedstorage.api.storage.tracker.IStorageTracker;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import com.refinedmods.refinedstorage.api.util.IComparer; import com.refinedmods.refinedstorage.api.util.IComparer;
import net.minecraft.item.ItemStack; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@@ -244,7 +244,7 @@ public interface INetwork {
/** /**
* @return the world where this network is in * @return the world where this network is in
*/ */
World getWorld(); Level getWorld();
/** /**
* @return the position of this network in the world * @return the position of this network in the world
@@ -254,13 +254,13 @@ public interface INetwork {
/** /**
* @return a read network * @return a read network
*/ */
INetwork readFromNbt(CompoundNBT tag); INetwork readFromNbt(CompoundTag tag);
/** /**
* @param tag the tag to write to * @param tag the tag to write to
* @return a written tag * @return a written tag
*/ */
CompoundNBT writeToNbt(CompoundNBT tag); CompoundTag writeToNbt(CompoundTag tag);
/** /**
* @return sampled tick times * @return sampled tick times

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.network; package com.refinedmods.refinedstorage.api.network;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network; package com.refinedmods.refinedstorage.api.network;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import java.util.Collection; import java.util.Collection;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -18,7 +18,7 @@ public interface INetworkNodeGraph {
* @param world the origin world * @param world the origin world
* @param origin the origin, usually the network position * @param origin the origin, usually the network position
*/ */
void invalidate(Action action, World world, BlockPos origin); void invalidate(Action action, Level world, BlockPos origin);
/** /**
* Runs an action on the network. * Runs an action on the network.

View File

@@ -1,9 +1,9 @@
package com.refinedmods.refinedstorage.api.network; package com.refinedmods.refinedstorage.api.network;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import net.minecraft.util.Direction; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.Direction;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -31,7 +31,7 @@ public interface INetworkNodeVisitor {
* @param pos the position * @param pos the position
* @param side the side * @param side the side
*/ */
void apply(World world, BlockPos pos, @Nullable Direction side); void apply(Level world, BlockPos pos, @Nullable Direction side);
/** /**
* Returns whether the network graph is scanning in simulation mode. * Returns whether the network graph is scanning in simulation mode.

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network; package com.refinedmods.refinedstorage.api.network;
import net.minecraft.util.RegistryKey; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
/** /**
* Represents a node that can send a wireless signal. * Represents a node that can send a wireless signal.
@@ -21,5 +21,5 @@ public interface IWirelessTransmitter {
/** /**
* @return the dimension in which the transmitter is * @return the dimension in which the transmitter is
*/ */
RegistryKey<World> getDimension(); ResourceKey<Level> getDimension();
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.network.grid; package com.refinedmods.refinedstorage.api.network.grid;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.StringRepresentable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -8,7 +8,7 @@ import javax.annotation.Nonnull;
* Represents a grid type. * Represents a grid type.
* Used in {@link IGrid} to determine grid GUI rendering. * Used in {@link IGrid} to determine grid GUI rendering.
*/ */
public enum GridType implements IStringSerializable { public enum GridType implements StringRepresentable {
/** /**
* A regular grid. * A regular grid.
*/ */

View File

@@ -1,9 +1,9 @@
package com.refinedmods.refinedstorage.api.network.grid; package com.refinedmods.refinedstorage.api.network.grid;
import com.refinedmods.refinedstorage.api.util.IStackList; import com.refinedmods.refinedstorage.api.util.IStackList;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.world.item.crafting.CraftingRecipe;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -20,7 +20,7 @@ public interface ICraftingGridBehavior {
* @param availableItems the items available for shift crafting * @param availableItems the items available for shift crafting
* @param usedItems the items used by shift crafting * @param usedItems the items used by shift crafting
*/ */
void onCrafted(INetworkAwareGrid grid, ICraftingRecipe recipe, PlayerEntity player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems); void onCrafted(INetworkAwareGrid grid, CraftingRecipe recipe, Player player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems);
/** /**
* Logic for crafting with shift click (mass crafting). * Logic for crafting with shift click (mass crafting).
@@ -28,7 +28,7 @@ public interface ICraftingGridBehavior {
* @param grid the grid * @param grid the grid
* @param player the player * @param player the player
*/ */
void onCraftedShift(INetworkAwareGrid grid, PlayerEntity player); void onCraftedShift(INetworkAwareGrid grid, Player player);
/** /**
* Logic for when a recipe is transferred to the grid. * Logic for when a recipe is transferred to the grid.
@@ -37,5 +37,5 @@ public interface ICraftingGridBehavior {
* @param player the player * @param player the player
* @param recipe the recipe * @param recipe the recipe
*/ */
void onRecipeTransfer(INetworkAwareGrid grid, PlayerEntity player, ItemStack[][] recipe); void onRecipeTransfer(INetworkAwareGrid grid, Player player, ItemStack[][] recipe);
} }

View File

@@ -6,12 +6,12 @@ import com.refinedmods.refinedstorage.api.storage.cache.IStorageCache;
import com.refinedmods.refinedstorage.api.storage.cache.IStorageCacheListener; import com.refinedmods.refinedstorage.api.storage.cache.IStorageCacheListener;
import com.refinedmods.refinedstorage.api.util.IFilter; import com.refinedmods.refinedstorage.api.util.IFilter;
import com.refinedmods.refinedstorage.api.util.IStackList; import com.refinedmods.refinedstorage.api.util.IStackList;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.chat.Component;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.inventory.CraftResultInventory; import net.minecraft.world.entity.player.Player;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.item.ItemStack; import net.minecraft.world.inventory.ResultContainer;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -48,6 +48,53 @@ public interface IGrid {
int SIZE_MEDIUM = 2; int SIZE_MEDIUM = 2;
int SIZE_LARGE = 3; int SIZE_LARGE = 3;
static boolean isValidViewType(int type) {
return type == VIEW_TYPE_NORMAL ||
type == VIEW_TYPE_CRAFTABLES ||
type == VIEW_TYPE_NON_CRAFTABLES;
}
static boolean isValidSearchBoxMode(int mode) {
return mode == SEARCH_BOX_MODE_NORMAL ||
mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean isSearchBoxModeWithAutoselection(int mode) {
return mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean doesSearchBoxModeUseJEI(int mode) {
return mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean isValidSortingType(int type) {
return type == SORTING_TYPE_QUANTITY ||
type == SORTING_TYPE_NAME ||
type == SORTING_TYPE_ID ||
type == SORTING_TYPE_INVENTORYTWEAKS ||
type == SORTING_TYPE_LAST_MODIFIED;
}
static boolean isValidSortingDirection(int direction) {
return direction == SORTING_DIRECTION_ASCENDING || direction == SORTING_DIRECTION_DESCENDING;
}
static boolean isValidSize(int size) {
return size == SIZE_STRETCH ||
size == SIZE_SMALL ||
size == SIZE_MEDIUM ||
size == SIZE_LARGE;
}
/** /**
* @return the grid type * @return the grid type
*/ */
@@ -57,7 +104,7 @@ public interface IGrid {
* @param player the player to create a listener for * @param player the player to create a listener for
* @return a listener for this grid, will be attached to the storage cache in {@link #getStorageCache()} * @return a listener for this grid, will be attached to the storage cache in {@link #getStorageCache()}
*/ */
IStorageCacheListener createListener(ServerPlayerEntity player); IStorageCacheListener createListener(ServerPlayer player);
/** /**
* @return the storage cache for this grid, or null if this grid is unavailable * @return the storage cache for this grid, or null if this grid is unavailable
@@ -92,7 +139,7 @@ public interface IGrid {
/** /**
* @return the title * @return the title
*/ */
ITextComponent getTitle(); Component getTitle();
/** /**
* @return the view type * @return the view type
@@ -188,13 +235,13 @@ public interface IGrid {
* @return the crafting matrix, or null if not a crafting grid * @return the crafting matrix, or null if not a crafting grid
*/ */
@Nullable @Nullable
CraftingInventory getCraftingMatrix(); CraftingContainer getCraftingMatrix();
/** /**
* @return the crafting result inventory, or null if not a crafting grid * @return the crafting result inventory, or null if not a crafting grid
*/ */
@Nullable @Nullable
CraftResultInventory getCraftingResult(); ResultContainer getCraftingResult();
/** /**
* Called when the crafting matrix changes. * Called when the crafting matrix changes.
@@ -208,19 +255,19 @@ public interface IGrid {
* @param availableItems the items available for shift crafting * @param availableItems the items available for shift crafting
* @param usedItems the items used by shift crafting * @param usedItems the items used by shift crafting
*/ */
void onCrafted(PlayerEntity player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems); void onCrafted(Player player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems);
/** /**
* Called when the clear button is pressed in the pattern grid or crafting grid. * Called when the clear button is pressed in the pattern grid or crafting grid.
*/ */
void onClear(PlayerEntity player); void onClear(Player player);
/** /**
* Called when an item is crafted with shift click (up to 64 items) in a crafting grid. * Called when an item is crafted with shift click (up to 64 items) in a crafting grid.
* *
* @param player the player that crafted the item * @param player the player that crafted the item
*/ */
void onCraftedShift(PlayerEntity player); void onCraftedShift(Player player);
/** /**
* Called when a JEI recipe transfer occurs. * Called when a JEI recipe transfer occurs.
@@ -228,14 +275,14 @@ public interface IGrid {
* @param player the player * @param player the player
* @param recipe a 9*x array stack array, where x is the possible combinations for the given slot * @param recipe a 9*x array stack array, where x is the possible combinations for the given slot
*/ */
void onRecipeTransfer(PlayerEntity player, ItemStack[][] recipe); void onRecipeTransfer(Player player, ItemStack[][] recipe);
/** /**
* Called when the grid is closed. * Called when the grid is closed.
* *
* @param player the player * @param player the player
*/ */
void onClosed(PlayerEntity player); void onClosed(Player player);
/** /**
* @return true if the grid is active, false otherwise * @return true if the grid is active, false otherwise
@@ -246,51 +293,4 @@ public interface IGrid {
* @return the slot id where this grid is located, if applicable, otherwise -1 * @return the slot id where this grid is located, if applicable, otherwise -1
*/ */
int getSlotId(); int getSlotId();
static boolean isValidViewType(int type) {
return type == VIEW_TYPE_NORMAL ||
type == VIEW_TYPE_CRAFTABLES ||
type == VIEW_TYPE_NON_CRAFTABLES;
}
static boolean isValidSearchBoxMode(int mode) {
return mode == SEARCH_BOX_MODE_NORMAL ||
mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean isSearchBoxModeWithAutoselection(int mode) {
return mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean doesSearchBoxModeUseJEI(int mode) {
return mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY ||
mode == SEARCH_BOX_MODE_JEI_SYNCHRONIZED_2WAY_AUTOSELECTED;
}
static boolean isValidSortingType(int type) {
return type == SORTING_TYPE_QUANTITY ||
type == SORTING_TYPE_NAME ||
type == SORTING_TYPE_ID ||
type == SORTING_TYPE_INVENTORYTWEAKS ||
type == SORTING_TYPE_LAST_MODIFIED;
}
static boolean isValidSortingDirection(int direction) {
return direction == SORTING_DIRECTION_ASCENDING || direction == SORTING_DIRECTION_DESCENDING;
}
static boolean isValidSize(int size) {
return size == SIZE_STRETCH ||
size == SIZE_SMALL ||
size == SIZE_MEDIUM ||
size == SIZE_LARGE;
}
} }

View File

@@ -1,11 +1,11 @@
package com.refinedmods.refinedstorage.api.network.grid; package com.refinedmods.refinedstorage.api.network.grid;
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot; import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.BlockPos;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.player.Player;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.world.World; import net.minecraft.world.level.block.entity.BlockEntity;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -22,7 +22,7 @@ public interface IGridFactory {
* @return the grid, or null if a problem occurred * @return the grid, or null if a problem occurred
*/ */
@Nullable @Nullable
IGrid createFromStack(PlayerEntity player, ItemStack stack, PlayerSlot slot); IGrid createFromStack(Player player, ItemStack stack, PlayerSlot slot);
/** /**
* Creates a grid from a block. Used when {@link #getType()} is BLOCK. * Creates a grid from a block. Used when {@link #getType()} is BLOCK.
@@ -32,7 +32,7 @@ public interface IGridFactory {
* @return the grid, or null if a problem occurred * @return the grid, or null if a problem occurred
*/ */
@Nullable @Nullable
IGrid createFromBlock(PlayerEntity player, BlockPos pos); IGrid createFromBlock(Player player, BlockPos pos);
/** /**
* Returns a possible tile for this grid if {@link #getType()} is BLOCK. * Returns a possible tile for this grid if {@link #getType()} is BLOCK.
@@ -42,7 +42,7 @@ public interface IGridFactory {
* @return the tile, or null if no tile is required * @return the tile, or null if no tile is required
*/ */
@Nullable @Nullable
TileEntity getRelevantTile(World world, BlockPos pos); BlockEntity getRelevantTile(Level world, BlockPos pos);
/** /**
* @return the type * @return the type

View File

@@ -1,12 +1,12 @@
package com.refinedmods.refinedstorage.api.network.grid; package com.refinedmods.refinedstorage.api.network.grid;
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot; import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -28,7 +28,7 @@ public interface IGridManager {
* @param player the player * @param player the player
* @param pos the block position * @param pos the block position
*/ */
void openGrid(ResourceLocation id, ServerPlayerEntity player, BlockPos pos); void openGrid(ResourceLocation id, ServerPlayer player, BlockPos pos);
/** /**
* Opens a grid. Can only be called on the server. * Opens a grid. Can only be called on the server.
@@ -38,7 +38,7 @@ public interface IGridManager {
* @param stack the stack * @param stack the stack
* @param slot the slot in the players inventory or curio slot, otherwise -1 * @param slot the slot in the players inventory or curio slot, otherwise -1
*/ */
void openGrid(ResourceLocation id, ServerPlayerEntity player, ItemStack stack, PlayerSlot slot); void openGrid(ResourceLocation id, ServerPlayer player, ItemStack stack, PlayerSlot slot);
/** /**
* Creates a grid. * Creates a grid.
@@ -51,5 +51,5 @@ public interface IGridManager {
* @return a grid, or null if an error has occurred * @return a grid, or null if an error has occurred
*/ */
@Nullable @Nullable
Pair<IGrid, TileEntity> createGrid(ResourceLocation id, PlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot); Pair<IGrid, BlockEntity> createGrid(ResourceLocation id, Player player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot);
} }

View File

@@ -1,10 +1,10 @@
package com.refinedmods.refinedstorage.api.network.grid; package com.refinedmods.refinedstorage.api.network.grid;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.api.render.IElementDrawer; import com.refinedmods.refinedstorage.api.render.IElementDrawer;
import com.refinedmods.refinedstorage.api.util.IFilter; import com.refinedmods.refinedstorage.api.util.IFilter;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Font;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;
@@ -31,7 +31,7 @@ public interface IGridTab {
* @param screenHeight the screen height * @param screenHeight the screen height
* @param fontRenderer the font renderer * @param fontRenderer the font renderer
*/ */
void drawTooltip(MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, FontRenderer fontRenderer); void drawTooltip(PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, Font fontRenderer);
/** /**
* Draws the icon. * Draws the icon.
@@ -40,5 +40,5 @@ public interface IGridTab {
* @param x the x position * @param x the x position
* @param y the y position * @param y the y position
*/ */
void drawIcon(MatrixStack matrixStack, int x, int y, IElementDrawer<ItemStack> itemDrawer, IElementDrawer<FluidStack> fluidDrawer); void drawIcon(PoseStack matrixStack, int x, int y, IElementDrawer<ItemStack> itemDrawer, IElementDrawer<FluidStack> fluidDrawer);
} }

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network.grid.handler; package com.refinedmods.refinedstorage.api.network.grid.handler;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
@@ -18,7 +18,7 @@ public interface IFluidGridHandler {
* @param id the id of the fluid we're trying to extract, this id is the id from {@link StackListEntry} * @param id the id of the fluid we're trying to extract, this id is the id from {@link StackListEntry}
* @param shift true if shift click was used, false otherwise * @param shift true if shift click was used, false otherwise
*/ */
void onExtract(ServerPlayerEntity player, UUID id, boolean shift); void onExtract(ServerPlayer player, UUID id, boolean shift);
/** /**
* Called when a player tries to insert fluids in the grid. * Called when a player tries to insert fluids in the grid.
@@ -28,14 +28,14 @@ public interface IFluidGridHandler {
* @return the remainder, or an empty stack if there is no remainder * @return the remainder, or an empty stack if there is no remainder
*/ */
@Nonnull @Nonnull
ItemStack onInsert(ServerPlayerEntity player, ItemStack container); ItemStack onInsert(ServerPlayer player, ItemStack container);
/** /**
* Called when a player is trying to insert a fluid that it is holding in their hand in the GUI. * Called when a player is trying to insert a fluid that it is holding in their hand in the GUI.
* *
* @param player the player that is attempting the insert * @param player the player that is attempting the insert
*/ */
void onInsertHeldContainer(ServerPlayerEntity player); void onInsertHeldContainer(ServerPlayer player);
/** /**
* Called when a player requests the crafting preview window to be opened. * Called when a player requests the crafting preview window to be opened.
@@ -45,7 +45,7 @@ public interface IFluidGridHandler {
* @param quantity the amount of that item that we need a preview for * @param quantity the amount of that item that we need a preview for
* @param noPreview true if the crafting preview window shouldn't be shown, false otherwise * @param noPreview true if the crafting preview window shouldn't be shown, false otherwise
*/ */
void onCraftingPreviewRequested(ServerPlayerEntity player, UUID id, int quantity, boolean noPreview); void onCraftingPreviewRequested(ServerPlayer player, UUID id, int quantity, boolean noPreview);
/** /**
* Called when a player requested crafting for an item. * Called when a player requested crafting for an item.
@@ -54,5 +54,5 @@ public interface IFluidGridHandler {
* @param id the id of the fluid we're trying to extract, this id is the id from {@link StackListEntry} * @param id the id of the fluid we're trying to extract, this id is the id from {@link StackListEntry}
* @param quantity the amount of the item that has to be crafted * @param quantity the amount of the item that has to be crafted
*/ */
void onCraftingRequested(ServerPlayerEntity player, UUID id, int quantity); void onCraftingRequested(ServerPlayer player, UUID id, int quantity);
} }

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network.grid.handler; package com.refinedmods.refinedstorage.api.network.grid.handler;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -24,7 +24,7 @@ public interface IItemGridHandler {
* @param preferredSlot playerInventory slot to prefer when adding or -1 * @param preferredSlot playerInventory slot to prefer when adding or -1
* @param flags how we are extracting, see the flags in {@link IItemGridHandler} * @param flags how we are extracting, see the flags in {@link IItemGridHandler}
*/ */
void onExtract(ServerPlayerEntity player, ItemStack stack, int preferredSlot, int flags); void onExtract(ServerPlayer player, ItemStack stack, int preferredSlot, int flags);
/** /**
* Called when a player tries to extract an item from the grid. * Called when a player tries to extract an item from the grid.
@@ -34,7 +34,7 @@ public interface IItemGridHandler {
* @param preferredSlot playerInventory slot to prefer when adding or -1 * @param preferredSlot playerInventory slot to prefer when adding or -1
* @param flags how we are extracting, see the flags in {@link IItemGridHandler} * @param flags how we are extracting, see the flags in {@link IItemGridHandler}
*/ */
void onExtract(ServerPlayerEntity player, UUID id, int preferredSlot, int flags); void onExtract(ServerPlayer player, UUID id, int preferredSlot, int flags);
/** /**
* Called when a player tries to insert an item in the grid. * Called when a player tries to insert an item in the grid.
@@ -45,7 +45,7 @@ public interface IItemGridHandler {
* @return the remainder, or an empty stack if there is no remainder * @return the remainder, or an empty stack if there is no remainder
*/ */
@Nonnull @Nonnull
ItemStack onInsert(ServerPlayerEntity player, ItemStack stack, boolean single); ItemStack onInsert(ServerPlayer player, ItemStack stack, boolean single);
/** /**
* Called when a player is trying to insert an item that it is holding in their hand in the GUI. * Called when a player is trying to insert an item that it is holding in their hand in the GUI.
@@ -53,7 +53,7 @@ public interface IItemGridHandler {
* @param player the player that is attempting the insert * @param player the player that is attempting the insert
* @param single true if we are only inserting a single item, false otherwise * @param single true if we are only inserting a single item, false otherwise
*/ */
void onInsertHeldItem(ServerPlayerEntity player, boolean single); void onInsertHeldItem(ServerPlayer player, boolean single);
/** /**
* Called when a player requests the crafting preview window to be opened. * Called when a player requests the crafting preview window to be opened.
@@ -63,7 +63,7 @@ public interface IItemGridHandler {
* @param quantity the amount of that item that we need a preview for * @param quantity the amount of that item that we need a preview for
* @param noPreview true if the crafting preview window shouldn't be shown, false otherwise * @param noPreview true if the crafting preview window shouldn't be shown, false otherwise
*/ */
void onCraftingPreviewRequested(ServerPlayerEntity player, UUID id, int quantity, boolean noPreview); void onCraftingPreviewRequested(ServerPlayer player, UUID id, int quantity, boolean noPreview);
/** /**
* Called when a player requested crafting for an item. * Called when a player requested crafting for an item.
@@ -72,7 +72,7 @@ public interface IItemGridHandler {
* @param id the id of the item we're trying to extract, this id is the id from {@link StackListEntry} * @param id the id of the item we're trying to extract, this id is the id from {@link StackListEntry}
* @param quantity the amount of the item that has to be crafted * @param quantity the amount of the item that has to be crafted
*/ */
void onCraftingRequested(ServerPlayerEntity player, UUID id, int quantity); void onCraftingRequested(ServerPlayer player, UUID id, int quantity);
/** /**
* Called when a player wants to cancel a crafting task. * Called when a player wants to cancel a crafting task.
@@ -80,7 +80,7 @@ public interface IItemGridHandler {
* @param player the player that requested the cancel * @param player the player that requested the cancel
* @param id the task id, or null to cancel all tasks that are in the network currently * @param id the task id, or null to cancel all tasks that are in the network currently
*/ */
void onCraftingCancelRequested(ServerPlayerEntity player, @Nullable UUID id); void onCraftingCancelRequested(ServerPlayer player, @Nullable UUID id);
/** /**
* Called when a player shift or ctrl scrolls in the player inventory * Called when a player shift or ctrl scrolls in the player inventory
@@ -90,7 +90,7 @@ public interface IItemGridHandler {
* @param shift if true shift is pressed, if false ctrl is pressed * @param shift if true shift is pressed, if false ctrl is pressed
* @param up whether the player is scrolling up or down * @param up whether the player is scrolling up or down
*/ */
void onInventoryScroll(ServerPlayerEntity player, int slot, boolean shift, boolean up); void onInventoryScroll(ServerPlayer player, int slot, boolean shift, boolean up);
/** /**
* Called when a player shift or ctrl scrolls in the Grid View * Called when a player shift or ctrl scrolls in the Grid View
@@ -100,5 +100,5 @@ public interface IItemGridHandler {
* @param shift if true shift is pressed, if false ctrl is pressed * @param shift if true shift is pressed, if false ctrl is pressed
* @param up whether the player is scrolling up or down * @param up whether the player is scrolling up or down
*/ */
void onGridScroll(ServerPlayerEntity player, @Nullable UUID id, boolean shift, boolean up); void onGridScroll(ServerPlayer player, @Nullable UUID id, boolean shift, boolean up);
} }

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.network.item; package com.refinedmods.refinedstorage.api.network.item;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
/** /**
* Represents a network item (an item that is connected to the network somehow). * Represents a network item (an item that is connected to the network somehow).
@@ -12,7 +12,7 @@ public interface INetworkItem {
/** /**
* @return the player using the network item * @return the player using the network item
*/ */
PlayerEntity getPlayer(); Player getPlayer();
/** /**
* Called when the network item is being opened. * Called when the network item is being opened.

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network.item; package com.refinedmods.refinedstorage.api.network.item;
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot; import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -18,14 +18,14 @@ public interface INetworkItemManager {
* @param stack the stack that has been opened * @param stack the stack that has been opened
* @param slot the slot in the players inventory or curio slot, otherwise -1 * @param slot the slot in the players inventory or curio slot, otherwise -1
*/ */
void open(PlayerEntity player, ItemStack stack, PlayerSlot slot); void open(Player player, ItemStack stack, PlayerSlot slot);
/** /**
* Called when the player closes a network item. * Called when the player closes a network item.
* *
* @param player the player that closed the network item * @param player the player that closed the network item
*/ */
void close(PlayerEntity player); void close(Player player);
/** /**
* Returns a {@link INetworkItem} for a player. * Returns a {@link INetworkItem} for a player.
@@ -34,11 +34,11 @@ public interface INetworkItemManager {
* @return the {@link INetworkItem} that corresponds to a player, or null if the player isn't using a network item * @return the {@link INetworkItem} that corresponds to a player, or null if the player isn't using a network item
*/ */
@Nullable @Nullable
INetworkItem getItem(PlayerEntity player); INetworkItem getItem(Player player);
/** /**
* @param player the player * @param player the player
* @param energy energy to extract * @param energy energy to extract
*/ */
void drainEnergy(PlayerEntity player, int energy); void drainEnergy(Player player, int energy);
} }

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network.item; package com.refinedmods.refinedstorage.api.network.item;
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot; import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -20,5 +20,5 @@ public interface INetworkItemProvider {
* @return the network item * @return the network item
*/ */
@Nonnull @Nonnull
INetworkItem provide(INetworkItemManager handler, PlayerEntity player, ItemStack stack, PlayerSlot slot); INetworkItem provide(INetworkItemManager handler, Player player, ItemStack stack, PlayerSlot slot);
} }

View File

@@ -1,12 +1,12 @@
package com.refinedmods.refinedstorage.api.network.node; package com.refinedmods.refinedstorage.api.network.node;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import net.minecraft.item.ItemStack; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -70,7 +70,7 @@ public interface INetworkNode {
* @param tag the tag * @param tag the tag
* @return the written tag * @return the written tag
*/ */
CompoundNBT write(CompoundNBT tag); CompoundTag write(CompoundTag tag);
/** /**
* @return the position of this network node * @return the position of this network node
@@ -80,7 +80,7 @@ public interface INetworkNode {
/** /**
* @return the world of this network node * @return the world of this network node
*/ */
World getWorld(); Level getWorld();
/** /**
* Marks this node as dirty for saving. * Marks this node as dirty for saving.
@@ -108,14 +108,14 @@ public interface INetworkNode {
return canConduct(direction); return canConduct(direction);
} }
/**
* @param owner the owner
*/
void setOwner(@Nullable UUID owner);
/** /**
* @return the owner * @return the owner
*/ */
@Nullable @Nullable
UUID getOwner(); UUID getOwner();
/**
* @param owner the owner
*/
void setOwner(@Nullable UUID owner);
} }

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.network.node; package com.refinedmods.refinedstorage.api.network.node;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -19,5 +19,5 @@ public interface INetworkNodeFactory {
* @return the network node * @return the network node
*/ */
@Nonnull @Nonnull
INetworkNode create(CompoundNBT tag, World world, BlockPos pos); INetworkNode create(CompoundTag tag, Level world, BlockPos pos);
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.network.node; package com.refinedmods.refinedstorage.api.network.node;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.network.node; package com.refinedmods.refinedstorage.api.network.node;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.network.security; package com.refinedmods.refinedstorage.api.network.security;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.player.Player;
/** /**
* The security manager of a network. * The security manager of a network.
@@ -11,7 +11,7 @@ public interface ISecurityManager {
* @param player the player to check that permission for * @param player the player to check that permission for
* @return true if the player has the given permission, false otherwise * @return true if the player has the given permission, false otherwise
*/ */
boolean hasPermission(Permission permission, PlayerEntity player); boolean hasPermission(Permission permission, Player player);
/** /**
* Invalidates the security list. * Invalidates the security list.

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.render; package com.refinedmods.refinedstorage.api.render;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
/** /**
* This {@link FunctionalInterface} is used to define a draw/render function. * This {@link FunctionalInterface} is used to define a draw/render function.
@@ -16,5 +16,5 @@ public interface IElementDrawer<T> {
* @param y the y axis * @param y the y axis
* @param element the element type * @param element the element type
*/ */
void draw(MatrixStack matrixStack, int x, int y, T element); void draw(PoseStack matrixStack, int x, int y, T element);
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.render; package com.refinedmods.refinedstorage.api.render;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
/** /**

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.storage; package com.refinedmods.refinedstorage.api.storage;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.storage.disk; package com.refinedmods.refinedstorage.api.storage.disk;
import com.refinedmods.refinedstorage.api.storage.IStorage; import com.refinedmods.refinedstorage.api.storage.IStorage;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
@@ -36,7 +36,7 @@ public interface IStorageDisk<T> extends IStorage<T> {
/** /**
* Writes the storage to NBT. * Writes the storage to NBT.
*/ */
CompoundNBT writeToNbt(); CompoundTag writeToNbt();
/** /**
* @return the factory id as registered in {@link IStorageDiskRegistry} * @return the factory id as registered in {@link IStorageDiskRegistry}

View File

@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage.api.storage.disk; package com.refinedmods.refinedstorage.api.storage.disk;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
@@ -20,7 +20,7 @@ public interface IStorageDiskFactory<T> {
* @param tag the tag * @param tag the tag
* @return the storage disk * @return the storage disk
*/ */
IStorageDisk<T> createFromNbt(ServerWorld world, CompoundNBT tag); IStorageDisk<T> createFromNbt(ServerLevel world, CompoundTag tag);
/** /**
* Creates a storage disk item based on ID. * Creates a storage disk item based on ID.
@@ -39,5 +39,5 @@ public interface IStorageDiskFactory<T> {
* @param owner the owner, or null if no owner * @param owner the owner, or null if no owner
* @return the storage disk * @return the storage disk
*/ */
IStorageDisk<T> create(ServerWorld world, int capacity, @Nullable UUID owner); IStorageDisk<T> create(ServerLevel world, int capacity, @Nullable UUID owner);
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.storage.disk; package com.refinedmods.refinedstorage.api.storage.disk;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.storage.disk; package com.refinedmods.refinedstorage.api.storage.disk;
import com.refinedmods.refinedstorage.api.storage.StorageType; import com.refinedmods.refinedstorage.api.storage.StorageType;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import java.util.UUID; import java.util.UUID;

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.storage.disk; package com.refinedmods.refinedstorage.api.storage.disk;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.storage.externalstorage; package com.refinedmods.refinedstorage.api.storage.externalstorage;
import com.refinedmods.refinedstorage.api.storage.AccessType; import com.refinedmods.refinedstorage.api.storage.AccessType;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
/** /**

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.storage.externalstorage; package com.refinedmods.refinedstorage.api.storage.externalstorage;
import net.minecraft.tileentity.TileEntity; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.world.level.block.entity.BlockEntity;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -16,7 +16,7 @@ public interface IExternalStorageProvider<T> {
* @param direction the direction of the external storage * @param direction the direction of the external storage
* @return true if the provider can provide, false otherwise * @return true if the provider can provide, false otherwise
*/ */
boolean canProvide(TileEntity tile, Direction direction); boolean canProvide(BlockEntity tile, Direction direction);
/** /**
* @param context the context of the external storage * @param context the context of the external storage
@@ -25,7 +25,7 @@ public interface IExternalStorageProvider<T> {
* @return the external storage handler * @return the external storage handler
*/ */
@Nonnull @Nonnull
IExternalStorage<T> provide(IExternalStorageContext context, TileEntity tile, Direction direction); IExternalStorage<T> provide(IExternalStorageContext context, BlockEntity tile, Direction direction);
/** /**
* Returns the priority of this external storage provider. * Returns the priority of this external storage provider.

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.api.storage.tracker; package com.refinedmods.refinedstorage.api.storage.tracker;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.world.entity.player.Player;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -15,7 +15,7 @@ public interface IStorageTracker<T> {
* @param player player * @param player player
* @param stack the stack * @param stack the stack
*/ */
void changed(PlayerEntity player, T stack); void changed(Player player, T stack);
/** /**
* @param stack the stack * @param stack the stack
@@ -29,12 +29,12 @@ public interface IStorageTracker<T> {
* *
* @param nbt to read from * @param nbt to read from
*/ */
void readFromNbt(ListNBT nbt); void readFromNbt(ListTag nbt);
/** /**
* write data to nbt * write data to nbt
* *
* @return data as nbt * @return data as nbt
*/ */
ListNBT serializeNbt(); ListTag serializeNbt();
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.api.util; package com.refinedmods.refinedstorage.api.util;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@@ -41,12 +41,12 @@ import com.refinedmods.refinedstorage.apiimpl.util.FluidStackList;
import com.refinedmods.refinedstorage.apiimpl.util.ItemStackList; import com.refinedmods.refinedstorage.apiimpl.util.ItemStackList;
import com.refinedmods.refinedstorage.apiimpl.util.QuantityFormatter; import com.refinedmods.refinedstorage.apiimpl.util.QuantityFormatter;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.Tag;
import net.minecraft.nbt.INBT; import net.minecraft.server.level.ServerLevel;
import net.minecraft.nbt.ListNBT; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
@@ -59,7 +59,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class API implements IRSAPI { public class API implements IRSAPI {
private static final Logger LOGGER = LogManager.getLogger(API.class); private static final Logger LOGGER = LogManager.getLogger(API.class);
@@ -89,23 +88,23 @@ public class API implements IRSAPI {
List<ModFileScanData.AnnotationData> annotations = ModList.get().getAllScanData().stream() List<ModFileScanData.AnnotationData> annotations = ModList.get().getAllScanData().stream()
.map(ModFileScanData::getAnnotations) .map(ModFileScanData::getAnnotations)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.filter(a -> annotationType.equals(a.getAnnotationType())) .filter(a -> annotationType.equals(a.annotationType()))
.collect(Collectors.toList()); .toList();
LOGGER.info("Found {} RS API injection {}", annotations.size(), annotations.size() == 1 ? "point" : "points"); LOGGER.info("Found {} RS API injection {}", annotations.size(), annotations.size() == 1 ? "point" : "points");
for (ModFileScanData.AnnotationData annotation : annotations) { for (ModFileScanData.AnnotationData annotation : annotations) {
try { try {
Class<?> clazz = Class.forName(annotation.getClassType().getClassName()); Class<?> clazz = Class.forName(annotation.clazz().getClassName());
Field field = clazz.getField(annotation.getMemberName()); Field field = clazz.getField(annotation.memberName());
if (field.getType() == IRSAPI.class) { if (field.getType() == IRSAPI.class) {
field.set(null, INSTANCE); field.set(null, INSTANCE);
} }
LOGGER.info("Injected RS API in {} {}", annotation.getClassType().getClassName(), annotation.getMemberName()); LOGGER.info("Injected RS API in {} {}", annotation.clazz().getClassName(), annotation.memberName());
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException e) { } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException e) {
LOGGER.error("Could not inject RS API in {} {}", annotation.getClassType().getClassName(), annotation.getMemberName(), e); LOGGER.error("Could not inject RS API in {} {}", annotation.clazz().getClassName(), annotation.memberName(), e);
} }
} }
} }
@@ -129,13 +128,21 @@ public class API implements IRSAPI {
} }
@Override @Override
public INetworkNodeManager getNetworkNodeManager(ServerWorld world) { public INetworkNodeManager getNetworkNodeManager(ServerLevel world) {
return world.getDataStorage().computeIfAbsent(() -> new NetworkNodeManager(NetworkNodeManager.NAME, world), NetworkNodeManager.NAME); return world.getDataStorage().computeIfAbsent(tag -> {
NetworkNodeManager manager = new NetworkNodeManager( world);
manager.load(tag);
return manager;
}, () -> new NetworkNodeManager(world), NetworkNodeManager.NAME);
} }
@Override @Override
public INetworkManager getNetworkManager(ServerWorld world) { public INetworkManager getNetworkManager(ServerLevel world) {
return world.getDataStorage().computeIfAbsent(() -> new NetworkManager(NetworkManager.NAME, world), NetworkManager.NAME); return world.getDataStorage().computeIfAbsent(tag -> {
NetworkManager manager = new NetworkManager(world);
manager.load(tag);
return manager;
}, () -> new NetworkManager(world), NetworkManager.NAME);
} }
@Override @Override
@@ -194,10 +201,14 @@ public class API implements IRSAPI {
@Nonnull @Nonnull
@Override @Override
public IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld) { public IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld) {
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld ServerLevel world = anyWorld.getServer().overworld(); // Get the overworld
return world.getDataStorage().computeIfAbsent(() -> new StorageDiskManager(StorageDiskManager.NAME, world), StorageDiskManager.NAME); return world.getDataStorage().computeIfAbsent(tag -> {
StorageDiskManager manager = new StorageDiskManager(world);
manager.load(tag);
return manager;
}, () -> new StorageDiskManager( world), StorageDiskManager.NAME);
} }
@Nonnull @Nonnull
@@ -208,10 +219,14 @@ public class API implements IRSAPI {
@Nonnull @Nonnull
@Override @Override
public IStorageTrackerManager getStorageTrackerManager(ServerWorld anyWorld) { public IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld) {
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld ServerLevel world = anyWorld.getServer().overworld(); // Get the overworld
return world.getDataStorage().computeIfAbsent(() -> new StorageTrackerManager(StorageTrackerManager.NAME), StorageTrackerManager.NAME); return world.getDataStorage().computeIfAbsent(tag -> {
StorageTrackerManager manager = new StorageTrackerManager();
manager.load(tag);
return manager;
}, StorageTrackerManager::new, StorageTrackerManager.NAME);
} }
@Override @Override
@@ -228,7 +243,7 @@ public class API implements IRSAPI {
@Override @Override
@Nonnull @Nonnull
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity, @Nullable PlayerEntity owner) { public IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel world, int capacity, @Nullable Player owner) {
if (world == null) { if (world == null) {
throw new IllegalArgumentException("World cannot be null"); throw new IllegalArgumentException("World cannot be null");
} }
@@ -238,7 +253,7 @@ public class API implements IRSAPI {
@Override @Override
@Nonnull @Nonnull
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity, @Nullable PlayerEntity owner) { public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel world, int capacity, @Nullable Player owner) {
if (world == null) { if (world == null) {
throw new IllegalArgumentException("World cannot be null"); throw new IllegalArgumentException("World cannot be null");
} }
@@ -257,7 +272,7 @@ public class API implements IRSAPI {
} }
@Override @Override
public ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException { public ICraftingRequestInfo createCraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException {
return new CraftingRequestInfo(tag); return new CraftingRequestInfo(tag);
} }
@@ -282,11 +297,11 @@ public class API implements IRSAPI {
return result; return result;
} }
private int getHashCode(INBT tag, int result) { private int getHashCode(Tag tag, int result) {
if (tag instanceof CompoundNBT) { if (tag instanceof CompoundTag) {
result = getHashCode((CompoundNBT) tag, result); result = getHashCode((CompoundTag) tag, result);
} else if (tag instanceof ListNBT) { } else if (tag instanceof ListTag) {
result = getHashCode((ListNBT) tag, result); result = getHashCode((ListTag) tag, result);
} else { } else {
result = 31 * result + tag.hashCode(); result = 31 * result + tag.hashCode();
} }
@@ -294,7 +309,7 @@ public class API implements IRSAPI {
return result; return result;
} }
private int getHashCode(CompoundNBT tag, int result) { private int getHashCode(CompoundTag tag, int result) {
for (String key : tag.getAllKeys()) { for (String key : tag.getAllKeys()) {
result = 31 * result + key.hashCode(); result = 31 * result + key.hashCode();
result = getHashCode(tag.get(key), result); result = getHashCode(tag.get(key), result);
@@ -303,8 +318,8 @@ public class API implements IRSAPI {
return result; return result;
} }
private int getHashCode(ListNBT tag, int result) { private int getHashCode(ListTag tag, int result) {
for (INBT tagItem : tag) { for (Tag tagItem : tag) {
result = getHashCode(tagItem, result); result = getHashCode(tagItem, result);
} }

View File

@@ -1,10 +1,10 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting; package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringNBT; import net.minecraft.nbt.StringTag;
import net.minecraft.util.ResourceLocation; import net.minecraft.nbt.Tag;
import net.minecraftforge.common.util.Constants; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@@ -15,12 +15,10 @@ import java.util.Set;
public class AllowedTagList { public class AllowedTagList {
private static final String NBT_ALLOWED_ITEM_TAGS = "AllowedItemTags"; private static final String NBT_ALLOWED_ITEM_TAGS = "AllowedItemTags";
private static final String NBT_ALLOWED_FLUID_TAGS = "AllowedFluidTags"; private static final String NBT_ALLOWED_FLUID_TAGS = "AllowedFluidTags";
private List<Set<ResourceLocation>> allowedItemTags = new ArrayList<>();
private List<Set<ResourceLocation>> allowedFluidTags = new ArrayList<>();
@Nullable @Nullable
private final Runnable listener; private final Runnable listener;
private List<Set<ResourceLocation>> allowedItemTags = new ArrayList<>();
private List<Set<ResourceLocation>> allowedFluidTags = new ArrayList<>();
public AllowedTagList(@Nullable Runnable listener, int size) { public AllowedTagList(@Nullable Runnable listener, int size) {
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
@@ -31,8 +29,8 @@ public class AllowedTagList {
this.listener = listener; this.listener = listener;
} }
public CompoundNBT writeToNbt() { public CompoundTag writeToNbt() {
CompoundNBT tag = new CompoundNBT(); CompoundTag tag = new CompoundTag();
tag.put(NBT_ALLOWED_ITEM_TAGS, getList(allowedItemTags)); tag.put(NBT_ALLOWED_ITEM_TAGS, getList(allowedItemTags));
tag.put(NBT_ALLOWED_FLUID_TAGS, getList(allowedFluidTags)); tag.put(NBT_ALLOWED_FLUID_TAGS, getList(allowedFluidTags));
@@ -40,23 +38,23 @@ public class AllowedTagList {
return tag; return tag;
} }
public void readFromNbt(CompoundNBT tag) { public void readFromNbt(CompoundTag tag) {
if (tag.contains(NBT_ALLOWED_ITEM_TAGS)) { if (tag.contains(NBT_ALLOWED_ITEM_TAGS)) {
applyList(allowedItemTags, tag.getList(NBT_ALLOWED_ITEM_TAGS, Constants.NBT.TAG_LIST)); applyList(allowedItemTags, tag.getList(NBT_ALLOWED_ITEM_TAGS, Tag.TAG_LIST));
} }
if (tag.contains(NBT_ALLOWED_FLUID_TAGS)) { if (tag.contains(NBT_ALLOWED_FLUID_TAGS)) {
applyList(allowedFluidTags, tag.getList(NBT_ALLOWED_FLUID_TAGS, Constants.NBT.TAG_LIST)); applyList(allowedFluidTags, tag.getList(NBT_ALLOWED_FLUID_TAGS, Tag.TAG_LIST));
} }
} }
private ListNBT getList(List<Set<ResourceLocation>> tagsPerSlot) { private ListTag getList(List<Set<ResourceLocation>> tagsPerSlot) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (Set<ResourceLocation> tags : tagsPerSlot) { for (Set<ResourceLocation> tags : tagsPerSlot) {
ListNBT subList = new ListNBT(); ListTag subList = new ListTag();
tags.forEach(t -> subList.add(StringNBT.valueOf(t.toString()))); tags.forEach(t -> subList.add(StringTag.valueOf(t.toString())));
list.add(subList); list.add(subList);
} }
@@ -64,9 +62,9 @@ public class AllowedTagList {
return list; return list;
} }
private void applyList(List<Set<ResourceLocation>> list, ListNBT tagList) { private void applyList(List<Set<ResourceLocation>> list, ListTag tagList) {
for (int i = 0; i < tagList.size(); ++i) { for (int i = 0; i < tagList.size(); ++i) {
ListNBT subList = tagList.getList(i); ListTag subList = tagList.getList(i);
for (int j = 0; j < subList.size(); ++j) { for (int j = 0; j < subList.size(); ++j) {
list.get(i).add(new ResourceLocation(subList.getString(j))); list.get(i).add(new ResourceLocation(subList.getString(j)));
@@ -78,16 +76,16 @@ public class AllowedTagList {
return allowedItemTags; return allowedItemTags;
} }
public List<Set<ResourceLocation>> getAllowedFluidTags() {
return allowedFluidTags;
}
public void setAllowedItemTags(List<Set<ResourceLocation>> allowedItemTags) { public void setAllowedItemTags(List<Set<ResourceLocation>> allowedItemTags) {
this.allowedItemTags = allowedItemTags; this.allowedItemTags = allowedItemTags;
notifyListener(); notifyListener();
} }
public List<Set<ResourceLocation>> getAllowedFluidTags() {
return allowedFluidTags;
}
public void setAllowedFluidTags(List<Set<ResourceLocation>> allowedFluidTags) { public void setAllowedFluidTags(List<Set<ResourceLocation>> allowedFluidTags) {
this.allowedFluidTags = allowedFluidTags; this.allowedFluidTags = allowedFluidTags;

View File

@@ -10,12 +10,12 @@ import com.refinedmods.refinedstorage.api.network.INetworkNodeGraphEntry;
import com.refinedmods.refinedstorage.api.util.IComparer; import com.refinedmods.refinedstorage.api.util.IComparer;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CalculationResult; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CalculationResult;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.network.chat.Component;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@@ -36,7 +36,7 @@ public class CraftingManager implements ICraftingManager {
private final INetwork network; private final INetwork network;
private final Map<ITextComponent, List<IItemHandlerModifiable>> containerInventories = new LinkedHashMap<>(); private final Map<Component, List<IItemHandlerModifiable>> containerInventories = new LinkedHashMap<>();
private final Map<ICraftingPattern, Set<ICraftingPatternContainer>> patternToContainer = new HashMap<>(); private final Map<ICraftingPattern, Set<ICraftingPatternContainer>> patternToContainer = new HashMap<>();
private final List<ICraftingPattern> patterns = new ArrayList<>(); private final List<ICraftingPattern> patterns = new ArrayList<>();
@@ -44,11 +44,9 @@ public class CraftingManager implements ICraftingManager {
private final Map<UUID, ICraftingTask> tasks = new LinkedHashMap<>(); private final Map<UUID, ICraftingTask> tasks = new LinkedHashMap<>();
private final List<ICraftingTask> tasksToAdd = new ArrayList<>(); private final List<ICraftingTask> tasksToAdd = new ArrayList<>();
private final List<UUID> tasksToCancel = new ArrayList<>(); private final List<UUID> tasksToCancel = new ArrayList<>();
private ListNBT tasksToRead;
private final Map<Object, Long> throttledRequesters = new HashMap<>(); private final Map<Object, Long> throttledRequesters = new HashMap<>();
private final Set<ICraftingMonitorListener> listeners = new HashSet<>(); private final Set<ICraftingMonitorListener> listeners = new HashSet<>();
private ListTag tasksToRead;
public CraftingManager(INetwork network) { public CraftingManager(INetwork network) {
this.network = network; this.network = network;
@@ -66,7 +64,7 @@ public class CraftingManager implements ICraftingManager {
} }
@Override @Override
public Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers() { public Map<Component, List<IItemHandlerModifiable>> getNamedContainers() {
return containerInventories; return containerInventories;
} }
@@ -179,10 +177,10 @@ public class CraftingManager implements ICraftingManager {
private void readTasks() { private void readTasks() {
for (int i = 0; i < tasksToRead.size(); ++i) { for (int i = 0; i < tasksToRead.size(); ++i) {
CompoundNBT taskTag = tasksToRead.getCompound(i); CompoundTag taskTag = tasksToRead.getCompound(i);
ResourceLocation taskType = new ResourceLocation(taskTag.getString(NBT_TASK_TYPE)); ResourceLocation taskType = new ResourceLocation(taskTag.getString(NBT_TASK_TYPE));
CompoundNBT taskData = taskTag.getCompound(NBT_TASK_DATA); CompoundTag taskData = taskTag.getCompound(NBT_TASK_DATA);
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(taskType); ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(taskType);
if (factory != null) { if (factory != null) {
@@ -200,19 +198,19 @@ public class CraftingManager implements ICraftingManager {
} }
@Override @Override
public void readFromNbt(CompoundNBT tag) { public void readFromNbt(CompoundTag tag) {
this.tasksToRead = tag.getList(NBT_TASKS, Constants.NBT.TAG_COMPOUND); this.tasksToRead = tag.getList(NBT_TASKS, Tag.TAG_COMPOUND);
} }
@Override @Override
public CompoundNBT writeToNbt(CompoundNBT tag) { public CompoundTag writeToNbt(CompoundTag tag) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (ICraftingTask task : tasks.values()) { for (ICraftingTask task : tasks.values()) {
CompoundNBT taskTag = new CompoundNBT(); CompoundTag taskTag = new CompoundTag();
taskTag.putString(NBT_TASK_TYPE, task.getPattern().getCraftingTaskFactoryId().toString()); taskTag.putString(NBT_TASK_TYPE, task.getPattern().getCraftingTaskFactoryId().toString());
taskTag.put(NBT_TASK_DATA, task.writeToNbt(new CompoundNBT())); taskTag.put(NBT_TASK_DATA, task.writeToNbt(new CompoundTag()));
list.add(taskTag); list.add(taskTag);
} }

View File

@@ -5,14 +5,14 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer
import com.refinedmods.refinedstorage.api.util.IComparer; import com.refinedmods.refinedstorage.api.util.IComparer;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.CraftingTaskFactory; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.CraftingTaskFactory;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.NonNullList;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.network.chat.Component;
import net.minecraft.inventory.container.Container; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.util.NonNullList; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -23,13 +23,13 @@ public class CraftingPattern implements ICraftingPattern {
private final boolean processing; private final boolean processing;
private final boolean exact; private final boolean exact;
@Nullable @Nullable
private final ICraftingRecipe recipe; private final CraftingRecipe recipe;
private final CraftingPatternInputs inputs; private final CraftingPatternInputs inputs;
private final CraftingPatternOutputs outputs; private final CraftingPatternOutputs outputs;
@Nullable @Nullable
private final AllowedTagList allowedTagList; private final AllowedTagList allowedTagList;
public CraftingPattern(CraftingPatternContext context, boolean processing, boolean exact, @Nullable ICraftingRecipe recipe, CraftingPatternInputs inputs, CraftingPatternOutputs outputs, @Nullable AllowedTagList allowedTagList) { public CraftingPattern(CraftingPatternContext context, boolean processing, boolean exact, @Nullable CraftingRecipe recipe, CraftingPatternInputs inputs, CraftingPatternOutputs outputs, @Nullable AllowedTagList allowedTagList) {
this.context = context; this.context = context;
this.processing = processing; this.processing = processing;
this.exact = exact; this.exact = exact;
@@ -61,7 +61,7 @@ public class CraftingPattern implements ICraftingPattern {
@Nullable @Nullable
@Override @Override
public ITextComponent getErrorMessage() { public Component getErrorMessage() {
return null; return null;
} }
@@ -89,7 +89,7 @@ public class CraftingPattern implements ICraftingPattern {
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")"); throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")");
} }
CraftingInventory inv = new DummyCraftingInventory(); CraftingContainer inv = new DummyCraftingInventory();
for (int i = 0; i < took.size(); ++i) { for (int i = 0; i < took.size(); ++i) {
inv.setItem(i, took.get(i)); inv.setItem(i, took.get(i));
@@ -122,7 +122,7 @@ public class CraftingPattern implements ICraftingPattern {
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")"); throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")");
} }
CraftingInventory inv = new DummyCraftingInventory(); CraftingContainer inv = new DummyCraftingInventory();
for (int i = 0; i < took.size(); ++i) { for (int i = 0; i < took.size(); ++i) {
inv.setItem(i, took.get(i)); inv.setItem(i, took.get(i));
@@ -265,11 +265,11 @@ public class CraftingPattern implements ICraftingPattern {
return result; return result;
} }
public static class DummyCraftingInventory extends CraftingInventory { public static class DummyCraftingInventory extends CraftingContainer {
public DummyCraftingInventory() { public DummyCraftingInventory() {
super(new Container(null, 0) { super(new AbstractContainerMenu(null, 0) {
@Override @Override
public boolean stillValid(PlayerEntity player) { public boolean stillValid(Player player) {
return true; return true;
} }
}, 3, 3); }, 3, 3);

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting; package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class CraftingPatternContext { public class CraftingPatternContext {
private final ICraftingPatternContainer container; private final ICraftingPatternContainer container;

View File

@@ -4,18 +4,18 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode; import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
import com.refinedmods.refinedstorage.item.PatternItem; import com.refinedmods.refinedstorage.item.PatternItem;
import net.minecraft.fluid.Fluid; import net.minecraft.core.NonNullList;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.item.Item; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.util.NonNullList; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.Item;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -24,7 +24,7 @@ import java.util.*;
public class CraftingPatternFactory { public class CraftingPatternFactory {
public static final CraftingPatternFactory INSTANCE = new CraftingPatternFactory(); public static final CraftingPatternFactory INSTANCE = new CraftingPatternFactory();
public ICraftingPattern create(World world, ICraftingPatternContainer container, ItemStack stack) { public ICraftingPattern create(Level world, ICraftingPatternContainer container, ItemStack stack) {
CraftingPatternContext context = new CraftingPatternContext(container, stack); CraftingPatternContext context = new CraftingPatternContext(container, stack);
boolean processing = PatternItem.isProcessing(stack); boolean processing = PatternItem.isProcessing(stack);
@@ -36,7 +36,7 @@ public class CraftingPatternFactory {
NonNullList<ItemStack> byproducts = NonNullList.create(); NonNullList<ItemStack> byproducts = NonNullList.create();
List<NonNullList<FluidStack>> fluidInputs = new ArrayList<>(); List<NonNullList<FluidStack>> fluidInputs = new ArrayList<>();
NonNullList<FluidStack> fluidOutputs = NonNullList.create(); NonNullList<FluidStack> fluidOutputs = NonNullList.create();
ICraftingRecipe recipe = null; CraftingRecipe recipe = null;
try { try {
if (processing) { if (processing) {
@@ -46,16 +46,16 @@ public class CraftingPatternFactory {
} }
if (outputs.isEmpty() && fluidOutputs.isEmpty()) { if (outputs.isEmpty() && fluidOutputs.isEmpty()) {
throw new CraftingPatternFactoryException(new TranslationTextComponent("misc.refinedstorage.pattern.error.processing_no_outputs")); throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.processing_no_outputs"));
} }
} else { } else {
CraftingInventory inv = new CraftingPattern.DummyCraftingInventory(); CraftingContainer inv = new CraftingPattern.DummyCraftingInventory();
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
fillCraftingInputs(inv, stack, inputs, i); fillCraftingInputs(inv, stack, inputs, i);
} }
Optional<ICraftingRecipe> foundRecipe = world.getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, inv, world); Optional<CraftingRecipe> foundRecipe = world.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inv, world);
if (foundRecipe.isPresent()) { if (foundRecipe.isPresent()) {
recipe = foundRecipe.get(); recipe = foundRecipe.get();
@@ -70,10 +70,10 @@ public class CraftingPatternFactory {
modifyCraftingInputsToUseAlternatives(recipe, inputs); modifyCraftingInputsToUseAlternatives(recipe, inputs);
} }
} else { } else {
throw new CraftingPatternFactoryException(new TranslationTextComponent("misc.refinedstorage.pattern.error.no_output")); throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.no_output"));
} }
} else { } else {
throw new CraftingPatternFactoryException(new TranslationTextComponent("misc.refinedstorage.pattern.error.recipe_does_not_exist")); throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.recipe_does_not_exist"));
} }
} }
} catch (CraftingPatternFactoryException e) { } catch (CraftingPatternFactoryException e) {
@@ -108,7 +108,7 @@ public class CraftingPatternFactory {
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) { for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
if (!tagsOfItem.contains(declaredAllowedTag)) { if (!tagsOfItem.contains(declaredAllowedTag)) {
throw new CraftingPatternFactoryException( throw new CraftingPatternFactoryException(
new TranslationTextComponent( new TranslatableComponent(
"misc.refinedstorage.pattern.error.tag_no_longer_applicable", "misc.refinedstorage.pattern.error.tag_no_longer_applicable",
declaredAllowedTag.toString(), declaredAllowedTag.toString(),
input.getHoverName() input.getHoverName()
@@ -147,7 +147,7 @@ public class CraftingPatternFactory {
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) { for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
if (!tagsOfFluid.contains(declaredAllowedTag)) { if (!tagsOfFluid.contains(declaredAllowedTag)) {
throw new CraftingPatternFactoryException( throw new CraftingPatternFactoryException(
new TranslationTextComponent( new TranslatableComponent(
"misc.refinedstorage.pattern.error.tag_no_longer_applicable", "misc.refinedstorage.pattern.error.tag_no_longer_applicable",
declaredAllowedTag.toString(), declaredAllowedTag.toString(),
input.getDisplayName() input.getDisplayName()
@@ -170,7 +170,7 @@ public class CraftingPatternFactory {
} }
} }
private void fillCraftingInputs(CraftingInventory inv, ItemStack stack, List<NonNullList<ItemStack>> inputs, int i) { private void fillCraftingInputs(CraftingContainer inv, ItemStack stack, List<NonNullList<ItemStack>> inputs, int i) {
ItemStack input = PatternItem.getInputSlot(stack, i); ItemStack input = PatternItem.getInputSlot(stack, i);
inputs.add(input.isEmpty() ? NonNullList.create() : NonNullList.of(ItemStack.EMPTY, input)); inputs.add(input.isEmpty() ? NonNullList.create() : NonNullList.of(ItemStack.EMPTY, input));
@@ -178,7 +178,7 @@ public class CraftingPatternFactory {
inv.setItem(i, input); inv.setItem(i, input);
} }
private void modifyCraftingInputsToUseAlternatives(ICraftingRecipe recipe, List<NonNullList<ItemStack>> inputs) { private void modifyCraftingInputsToUseAlternatives(CraftingRecipe recipe, List<NonNullList<ItemStack>> inputs) {
if (!recipe.getIngredients().isEmpty()) { if (!recipe.getIngredients().isEmpty()) {
inputs.clear(); inputs.clear();

View File

@@ -1,15 +1,15 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting; package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import net.minecraft.util.text.ITextComponent; import net.minecraft.network.chat.Component;
public class CraftingPatternFactoryException extends Exception { public class CraftingPatternFactoryException extends Exception {
private final transient ITextComponent errorMessage; private final transient Component errorMessage;
public CraftingPatternFactoryException(ITextComponent errorMessage) { public CraftingPatternFactoryException(Component errorMessage) {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
public ITextComponent getErrorMessage() { public Component getErrorMessage() {
return errorMessage; return errorMessage;
} }
} }

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting; package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;

View File

@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting; package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class CraftingPatternOutputs { public class CraftingPatternOutputs {

View File

@@ -2,10 +2,10 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.network.chat.Component;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -15,9 +15,9 @@ public class InvalidCraftingPattern implements ICraftingPattern {
private static final String EXCEPTION_MESSAGE = "Crafting pattern is invalid"; private static final String EXCEPTION_MESSAGE = "Crafting pattern is invalid";
private final CraftingPatternContext context; private final CraftingPatternContext context;
private final ITextComponent errorMessage; private final Component errorMessage;
public InvalidCraftingPattern(CraftingPatternContext context, ITextComponent errorMessage) { public InvalidCraftingPattern(CraftingPatternContext context, Component errorMessage) {
this.context = context; this.context = context;
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
@@ -39,7 +39,7 @@ public class InvalidCraftingPattern implements ICraftingPattern {
@Nullable @Nullable
@Override @Override
public ITextComponent getErrorMessage() { public Component getErrorMessage() {
return errorMessage; return errorMessage;
} }

View File

@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import java.util.*; import java.util.*;

View File

@@ -2,8 +2,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementRegistry;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;
@@ -11,16 +11,16 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
public class CraftingMonitorElementRegistry implements ICraftingMonitorElementRegistry { public class CraftingMonitorElementRegistry implements ICraftingMonitorElementRegistry {
private final Map<ResourceLocation, Function<PacketBuffer, ICraftingMonitorElement>> registry = new HashMap<>(); private final Map<ResourceLocation, Function<FriendlyByteBuf, ICraftingMonitorElement>> registry = new HashMap<>();
@Override @Override
public void add(ResourceLocation id, Function<PacketBuffer, ICraftingMonitorElement> factory) { public void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingMonitorElement> factory) {
registry.put(id, factory); registry.put(id, factory);
} }
@Nullable @Nullable
@Override @Override
public Function<PacketBuffer, ICraftingMonitorElement> get(ResourceLocation id) { public Function<FriendlyByteBuf, ICraftingMonitorElement> get(ResourceLocation id) {
return registry.get(id); return registry.get(id);
} }
} }

View File

@@ -1,15 +1,15 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor; package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.render.Styles; import com.refinedmods.refinedstorage.render.Styles;
import com.refinedmods.refinedstorage.util.PacketBufferUtils; import com.refinedmods.refinedstorage.util.PacketBufferUtils;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.ITextComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@@ -26,9 +26,19 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
this.message = message; this.message = message;
} }
public static ErrorCraftingMonitorElement read(FriendlyByteBuf buf) {
ResourceLocation id = buf.readResourceLocation();
String message = PacketBufferUtils.readString(buf);
return new ErrorCraftingMonitorElement(
API.instance().getCraftingMonitorElementRegistry().get(id).apply(buf),
message
);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
base.draw(matrixStack, x, y, drawers); base.draw(matrixStack, x, y, drawers);
drawers.getErrorDrawer().draw(matrixStack, x, y, null); drawers.getErrorDrawer().draw(matrixStack, x, y, null);
@@ -36,9 +46,9 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
@Nullable @Nullable
@Override @Override
public List<ITextComponent> getTooltip() { public List<Component> getTooltip() {
List<ITextComponent> items = new ArrayList<>(base.getTooltip()); List<Component> items = new ArrayList<>(base.getTooltip());
items.add(new TranslationTextComponent(message).setStyle(Styles.RED)); items.add(new TranslatableComponent(message).setStyle(Styles.RED));
return items; return items;
} }
@@ -53,23 +63,13 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
} }
@Override @Override
public void write(PacketBuffer buf) { public void write(FriendlyByteBuf buf) {
buf.writeResourceLocation(base.getId()); buf.writeResourceLocation(base.getId());
buf.writeUtf(message); buf.writeUtf(message);
base.write(buf); base.write(buf);
} }
public static ErrorCraftingMonitorElement read(PacketBuffer buf) {
ResourceLocation id = buf.readResourceLocation();
String message = PacketBufferUtils.readString(buf);
return new ErrorCraftingMonitorElement(
API.instance().getCraftingMonitorElementRegistry().get(id).apply(buf),
message
);
}
@Override @Override
public boolean merge(ICraftingMonitorElement element) { public boolean merge(ICraftingMonitorElement element) {
return elementHashCode() == element.elementHashCode() && base.merge(((ErrorCraftingMonitorElement) element).base); return elementHashCode() == element.elementHashCode() && base.merge(((ErrorCraftingMonitorElement) element).base);

View File

@@ -1,16 +1,16 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor; package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.RS; import com.refinedmods.refinedstorage.RS;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.util.RenderUtils; import com.refinedmods.refinedstorage.util.RenderUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.ITextComponent; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@@ -20,13 +20,11 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class FluidCraftingMonitorElement implements ICraftingMonitorElement { public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid");
private static final int COLOR_PROCESSING = 0xFFD9EDF7; private static final int COLOR_PROCESSING = 0xFFD9EDF7;
private static final int COLOR_MISSING = 0xFFF2DEDE; private static final int COLOR_MISSING = 0xFFF2DEDE;
private static final int COLOR_SCHEDULED = 0xFFE8E5CA; private static final int COLOR_SCHEDULED = 0xFFE8E5CA;
private static final int COLOR_CRAFTING = 0xFFADDBC6; private static final int COLOR_CRAFTING = 0xFFADDBC6;
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid");
private final FluidStack stack; private final FluidStack stack;
private int stored; private int stored;
private int missing; private int missing;
@@ -43,9 +41,20 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
this.crafting = crafting; this.crafting = crafting;
} }
public static FluidCraftingMonitorElement read(FriendlyByteBuf buf) {
return new FluidCraftingMonitorElement(
FluidStack.readFromPacket(buf),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt()
);
}
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
if (missing > 0) { if (missing > 0) {
drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING); drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING);
} else if (processing > 0) { } else if (processing > 0) {
@@ -108,12 +117,12 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
@Nullable @Nullable
@Override @Override
public List<ITextComponent> getTooltip() { public List<Component> getTooltip() {
return Collections.singletonList(stack.getFluid().getAttributes().getDisplayName(stack)); return Collections.singletonList(stack.getFluid().getAttributes().getDisplayName(stack));
} }
@Override @Override
public void write(PacketBuffer buf) { public void write(FriendlyByteBuf buf) {
stack.writeToPacket(buf); stack.writeToPacket(buf);
buf.writeInt(stored); buf.writeInt(stored);
buf.writeInt(missing); buf.writeInt(missing);
@@ -122,17 +131,6 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
buf.writeInt(crafting); buf.writeInt(crafting);
} }
public static FluidCraftingMonitorElement read(PacketBuffer buf) {
return new FluidCraftingMonitorElement(
FluidStack.readFromPacket(buf),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt()
);
}
@Override @Override
public boolean merge(ICraftingMonitorElement element) { public boolean merge(ICraftingMonitorElement element) {
if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) { if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) {
@@ -170,6 +168,10 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
this.stack = stack; this.stack = stack;
} }
public static FluidCraftingMonitorElement.Builder forStack(FluidStack stack) {
return new FluidCraftingMonitorElement.Builder(stack);
}
public FluidCraftingMonitorElement.Builder stored(int stored) { public FluidCraftingMonitorElement.Builder stored(int stored) {
this.stored = stored; this.stored = stored;
return this; return this;
@@ -198,9 +200,5 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
public FluidCraftingMonitorElement build() { public FluidCraftingMonitorElement build() {
return new FluidCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting); return new FluidCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting);
} }
public static FluidCraftingMonitorElement.Builder forStack(FluidStack stack) {
return new FluidCraftingMonitorElement.Builder(stack);
}
} }
} }

View File

@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor; package com.refinedmods.refinedstorage.apiimpl.autocrafting.craftingmonitor;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.RS; import com.refinedmods.refinedstorage.RS;
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement; import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
@@ -8,11 +8,11 @@ import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.util.RenderUtils; import com.refinedmods.refinedstorage.util.RenderUtils;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.item.ItemStack; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.chat.Component;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -20,13 +20,11 @@ import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemCraftingMonitorElement implements ICraftingMonitorElement { public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item");
private static final int COLOR_PROCESSING = 0xFFD9EDF7; private static final int COLOR_PROCESSING = 0xFFD9EDF7;
private static final int COLOR_MISSING = 0xFFF2DEDE; private static final int COLOR_MISSING = 0xFFF2DEDE;
private static final int COLOR_SCHEDULED = 0xFFE8E5CA; private static final int COLOR_SCHEDULED = 0xFFE8E5CA;
private static final int COLOR_CRAFTING = 0xFFADDBC6; private static final int COLOR_CRAFTING = 0xFFADDBC6;
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item");
private final ItemStack stack; private final ItemStack stack;
private int stored; private int stored;
private int missing; private int missing;
@@ -43,9 +41,20 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
this.crafting = crafting; this.crafting = crafting;
} }
public static ItemCraftingMonitorElement read(FriendlyByteBuf buf) {
return new ItemCraftingMonitorElement(
StackUtils.readItemStack(buf),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt()
);
}
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
if (missing > 0) { if (missing > 0) {
drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING); drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING);
} else if (processing > 0) { } else if (processing > 0) {
@@ -108,12 +117,12 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
@Nullable @Nullable
@Override @Override
public List<ITextComponent> getTooltip() { public List<Component> getTooltip() {
return RenderUtils.getTooltipFromItem(this.stack); return RenderUtils.getTooltipFromItem(this.stack);
} }
@Override @Override
public void write(PacketBuffer buf) { public void write(FriendlyByteBuf buf) {
StackUtils.writeItemStack(buf, stack); StackUtils.writeItemStack(buf, stack);
buf.writeInt(stored); buf.writeInt(stored);
buf.writeInt(missing); buf.writeInt(missing);
@@ -122,17 +131,6 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
buf.writeInt(crafting); buf.writeInt(crafting);
} }
public static ItemCraftingMonitorElement read(PacketBuffer buf) {
return new ItemCraftingMonitorElement(
StackUtils.readItemStack(buf),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt(),
buf.readInt()
);
}
@Override @Override
public boolean merge(ICraftingMonitorElement element) { public boolean merge(ICraftingMonitorElement element) {
if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) { if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) {
@@ -170,6 +168,10 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
this.stack = stack; this.stack = stack;
} }
public static Builder forStack(ItemStack stack) {
return new Builder(stack);
}
public Builder stored(int stored) { public Builder stored(int stored) {
this.stored = stored; this.stored = stored;
return this; return this;
@@ -198,9 +200,5 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
public ItemCraftingMonitorElement build() { public ItemCraftingMonitorElement build() {
return new ItemCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting); return new ItemCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting);
} }
public static Builder forStack(ItemStack stack) {
return new Builder(stack);
}
} }
} }

View File

@@ -2,8 +2,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview;
import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement; import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry; import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElementRegistry;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;
@@ -11,16 +11,16 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
public class CraftingPreviewElementRegistry implements ICraftingPreviewElementRegistry { public class CraftingPreviewElementRegistry implements ICraftingPreviewElementRegistry {
private final Map<ResourceLocation, Function<PacketBuffer, ICraftingPreviewElement>> registry = new HashMap<>(); private final Map<ResourceLocation, Function<FriendlyByteBuf, ICraftingPreviewElement>> registry = new HashMap<>();
@Override @Override
public void add(ResourceLocation id, Function<PacketBuffer, ICraftingPreviewElement> factory) { public void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingPreviewElement> factory) {
registry.put(id, factory); registry.put(id, factory);
} }
@Nullable @Nullable
@Override @Override
public Function<PacketBuffer, ICraftingPreviewElement> get(ResourceLocation id) { public Function<FriendlyByteBuf, ICraftingPreviewElement> get(ResourceLocation id) {
return registry.get(id); return registry.get(id);
} }
} }

View File

@@ -1,13 +1,13 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview; package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.RS; import com.refinedmods.refinedstorage.RS;
import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement; import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
import com.refinedmods.refinedstorage.api.autocrafting.task.CalculationResultType; import com.refinedmods.refinedstorage.api.autocrafting.task.CalculationResultType;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import net.minecraft.item.ItemStack; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
public class ErrorCraftingPreviewElement implements ICraftingPreviewElement { public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "error"); public static final ResourceLocation ID = new ResourceLocation(RS.ID, "error");
@@ -20,12 +20,20 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
this.recursedPattern = recursedPattern; this.recursedPattern = recursedPattern;
} }
public static ErrorCraftingPreviewElement read(FriendlyByteBuf buf) {
int errorIdx = buf.readInt();
CalculationResultType error = errorIdx >= 0 && errorIdx < CalculationResultType.values().length ? CalculationResultType.values()[errorIdx] : CalculationResultType.TOO_COMPLEX;
ItemStack stack = buf.readItem();
return new ErrorCraftingPreviewElement(error, stack);
}
public ItemStack getRecursedPattern() { public ItemStack getRecursedPattern() {
return recursedPattern; return recursedPattern;
} }
@Override @Override
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
// NO OP // NO OP
} }
@@ -35,7 +43,7 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
} }
@Override @Override
public void write(PacketBuffer buf) { public void write(FriendlyByteBuf buf) {
buf.writeInt(type.ordinal()); buf.writeInt(type.ordinal());
buf.writeItem(recursedPattern); buf.writeItem(recursedPattern);
} }
@@ -44,14 +52,6 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
return type; return type;
} }
public static ErrorCraftingPreviewElement read(PacketBuffer buf) {
int errorIdx = buf.readInt();
CalculationResultType error = errorIdx >= 0 && errorIdx < CalculationResultType.values().length ? CalculationResultType.values()[errorIdx] : CalculationResultType.TOO_COMPLEX;
ItemStack stack = buf.readItem();
return new ErrorCraftingPreviewElement(error, stack);
}
@Override @Override
public ResourceLocation getId() { public ResourceLocation getId() {
return ID; return ID;

View File

@@ -1,15 +1,15 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview; package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.RS; import com.refinedmods.refinedstorage.RS;
import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement; import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.util.RenderUtils; import com.refinedmods.refinedstorage.util.RenderUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@@ -34,15 +34,7 @@ public class FluidCraftingPreviewElement implements ICraftingPreviewElement {
this.toCraft = toCraft; this.toCraft = toCraft;
} }
@Override public static FluidCraftingPreviewElement read(FriendlyByteBuf buf) {
public void write(PacketBuffer buf) {
stack.writeToPacket(buf);
buf.writeInt(available);
buf.writeBoolean(missing);
buf.writeInt(toCraft);
}
public static FluidCraftingPreviewElement read(PacketBuffer buf) {
FluidStack stack = FluidStack.readFromPacket(buf); FluidStack stack = FluidStack.readFromPacket(buf);
int available = buf.readInt(); int available = buf.readInt();
boolean missing = buf.readBoolean(); boolean missing = buf.readBoolean();
@@ -51,13 +43,21 @@ public class FluidCraftingPreviewElement implements ICraftingPreviewElement {
return new FluidCraftingPreviewElement(stack, available, missing, toCraft); return new FluidCraftingPreviewElement(stack, available, missing, toCraft);
} }
@Override
public void write(FriendlyByteBuf buf) {
stack.writeToPacket(buf);
buf.writeInt(available);
buf.writeBoolean(missing);
buf.writeInt(toCraft);
}
public FluidStack getStack() { public FluidStack getStack() {
return stack; return stack;
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
if (missing) { if (missing) {
drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE); drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE);
} }

View File

@@ -1,15 +1,15 @@
package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview; package com.refinedmods.refinedstorage.apiimpl.autocrafting.preview;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.refinedmods.refinedstorage.RS; import com.refinedmods.refinedstorage.RS;
import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement; import com.refinedmods.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
import com.refinedmods.refinedstorage.api.render.IElementDrawers; import com.refinedmods.refinedstorage.api.render.IElementDrawers;
import com.refinedmods.refinedstorage.util.RenderUtils; import com.refinedmods.refinedstorage.util.RenderUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.item.ItemStack; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
@@ -34,19 +34,7 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
this.toCraft = toCraft; this.toCraft = toCraft;
} }
public ItemStack getStack() { public static ItemCraftingPreviewElement read(FriendlyByteBuf buf) {
return stack;
}
@Override
public void write(PacketBuffer buf) {
buf.writeItem(stack);
buf.writeInt(available);
buf.writeBoolean(missing);
buf.writeInt(toCraft);
}
public static ItemCraftingPreviewElement read(PacketBuffer buf) {
ItemStack stack = buf.readItem(); ItemStack stack = buf.readItem();
int available = buf.readInt(); int available = buf.readInt();
boolean missing = buf.readBoolean(); boolean missing = buf.readBoolean();
@@ -55,9 +43,21 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
return new ItemCraftingPreviewElement(stack, available, missing, toCraft); return new ItemCraftingPreviewElement(stack, available, missing, toCraft);
} }
public ItemStack getStack() {
return stack;
}
@Override
public void write(FriendlyByteBuf buf) {
buf.writeItem(stack);
buf.writeInt(available);
buf.writeBoolean(missing);
buf.writeInt(toCraft);
}
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void draw(MatrixStack matrixStack, int x, int y, IElementDrawers drawers) { public void draw(PoseStack matrixStack, int x, int y, IElementDrawers drawers) {
if (missing) { if (missing) {
drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE); drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE);
} }

View File

@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task;
import com.refinedmods.refinedstorage.api.autocrafting.task.CraftingTaskReadException; import com.refinedmods.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingRequestInfo; import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -16,7 +16,7 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
private ItemStack item; private ItemStack item;
private FluidStack fluid; private FluidStack fluid;
public CraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException { public CraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException {
if (!tag.getBoolean(NBT_FLUID)) { if (!tag.getBoolean(NBT_FLUID)) {
item = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK)); item = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK));
@@ -53,13 +53,13 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
} }
@Override @Override
public CompoundNBT writeToNbt() { public CompoundTag writeToNbt() {
CompoundNBT tag = new CompoundNBT(); CompoundTag tag = new CompoundTag();
tag.putBoolean(NBT_FLUID, fluid != null); tag.putBoolean(NBT_FLUID, fluid != null);
if (fluid != null) { if (fluid != null) {
tag.put(NBT_STACK, fluid.writeToNBT(new CompoundNBT())); tag.put(NBT_STACK, fluid.writeToNBT(new CompoundTag()));
} else { } else {
tag.put(NBT_STACK, StackUtils.serializeStackToNbt(item)); tag.put(NBT_STACK, StackUtils.serializeStackToNbt(item));
} }

View File

@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskFactory; import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskFactory;
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry; import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;

View File

@@ -1,4 +1,5 @@
# Autocrafting # Autocrafting
Autocrafting has had several refactors. Autocrafting has had several refactors.
Some history: Some history:

View File

@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.util.IComparer; import com.refinedmods.refinedstorage.api.util.IComparer;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@@ -20,10 +20,10 @@ import com.refinedmods.refinedstorage.apiimpl.storage.disk.FluidStorageDisk;
import com.refinedmods.refinedstorage.apiimpl.storage.disk.ItemStorageDisk; import com.refinedmods.refinedstorage.apiimpl.storage.disk.ItemStorageDisk;
import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory; import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.FluidStorageDiskFactory;
import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory; import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList; import java.util.ArrayList;
@@ -56,14 +56,12 @@ public class CraftingTask implements ICraftingTask, NodeListener {
private final NodeList nodes; private final NodeList nodes;
private final IStackList<ItemStack> toExtractInitial; private final IStackList<ItemStack> toExtractInitial;
private final IStackList<FluidStack> toExtractInitialFluids; private final IStackList<FluidStack> toExtractInitialFluids;
private final CraftingMonitorElementFactory craftingMonitorElementFactory = new CraftingMonitorElementFactory();
private int ticks; private int ticks;
private long startTime = -1; private long startTime = -1;
private int totalSteps; private int totalSteps;
private int currentStep; private int currentStep;
private final CraftingMonitorElementFactory craftingMonitorElementFactory = new CraftingMonitorElementFactory();
public CraftingTask(INetwork network, public CraftingTask(INetwork network,
ICraftingRequestInfo requested, ICraftingRequestInfo requested,
int quantity, int quantity,
@@ -86,7 +84,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
this.toExtractInitialFluids = toExtractInitialFluids; this.toExtractInitialFluids = toExtractInitialFluids;
} }
public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public CraftingTask(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
this.network = network; this.network = network;
this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED)); this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED));
@@ -103,10 +101,10 @@ public class CraftingTask implements ICraftingTask, NodeListener {
this.internalStorage = new ItemStorageDiskFactory().createFromNbt(null, tag.getCompound(NBT_INTERNAL_STORAGE)); this.internalStorage = new ItemStorageDiskFactory().createFromNbt(null, tag.getCompound(NBT_INTERNAL_STORAGE));
this.internalFluidStorage = new FluidStorageDiskFactory().createFromNbt(null, tag.getCompound(NBT_INTERNAL_FLUID_STORAGE)); this.internalFluidStorage = new FluidStorageDiskFactory().createFromNbt(null, tag.getCompound(NBT_INTERNAL_FLUID_STORAGE));
this.toExtractInitial = SerializationUtil.readItemStackList(tag.getList(NBT_TO_EXTRACT_INITIAL, Constants.NBT.TAG_COMPOUND)); this.toExtractInitial = SerializationUtil.readItemStackList(tag.getList(NBT_TO_EXTRACT_INITIAL, Tag.TAG_COMPOUND));
this.toExtractInitialFluids = SerializationUtil.readFluidStackList(tag.getList(NBT_TO_EXTRACT_INITIAL_FLUIDS, Constants.NBT.TAG_COMPOUND)); this.toExtractInitialFluids = SerializationUtil.readFluidStackList(tag.getList(NBT_TO_EXTRACT_INITIAL_FLUIDS, Tag.TAG_COMPOUND));
ListNBT nodeList = tag.getList(NBT_CRAFTS, Constants.NBT.TAG_COMPOUND); ListTag nodeList = tag.getList(NBT_CRAFTS, Tag.TAG_COMPOUND);
for (int i = 0; i < nodeList.size(); ++i) { for (int i = 0; i < nodeList.size(); ++i) {
Node node = Node.fromNbt(network, nodeList.getCompound(i)); Node node = Node.fromNbt(network, nodeList.getCompound(i));
nodes.put(node.getPattern(), node); nodes.put(node.getPattern(), node);
@@ -114,7 +112,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
} }
@Override @Override
public CompoundNBT writeToNbt(CompoundNBT tag) { public CompoundTag writeToNbt(CompoundTag tag) {
tag.put(NBT_REQUESTED, requested.writeToNbt()); tag.put(NBT_REQUESTED, requested.writeToNbt());
tag.putInt(NBT_QUANTITY, quantity); tag.putInt(NBT_QUANTITY, quantity);
tag.put(NBT_PATTERN, SerializationUtil.writePatternToNbt(pattern)); tag.put(NBT_PATTERN, SerializationUtil.writePatternToNbt(pattern));
@@ -128,7 +126,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
tag.putInt(NBT_TOTAL_STEPS, totalSteps); tag.putInt(NBT_TOTAL_STEPS, totalSteps);
tag.putInt(NBT_CURRENT_STEP, currentStep); tag.putInt(NBT_CURRENT_STEP, currentStep);
ListNBT nodeList = new ListNBT(); ListTag nodeList = new ListTag();
for (Node node : this.nodes.all()) { for (Node node : this.nodes.all()) {
nodeList.add(node.writeToNbt()); nodeList.add(node.writeToNbt());
} }

View File

@@ -5,8 +5,8 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.autocrafting.task.*; import com.refinedmods.refinedstorage.api.autocrafting.task.*;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CraftingCalculator; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CraftingCalculator;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
public class CraftingTaskFactory implements ICraftingTaskFactory { public class CraftingTaskFactory implements ICraftingTaskFactory {
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "v6"); public static final ResourceLocation ID = new ResourceLocation(RS.ID, "v6");
@@ -18,7 +18,7 @@ public class CraftingTaskFactory implements ICraftingTaskFactory {
} }
@Override @Override
public ICraftingTask createFromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public ICraftingTask createFromNbt(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
return new CraftingTask(network, tag); return new CraftingTask(network, tag);
} }
} }

View File

@@ -7,7 +7,7 @@ import com.refinedmods.refinedstorage.api.util.IComparer;
import com.refinedmods.refinedstorage.api.util.IStackList; import com.refinedmods.refinedstorage.api.util.IStackList;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -9,12 +9,12 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.World; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.level.Level;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class SerializationUtil { public class SerializationUtil {
@@ -24,8 +24,8 @@ public class SerializationUtil {
private SerializationUtil() { private SerializationUtil() {
} }
public static ListNBT writeItemStackList(IStackList<ItemStack> stacks) { public static ListTag writeItemStackList(IStackList<ItemStack> stacks) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (StackListEntry<ItemStack> entry : stacks.getStacks()) { for (StackListEntry<ItemStack> entry : stacks.getStacks()) {
list.add(StackUtils.serializeStackToNbt(entry.getStack())); list.add(StackUtils.serializeStackToNbt(entry.getStack()));
@@ -34,7 +34,7 @@ public class SerializationUtil {
return list; return list;
} }
public static IStackList<ItemStack> readItemStackList(ListNBT list) throws CraftingTaskReadException { public static IStackList<ItemStack> readItemStackList(ListTag list) throws CraftingTaskReadException {
IStackList<ItemStack> stacks = API.instance().createItemStackList(); IStackList<ItemStack> stacks = API.instance().createItemStackList();
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
@@ -50,17 +50,17 @@ public class SerializationUtil {
return stacks; return stacks;
} }
public static ListNBT writeFluidStackList(IStackList<FluidStack> stacks) { public static ListTag writeFluidStackList(IStackList<FluidStack> stacks) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (StackListEntry<FluidStack> entry : stacks.getStacks()) { for (StackListEntry<FluidStack> entry : stacks.getStacks()) {
list.add(entry.getStack().writeToNBT(new CompoundNBT())); list.add(entry.getStack().writeToNBT(new CompoundTag()));
} }
return list; return list;
} }
public static IStackList<FluidStack> readFluidStackList(ListNBT list) throws CraftingTaskReadException { public static IStackList<FluidStack> readFluidStackList(ListTag list) throws CraftingTaskReadException {
IStackList<FluidStack> stacks = API.instance().createFluidStackList(); IStackList<FluidStack> stacks = API.instance().createFluidStackList();
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
@@ -76,8 +76,8 @@ public class SerializationUtil {
return stacks; return stacks;
} }
public static CompoundNBT writePatternToNbt(ICraftingPattern pattern) { public static CompoundTag writePatternToNbt(ICraftingPattern pattern) {
CompoundNBT tag = new CompoundNBT(); CompoundTag tag = new CompoundTag();
tag.put(NBT_PATTERN_STACK, pattern.getStack().serializeNBT()); tag.put(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().asLong()); tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().asLong());
@@ -85,10 +85,10 @@ public class SerializationUtil {
return tag; return tag;
} }
public static ICraftingPattern readPatternFromNbt(CompoundNBT tag, World world) throws CraftingTaskReadException { public static ICraftingPattern readPatternFromNbt(CompoundTag tag, Level world) throws CraftingTaskReadException {
BlockPos containerPos = BlockPos.of(tag.getLong(NBT_PATTERN_CONTAINER_POS)); BlockPos containerPos = BlockPos.of(tag.getLong(NBT_PATTERN_CONTAINER_POS));
INetworkNode node = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(containerPos); INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(containerPos);
if (node instanceof ICraftingPatternContainer) { if (node instanceof ICraftingPatternContainer) {
ItemStack stack = ItemStack.of(tag.getCompound(NBT_PATTERN_STACK)); ItemStack stack = ItemStack.of(tag.getCompound(NBT_PATTERN_STACK));

View File

@@ -19,7 +19,7 @@ import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.Processi
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview.CraftingPreviewElementFactory; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview.CraftingPreviewElementFactory;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview.CraftingPreviewInfo; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview.CraftingPreviewInfo;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;

View File

@@ -12,7 +12,7 @@ import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.Crafting
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.Node; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.Node;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.ProcessingNode; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.ProcessingNode;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.ProcessingState; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node.ProcessingState;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.Collection; import java.util.Collection;

View File

@@ -8,11 +8,11 @@ import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class CraftingNode extends Node { public class CraftingNode extends Node {
@@ -26,12 +26,12 @@ public class CraftingNode extends Node {
this.recipe = recipe; this.recipe = recipe;
} }
public CraftingNode(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public CraftingNode(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
super(network, tag); super(network, tag);
this.recipe = NonNullList.create(); this.recipe = NonNullList.create();
ListNBT tookList = tag.getList(NBT_RECIPE, Constants.NBT.TAG_COMPOUND); ListTag tookList = tag.getList(NBT_RECIPE, Tag.TAG_COMPOUND);
for (int i = 0; i < tookList.size(); ++i) { for (int i = 0; i < tookList.size(); ++i) {
recipe.add(StackUtils.deserializeStackFromNbt(tookList.getCompound(i))); recipe.add(StackUtils.deserializeStackFromNbt(tookList.getCompound(i)));
} }
@@ -83,10 +83,10 @@ public class CraftingNode extends Node {
} }
@Override @Override
public CompoundNBT writeToNbt() { public CompoundTag writeToNbt() {
CompoundNBT tag = super.writeToNbt(); CompoundTag tag = super.writeToNbt();
ListNBT tookList = new ListNBT(); ListTag tookList = new ListTag();
for (ItemStack took : this.recipe) { for (ItemStack took : this.recipe) {
tookList.add(StackUtils.serializeStackToNbt(took)); tookList.add(StackUtils.serializeStackToNbt(took));
} }

View File

@@ -5,8 +5,8 @@ import com.refinedmods.refinedstorage.api.autocrafting.task.CraftingTaskReadExce
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk; import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public abstract class Node { public abstract class Node {
@@ -15,21 +15,18 @@ public abstract class Node {
private static final String NBT_IS_PROCESSING = "IsProcessing"; private static final String NBT_IS_PROCESSING = "IsProcessing";
private static final String NBT_QUANTITY = "Quantity"; private static final String NBT_QUANTITY = "Quantity";
private static final String NBT_QUANTITY_TOTAL = "TotalQuantity"; private static final String NBT_QUANTITY_TOTAL = "TotalQuantity";
protected final NodeRequirements requirements = new NodeRequirements();
private final boolean root; private final boolean root;
private final ICraftingPattern pattern; private final ICraftingPattern pattern;
protected int quantity; protected int quantity;
protected int totalQuantity; protected int totalQuantity;
protected final NodeRequirements requirements = new NodeRequirements();
protected Node(ICraftingPattern pattern, boolean root) { protected Node(ICraftingPattern pattern, boolean root) {
this.pattern = pattern; this.pattern = pattern;
this.root = root; this.root = root;
} }
protected Node(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { protected Node(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
this.quantity = tag.getInt(NBT_QUANTITY); this.quantity = tag.getInt(NBT_QUANTITY);
this.totalQuantity = tag.getInt(NBT_QUANTITY_TOTAL); this.totalQuantity = tag.getInt(NBT_QUANTITY_TOTAL);
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld()); this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
@@ -37,7 +34,7 @@ public abstract class Node {
this.requirements.readFromNbt(tag); this.requirements.readFromNbt(tag);
} }
public static Node fromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public static Node fromNbt(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
return tag.getBoolean(NBT_IS_PROCESSING) ? new ProcessingNode(network, tag) : new CraftingNode(network, tag); return tag.getBoolean(NBT_IS_PROCESSING) ? new ProcessingNode(network, tag) : new CraftingNode(network, tag);
} }
@@ -71,8 +68,8 @@ public abstract class Node {
return requirements; return requirements;
} }
public CompoundNBT writeToNbt() { public CompoundTag writeToNbt() {
CompoundNBT tag = new CompoundNBT(); CompoundTag tag = new CompoundTag();
tag.putInt(NBT_QUANTITY, quantity); tag.putInt(NBT_QUANTITY, quantity);
tag.putInt(NBT_QUANTITY_TOTAL, totalQuantity); tag.putInt(NBT_QUANTITY_TOTAL, totalQuantity);

View File

@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.node;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer; import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import net.minecraft.item.ItemStack; import net.minecraft.core.NonNullList;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.ItemStack;
import java.util.*; import java.util.*;

View File

@@ -6,10 +6,10 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
import com.refinedmods.refinedstorage.api.util.StackListEntry; import com.refinedmods.refinedstorage.api.util.StackListEntry;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.Tag;
import net.minecraftforge.common.util.Constants; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -146,8 +146,8 @@ public class NodeRequirements {
return toReturn; return toReturn;
} }
public void readFromNbt(CompoundNBT tag) throws CraftingTaskReadException { public void readFromNbt(CompoundTag tag) throws CraftingTaskReadException {
ListNBT itemRequirementsTag = tag.getList(NBT_ITEMS_TO_USE, Constants.NBT.TAG_LIST); ListTag itemRequirementsTag = tag.getList(NBT_ITEMS_TO_USE, Tag.TAG_LIST);
for (int i = 0; i < itemRequirementsTag.size(); i++) { for (int i = 0; i < itemRequirementsTag.size(); i++) {
itemRequirements.put(i, SerializationUtil.readItemStackList(itemRequirementsTag.getList(i))); itemRequirements.put(i, SerializationUtil.readItemStackList(itemRequirementsTag.getList(i)));
} }
@@ -157,7 +157,7 @@ public class NodeRequirements {
itemsNeededPerCraft.put(i, itemsNeededPerCraftTag.get(i)); itemsNeededPerCraft.put(i, itemsNeededPerCraftTag.get(i));
} }
ListNBT fluidRequirementsTag = tag.getList(NBT_FLUIDS_TO_USE, Constants.NBT.TAG_LIST); ListTag fluidRequirementsTag = tag.getList(NBT_FLUIDS_TO_USE, Tag.TAG_LIST);
for (int i = 0; i < fluidRequirementsTag.size(); i++) { for (int i = 0; i < fluidRequirementsTag.size(); i++) {
fluidRequirements.put(i, SerializationUtil.readFluidStackList(fluidRequirementsTag.getList(i))); fluidRequirements.put(i, SerializationUtil.readFluidStackList(fluidRequirementsTag.getList(i)));
} }
@@ -168,8 +168,8 @@ public class NodeRequirements {
} }
} }
public CompoundNBT writeToNbt(CompoundNBT tag) { public CompoundTag writeToNbt(CompoundTag tag) {
ListNBT itemRequirementsTag = new ListNBT(); ListTag itemRequirementsTag = new ListTag();
for (IStackList<ItemStack> list : itemRequirements.values()) { for (IStackList<ItemStack> list : itemRequirements.values()) {
itemRequirementsTag.add(SerializationUtil.writeItemStackList(list)); itemRequirementsTag.add(SerializationUtil.writeItemStackList(list));
} }
@@ -177,7 +177,7 @@ public class NodeRequirements {
tag.putIntArray(NBT_ITEMS_NEEDED_PER_CRAFT, Ints.toArray(itemsNeededPerCraft.values())); tag.putIntArray(NBT_ITEMS_NEEDED_PER_CRAFT, Ints.toArray(itemsNeededPerCraft.values()));
ListNBT fluidRequirementsTag = new ListNBT(); ListTag fluidRequirementsTag = new ListTag();
for (IStackList<FluidStack> list : fluidRequirements.values()) { for (IStackList<FluidStack> list : fluidRequirements.values()) {
fluidRequirementsTag.add(SerializationUtil.writeFluidStackList(list)); fluidRequirementsTag.add(SerializationUtil.writeFluidStackList(list));
} }

View File

@@ -11,9 +11,9 @@ import com.refinedmods.refinedstorage.api.util.StackListEntry;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil; import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class ProcessingNode extends Node { public class ProcessingNode extends Node {
@@ -42,14 +42,14 @@ public class ProcessingNode extends Node {
initSetsToReceive(); initSetsToReceive();
} }
public ProcessingNode(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public ProcessingNode(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
super(network, tag); super(network, tag);
this.itemsReceived = SerializationUtil.readItemStackList(tag.getList(NBT_ITEMS_RECEIVED, Constants.NBT.TAG_COMPOUND)); this.itemsReceived = SerializationUtil.readItemStackList(tag.getList(NBT_ITEMS_RECEIVED, Tag.TAG_COMPOUND));
this.fluidsReceived = SerializationUtil.readFluidStackList(tag.getList(NBT_FLUIDS_RECEIVED, Constants.NBT.TAG_COMPOUND)); this.fluidsReceived = SerializationUtil.readFluidStackList(tag.getList(NBT_FLUIDS_RECEIVED, Tag.TAG_COMPOUND));
this.singleItemSetToRequire = SerializationUtil.readItemStackList(tag.getList(NBT_SINGLE_ITEM_SET_TO_REQUIRE, Constants.NBT.TAG_COMPOUND)); this.singleItemSetToRequire = SerializationUtil.readItemStackList(tag.getList(NBT_SINGLE_ITEM_SET_TO_REQUIRE, Tag.TAG_COMPOUND));
this.singleFluidSetToRequire = SerializationUtil.readFluidStackList(tag.getList(NBT_SINGLE_FLUID_SET_TO_REQUIRE, Constants.NBT.TAG_COMPOUND)); this.singleFluidSetToRequire = SerializationUtil.readFluidStackList(tag.getList(NBT_SINGLE_FLUID_SET_TO_REQUIRE, Tag.TAG_COMPOUND));
this.state = ProcessingState.values()[tag.getInt(NBT_STATE)]; this.state = ProcessingState.values()[tag.getInt(NBT_STATE)];
@@ -254,8 +254,8 @@ public class ProcessingNode extends Node {
} }
@Override @Override
public CompoundNBT writeToNbt() { public CompoundTag writeToNbt() {
CompoundNBT tag = super.writeToNbt(); CompoundTag tag = super.writeToNbt();
tag.put(NBT_ITEMS_RECEIVED, SerializationUtil.writeItemStackList(itemsReceived)); tag.put(NBT_ITEMS_RECEIVED, SerializationUtil.writeItemStackList(itemsReceived));
tag.put(NBT_FLUIDS_RECEIVED, SerializationUtil.writeFluidStackList(fluidsReceived)); tag.put(NBT_FLUIDS_RECEIVED, SerializationUtil.writeFluidStackList(fluidsReceived));

View File

@@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.util.StackListEntry;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.preview.FluidCraftingPreviewElement; import com.refinedmods.refinedstorage.apiimpl.autocrafting.preview.FluidCraftingPreviewElement;
import com.refinedmods.refinedstorage.apiimpl.autocrafting.preview.ItemCraftingPreviewElement; import com.refinedmods.refinedstorage.apiimpl.autocrafting.preview.ItemCraftingPreviewElement;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList; import java.util.ArrayList;
@@ -38,7 +38,7 @@ public class CraftingPreviewElementFactory {
for (ItemStack stack : ImmutableList.copyOf(info.getToCraft()).reverse()) { for (ItemStack stack : ImmutableList.copyOf(info.getToCraft()).reverse()) {
int hash = API.instance().getItemStackHashCode(stack); int hash = API.instance().getItemStackHashCode(stack);
ItemCraftingPreviewElement previewStack = map.computeIfAbsent(hash, key -> new ItemCraftingPreviewElement(stack.getStack())); ItemCraftingPreviewElement previewStack = map.computeIfAbsent(hash, key -> new ItemCraftingPreviewElement(stack));
previewStack.addToCraft(stack.getCount()); previewStack.addToCraft(stack.getCount());
} }

View File

@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview;
import com.refinedmods.refinedstorage.api.util.IStackList; import com.refinedmods.refinedstorage.api.util.IStackList;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList; import java.util.ArrayList;

View File

@@ -35,15 +35,15 @@ import com.refinedmods.refinedstorage.tile.ControllerTile;
import com.refinedmods.refinedstorage.tile.config.IRedstoneConfigurable; import com.refinedmods.refinedstorage.tile.config.IRedstoneConfigurable;
import com.refinedmods.refinedstorage.tile.config.RedstoneMode; import com.refinedmods.refinedstorage.tile.config.RedstoneMode;
import com.refinedmods.refinedstorage.util.StackUtils; import com.refinedmods.refinedstorage.util.StackUtils;
import net.minecraft.block.BlockState; import net.minecraft.Util;
import net.minecraft.item.ItemStack; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.TileEntity; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Util; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.world.World; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
@@ -76,16 +76,13 @@ public class Network implements INetwork, IRedstoneConfigurable {
private final IStorageCache<FluidStack> fluidStorage = new FluidStorageCache(this); private final IStorageCache<FluidStack> fluidStorage = new FluidStorageCache(this);
private final BaseEnergyStorage energy = new BaseEnergyStorage(RS.SERVER_CONFIG.getController().getCapacity(), RS.SERVER_CONFIG.getController().getMaxTransfer(), 0); private final BaseEnergyStorage energy = new BaseEnergyStorage(RS.SERVER_CONFIG.getController().getCapacity(), RS.SERVER_CONFIG.getController().getMaxTransfer(), 0);
private final RootNetworkNode root; private final RootNetworkNode root;
private final BlockPos pos;
private final Level world;
private final NetworkType type;
private ItemStorageTracker itemStorageTracker; private ItemStorageTracker itemStorageTracker;
private UUID itemStorageTrackerId; private UUID itemStorageTrackerId;
private FluidStorageTracker fluidStorageTracker; private FluidStorageTracker fluidStorageTracker;
private UUID fluidStorageTrackerId; private UUID fluidStorageTrackerId;
private final BlockPos pos;
private final World world;
private final NetworkType type;
private ControllerBlock.EnergyType lastEnergyType = ControllerBlock.EnergyType.OFF; private ControllerBlock.EnergyType lastEnergyType = ControllerBlock.EnergyType.OFF;
private int lastEnergyUsage; private int lastEnergyUsage;
private RedstoneMode redstoneMode = RedstoneMode.IGNORE; private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
@@ -99,13 +96,13 @@ public class Network implements INetwork, IRedstoneConfigurable {
private long[] tickTimes = new long[100]; private long[] tickTimes = new long[100];
private int tickCounter = 0; private int tickCounter = 0;
public Network(World world, BlockPos pos, NetworkType type) { public Network(Level world, BlockPos pos, NetworkType type) {
this.pos = pos; this.pos = pos;
this.world = world; this.world = world;
this.type = type; this.type = type;
this.root = new RootNetworkNode(this, world, pos); this.root = new RootNetworkNode(this, world, pos);
this.nodeGraph.addListener(() -> { this.nodeGraph.addListener(() -> {
TileEntity tile = world.getBlockEntity(pos); BlockEntity tile = world.getBlockEntity(pos);
if (tile instanceof ControllerTile) { if (tile instanceof ControllerTile) {
((ControllerTile) tile).getDataManager().sendParameterToWatchers(ControllerTile.NODES); ((ControllerTile) tile).getDataManager().sendParameterToWatchers(ControllerTile.NODES);
@@ -113,6 +110,24 @@ public class Network implements INetwork, IRedstoneConfigurable {
}); });
} }
public static int getEnergyScaled(int stored, int capacity, int scale) {
return (int) ((float) stored / (float) capacity * (float) scale);
}
public static ControllerBlock.EnergyType getEnergyType(int stored, int capacity) {
int energy = getEnergyScaled(stored, capacity, 100);
if (energy <= 0) {
return ControllerBlock.EnergyType.OFF;
} else if (energy <= 10) {
return ControllerBlock.EnergyType.NEARLY_OFF;
} else if (energy <= 20) {
return ControllerBlock.EnergyType.NEARLY_ON;
}
return ControllerBlock.EnergyType.ON;
}
public RootNetworkNode getRoot() { public RootNetworkNode getRoot() {
return root; return root;
} }
@@ -236,8 +251,8 @@ public class Network implements INetwork, IRedstoneConfigurable {
} }
nodeGraph.disconnectAll(); nodeGraph.disconnectAll();
API.instance().getStorageTrackerManager((ServerWorld) getWorld()).remove(itemStorageTrackerId); API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(itemStorageTrackerId);
API.instance().getStorageTrackerManager((ServerWorld) getWorld()).remove(fluidStorageTrackerId); API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(fluidStorageTrackerId);
} }
@Override @Override
@@ -471,7 +486,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
this.itemStorageTrackerId = UUID.randomUUID(); this.itemStorageTrackerId = UUID.randomUUID();
} }
this.itemStorageTracker = (ItemStorageTracker) API.instance().getStorageTrackerManager((ServerWorld) world).getOrCreate(itemStorageTrackerId, StorageType.ITEM); this.itemStorageTracker = (ItemStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) world).getOrCreate(itemStorageTrackerId, StorageType.ITEM);
} }
return itemStorageTracker; return itemStorageTracker;
@@ -484,19 +499,19 @@ public class Network implements INetwork, IRedstoneConfigurable {
this.fluidStorageTrackerId = UUID.randomUUID(); this.fluidStorageTrackerId = UUID.randomUUID();
} }
this.fluidStorageTracker = (FluidStorageTracker) API.instance().getStorageTrackerManager((ServerWorld) world).getOrCreate(fluidStorageTrackerId, StorageType.FLUID); this.fluidStorageTracker = (FluidStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) world).getOrCreate(fluidStorageTrackerId, StorageType.FLUID);
} }
return fluidStorageTracker; return fluidStorageTracker;
} }
@Override @Override
public World getWorld() { public Level getWorld() {
return world; return world;
} }
@Override @Override
public INetwork readFromNbt(CompoundNBT tag) { public INetwork readFromNbt(CompoundTag tag) {
if (tag.contains(NBT_ENERGY)) { if (tag.contains(NBT_ENERGY)) {
this.energy.setStored(tag.getInt(NBT_ENERGY)); this.energy.setStored(tag.getInt(NBT_ENERGY));
} }
@@ -509,7 +524,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
this.itemStorageTrackerId = tag.getUUID(NBT_ITEM_STORAGE_TRACKER_ID); this.itemStorageTrackerId = tag.getUUID(NBT_ITEM_STORAGE_TRACKER_ID);
} else { } else {
if (tag.contains(NBT_ITEM_STORAGE_TRACKER)) { //TODO: remove next version if (tag.contains(NBT_ITEM_STORAGE_TRACKER)) { //TODO: remove next version
getItemStorageTracker().readFromNbt(tag.getList(NBT_ITEM_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND)); getItemStorageTracker().readFromNbt(tag.getList(NBT_ITEM_STORAGE_TRACKER, Tag.TAG_COMPOUND));
} }
} }
@@ -517,7 +532,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
this.fluidStorageTrackerId = tag.getUUID(NBT_FLUID_STORAGE_TRACKER_ID); this.fluidStorageTrackerId = tag.getUUID(NBT_FLUID_STORAGE_TRACKER_ID);
} else { } else {
if (tag.contains(NBT_FLUID_STORAGE_TRACKER)) { //TODO: remove next version if (tag.contains(NBT_FLUID_STORAGE_TRACKER)) { //TODO: remove next version
getFluidStorageTracker().readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND)); getFluidStorageTracker().readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Tag.TAG_COMPOUND));
} }
} }
@@ -525,7 +540,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
} }
@Override @Override
public CompoundNBT writeToNbt(CompoundNBT tag) { public CompoundTag writeToNbt(CompoundTag tag) {
tag.putInt(NBT_ENERGY, this.energy.getEnergyStored()); tag.putInt(NBT_ENERGY, this.energy.getEnergyStored());
redstoneMode.write(tag); redstoneMode.write(tag);
@@ -549,11 +564,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
@Override @Override
public void markDirty() { public void markDirty() {
API.instance().getNetworkManager((ServerWorld) world).markForSaving(); API.instance().getNetworkManager((ServerLevel) world).markForSaving();
}
public static int getEnergyScaled(int stored, int capacity, int scale) {
return (int) ((float) stored / (float) capacity * (float) scale);
} }
public ControllerBlock.EnergyType getEnergyType() { public ControllerBlock.EnergyType getEnergyType() {
@@ -564,20 +575,6 @@ public class Network implements INetwork, IRedstoneConfigurable {
return getEnergyType(this.energy.getEnergyStored(), this.energy.getMaxEnergyStored()); return getEnergyType(this.energy.getEnergyStored(), this.energy.getMaxEnergyStored());
} }
public static ControllerBlock.EnergyType getEnergyType(int stored, int capacity) {
int energy = getEnergyScaled(stored, capacity, 100);
if (energy <= 0) {
return ControllerBlock.EnergyType.OFF;
} else if (energy <= 10) {
return ControllerBlock.EnergyType.NEARLY_OFF;
} else if (energy <= 20) {
return ControllerBlock.EnergyType.NEARLY_ON;
}
return ControllerBlock.EnergyType.ON;
}
@Override @Override
public RedstoneMode getRedstoneMode() { public RedstoneMode getRedstoneMode() {
return redstoneMode; return redstoneMode;

View File

@@ -3,7 +3,7 @@ package com.refinedmods.refinedstorage.apiimpl.network;
import com.refinedmods.refinedstorage.api.network.INetwork; import com.refinedmods.refinedstorage.api.network.INetwork;
import com.refinedmods.refinedstorage.api.network.node.INetworkNode; import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import net.minecraft.world.server.ServerWorld; import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -13,7 +13,7 @@ public class NetworkListener {
if (!e.world.isClientSide() && e.phase == TickEvent.Phase.END) { if (!e.world.isClientSide() && e.phase == TickEvent.Phase.END) {
e.world.getProfiler().push("network ticking"); e.world.getProfiler().push("network ticking");
for (INetwork network : API.instance().getNetworkManager((ServerWorld) e.world).all()) { for (INetwork network : API.instance().getNetworkManager((ServerLevel) e.world).all()) {
network.update(); network.update();
} }
@@ -21,7 +21,7 @@ public class NetworkListener {
e.world.getProfiler().push("network node ticking"); e.world.getProfiler().push("network node ticking");
for (INetworkNode node : API.instance().getNetworkNodeManager((ServerWorld) e.world).all()) { for (INetworkNode node : API.instance().getNetworkNodeManager((ServerLevel) e.world).all()) {
node.update(); node.update();
} }

View File

@@ -4,11 +4,11 @@ import com.refinedmods.refinedstorage.api.network.INetwork;
import com.refinedmods.refinedstorage.api.network.INetworkManager; import com.refinedmods.refinedstorage.api.network.INetworkManager;
import com.refinedmods.refinedstorage.api.network.NetworkType; import com.refinedmods.refinedstorage.api.network.NetworkType;
import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData; import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.nbt.ListTag;
import net.minecraft.world.World; import net.minecraft.nbt.Tag;
import net.minecraftforge.common.util.Constants; import net.minecraft.world.level.Level;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -24,29 +24,27 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
private static final String NBT_DATA = "Data"; private static final String NBT_DATA = "Data";
private static final String NBT_POS = "Pos"; private static final String NBT_POS = "Pos";
private final World world; private final Level world;
private final Logger logger = LogManager.getLogger(getClass()); private final Logger logger = LogManager.getLogger(getClass());
private final ConcurrentHashMap<BlockPos, INetwork> networks = new ConcurrentHashMap<>(); private final ConcurrentHashMap<BlockPos, INetwork> networks = new ConcurrentHashMap<>();
public NetworkManager(String name, World world) { public NetworkManager(Level world) {
super(name);
this.world = world; this.world = world;
} }
@Override @Override
public void load(CompoundNBT tag) { public void load(CompoundTag tag) {
if (tag.contains(NBT_NETWORKS)) { if (tag.contains(NBT_NETWORKS)) {
ListNBT networksTag = tag.getList(NBT_NETWORKS, Constants.NBT.TAG_COMPOUND); ListTag networksTag = tag.getList(NBT_NETWORKS, Tag.TAG_COMPOUND);
this.networks.clear(); this.networks.clear();
for (int i = 0; i < networksTag.size(); ++i) { for (int i = 0; i < networksTag.size(); ++i) {
CompoundNBT networkTag = networksTag.getCompound(i); CompoundTag networkTag = networksTag.getCompound(i);
CompoundNBT data = networkTag.getCompound(NBT_DATA); CompoundTag data = networkTag.getCompound(NBT_DATA);
BlockPos pos = BlockPos.of(networkTag.getLong(NBT_POS)); BlockPos pos = BlockPos.of(networkTag.getLong(NBT_POS));
int type = networkTag.getInt(NBT_TYPE); int type = networkTag.getInt(NBT_TYPE);
@@ -64,15 +62,15 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
} }
@Override @Override
public CompoundNBT save(CompoundNBT tag) { public CompoundTag save(CompoundTag tag) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (INetwork network : all()) { for (INetwork network : all()) {
try { try {
CompoundNBT networkTag = new CompoundNBT(); CompoundTag networkTag = new CompoundTag();
networkTag.putLong(NBT_POS, network.getPosition().asLong()); networkTag.putLong(NBT_POS, network.getPosition().asLong());
networkTag.put(NBT_DATA, network.writeToNbt(new CompoundNBT())); networkTag.put(NBT_DATA, network.writeToNbt(new CompoundTag()));
networkTag.putInt(NBT_TYPE, network.getType().ordinal()); networkTag.putInt(NBT_TYPE, network.getType().ordinal());
list.add(networkTag); list.add(networkTag);

View File

@@ -5,25 +5,21 @@ import com.refinedmods.refinedstorage.api.network.*;
import com.refinedmods.refinedstorage.api.network.node.INetworkNode; import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
import com.refinedmods.refinedstorage.api.util.Action; import com.refinedmods.refinedstorage.api.util.Action;
import com.refinedmods.refinedstorage.util.NetworkUtils; import com.refinedmods.refinedstorage.util.NetworkUtils;
import net.minecraft.block.Block; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.TileEntity; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.world.level.Level;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.Block;
import net.minecraft.world.World; import net.minecraft.world.level.block.entity.BlockEntity;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
public class NetworkNodeGraph implements INetworkNodeGraph { public class NetworkNodeGraph implements INetworkNodeGraph {
private final INetwork network; private final INetwork network;
private Set<INetworkNodeGraphEntry> entries = Sets.newConcurrentHashSet();
private final List<INetworkNodeGraphListener> listeners = new LinkedList<>(); private final List<INetworkNodeGraphListener> listeners = new LinkedList<>();
private final Set<Consumer<INetwork>> actions = new HashSet<>(); private final Set<Consumer<INetwork>> actions = new HashSet<>();
private Set<INetworkNodeGraphEntry> entries = Sets.newConcurrentHashSet();
private boolean invalidating = false; private boolean invalidating = false;
public NetworkNodeGraph(INetwork network) { public NetworkNodeGraph(INetwork network) {
@@ -31,7 +27,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
} }
@Override @Override
public void invalidate(Action action, World world, BlockPos origin) { public void invalidate(Action action, Level world, BlockPos origin) {
this.invalidating = true; this.invalidating = true;
Operator operator = new Operator(action); Operator operator = new Operator(action);
@@ -95,10 +91,43 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
listeners.forEach(INetworkNodeGraphListener::onChanged); listeners.forEach(INetworkNodeGraphListener::onChanged);
} }
protected World getWorld() { protected Level getWorld() {
return network.getWorld(); return network.getWorld();
} }
private static class Visitor implements INetworkNodeVisitor {
private final INetworkNode node;
private final Level world;
private final BlockPos pos;
private final Direction side;
private final BlockEntity tile;
Visitor(INetworkNode node, Level world, BlockPos pos, Direction side, BlockEntity tile) {
this.node = node;
this.world = world;
this.pos = pos;
this.side = side;
this.tile = tile;
}
@Override
public void visit(Operator operator) {
if (node instanceof INetworkNodeVisitor) {
((INetworkNodeVisitor) node).visit(operator);
} else {
for (Direction checkSide : Direction.values()) {
if (checkSide != side) { // Avoid going backward
INetworkNode nodeOnSide = NetworkUtils.getNodeFromTile(tile);
if (nodeOnSide == node) {
operator.apply(world, pos.relative(checkSide), checkSide.getOpposite());
}
}
}
}
}
}
private class Operator implements INetworkNodeVisitor.Operator { private class Operator implements INetworkNodeVisitor.Operator {
private final Set<INetworkNodeGraphEntry> foundNodes = Sets.newConcurrentHashSet(); // All scanned entries private final Set<INetworkNodeGraphEntry> foundNodes = Sets.newConcurrentHashSet(); // All scanned entries
@@ -114,8 +143,8 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
} }
@Override @Override
public void apply(World world, BlockPos pos, @Nullable Direction side) { public void apply(Level world, BlockPos pos, @Nullable Direction side) {
TileEntity tile = world.getBlockEntity(pos); BlockEntity tile = world.getBlockEntity(pos);
INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile); INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile);
if (otherNode != null) { if (otherNode != null) {
@@ -144,7 +173,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
} }
} }
private void dropConflictingBlock(World world, BlockPos pos) { private void dropConflictingBlock(Level world, BlockPos pos) {
if (!network.getPosition().equals(pos)) { if (!network.getPosition().equals(pos)) {
Block.dropResources(world.getBlockState(pos), world, pos, world.getBlockEntity(pos)); Block.dropResources(world.getBlockState(pos), world, pos, world.getBlockEntity(pos));
@@ -157,37 +186,4 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
return action; return action;
} }
} }
private static class Visitor implements INetworkNodeVisitor {
private final INetworkNode node;
private final World world;
private final BlockPos pos;
private final Direction side;
private final TileEntity tile;
Visitor(INetworkNode node, World world, BlockPos pos, Direction side, TileEntity tile) {
this.node = node;
this.world = world;
this.pos = pos;
this.side = side;
this.tile = tile;
}
@Override
public void visit(Operator operator) {
if (node instanceof INetworkNodeVisitor) {
((INetworkNodeVisitor) node).visit(operator);
} else {
for (Direction checkSide : Direction.values()) {
if (checkSide != side) { // Avoid going backward
INetworkNode nodeOnSide = NetworkUtils.getNodeFromTile(tile);
if (nodeOnSide == node) {
operator.apply(world, pos.relative(checkSide), checkSide.getOpposite());
}
}
}
}
}
}
} }

View File

@@ -6,19 +6,19 @@ import com.refinedmods.refinedstorage.api.util.Action;
import com.refinedmods.refinedstorage.util.NetworkUtils; import com.refinedmods.refinedstorage.util.NetworkUtils;
import com.refinedmods.refinedstorage.util.PlayerUtils; import com.refinedmods.refinedstorage.util.PlayerUtils;
import com.refinedmods.refinedstorage.util.WorldUtils; import com.refinedmods.refinedstorage.util.WorldUtils;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.IWorld; import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class NetworkNodeListener { public class NetworkNodeListener {
@SubscribeEvent @SubscribeEvent
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) { public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
if (!e.getWorld().isClientSide() && e.getEntity() instanceof PlayerEntity) { if (!e.getWorld().isClientSide() && e.getEntity() instanceof Player) {
PlayerEntity player = (PlayerEntity) e.getEntity(); Player player = (Player) e.getEntity();
INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getPos())); INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getPos()));
@@ -32,7 +32,7 @@ public class NetworkNodeListener {
e.setCanceled(true); e.setCanceled(true);
//Fixes desync as we do not cancel the event clientside //Fixes desync as we do not cancel the event clientside
PlayerUtils.updateHeldItems((ServerPlayerEntity) player); PlayerUtils.updateHeldItems((ServerPlayer) player);
return; return;
} }
@@ -45,7 +45,7 @@ public class NetworkNodeListener {
} }
} }
private void discoverNode(IWorld world, BlockPos pos) { private void discoverNode(LevelAccessor world, BlockPos pos) {
for (Direction facing : Direction.values()) { for (Direction facing : Direction.values()) {
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing))); INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));

View File

@@ -5,12 +5,12 @@ import com.refinedmods.refinedstorage.api.network.node.INetworkNodeFactory;
import com.refinedmods.refinedstorage.api.network.node.INetworkNodeManager; import com.refinedmods.refinedstorage.api.network.node.INetworkNodeManager;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData; import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation; import net.minecraft.nbt.ListTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import net.minecraftforge.common.util.Constants; import net.minecraft.nbt.Tag;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -26,30 +26,28 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
private static final String NBT_NODE_DATA = "Data"; private static final String NBT_NODE_DATA = "Data";
private static final String NBT_NODE_POS = "Pos"; private static final String NBT_NODE_POS = "Pos";
private final World world; private final Level world;
private final Logger logger = LogManager.getLogger(getClass()); private final Logger logger = LogManager.getLogger(getClass());
private final ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>(); private final ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
public NetworkNodeManager(String name, World world) { public NetworkNodeManager(Level world) {
super(name);
this.world = world; this.world = world;
} }
@Override @Override
public void load(CompoundNBT tag) { public void load(CompoundTag tag) {
if (tag.contains(NBT_NODES)) { if (tag.contains(NBT_NODES)) {
ListNBT nodesTag = tag.getList(NBT_NODES, Constants.NBT.TAG_COMPOUND); ListTag nodesTag = tag.getList(NBT_NODES, Tag.TAG_COMPOUND);
this.nodes.clear(); this.nodes.clear();
for (int i = 0; i < nodesTag.size(); ++i) { for (int i = 0; i < nodesTag.size(); ++i) {
CompoundNBT nodeTag = nodesTag.getCompound(i); CompoundTag nodeTag = nodesTag.getCompound(i);
ResourceLocation id = new ResourceLocation(nodeTag.getString(NBT_NODE_ID)); ResourceLocation id = new ResourceLocation(nodeTag.getString(NBT_NODE_ID));
CompoundNBT data = nodeTag.getCompound(NBT_NODE_DATA); CompoundTag data = nodeTag.getCompound(NBT_NODE_DATA);
BlockPos pos = BlockPos.of(nodeTag.getLong(NBT_NODE_POS)); BlockPos pos = BlockPos.of(nodeTag.getLong(NBT_NODE_POS));
INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id); INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id);
@@ -74,16 +72,16 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
} }
@Override @Override
public CompoundNBT save(CompoundNBT tag) { public CompoundTag save(CompoundTag tag) {
ListNBT list = new ListNBT(); ListTag list = new ListTag();
for (INetworkNode node : all()) { for (INetworkNode node : all()) {
try { try {
CompoundNBT nodeTag = new CompoundNBT(); CompoundTag nodeTag = new CompoundTag();
nodeTag.putString(NBT_NODE_ID, node.getId().toString()); nodeTag.putString(NBT_NODE_ID, node.getId().toString());
nodeTag.putLong(NBT_NODE_POS, node.getPos().asLong()); nodeTag.putLong(NBT_NODE_POS, node.getPos().asLong());
nodeTag.put(NBT_NODE_DATA, node.write(new CompoundNBT())); nodeTag.put(NBT_NODE_DATA, node.write(new CompoundTag()));
list.add(nodeTag); list.add(nodeTag);
} catch (Throwable t) { } catch (Throwable t) {

View File

@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.network;
import com.refinedmods.refinedstorage.api.network.node.INetworkNodeFactory; import com.refinedmods.refinedstorage.api.network.node.INetworkNodeFactory;
import com.refinedmods.refinedstorage.api.network.node.INetworkNodeRegistry; import com.refinedmods.refinedstorage.api.network.node.INetworkNodeRegistry;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;

View File

@@ -13,15 +13,15 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
import com.refinedmods.refinedstorage.apiimpl.API; import com.refinedmods.refinedstorage.apiimpl.API;
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode; import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
import com.refinedmods.refinedstorage.item.PatternItem; import com.refinedmods.refinedstorage.item.PatternItem;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.NonNullList;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.world.Containers;
import net.minecraft.inventory.InventoryHelper; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.Item; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.Item;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fml.hooks.BasicEventHooks; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -30,12 +30,12 @@ import java.util.concurrent.atomic.AtomicReference;
public class CraftingGridBehavior implements ICraftingGridBehavior { public class CraftingGridBehavior implements ICraftingGridBehavior {
@Override @Override
public void onCrafted(INetworkAwareGrid grid, ICraftingRecipe recipe, PlayerEntity player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems) { public void onCrafted(INetworkAwareGrid grid, CraftingRecipe recipe, Player player, @Nullable IStackList<ItemStack> availableItems, @Nullable IStackList<ItemStack> usedItems) {
NonNullList<ItemStack> remainder = recipe.getRemainingItems(grid.getCraftingMatrix()); NonNullList<ItemStack> remainder = recipe.getRemainingItems(grid.getCraftingMatrix());
INetwork network = grid.getNetwork(); INetwork network = grid.getNetwork();
CraftingInventory matrix = grid.getCraftingMatrix(); CraftingContainer matrix = grid.getCraftingMatrix();
for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) { for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) {
ItemStack slot = matrix.getItem(i); ItemStack slot = matrix.getItem(i);
@@ -44,12 +44,12 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
if (i < remainder.size() && !remainder.get(i).isEmpty()) { if (i < remainder.size() && !remainder.get(i).isEmpty()) {
// If there is no space for the remainder, dump it in the player inventory. // If there is no space for the remainder, dump it in the player inventory.
if (!slot.isEmpty() && slot.getCount() > 1) { if (!slot.isEmpty() && slot.getCount() > 1) {
if (!player.inventory.add(remainder.get(i).copy())) { // If there is no space in the player inventory, try to dump it in the network. if (!player.getInventory().add(remainder.get(i).copy())) { // If there is no space in the player inventory, try to dump it in the network.
ItemStack remainderStack = network == null ? remainder.get(i).copy() : network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), Action.PERFORM); ItemStack remainderStack = network == null ? remainder.get(i).copy() : network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), Action.PERFORM);
// If there is no space in the network, just dump it in the world. // If there is no space in the network, just dump it in the world.
if (!remainderStack.isEmpty()) { if (!remainderStack.isEmpty()) {
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainderStack); Containers.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainderStack);
} }
} }
@@ -87,8 +87,8 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
@Override @Override
public void onCraftedShift(INetworkAwareGrid grid, PlayerEntity player) { public void onCraftedShift(INetworkAwareGrid grid, Player player) {
CraftingInventory matrix = grid.getCraftingMatrix(); CraftingContainer matrix = grid.getCraftingMatrix();
INetwork network = grid.getNetwork(); INetwork network = grid.getNetwork();
List<ItemStack> craftedItemsList = new ArrayList<>(); List<ItemStack> craftedItemsList = new ArrayList<>();
ItemStack crafted = grid.getCraftingResult().getItem(0); ItemStack crafted = grid.getCraftingResult().getItem(0);
@@ -123,8 +123,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
for (ItemStack craftedItem : craftedItemsList) { for (ItemStack craftedItem : craftedItemsList) {
if (!player.inventory.add(craftedItem.copy())) { if (!player.getInventory().add(craftedItem.copy())) {
ItemStack remainder = craftedItem; ItemStack remainder = craftedItem;
if (useNetwork) { if (useNetwork) {
@@ -132,7 +131,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
if (!remainder.isEmpty()) { if (!remainder.isEmpty()) {
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainder); Containers.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainder);
} }
} }
} }
@@ -141,11 +140,11 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
// otherwise it's not being called. // otherwise it's not being called.
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack) // For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
crafted.onCraftedBy(player.level, player, amountCrafted); crafted.onCraftedBy(player.level, player, amountCrafted);
BasicEventHooks.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix()); ForgeEventFactory.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix());
ForgeHooks.setCraftingPlayer(null); ForgeHooks.setCraftingPlayer(null);
} }
private void filterDuplicateStacks(INetwork network, CraftingInventory matrix, IStackList<ItemStack> availableItems) { private void filterDuplicateStacks(INetwork network, CraftingContainer matrix, IStackList<ItemStack> availableItems) {
for (int i = 0; i < matrix.getContainerSize(); ++i) { for (int i = 0; i < matrix.getContainerSize(); ++i) {
ItemStack stack = network.getItemStorageCache().getList().get(matrix.getItem(i)); ItemStack stack = network.getItemStorageCache().getList().get(matrix.getItem(i));
@@ -157,7 +156,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
@Override @Override
public void onRecipeTransfer(INetworkAwareGrid grid, PlayerEntity player, ItemStack[][] recipe) { public void onRecipeTransfer(INetworkAwareGrid grid, Player player, ItemStack[][] recipe) {
INetwork network = grid.getNetwork(); INetwork network = grid.getNetwork();
if (network != null && grid.getGridType() == GridType.CRAFTING && !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) { if (network != null && grid.getGridType() == GridType.CRAFTING && !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
@@ -182,7 +181,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
} else { } else {
// If we aren't connected, try to insert into player inventory. If it fails, stop. // If we aren't connected, try to insert into player inventory. If it fails, stop.
if (!player.inventory.add(slot.copy())) { if (!player.getInventory().add(slot.copy())) {
return; return;
} }
} }
@@ -228,11 +227,11 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
// If we haven't found anything in the network (or we are disconnected), go look in the player inventory // If we haven't found anything in the network (or we are disconnected), go look in the player inventory
if (!found) { if (!found) {
for (ItemStack possibility : possibilities) { for (ItemStack possibility : possibilities) {
for (int j = 0; j < player.inventory.getContainerSize(); ++j) { for (int j = 0; j < player.getInventory().getContainerSize(); ++j) {
if (API.instance().getComparer().isEqual(possibility, player.inventory.getItem(j), IComparer.COMPARE_NBT)) { if (API.instance().getComparer().isEqual(possibility, player.getInventory().getItem(j), IComparer.COMPARE_NBT)) {
grid.getCraftingMatrix().setItem(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getItem(j), 1)); grid.getCraftingMatrix().setItem(i, ItemHandlerHelper.copyStackWithSize(player.getInventory().getItem(j), 1));
player.inventory.removeItem(j, 1); player.getInventory().removeItem(j, 1);
found = true; found = true;
@@ -258,7 +257,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
} }
} }
private Comparator<ItemStack> compareByItemStackCounts(PlayerEntity player, INetwork network, AtomicReference<Map<Item, ItemStack>> playerItems) { private Comparator<ItemStack> compareByItemStackCounts(Player player, INetwork network, AtomicReference<Map<Item, ItemStack>> playerItems) {
return Comparator.comparingInt((ItemStack itemStack) -> { return Comparator.comparingInt((ItemStack itemStack) -> {
ItemStack stack = network.getItemStorageCache().getList().get(itemStack); ItemStack stack = network.getItemStorageCache().getList().get(itemStack);
@@ -282,10 +281,10 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
}).reversed(); }).reversed();
} }
private Map<Item, ItemStack> makePlayerInventoryMap(PlayerEntity player, INetwork network) { private Map<Item, ItemStack> makePlayerInventoryMap(Player player, INetwork network) {
Map<Item, ItemStack> playerItems = new HashMap<>(); Map<Item, ItemStack> playerItems = new HashMap<>();
for (int j = 0; j < player.inventory.getContainerSize(); j++) { for (int j = 0; j < player.getInventory().getContainerSize(); j++) {
ItemStack inventoryStack = player.inventory.getItem(j); ItemStack inventoryStack = player.getInventory().getItem(j);
if (inventoryStack.getItem() instanceof ICraftingPatternProvider) { if (inventoryStack.getItem() instanceof ICraftingPatternProvider) {
ICraftingPattern pattern = PatternItem.fromCache(network.getWorld(), inventoryStack); ICraftingPattern pattern = PatternItem.fromCache(network.getWorld(), inventoryStack);

View File

@@ -6,13 +6,13 @@ import com.refinedmods.refinedstorage.api.network.grid.IGridFactory;
import com.refinedmods.refinedstorage.api.network.grid.IGridManager; import com.refinedmods.refinedstorage.api.network.grid.IGridManager;
import com.refinedmods.refinedstorage.container.factory.GridContainerProvider; import com.refinedmods.refinedstorage.container.factory.GridContainerProvider;
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot; import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -28,17 +28,17 @@ public class GridManager implements IGridManager {
} }
@Override @Override
public void openGrid(ResourceLocation id, ServerPlayerEntity player, BlockPos pos) { public void openGrid(ResourceLocation id, ServerPlayer player, BlockPos pos) {
openGrid(id, player, null, pos, new PlayerSlot(-1)); openGrid(id, player, null, pos, new PlayerSlot(-1));
} }
@Override @Override
public void openGrid(ResourceLocation id, ServerPlayerEntity player, ItemStack stack, PlayerSlot slot) { public void openGrid(ResourceLocation id, ServerPlayer player, ItemStack stack, PlayerSlot slot) {
openGrid(id, player, stack, null, slot); openGrid(id, player, stack, null, slot);
} }
private void openGrid(ResourceLocation id, ServerPlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) { private void openGrid(ResourceLocation id, ServerPlayer player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) {
Pair<IGrid, TileEntity> grid = createGrid(id, player, stack, pos, slot); Pair<IGrid, BlockEntity> grid = createGrid(id, player, stack, pos, slot);
if (grid == null) { if (grid == null) {
return; return;
} }
@@ -62,7 +62,7 @@ public class GridManager implements IGridManager {
@Override @Override
@Nullable @Nullable
public Pair<IGrid, TileEntity> createGrid(ResourceLocation id, PlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) { public Pair<IGrid, BlockEntity> createGrid(ResourceLocation id, Player player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) {
IGridFactory factory = factories.get(id); IGridFactory factory = factories.get(id);
if (factory == null) { if (factory == null) {
@@ -70,7 +70,7 @@ public class GridManager implements IGridManager {
} }
IGrid grid = null; IGrid grid = null;
TileEntity tile = factory.getRelevantTile(player.level, pos); BlockEntity tile = factory.getRelevantTile(player.level, pos);
if (factory.getType() == GridFactoryType.STACK) { if (factory.getType() == GridFactoryType.STACK) {
grid = factory.createFromStack(player, stack, slot); grid = factory.createFromStack(player, stack, slot);

Some files were not shown because too many files have changed in this diff Show More