Porting to 1.18.1
This commit is contained in:
@@ -10,10 +10,10 @@ import com.refinedmods.refinedstorage.network.NetworkHandler;
|
||||
import com.refinedmods.refinedstorage.setup.ClientSetup;
|
||||
import com.refinedmods.refinedstorage.setup.CommonSetup;
|
||||
import com.refinedmods.refinedstorage.setup.ServerSetup;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
@@ -28,7 +28,7 @@ public final class RS {
|
||||
public static final String NAME = "Refined Storage";
|
||||
|
||||
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 ClientConfig CLIENT_CONFIG = new ClientConfig();
|
||||
|
||||
@@ -46,9 +46,10 @@ public final class RS {
|
||||
RSLootFunctions.register();
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(commonSetup::onCommonSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(TileEntityType.class, commonSetup::onRegisterTiles);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(IRecipeSerializer.class, commonSetup::onRegisterRecipeSerializers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ContainerType.class, commonSetup::onRegisterContainers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(BlockEntityType.class, commonSetup::onRegisterTiles);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(RecipeSerializer.class, commonSetup::onRegisterRecipeSerializers);
|
||||
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 CuriosIntegration());
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.refinedmods.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.refinedmods.refinedstorage.block.*;
|
||||
import com.refinedmods.refinedstorage.item.blockitem.PortableGridBlockItem;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
@@ -19,13 +19,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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<ExporterBlock> EXPORTER;
|
||||
|
||||
public static final RegistryObject<QuartzEnrichedIronBlock> QUARTZ_ENRICHED_IRON;
|
||||
public static final RegistryObject<MachineCasingBlock> MACHINE_CASING;
|
||||
public static final RegistryObject<CableBlock> CABLE;
|
||||
@@ -40,7 +35,8 @@ public final class RSBlocks {
|
||||
public static final RegistryObject<DestructorBlock> DESTRUCTOR;
|
||||
public static final RegistryObject<PortableGridBlock> 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<RelayBlock> RELAY = 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<CraftingMonitorBlock> CRAFTING_MONITOR = new ColorMap<>(BLOCKS);
|
||||
public static final ColorMap<DetectorBlock> DETECTOR = new ColorMap<>(BLOCKS);
|
||||
|
||||
public static final List<RegistryObject<? extends Block>> COLORED_BLOCKS = new ArrayList<>();
|
||||
private static final String GRID_SUFFIX = "_grid";
|
||||
|
||||
static {
|
||||
QUARTZ_ENRICHED_IRON = BLOCKS.register("quartz_enriched_iron_block", QuartzEnrichedIronBlock::new);
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
package com.refinedmods.refinedstorage;
|
||||
|
||||
import com.refinedmods.refinedstorage.container.*;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@ObjectHolder(RS.ID)
|
||||
public final class RSContainers {
|
||||
@ObjectHolder("controller")
|
||||
public static final ContainerType<ControllerContainer> CONTROLLER = null;
|
||||
public static final MenuType<ControllerContainer> CONTROLLER = null;
|
||||
@ObjectHolder("grid")
|
||||
public static final ContainerType<GridContainer> GRID = null;
|
||||
public static final MenuType<GridContainer> GRID = null;
|
||||
@ObjectHolder("detector")
|
||||
public static final ContainerType<DetectorContainer> DETECTOR = null;
|
||||
public static final MenuType<DetectorContainer> DETECTOR = null;
|
||||
@ObjectHolder("exporter")
|
||||
public static final ContainerType<ExporterContainer> EXPORTER = null;
|
||||
public static final MenuType<ExporterContainer> EXPORTER = null;
|
||||
@ObjectHolder("external_storage")
|
||||
public static final ContainerType<ExternalStorageContainer> EXTERNAL_STORAGE = null;
|
||||
public static final MenuType<ExternalStorageContainer> EXTERNAL_STORAGE = null;
|
||||
@ObjectHolder("filter")
|
||||
public static final ContainerType<FilterContainer> FILTER = null;
|
||||
public static final MenuType<FilterContainer> FILTER = null;
|
||||
@ObjectHolder("importer")
|
||||
public static final ContainerType<ImporterContainer> IMPORTER = null;
|
||||
public static final MenuType<ImporterContainer> IMPORTER = null;
|
||||
@ObjectHolder("network_transmitter")
|
||||
public static final ContainerType<NetworkTransmitterContainer> NETWORK_TRANSMITTER = null;
|
||||
public static final MenuType<NetworkTransmitterContainer> NETWORK_TRANSMITTER = null;
|
||||
@ObjectHolder("relay")
|
||||
public static final ContainerType<RelayContainer> RELAY = null;
|
||||
public static final MenuType<RelayContainer> RELAY = null;
|
||||
@ObjectHolder("disk_drive")
|
||||
public static final ContainerType<DiskDriveContainer> DISK_DRIVE = null;
|
||||
public static final MenuType<DiskDriveContainer> DISK_DRIVE = null;
|
||||
@ObjectHolder("storage_block")
|
||||
public static final ContainerType<StorageContainer> STORAGE_BLOCK = null;
|
||||
public static final MenuType<StorageContainer> STORAGE_BLOCK = null;
|
||||
@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")
|
||||
public static final ContainerType<SecurityManagerContainer> SECURITY_MANAGER = null;
|
||||
public static final MenuType<SecurityManagerContainer> SECURITY_MANAGER = null;
|
||||
@ObjectHolder("interface")
|
||||
public static final ContainerType<InterfaceContainer> INTERFACE = null;
|
||||
public static final MenuType<InterfaceContainer> INTERFACE = null;
|
||||
@ObjectHolder("fluid_interface")
|
||||
public static final ContainerType<FluidInterfaceContainer> FLUID_INTERFACE = null;
|
||||
public static final MenuType<FluidInterfaceContainer> FLUID_INTERFACE = null;
|
||||
@ObjectHolder("wireless_transmitter")
|
||||
public static final ContainerType<WirelessTransmitterContainer> WIRELESS_TRANSMITTER = null;
|
||||
public static final MenuType<WirelessTransmitterContainer> WIRELESS_TRANSMITTER = null;
|
||||
@ObjectHolder("storage_monitor")
|
||||
public static final ContainerType<StorageMonitorContainer> STORAGE_MONITOR = null;
|
||||
public static final MenuType<StorageMonitorContainer> STORAGE_MONITOR = null;
|
||||
@ObjectHolder("constructor")
|
||||
public static final ContainerType<ConstructorContainer> CONSTRUCTOR = null;
|
||||
public static final MenuType<ConstructorContainer> CONSTRUCTOR = null;
|
||||
@ObjectHolder("destructor")
|
||||
public static final ContainerType<DestructorContainer> DESTRUCTOR = null;
|
||||
public static final MenuType<DestructorContainer> DESTRUCTOR = null;
|
||||
@ObjectHolder("disk_manipulator")
|
||||
public static final ContainerType<DiskManipulatorContainer> DISK_MANIPULATOR = null;
|
||||
public static final MenuType<DiskManipulatorContainer> DISK_MANIPULATOR = null;
|
||||
@ObjectHolder("crafter")
|
||||
public static final ContainerType<CrafterContainer> CRAFTER = null;
|
||||
public static final MenuType<CrafterContainer> CRAFTER = null;
|
||||
@ObjectHolder("crafter_manager")
|
||||
public static final ContainerType<CrafterManagerContainer> CRAFTER_MANAGER = null;
|
||||
public static final MenuType<CrafterManagerContainer> CRAFTER_MANAGER = null;
|
||||
@ObjectHolder("crafting_monitor")
|
||||
public static final ContainerType<CraftingMonitorContainer> CRAFTING_MONITOR = null;
|
||||
public static final MenuType<CraftingMonitorContainer> CRAFTING_MONITOR = null;
|
||||
@ObjectHolder("wireless_crafting_monitor")
|
||||
public static final ContainerType<CraftingMonitorContainer> WIRELESS_CRAFTING_MONITOR = null;
|
||||
public static final MenuType<CraftingMonitorContainer> WIRELESS_CRAFTING_MONITOR = null;
|
||||
|
||||
private RSContainers() {
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ import com.refinedmods.refinedstorage.item.*;
|
||||
import com.refinedmods.refinedstorage.item.blockitem.*;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -167,13 +167,13 @@ public final class RSItems {
|
||||
LATE_REGISTRATION.add(() -> {
|
||||
RSBlocks.CONTROLLER.forEach((color, block) -> {
|
||||
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) -> {
|
||||
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()))));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package com.refinedmods.refinedstorage;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||
import net.minecraftforge.client.settings.KeyModifier;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
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",
|
||||
KeyConflictContext.GUI,
|
||||
InputMappings.Type.KEYSYM,
|
||||
InputConstants.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_TAB,
|
||||
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",
|
||||
KeyConflictContext.GUI,
|
||||
KeyModifier.CONTROL,
|
||||
InputMappings.Type.KEYSYM,
|
||||
InputConstants.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_X,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding(
|
||||
public static final KeyMapping OPEN_WIRELESS_GRID = new KeyMapping(
|
||||
"key.refinedstorage.openWirelessGrid",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.UNKNOWN,
|
||||
InputConstants.UNKNOWN,
|
||||
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",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.UNKNOWN,
|
||||
InputConstants.UNKNOWN,
|
||||
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",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.UNKNOWN,
|
||||
InputConstants.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding(
|
||||
public static final KeyMapping OPEN_PORTABLE_GRID = new KeyMapping(
|
||||
"key.refinedstorage.openPortableGrid",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.UNKNOWN,
|
||||
InputConstants.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
|
||||
@@ -4,39 +4,39 @@ import com.refinedmods.refinedstorage.loottable.ControllerLootFunction;
|
||||
import com.refinedmods.refinedstorage.loottable.CrafterLootFunction;
|
||||
import com.refinedmods.refinedstorage.loottable.PortableGridBlockLootFunction;
|
||||
import com.refinedmods.refinedstorage.loottable.StorageBlockLootFunction;
|
||||
import net.minecraft.loot.LootFunctionType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
|
||||
|
||||
public final class RSLootFunctions {
|
||||
private static LootFunctionType storageBlock;
|
||||
private static LootFunctionType portableGrid;
|
||||
private static LootFunctionType crafter;
|
||||
private static LootFunctionType controller;
|
||||
private static LootItemFunctionType storageBlock;
|
||||
private static LootItemFunctionType portableGrid;
|
||||
private static LootItemFunctionType crafter;
|
||||
private static LootItemFunctionType controller;
|
||||
|
||||
private RSLootFunctions() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
storageBlock = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootFunctionType(new StorageBlockLootFunction.Serializer()));
|
||||
portableGrid = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootFunctionType(new PortableGridBlockLootFunction.Serializer()));
|
||||
crafter = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "crafter"), new LootFunctionType(new CrafterLootFunction.Serializer()));
|
||||
controller = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "controller"), new LootFunctionType(new ControllerLootFunction.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 LootItemFunctionType(new PortableGridBlockLootFunction.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 LootItemFunctionType(new ControllerLootFunction.Serializer()));
|
||||
}
|
||||
|
||||
public static LootFunctionType getStorageBlock() {
|
||||
public static LootItemFunctionType getStorageBlock() {
|
||||
return storageBlock;
|
||||
}
|
||||
|
||||
public static LootFunctionType getPortableGrid() {
|
||||
public static LootItemFunctionType getPortableGrid() {
|
||||
return portableGrid;
|
||||
}
|
||||
|
||||
public static LootFunctionType getCrafter() {
|
||||
public static LootItemFunctionType getCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
|
||||
public static LootFunctionType getController() {
|
||||
public static LootItemFunctionType getController() {
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,87 +4,87 @@ import com.refinedmods.refinedstorage.tile.*;
|
||||
import com.refinedmods.refinedstorage.tile.craftingmonitor.CraftingMonitorTile;
|
||||
import com.refinedmods.refinedstorage.tile.grid.GridTile;
|
||||
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;
|
||||
|
||||
@ObjectHolder(RS.ID)
|
||||
public final class RSTiles {
|
||||
@ObjectHolder("controller")
|
||||
public static final TileEntityType<ControllerTile> CONTROLLER = null;
|
||||
public static final BlockEntityType<ControllerTile> CONTROLLER = null;
|
||||
@ObjectHolder("creative_controller")
|
||||
public static final TileEntityType<ControllerTile> CREATIVE_CONTROLLER = null;
|
||||
public static final BlockEntityType<ControllerTile> CREATIVE_CONTROLLER = null;
|
||||
@ObjectHolder("detector")
|
||||
public static final TileEntityType<DetectorTile> DETECTOR = null;
|
||||
public static final BlockEntityType<DetectorTile> DETECTOR = null;
|
||||
@ObjectHolder("disk_drive")
|
||||
public static final TileEntityType<DiskDriveTile> DISK_DRIVE = null;
|
||||
public static final BlockEntityType<DiskDriveTile> DISK_DRIVE = null;
|
||||
@ObjectHolder("exporter")
|
||||
public static final TileEntityType<ExporterTile> EXPORTER = null;
|
||||
public static final BlockEntityType<ExporterTile> EXPORTER = null;
|
||||
@ObjectHolder("external_storage")
|
||||
public static final TileEntityType<ExternalStorageTile> EXTERNAL_STORAGE = null;
|
||||
public static final BlockEntityType<ExternalStorageTile> EXTERNAL_STORAGE = null;
|
||||
@ObjectHolder("grid")
|
||||
public static final TileEntityType<GridTile> GRID = null;
|
||||
public static final BlockEntityType<GridTile> GRID = null;
|
||||
@ObjectHolder("crafting_grid")
|
||||
public static final TileEntityType<GridTile> CRAFTING_GRID = null;
|
||||
public static final BlockEntityType<GridTile> CRAFTING_GRID = null;
|
||||
@ObjectHolder("pattern_grid")
|
||||
public static final TileEntityType<GridTile> PATTERN_GRID = null;
|
||||
public static final BlockEntityType<GridTile> PATTERN_GRID = null;
|
||||
@ObjectHolder("fluid_grid")
|
||||
public static final TileEntityType<GridTile> FLUID_GRID = null;
|
||||
public static final BlockEntityType<GridTile> FLUID_GRID = null;
|
||||
@ObjectHolder("importer")
|
||||
public static final TileEntityType<ImporterTile> IMPORTER = null;
|
||||
public static final BlockEntityType<ImporterTile> IMPORTER = null;
|
||||
@ObjectHolder("network_transmitter")
|
||||
public static final TileEntityType<NetworkTransmitterTile> NETWORK_TRANSMITTER = null;
|
||||
public static final BlockEntityType<NetworkTransmitterTile> NETWORK_TRANSMITTER = null;
|
||||
@ObjectHolder("network_receiver")
|
||||
public static final TileEntityType<NetworkReceiverTile> NETWORK_RECEIVER = null;
|
||||
public static final BlockEntityType<NetworkReceiverTile> NETWORK_RECEIVER = null;
|
||||
@ObjectHolder("relay")
|
||||
public static final TileEntityType<RelayTile> RELAY = null;
|
||||
public static final BlockEntityType<RelayTile> RELAY = null;
|
||||
@ObjectHolder("cable")
|
||||
public static final TileEntityType<CableTile> CABLE = null;
|
||||
public static final BlockEntityType<CableTile> CABLE = null;
|
||||
@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")
|
||||
public static final TileEntityType<StorageTile> FOUR_K_STORAGE_BLOCK = null;
|
||||
public static final BlockEntityType<StorageTile> FOUR_K_STORAGE_BLOCK = null;
|
||||
@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")
|
||||
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")
|
||||
public static final TileEntityType<StorageTile> CREATIVE_STORAGE_BLOCK = null;
|
||||
public static final BlockEntityType<StorageTile> CREATIVE_STORAGE_BLOCK = null;
|
||||
@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")
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
public static final TileEntityType<FluidStorageTile> CREATIVE_FLUID_STORAGE_BLOCK = null;
|
||||
public static final BlockEntityType<FluidStorageTile> CREATIVE_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("security_manager")
|
||||
public static final TileEntityType<SecurityManagerTile> SECURITY_MANAGER = null;
|
||||
public static final BlockEntityType<SecurityManagerTile> SECURITY_MANAGER = null;
|
||||
@ObjectHolder("interface")
|
||||
public static final TileEntityType<InterfaceTile> INTERFACE = null;
|
||||
public static final BlockEntityType<InterfaceTile> INTERFACE = null;
|
||||
@ObjectHolder("fluid_interface")
|
||||
public static final TileEntityType<FluidInterfaceTile> FLUID_INTERFACE = null;
|
||||
public static final BlockEntityType<FluidInterfaceTile> FLUID_INTERFACE = null;
|
||||
@ObjectHolder("wireless_transmitter")
|
||||
public static final TileEntityType<WirelessTransmitterTile> WIRELESS_TRANSMITTER = null;
|
||||
public static final BlockEntityType<WirelessTransmitterTile> WIRELESS_TRANSMITTER = null;
|
||||
@ObjectHolder("storage_monitor")
|
||||
public static final TileEntityType<StorageMonitorTile> STORAGE_MONITOR = null;
|
||||
public static final BlockEntityType<StorageMonitorTile> STORAGE_MONITOR = null;
|
||||
@ObjectHolder("constructor")
|
||||
public static final TileEntityType<ConstructorTile> CONSTRUCTOR = null;
|
||||
public static final BlockEntityType<ConstructorTile> CONSTRUCTOR = null;
|
||||
@ObjectHolder("destructor")
|
||||
public static final TileEntityType<DestructorTile> DESTRUCTOR = null;
|
||||
public static final BlockEntityType<DestructorTile> DESTRUCTOR = null;
|
||||
@ObjectHolder("disk_manipulator")
|
||||
public static final TileEntityType<DiskManipulatorTile> DISK_MANIPULATOR = null;
|
||||
public static final BlockEntityType<DiskManipulatorTile> DISK_MANIPULATOR = null;
|
||||
@ObjectHolder("portable_grid")
|
||||
public static final TileEntityType<PortableGridTile> PORTABLE_GRID = null;
|
||||
public static final BlockEntityType<PortableGridTile> PORTABLE_GRID = null;
|
||||
@ObjectHolder("creative_portable_grid")
|
||||
public static final TileEntityType<PortableGridTile> CREATIVE_PORTABLE_GRID = null;
|
||||
public static final BlockEntityType<PortableGridTile> CREATIVE_PORTABLE_GRID = null;
|
||||
@ObjectHolder("crafter")
|
||||
public static final TileEntityType<CrafterTile> CRAFTER = null;
|
||||
public static final BlockEntityType<CrafterTile> CRAFTER = null;
|
||||
@ObjectHolder("crafter_manager")
|
||||
public static final TileEntityType<CrafterManagerTile> CRAFTER_MANAGER = null;
|
||||
public static final BlockEntityType<CrafterManagerTile> CRAFTER_MANAGER = null;
|
||||
@ObjectHolder("crafting_monitor")
|
||||
public static final TileEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null;
|
||||
public static final BlockEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null;
|
||||
|
||||
private RSTiles() {
|
||||
}
|
||||
|
||||
@@ -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.IQuantityFormatter;
|
||||
import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -62,7 +62,7 @@ public interface IRSAPI {
|
||||
* @param world 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.
|
||||
@@ -70,7 +70,7 @@ public interface IRSAPI {
|
||||
* @param world world
|
||||
* @return the network manager for a given world
|
||||
*/
|
||||
INetworkManager getNetworkManager(ServerWorld world);
|
||||
INetworkManager getNetworkManager(ServerLevel world);
|
||||
|
||||
/**
|
||||
* @return the crafting task registry
|
||||
@@ -131,7 +131,7 @@ public interface IRSAPI {
|
||||
* @return the storage disk manager
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld);
|
||||
IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld);
|
||||
|
||||
/**
|
||||
* @return the storage disk sync manager
|
||||
@@ -143,7 +143,7 @@ public interface IRSAPI {
|
||||
* @return the storage tracker manager
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageTrackerManager getStorageTrackerManager(ServerWorld anyWorld);
|
||||
IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld);
|
||||
|
||||
/**
|
||||
* Adds an external storage provider for the given storage type.
|
||||
@@ -166,7 +166,7 @@ public interface IRSAPI {
|
||||
* @return a storage disk
|
||||
*/
|
||||
@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
|
||||
@@ -175,7 +175,7 @@ public interface IRSAPI {
|
||||
* @return a fluid storage disk
|
||||
*/
|
||||
@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.
|
||||
@@ -201,7 +201,7 @@ public interface IRSAPI {
|
||||
* @param tag the nbt tag
|
||||
* @return the request info
|
||||
*/
|
||||
ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException;
|
||||
ICraftingRequestInfo createCraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException;
|
||||
|
||||
/**
|
||||
* @param renderHandler the render handler to add
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.refinedmods.refinedstorage.api.autocrafting;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.task.ICalculationResult;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface ICraftingManager {
|
||||
/**
|
||||
* @return named crafting pattern containers
|
||||
*/
|
||||
Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers();
|
||||
Map<Component, List<IItemHandlerModifiable>> getNamedContainers();
|
||||
|
||||
/**
|
||||
* Starts a crafting task.
|
||||
@@ -140,13 +140,13 @@ public interface ICraftingManager {
|
||||
/**
|
||||
* @param tag the tag to read from
|
||||
*/
|
||||
void readFromNbt(CompoundNBT tag);
|
||||
void readFromNbt(CompoundTag tag);
|
||||
|
||||
/**
|
||||
* @param tag the tag to write to
|
||||
* @return the written tag
|
||||
*/
|
||||
CompoundNBT writeToNbt(CompoundNBT tag);
|
||||
CompoundTag writeToNbt(CompoundTag tag);
|
||||
|
||||
/**
|
||||
* @param listener the listener
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.task.ICraftingTaskRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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
|
||||
*/
|
||||
@Nullable
|
||||
ITextComponent getErrorMessage();
|
||||
Component getErrorMessage();
|
||||
|
||||
/**
|
||||
* @return true if the crafting pattern can be treated as a processing pattern, false otherwise
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.refinedmods.refinedstorage.api.autocrafting;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
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
|
||||
*/
|
||||
@Nullable
|
||||
TileEntity getConnectedTile();
|
||||
BlockEntity getConnectedTile();
|
||||
|
||||
/**
|
||||
* @return the tile that this container is facing
|
||||
*/
|
||||
TileEntity getFacingTile();
|
||||
BlockEntity getFacingTile();
|
||||
|
||||
/**
|
||||
* @return the direction to the facing tile
|
||||
@@ -90,7 +90,7 @@ public interface ICraftingPatternContainer {
|
||||
*
|
||||
* @return the name of this container
|
||||
*/
|
||||
ITextComponent getName();
|
||||
Component getName();
|
||||
|
||||
/**
|
||||
* @return the position of this container
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -19,5 +19,5 @@ public interface ICraftingPatternProvider {
|
||||
* @return the crafting pattern
|
||||
*/
|
||||
@Nonnull
|
||||
ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container);
|
||||
ICraftingPattern create(Level world, ItemStack stack, ICraftingPatternContainer container);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.IRSAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Defines the behavior of pattern rendering.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -23,7 +23,7 @@ public interface ICraftingMonitorElement {
|
||||
* @param drawers the drawers that this element can use
|
||||
*/
|
||||
@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}
|
||||
@@ -42,7 +42,7 @@ public interface ICraftingMonitorElement {
|
||||
/**
|
||||
* @return the tooltip of this element
|
||||
*/
|
||||
default List<ITextComponent> getTooltip() {
|
||||
default List<Component> getTooltip() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface ICraftingMonitorElement {
|
||||
*
|
||||
* @param buf the buffer
|
||||
*/
|
||||
void write(PacketBuffer buf);
|
||||
void write(FriendlyByteBuf buf);
|
||||
|
||||
/**
|
||||
* Merge an element into the current element.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Function;
|
||||
@@ -16,7 +16,7 @@ public interface ICraftingMonitorElementRegistry {
|
||||
* @param id the id, as specified in {@link ICraftingMonitorElement#getId()}
|
||||
* @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.
|
||||
@@ -25,5 +25,5 @@ public interface ICraftingMonitorElementRegistry {
|
||||
* @return the factory, or null if no factory was found
|
||||
*/
|
||||
@Nullable
|
||||
Function<PacketBuffer, ICraftingMonitorElement> get(ResourceLocation id);
|
||||
Function<FriendlyByteBuf, ICraftingMonitorElement> get(ResourceLocation id);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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 net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface ICraftingPreviewElement {
|
||||
* @param drawers the drawers this element can use
|
||||
*/
|
||||
@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
|
||||
@@ -28,7 +28,7 @@ public interface ICraftingPreviewElement {
|
||||
/**
|
||||
* @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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting.preview;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Function;
|
||||
@@ -16,7 +16,7 @@ public interface ICraftingPreviewElementRegistry {
|
||||
* @param id the id, as specified in {@link ICraftingPreviewElement#getId()}
|
||||
* @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.
|
||||
@@ -25,5 +25,5 @@ public interface ICraftingPreviewElementRegistry {
|
||||
* @return the factory, or null if no factory was found
|
||||
*/
|
||||
@Nullable
|
||||
Function<PacketBuffer, ICraftingPreviewElement> get(ResourceLocation id);
|
||||
Function<FriendlyByteBuf, ICraftingPreviewElement> get(ResourceLocation id);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting.task;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -25,5 +25,5 @@ public interface ICraftingRequestInfo {
|
||||
/**
|
||||
* @return the written tag
|
||||
*/
|
||||
CompoundNBT writeToNbt();
|
||||
CompoundTag writeToNbt();
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.api.autocrafting.task;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
@@ -63,7 +63,7 @@ public interface ICraftingTask {
|
||||
* @param tag the 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
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.api.autocrafting.task;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
/**
|
||||
* A factory that creates a crafting task.
|
||||
@@ -27,5 +27,5 @@ public interface ICraftingTaskFactory {
|
||||
* @param tag the tag
|
||||
* @return the crafting task
|
||||
*/
|
||||
ICraftingTask createFromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException;
|
||||
ICraftingTask createFromNbt(INetwork network, CompoundTag tag) throws CraftingTaskReadException;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.autocrafting.task;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -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.util.Action;
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -244,7 +244,7 @@ public interface INetwork {
|
||||
/**
|
||||
* @return the world where this network is in
|
||||
*/
|
||||
World getWorld();
|
||||
Level getWorld();
|
||||
|
||||
/**
|
||||
* @return the position of this network in the world
|
||||
@@ -254,13 +254,13 @@ public interface INetwork {
|
||||
/**
|
||||
* @return a read network
|
||||
*/
|
||||
INetwork readFromNbt(CompoundNBT tag);
|
||||
INetwork readFromNbt(CompoundTag tag);
|
||||
|
||||
/**
|
||||
* @param tag the tag to write to
|
||||
* @return a written tag
|
||||
*/
|
||||
CompoundNBT writeToNbt(CompoundNBT tag);
|
||||
CompoundTag writeToNbt(CompoundTag tag);
|
||||
|
||||
/**
|
||||
* @return sampled tick times
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.network;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
@@ -18,7 +18,7 @@ public interface INetworkNodeGraph {
|
||||
* @param world the origin world
|
||||
* @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.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.refinedmods.refinedstorage.api.network;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface INetworkNodeVisitor {
|
||||
* @param pos the position
|
||||
* @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.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
/**
|
||||
* Represents a node that can send a wireless signal.
|
||||
@@ -21,5 +21,5 @@ public interface IWirelessTransmitter {
|
||||
/**
|
||||
* @return the dimension in which the transmitter is
|
||||
*/
|
||||
RegistryKey<World> getDimension();
|
||||
ResourceKey<Level> getDimension();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.annotation.Nonnull;
|
||||
* Represents a grid type.
|
||||
* Used in {@link IGrid} to determine grid GUI rendering.
|
||||
*/
|
||||
public enum GridType implements IStringSerializable {
|
||||
public enum GridType implements StringRepresentable {
|
||||
/**
|
||||
* A regular grid.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface ICraftingGridBehavior {
|
||||
* @param availableItems the items available for 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).
|
||||
@@ -28,7 +28,7 @@ public interface ICraftingGridBehavior {
|
||||
* @param grid the grid
|
||||
* @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.
|
||||
@@ -37,5 +37,5 @@ public interface ICraftingGridBehavior {
|
||||
* @param player the player
|
||||
* @param recipe the recipe
|
||||
*/
|
||||
void onRecipeTransfer(INetworkAwareGrid grid, PlayerEntity player, ItemStack[][] recipe);
|
||||
void onRecipeTransfer(INetworkAwareGrid grid, Player player, ItemStack[][] recipe);
|
||||
}
|
||||
|
||||
@@ -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.util.IFilter;
|
||||
import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.CraftResultInventory;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.inventory.ResultContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -48,6 +48,53 @@ public interface IGrid {
|
||||
int SIZE_MEDIUM = 2;
|
||||
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
|
||||
*/
|
||||
@@ -57,7 +104,7 @@ public interface IGrid {
|
||||
* @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()}
|
||||
*/
|
||||
IStorageCacheListener createListener(ServerPlayerEntity player);
|
||||
IStorageCacheListener createListener(ServerPlayer player);
|
||||
|
||||
/**
|
||||
* @return the storage cache for this grid, or null if this grid is unavailable
|
||||
@@ -92,7 +139,7 @@ public interface IGrid {
|
||||
/**
|
||||
* @return the title
|
||||
*/
|
||||
ITextComponent getTitle();
|
||||
Component getTitle();
|
||||
|
||||
/**
|
||||
* @return the view type
|
||||
@@ -188,13 +235,13 @@ public interface IGrid {
|
||||
* @return the crafting matrix, or null if not a crafting grid
|
||||
*/
|
||||
@Nullable
|
||||
CraftingInventory getCraftingMatrix();
|
||||
CraftingContainer getCraftingMatrix();
|
||||
|
||||
/**
|
||||
* @return the crafting result inventory, or null if not a crafting grid
|
||||
*/
|
||||
@Nullable
|
||||
CraftResultInventory getCraftingResult();
|
||||
ResultContainer getCraftingResult();
|
||||
|
||||
/**
|
||||
* Called when the crafting matrix changes.
|
||||
@@ -208,19 +255,19 @@ public interface IGrid {
|
||||
* @param availableItems the items available for 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.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param player the player that crafted the item
|
||||
*/
|
||||
void onCraftedShift(PlayerEntity player);
|
||||
void onCraftedShift(Player player);
|
||||
|
||||
/**
|
||||
* Called when a JEI recipe transfer occurs.
|
||||
@@ -228,14 +275,14 @@ public interface IGrid {
|
||||
* @param player the player
|
||||
* @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.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
void onClosed(PlayerEntity player);
|
||||
void onClosed(Player player);
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid;
|
||||
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface IGridFactory {
|
||||
* @return the grid, or null if a problem occurred
|
||||
*/
|
||||
@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.
|
||||
@@ -32,7 +32,7 @@ public interface IGridFactory {
|
||||
* @return the grid, or null if a problem occurred
|
||||
*/
|
||||
@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.
|
||||
@@ -42,7 +42,7 @@ public interface IGridFactory {
|
||||
* @return the tile, or null if no tile is required
|
||||
*/
|
||||
@Nullable
|
||||
TileEntity getRelevantTile(World world, BlockPos pos);
|
||||
BlockEntity getRelevantTile(Level world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid;
|
||||
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -28,7 +28,7 @@ public interface IGridManager {
|
||||
* @param player the player
|
||||
* @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.
|
||||
@@ -38,7 +38,7 @@ public interface IGridManager {
|
||||
* @param stack the stack
|
||||
* @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.
|
||||
@@ -51,5 +51,5 @@ public interface IGridManager {
|
||||
* @return a grid, or null if an error has occurred
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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.util.IFilter;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
@@ -31,7 +31,7 @@ public interface IGridTab {
|
||||
* @param screenHeight the screen height
|
||||
* @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.
|
||||
@@ -40,5 +40,5 @@ public interface IGridTab {
|
||||
* @param x the x 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);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid.handler;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
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 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.
|
||||
@@ -28,14 +28,14 @@ public interface IFluidGridHandler {
|
||||
* @return the remainder, or an empty stack if there is no remainder
|
||||
*/
|
||||
@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.
|
||||
*
|
||||
* @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.
|
||||
@@ -45,7 +45,7 @@ public interface IFluidGridHandler {
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
@@ -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 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);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network.grid.handler;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -24,7 +24,7 @@ public interface IItemGridHandler {
|
||||
* @param preferredSlot playerInventory slot to prefer when adding or -1
|
||||
* @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.
|
||||
@@ -34,7 +34,7 @@ public interface IItemGridHandler {
|
||||
* @param preferredSlot playerInventory slot to prefer when adding or -1
|
||||
* @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.
|
||||
@@ -45,7 +45,7 @@ public interface IItemGridHandler {
|
||||
* @return the remainder, or an empty stack if there is no remainder
|
||||
*/
|
||||
@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.
|
||||
@@ -53,7 +53,7 @@ public interface IItemGridHandler {
|
||||
* @param player the player that is attempting the insert
|
||||
* @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.
|
||||
@@ -63,7 +63,7 @@ public interface IItemGridHandler {
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
@@ -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 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.
|
||||
@@ -80,7 +80,7 @@ public interface IItemGridHandler {
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
@@ -90,7 +90,7 @@ public interface IItemGridHandler {
|
||||
* @param shift if true shift is pressed, if false ctrl is pressed
|
||||
* @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
|
||||
@@ -100,5 +100,5 @@ public interface IItemGridHandler {
|
||||
* @param shift if true shift is pressed, if false ctrl is pressed
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.network.item;
|
||||
|
||||
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).
|
||||
@@ -12,7 +12,7 @@ public interface INetworkItem {
|
||||
/**
|
||||
* @return the player using the network item
|
||||
*/
|
||||
PlayerEntity getPlayer();
|
||||
Player getPlayer();
|
||||
|
||||
/**
|
||||
* Called when the network item is being opened.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network.item;
|
||||
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -18,14 +18,14 @@ public interface INetworkItemManager {
|
||||
* @param stack the stack that has been opened
|
||||
* @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.
|
||||
*
|
||||
* @param player the player that closed the network item
|
||||
*/
|
||||
void close(PlayerEntity player);
|
||||
void close(Player 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
|
||||
*/
|
||||
@Nullable
|
||||
INetworkItem getItem(PlayerEntity player);
|
||||
INetworkItem getItem(Player player);
|
||||
|
||||
/**
|
||||
* @param player the player
|
||||
* @param energy energy to extract
|
||||
*/
|
||||
void drainEnergy(PlayerEntity player, int energy);
|
||||
void drainEnergy(Player player, int energy);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network.item;
|
||||
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -20,5 +20,5 @@ public interface INetworkItemProvider {
|
||||
* @return the network item
|
||||
*/
|
||||
@Nonnull
|
||||
INetworkItem provide(INetworkItemManager handler, PlayerEntity player, ItemStack stack, PlayerSlot slot);
|
||||
INetworkItem provide(INetworkItemManager handler, Player player, ItemStack stack, PlayerSlot slot);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.refinedmods.refinedstorage.api.network.node;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -70,7 +70,7 @@ public interface INetworkNode {
|
||||
* @param tag the tag
|
||||
* @return the written tag
|
||||
*/
|
||||
CompoundNBT write(CompoundNBT tag);
|
||||
CompoundTag write(CompoundTag tag);
|
||||
|
||||
/**
|
||||
* @return the position of this network node
|
||||
@@ -80,7 +80,7 @@ public interface INetworkNode {
|
||||
/**
|
||||
* @return the world of this network node
|
||||
*/
|
||||
World getWorld();
|
||||
Level getWorld();
|
||||
|
||||
/**
|
||||
* Marks this node as dirty for saving.
|
||||
@@ -108,14 +108,14 @@ public interface INetworkNode {
|
||||
return canConduct(direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param owner the owner
|
||||
*/
|
||||
void setOwner(@Nullable UUID owner);
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
@Nullable
|
||||
UUID getOwner();
|
||||
|
||||
/**
|
||||
* @param owner the owner
|
||||
*/
|
||||
void setOwner(@Nullable UUID owner);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network.node;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -19,5 +19,5 @@ public interface INetworkNodeFactory {
|
||||
* @return the network node
|
||||
*/
|
||||
@Nonnull
|
||||
INetworkNode create(CompoundNBT tag, World world, BlockPos pos);
|
||||
INetworkNode create(CompoundTag tag, Level world, BlockPos pos);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.network.node;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.network.node;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.
|
||||
@@ -11,7 +11,7 @@ public interface ISecurityManager {
|
||||
* @param player the player to check that permission for
|
||||
* @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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.
|
||||
@@ -16,5 +16,5 @@ public interface IElementDrawer<T> {
|
||||
* @param y the y axis
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.render;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.disk;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.storage.IStorage;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
@@ -36,7 +36,7 @@ public interface IStorageDisk<T> extends IStorage<T> {
|
||||
/**
|
||||
* Writes the storage to NBT.
|
||||
*/
|
||||
CompoundNBT writeToNbt();
|
||||
CompoundTag writeToNbt();
|
||||
|
||||
/**
|
||||
* @return the factory id as registered in {@link IStorageDiskRegistry}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.disk;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
@@ -20,7 +20,7 @@ public interface IStorageDiskFactory<T> {
|
||||
* @param tag the tag
|
||||
* @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.
|
||||
@@ -39,5 +39,5 @@ public interface IStorageDiskFactory<T> {
|
||||
* @param owner the owner, or null if no owner
|
||||
* @return the storage disk
|
||||
*/
|
||||
IStorageDisk<T> create(ServerWorld world, int capacity, @Nullable UUID owner);
|
||||
IStorageDisk<T> create(ServerLevel world, int capacity, @Nullable UUID owner);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.disk;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.disk;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.storage.StorageType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.disk;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.externalstorage;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.storage.AccessType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.externalstorage;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IExternalStorageProvider<T> {
|
||||
* @param direction the direction of the external storage
|
||||
* @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
|
||||
@@ -25,7 +25,7 @@ public interface IExternalStorageProvider<T> {
|
||||
* @return the external storage handler
|
||||
*/
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.api.storage.tracker;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IStorageTracker<T> {
|
||||
* @param player player
|
||||
* @param stack the stack
|
||||
*/
|
||||
void changed(PlayerEntity player, T stack);
|
||||
void changed(Player player, T stack);
|
||||
|
||||
/**
|
||||
* @param stack the stack
|
||||
@@ -29,12 +29,12 @@ public interface IStorageTracker<T> {
|
||||
*
|
||||
* @param nbt to read from
|
||||
*/
|
||||
void readFromNbt(ListNBT nbt);
|
||||
void readFromNbt(ListTag nbt);
|
||||
|
||||
/**
|
||||
* write data to nbt
|
||||
*
|
||||
* @return data as nbt
|
||||
*/
|
||||
ListNBT serializeNbt();
|
||||
ListTag serializeNbt();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.refinedmods.refinedstorage.api.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -41,12 +41,12 @@ import com.refinedmods.refinedstorage.apiimpl.util.FluidStackList;
|
||||
import com.refinedmods.refinedstorage.apiimpl.util.ItemStackList;
|
||||
import com.refinedmods.refinedstorage.apiimpl.util.QuantityFormatter;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
@@ -59,7 +59,6 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class API implements IRSAPI {
|
||||
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()
|
||||
.map(ModFileScanData::getAnnotations)
|
||||
.flatMap(Collection::stream)
|
||||
.filter(a -> annotationType.equals(a.getAnnotationType()))
|
||||
.collect(Collectors.toList());
|
||||
.filter(a -> annotationType.equals(a.annotationType()))
|
||||
.toList();
|
||||
|
||||
LOGGER.info("Found {} RS API injection {}", annotations.size(), annotations.size() == 1 ? "point" : "points");
|
||||
|
||||
for (ModFileScanData.AnnotationData annotation : annotations) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(annotation.getClassType().getClassName());
|
||||
Field field = clazz.getField(annotation.getMemberName());
|
||||
Class<?> clazz = Class.forName(annotation.clazz().getClassName());
|
||||
Field field = clazz.getField(annotation.memberName());
|
||||
|
||||
if (field.getType() == IRSAPI.class) {
|
||||
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) {
|
||||
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
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerWorld world) {
|
||||
return world.getDataStorage().computeIfAbsent(() -> new NetworkNodeManager(NetworkNodeManager.NAME, world), NetworkNodeManager.NAME);
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerLevel world) {
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkNodeManager manager = new NetworkNodeManager( world);
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
}, () -> new NetworkNodeManager(world), NetworkNodeManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkManager getNetworkManager(ServerWorld world) {
|
||||
return world.getDataStorage().computeIfAbsent(() -> new NetworkManager(NetworkManager.NAME, world), NetworkManager.NAME);
|
||||
public INetworkManager getNetworkManager(ServerLevel world) {
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkManager manager = new NetworkManager(world);
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
}, () -> new NetworkManager(world), NetworkManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,10 +201,14 @@ public class API implements IRSAPI {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld) {
|
||||
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
public IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld) {
|
||||
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
|
||||
@@ -208,10 +219,14 @@ public class API implements IRSAPI {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageTrackerManager getStorageTrackerManager(ServerWorld anyWorld) {
|
||||
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
public IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld) {
|
||||
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
|
||||
@@ -228,7 +243,7 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
}
|
||||
@@ -238,7 +253,7 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
}
|
||||
@@ -257,7 +272,7 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public ICraftingRequestInfo createCraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException {
|
||||
return new CraftingRequestInfo(tag);
|
||||
}
|
||||
|
||||
@@ -282,11 +297,11 @@ public class API implements IRSAPI {
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(INBT tag, int result) {
|
||||
if (tag instanceof CompoundNBT) {
|
||||
result = getHashCode((CompoundNBT) tag, result);
|
||||
} else if (tag instanceof ListNBT) {
|
||||
result = getHashCode((ListNBT) tag, result);
|
||||
private int getHashCode(Tag tag, int result) {
|
||||
if (tag instanceof CompoundTag) {
|
||||
result = getHashCode((CompoundTag) tag, result);
|
||||
} else if (tag instanceof ListTag) {
|
||||
result = getHashCode((ListTag) tag, result);
|
||||
} else {
|
||||
result = 31 * result + tag.hashCode();
|
||||
}
|
||||
@@ -294,7 +309,7 @@ public class API implements IRSAPI {
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(CompoundNBT tag, int result) {
|
||||
private int getHashCode(CompoundTag tag, int result) {
|
||||
for (String key : tag.getAllKeys()) {
|
||||
result = 31 * result + key.hashCode();
|
||||
result = getHashCode(tag.get(key), result);
|
||||
@@ -303,8 +318,8 @@ public class API implements IRSAPI {
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(ListNBT tag, int result) {
|
||||
for (INBT tagItem : tag) {
|
||||
private int getHashCode(ListTag tag, int result) {
|
||||
for (Tag tagItem : tag) {
|
||||
result = getHashCode(tagItem, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
@@ -15,12 +15,10 @@ import java.util.Set;
|
||||
public class AllowedTagList {
|
||||
private static final String NBT_ALLOWED_ITEM_TAGS = "AllowedItemTags";
|
||||
private static final String NBT_ALLOWED_FLUID_TAGS = "AllowedFluidTags";
|
||||
|
||||
private List<Set<ResourceLocation>> allowedItemTags = new ArrayList<>();
|
||||
private List<Set<ResourceLocation>> allowedFluidTags = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
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) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
@@ -31,8 +29,8 @@ public class AllowedTagList {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
public CompoundTag writeToNbt() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
tag.put(NBT_ALLOWED_ITEM_TAGS, getList(allowedItemTags));
|
||||
tag.put(NBT_ALLOWED_FLUID_TAGS, getList(allowedFluidTags));
|
||||
@@ -40,23 +38,23 @@ public class AllowedTagList {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void readFromNbt(CompoundNBT tag) {
|
||||
public void readFromNbt(CompoundTag tag) {
|
||||
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)) {
|
||||
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) {
|
||||
ListNBT list = new ListNBT();
|
||||
private ListTag getList(List<Set<ResourceLocation>> tagsPerSlot) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -64,9 +62,9 @@ public class AllowedTagList {
|
||||
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) {
|
||||
ListNBT subList = tagList.getList(i);
|
||||
ListTag subList = tagList.getList(i);
|
||||
|
||||
for (int j = 0; j < subList.size(); ++j) {
|
||||
list.get(i).add(new ResourceLocation(subList.getString(j)));
|
||||
@@ -78,16 +76,16 @@ public class AllowedTagList {
|
||||
return allowedItemTags;
|
||||
}
|
||||
|
||||
public List<Set<ResourceLocation>> getAllowedFluidTags() {
|
||||
return allowedFluidTags;
|
||||
}
|
||||
|
||||
public void setAllowedItemTags(List<Set<ResourceLocation>> allowedItemTags) {
|
||||
this.allowedItemTags = allowedItemTags;
|
||||
|
||||
notifyListener();
|
||||
}
|
||||
|
||||
public List<Set<ResourceLocation>> getAllowedFluidTags() {
|
||||
return allowedFluidTags;
|
||||
}
|
||||
|
||||
public void setAllowedFluidTags(List<Set<ResourceLocation>> allowedFluidTags) {
|
||||
this.allowedFluidTags = allowedFluidTags;
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.refinedmods.refinedstorage.api.network.INetworkNodeGraphEntry;
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CalculationResult;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -36,7 +36,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
|
||||
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 List<ICraftingPattern> patterns = new ArrayList<>();
|
||||
@@ -44,11 +44,9 @@ public class CraftingManager implements ICraftingManager {
|
||||
private final Map<UUID, ICraftingTask> tasks = new LinkedHashMap<>();
|
||||
private final List<ICraftingTask> tasksToAdd = new ArrayList<>();
|
||||
private final List<UUID> tasksToCancel = new ArrayList<>();
|
||||
private ListNBT tasksToRead;
|
||||
|
||||
private final Map<Object, Long> throttledRequesters = new HashMap<>();
|
||||
|
||||
private final Set<ICraftingMonitorListener> listeners = new HashSet<>();
|
||||
private ListTag tasksToRead;
|
||||
|
||||
public CraftingManager(INetwork network) {
|
||||
this.network = network;
|
||||
@@ -66,7 +64,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ITextComponent, List<IItemHandlerModifiable>> getNamedContainers() {
|
||||
public Map<Component, List<IItemHandlerModifiable>> getNamedContainers() {
|
||||
return containerInventories;
|
||||
}
|
||||
|
||||
@@ -179,10 +177,10 @@ public class CraftingManager implements ICraftingManager {
|
||||
|
||||
private void readTasks() {
|
||||
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));
|
||||
CompoundNBT taskData = taskTag.getCompound(NBT_TASK_DATA);
|
||||
CompoundTag taskData = taskTag.getCompound(NBT_TASK_DATA);
|
||||
|
||||
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(taskType);
|
||||
if (factory != null) {
|
||||
@@ -200,19 +198,19 @@ public class CraftingManager implements ICraftingManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNbt(CompoundNBT tag) {
|
||||
this.tasksToRead = tag.getList(NBT_TASKS, Constants.NBT.TAG_COMPOUND);
|
||||
public void readFromNbt(CompoundTag tag) {
|
||||
this.tasksToRead = tag.getList(NBT_TASKS, Tag.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
public CompoundTag writeToNbt(CompoundTag tag) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for (ICraftingTask task : tasks.values()) {
|
||||
CompoundNBT taskTag = new CompoundNBT();
|
||||
CompoundTag taskTag = new CompoundTag();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.CraftingTaskFactory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -23,13 +23,13 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
private final boolean processing;
|
||||
private final boolean exact;
|
||||
@Nullable
|
||||
private final ICraftingRecipe recipe;
|
||||
private final CraftingRecipe recipe;
|
||||
private final CraftingPatternInputs inputs;
|
||||
private final CraftingPatternOutputs outputs;
|
||||
@Nullable
|
||||
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.processing = processing;
|
||||
this.exact = exact;
|
||||
@@ -61,7 +61,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ITextComponent getErrorMessage() {
|
||||
public Component getErrorMessage() {
|
||||
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() + ")");
|
||||
}
|
||||
|
||||
CraftingInventory inv = new DummyCraftingInventory();
|
||||
CraftingContainer inv = new DummyCraftingInventory();
|
||||
|
||||
for (int i = 0; i < took.size(); ++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() + ")");
|
||||
}
|
||||
|
||||
CraftingInventory inv = new DummyCraftingInventory();
|
||||
CraftingContainer inv = new DummyCraftingInventory();
|
||||
|
||||
for (int i = 0; i < took.size(); ++i) {
|
||||
inv.setItem(i, took.get(i));
|
||||
@@ -265,11 +265,11 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class DummyCraftingInventory extends CraftingInventory {
|
||||
public static class DummyCraftingInventory extends CraftingContainer {
|
||||
public DummyCraftingInventory() {
|
||||
super(new Container(null, 0) {
|
||||
super(new AbstractContainerMenu(null, 0) {
|
||||
@Override
|
||||
public boolean stillValid(PlayerEntity player) {
|
||||
public boolean stillValid(Player player) {
|
||||
return true;
|
||||
}
|
||||
}, 3, 3);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class CraftingPatternContext {
|
||||
private final ICraftingPatternContainer container;
|
||||
|
||||
@@ -4,18 +4,18 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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 javax.annotation.Nullable;
|
||||
@@ -24,7 +24,7 @@ import java.util.*;
|
||||
public class 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);
|
||||
|
||||
boolean processing = PatternItem.isProcessing(stack);
|
||||
@@ -36,7 +36,7 @@ public class CraftingPatternFactory {
|
||||
NonNullList<ItemStack> byproducts = NonNullList.create();
|
||||
List<NonNullList<FluidStack>> fluidInputs = new ArrayList<>();
|
||||
NonNullList<FluidStack> fluidOutputs = NonNullList.create();
|
||||
ICraftingRecipe recipe = null;
|
||||
CraftingRecipe recipe = null;
|
||||
|
||||
try {
|
||||
if (processing) {
|
||||
@@ -46,16 +46,16 @@ public class CraftingPatternFactory {
|
||||
}
|
||||
|
||||
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 {
|
||||
CraftingInventory inv = new CraftingPattern.DummyCraftingInventory();
|
||||
CraftingContainer inv = new CraftingPattern.DummyCraftingInventory();
|
||||
|
||||
for (int i = 0; i < 9; ++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()) {
|
||||
recipe = foundRecipe.get();
|
||||
|
||||
@@ -70,10 +70,10 @@ public class CraftingPatternFactory {
|
||||
modifyCraftingInputsToUseAlternatives(recipe, inputs);
|
||||
}
|
||||
} else {
|
||||
throw new CraftingPatternFactoryException(new TranslationTextComponent("misc.refinedstorage.pattern.error.no_output"));
|
||||
throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.no_output"));
|
||||
}
|
||||
} 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) {
|
||||
@@ -108,7 +108,7 @@ public class CraftingPatternFactory {
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
if (!tagsOfItem.contains(declaredAllowedTag)) {
|
||||
throw new CraftingPatternFactoryException(
|
||||
new TranslationTextComponent(
|
||||
new TranslatableComponent(
|
||||
"misc.refinedstorage.pattern.error.tag_no_longer_applicable",
|
||||
declaredAllowedTag.toString(),
|
||||
input.getHoverName()
|
||||
@@ -147,7 +147,7 @@ public class CraftingPatternFactory {
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
if (!tagsOfFluid.contains(declaredAllowedTag)) {
|
||||
throw new CraftingPatternFactoryException(
|
||||
new TranslationTextComponent(
|
||||
new TranslatableComponent(
|
||||
"misc.refinedstorage.pattern.error.tag_no_longer_applicable",
|
||||
declaredAllowedTag.toString(),
|
||||
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);
|
||||
|
||||
inputs.add(input.isEmpty() ? NonNullList.create() : NonNullList.of(ItemStack.EMPTY, input));
|
||||
@@ -178,7 +178,7 @@ public class CraftingPatternFactory {
|
||||
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()) {
|
||||
inputs.clear();
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public ITextComponent getErrorMessage() {
|
||||
public Component getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CraftingPatternOutputs {
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -15,9 +15,9 @@ public class InvalidCraftingPattern implements ICraftingPattern {
|
||||
private static final String EXCEPTION_MESSAGE = "Crafting pattern is invalid";
|
||||
|
||||
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.errorMessage = errorMessage;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class InvalidCraftingPattern implements ICraftingPattern {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ITextComponent getErrorMessage() {
|
||||
public Component getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.ICraftingMonitorElementList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -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.ICraftingMonitorElementRegistry;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
@@ -11,16 +11,16 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
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
|
||||
public void add(ResourceLocation id, Function<PacketBuffer, ICraftingMonitorElement> factory) {
|
||||
public void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingMonitorElement> factory) {
|
||||
registry.put(id, factory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Function<PacketBuffer, ICraftingMonitorElement> get(ResourceLocation id) {
|
||||
public Function<FriendlyByteBuf, ICraftingMonitorElement> get(ResourceLocation id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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.render.IElementDrawers;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import com.refinedmods.refinedstorage.util.PacketBufferUtils;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
@@ -26,9 +26,19 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
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
|
||||
@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);
|
||||
|
||||
drawers.getErrorDrawer().draw(matrixStack, x, y, null);
|
||||
@@ -36,9 +46,9 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ITextComponent> getTooltip() {
|
||||
List<ITextComponent> items = new ArrayList<>(base.getTooltip());
|
||||
items.add(new TranslationTextComponent(message).setStyle(Styles.RED));
|
||||
public List<Component> getTooltip() {
|
||||
List<Component> items = new ArrayList<>(base.getTooltip());
|
||||
items.add(new TranslatableComponent(message).setStyle(Styles.RED));
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -53,23 +63,13 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeResourceLocation(base.getId());
|
||||
buf.writeUtf(message);
|
||||
|
||||
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
|
||||
public boolean merge(ICraftingMonitorElement element) {
|
||||
return elementHashCode() == element.elementHashCode() && base.merge(((ErrorCraftingMonitorElement) element).base);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
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.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawers;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -20,13 +20,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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_MISSING = 0xFFF2DEDE;
|
||||
private static final int COLOR_SCHEDULED = 0xFFE8E5CA;
|
||||
private static final int COLOR_CRAFTING = 0xFFADDBC6;
|
||||
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid");
|
||||
|
||||
private final FluidStack stack;
|
||||
private int stored;
|
||||
private int missing;
|
||||
@@ -43,9 +41,20 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
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
|
||||
@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) {
|
||||
drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING);
|
||||
} else if (processing > 0) {
|
||||
@@ -108,12 +117,12 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ITextComponent> getTooltip() {
|
||||
public List<Component> getTooltip() {
|
||||
return Collections.singletonList(stack.getFluid().getAttributes().getDisplayName(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
stack.writeToPacket(buf);
|
||||
buf.writeInt(stored);
|
||||
buf.writeInt(missing);
|
||||
@@ -122,17 +131,6 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
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
|
||||
public boolean merge(ICraftingMonitorElement element) {
|
||||
if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) {
|
||||
@@ -170,6 +168,10 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static FluidCraftingMonitorElement.Builder forStack(FluidStack stack) {
|
||||
return new FluidCraftingMonitorElement.Builder(stack);
|
||||
}
|
||||
|
||||
public FluidCraftingMonitorElement.Builder stored(int stored) {
|
||||
this.stored = stored;
|
||||
return this;
|
||||
@@ -198,9 +200,5 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
public FluidCraftingMonitorElement build() {
|
||||
return new FluidCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting);
|
||||
}
|
||||
|
||||
public static FluidCraftingMonitorElement.Builder forStack(FluidStack stack) {
|
||||
return new FluidCraftingMonitorElement.Builder(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
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.StackUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -20,13 +20,11 @@ import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
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_MISSING = 0xFFF2DEDE;
|
||||
private static final int COLOR_SCHEDULED = 0xFFE8E5CA;
|
||||
private static final int COLOR_CRAFTING = 0xFFADDBC6;
|
||||
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item");
|
||||
|
||||
private final ItemStack stack;
|
||||
private int stored;
|
||||
private int missing;
|
||||
@@ -43,9 +41,20 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
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
|
||||
@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) {
|
||||
drawers.getOverlayDrawer().draw(matrixStack, x, y, COLOR_MISSING);
|
||||
} else if (processing > 0) {
|
||||
@@ -108,12 +117,12 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ITextComponent> getTooltip() {
|
||||
public List<Component> getTooltip() {
|
||||
return RenderUtils.getTooltipFromItem(this.stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
StackUtils.writeItemStack(buf, stack);
|
||||
buf.writeInt(stored);
|
||||
buf.writeInt(missing);
|
||||
@@ -122,17 +131,6 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
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
|
||||
public boolean merge(ICraftingMonitorElement element) {
|
||||
if (element.getId().equals(getId()) && elementHashCode() == element.elementHashCode()) {
|
||||
@@ -170,6 +168,10 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static Builder forStack(ItemStack stack) {
|
||||
return new Builder(stack);
|
||||
}
|
||||
|
||||
public Builder stored(int stored) {
|
||||
this.stored = stored;
|
||||
return this;
|
||||
@@ -198,9 +200,5 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
public ItemCraftingMonitorElement build() {
|
||||
return new ItemCraftingMonitorElement(stack, stored, missing, processing, scheduled, crafting);
|
||||
}
|
||||
|
||||
public static Builder forStack(ItemStack stack) {
|
||||
return new Builder(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.ICraftingPreviewElementRegistry;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
@@ -11,16 +11,16 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
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
|
||||
public void add(ResourceLocation id, Function<PacketBuffer, ICraftingPreviewElement> factory) {
|
||||
public void add(ResourceLocation id, Function<FriendlyByteBuf, ICraftingPreviewElement> factory) {
|
||||
registry.put(id, factory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Function<PacketBuffer, ICraftingPreviewElement> get(ResourceLocation id) {
|
||||
public Function<FriendlyByteBuf, ICraftingPreviewElement> get(ResourceLocation id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
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.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.task.CalculationResultType;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawers;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "error");
|
||||
@@ -20,12 +20,20 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
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() {
|
||||
return recursedPattern;
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
@@ -35,7 +43,7 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeInt(type.ordinal());
|
||||
buf.writeItem(recursedPattern);
|
||||
}
|
||||
@@ -44,14 +52,6 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
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
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawers;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -34,15 +34,7 @@ public class FluidCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
this.toCraft = toCraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
stack.writeToPacket(buf);
|
||||
buf.writeInt(available);
|
||||
buf.writeBoolean(missing);
|
||||
buf.writeInt(toCraft);
|
||||
}
|
||||
|
||||
public static FluidCraftingPreviewElement read(PacketBuffer buf) {
|
||||
public static FluidCraftingPreviewElement read(FriendlyByteBuf buf) {
|
||||
FluidStack stack = FluidStack.readFromPacket(buf);
|
||||
int available = buf.readInt();
|
||||
boolean missing = buf.readBoolean();
|
||||
@@ -51,13 +43,21 @@ public class FluidCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
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() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawers;
|
||||
import com.refinedmods.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -34,19 +34,7 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
this.toCraft = toCraft;
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
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) {
|
||||
public static ItemCraftingPreviewElement read(FriendlyByteBuf buf) {
|
||||
ItemStack stack = buf.readItem();
|
||||
int available = buf.readInt();
|
||||
boolean missing = buf.readBoolean();
|
||||
@@ -55,9 +43,21 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
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
|
||||
@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) {
|
||||
drawers.getOverlayDrawer().draw(matrixStack, x, y, 0xFFF2DEDE);
|
||||
}
|
||||
|
||||
@@ -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.ICraftingRequestInfo;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -16,7 +16,7 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
|
||||
private ItemStack item;
|
||||
private FluidStack fluid;
|
||||
|
||||
public CraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public CraftingRequestInfo(CompoundTag tag) throws CraftingTaskReadException {
|
||||
if (!tag.getBoolean(NBT_FLUID)) {
|
||||
item = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK));
|
||||
|
||||
@@ -53,13 +53,13 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
public CompoundTag writeToNbt() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
tag.putBoolean(NBT_FLUID, fluid != null);
|
||||
|
||||
if (fluid != null) {
|
||||
tag.put(NBT_STACK, fluid.writeToNBT(new CompoundNBT()));
|
||||
tag.put(NBT_STACK, fluid.writeToNBT(new CompoundTag()));
|
||||
} else {
|
||||
tag.put(NBT_STACK, StackUtils.serializeStackToNbt(item));
|
||||
}
|
||||
|
||||
@@ -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.ICraftingTaskRegistry;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Autocrafting
|
||||
|
||||
Autocrafting has had several refactors.
|
||||
|
||||
Some history:
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -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.factory.FluidStorageDiskFactory;
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -56,14 +56,12 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
private final NodeList nodes;
|
||||
private final IStackList<ItemStack> toExtractInitial;
|
||||
private final IStackList<FluidStack> toExtractInitialFluids;
|
||||
|
||||
private final CraftingMonitorElementFactory craftingMonitorElementFactory = new CraftingMonitorElementFactory();
|
||||
private int ticks;
|
||||
private long startTime = -1;
|
||||
private int totalSteps;
|
||||
private int currentStep;
|
||||
|
||||
private final CraftingMonitorElementFactory craftingMonitorElementFactory = new CraftingMonitorElementFactory();
|
||||
|
||||
public CraftingTask(INetwork network,
|
||||
ICraftingRequestInfo requested,
|
||||
int quantity,
|
||||
@@ -86,7 +84,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
this.toExtractInitialFluids = toExtractInitialFluids;
|
||||
}
|
||||
|
||||
public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public CraftingTask(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
|
||||
this.network = network;
|
||||
|
||||
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.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.toExtractInitialFluids = SerializationUtil.readFluidStackList(tag.getList(NBT_TO_EXTRACT_INITIAL_FLUIDS, 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, 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) {
|
||||
Node node = Node.fromNbt(network, nodeList.getCompound(i));
|
||||
nodes.put(node.getPattern(), node);
|
||||
@@ -114,7 +112,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
public CompoundTag writeToNbt(CompoundTag tag) {
|
||||
tag.put(NBT_REQUESTED, requested.writeToNbt());
|
||||
tag.putInt(NBT_QUANTITY, quantity);
|
||||
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_CURRENT_STEP, currentStep);
|
||||
|
||||
ListNBT nodeList = new ListNBT();
|
||||
ListTag nodeList = new ListTag();
|
||||
for (Node node : this.nodes.all()) {
|
||||
nodeList.add(node.writeToNbt());
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.refinedmods.refinedstorage.api.autocrafting.task.*;
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CraftingCalculator;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class CraftingTaskFactory implements ICraftingTaskFactory {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "v6");
|
||||
@@ -18,7 +18,7 @@ public class CraftingTaskFactory implements ICraftingTaskFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingTask createFromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public ICraftingTask createFromNbt(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
|
||||
return new CraftingTask(network, tag);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -9,12 +9,12 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SerializationUtil {
|
||||
@@ -24,8 +24,8 @@ public class SerializationUtil {
|
||||
private SerializationUtil() {
|
||||
}
|
||||
|
||||
public static ListNBT writeItemStackList(IStackList<ItemStack> stacks) {
|
||||
ListNBT list = new ListNBT();
|
||||
public static ListTag writeItemStackList(IStackList<ItemStack> stacks) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for (StackListEntry<ItemStack> entry : stacks.getStacks()) {
|
||||
list.add(StackUtils.serializeStackToNbt(entry.getStack()));
|
||||
@@ -34,7 +34,7 @@ public class SerializationUtil {
|
||||
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();
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
@@ -50,17 +50,17 @@ public class SerializationUtil {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static ListNBT writeFluidStackList(IStackList<FluidStack> stacks) {
|
||||
ListNBT list = new ListNBT();
|
||||
public static ListTag writeFluidStackList(IStackList<FluidStack> stacks) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for (StackListEntry<FluidStack> entry : stacks.getStacks()) {
|
||||
list.add(entry.getStack().writeToNBT(new CompoundNBT()));
|
||||
list.add(entry.getStack().writeToNBT(new CompoundTag()));
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
@@ -76,8 +76,8 @@ public class SerializationUtil {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static CompoundNBT writePatternToNbt(ICraftingPattern pattern) {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
public static CompoundTag writePatternToNbt(ICraftingPattern pattern) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
tag.put(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
|
||||
tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().asLong());
|
||||
@@ -85,10 +85,10 @@ public class SerializationUtil {
|
||||
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));
|
||||
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(containerPos);
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(containerPos);
|
||||
|
||||
if (node instanceof ICraftingPatternContainer) {
|
||||
ItemStack stack = ItemStack.of(tag.getCompound(NBT_PATTERN_STACK));
|
||||
|
||||
@@ -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.CraftingPreviewInfo;
|
||||
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.items.ItemHandlerHelper;
|
||||
|
||||
|
||||
@@ -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.ProcessingNode;
|
||||
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 java.util.Collection;
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CraftingNode extends Node {
|
||||
@@ -26,12 +26,12 @@ public class CraftingNode extends Node {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
public CraftingNode(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public CraftingNode(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
|
||||
super(network, tag);
|
||||
|
||||
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) {
|
||||
recipe.add(StackUtils.deserializeStackFromNbt(tookList.getCompound(i)));
|
||||
}
|
||||
@@ -83,10 +83,10 @@ public class CraftingNode extends Node {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = super.writeToNbt();
|
||||
public CompoundTag writeToNbt() {
|
||||
CompoundTag tag = super.writeToNbt();
|
||||
|
||||
ListNBT tookList = new ListNBT();
|
||||
ListTag tookList = new ListTag();
|
||||
for (ItemStack took : this.recipe) {
|
||||
tookList.add(StackUtils.serializeStackToNbt(took));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.refinedmods.refinedstorage.api.autocrafting.task.CraftingTaskReadExce
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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_QUANTITY = "Quantity";
|
||||
private static final String NBT_QUANTITY_TOTAL = "TotalQuantity";
|
||||
|
||||
protected final NodeRequirements requirements = new NodeRequirements();
|
||||
private final boolean root;
|
||||
private final ICraftingPattern pattern;
|
||||
|
||||
protected int quantity;
|
||||
protected int totalQuantity;
|
||||
|
||||
protected final NodeRequirements requirements = new NodeRequirements();
|
||||
|
||||
protected Node(ICraftingPattern pattern, boolean root) {
|
||||
this.pattern = pattern;
|
||||
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.totalQuantity = tag.getInt(NBT_QUANTITY_TOTAL);
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
|
||||
@@ -37,7 +34,7 @@ public abstract class Node {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -71,8 +68,8 @@ public abstract class Node {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
public CompoundTag writeToNbt() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
tag.putInt(NBT_QUANTITY, quantity);
|
||||
tag.putInt(NBT_QUANTITY_TOTAL, totalQuantity);
|
||||
|
||||
@@ -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.ICraftingPatternContainer;
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -146,8 +146,8 @@ public class NodeRequirements {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public void readFromNbt(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
ListNBT itemRequirementsTag = tag.getList(NBT_ITEMS_TO_USE, Constants.NBT.TAG_LIST);
|
||||
public void readFromNbt(CompoundTag tag) throws CraftingTaskReadException {
|
||||
ListTag itemRequirementsTag = tag.getList(NBT_ITEMS_TO_USE, Tag.TAG_LIST);
|
||||
for (int i = 0; i < itemRequirementsTag.size(); i++) {
|
||||
itemRequirements.put(i, SerializationUtil.readItemStackList(itemRequirementsTag.getList(i)));
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class NodeRequirements {
|
||||
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++) {
|
||||
fluidRequirements.put(i, SerializationUtil.readFluidStackList(fluidRequirementsTag.getList(i)));
|
||||
}
|
||||
@@ -168,8 +168,8 @@ public class NodeRequirements {
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
ListNBT itemRequirementsTag = new ListNBT();
|
||||
public CompoundTag writeToNbt(CompoundTag tag) {
|
||||
ListTag itemRequirementsTag = new ListTag();
|
||||
for (IStackList<ItemStack> list : itemRequirements.values()) {
|
||||
itemRequirementsTag.add(SerializationUtil.writeItemStackList(list));
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class NodeRequirements {
|
||||
|
||||
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()) {
|
||||
fluidRequirementsTag.add(SerializationUtil.writeFluidStackList(list));
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ProcessingNode extends Node {
|
||||
@@ -42,14 +42,14 @@ public class ProcessingNode extends Node {
|
||||
initSetsToReceive();
|
||||
}
|
||||
|
||||
public ProcessingNode(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
public ProcessingNode(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
|
||||
super(network, tag);
|
||||
|
||||
this.itemsReceived = SerializationUtil.readItemStackList(tag.getList(NBT_ITEMS_RECEIVED, Constants.NBT.TAG_COMPOUND));
|
||||
this.fluidsReceived = SerializationUtil.readFluidStackList(tag.getList(NBT_FLUIDS_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, Tag.TAG_COMPOUND));
|
||||
|
||||
this.singleItemSetToRequire = SerializationUtil.readItemStackList(tag.getList(NBT_SINGLE_ITEM_SET_TO_REQUIRE, Constants.NBT.TAG_COMPOUND));
|
||||
this.singleFluidSetToRequire = SerializationUtil.readFluidStackList(tag.getList(NBT_SINGLE_FLUID_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, Tag.TAG_COMPOUND));
|
||||
|
||||
this.state = ProcessingState.values()[tag.getInt(NBT_STATE)];
|
||||
|
||||
@@ -254,8 +254,8 @@ public class ProcessingNode extends Node {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = super.writeToNbt();
|
||||
public CompoundTag writeToNbt() {
|
||||
CompoundTag tag = super.writeToNbt();
|
||||
|
||||
tag.put(NBT_ITEMS_RECEIVED, SerializationUtil.writeItemStackList(itemsReceived));
|
||||
tag.put(NBT_FLUIDS_RECEIVED, SerializationUtil.writeFluidStackList(fluidsReceived));
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.api.util.StackListEntry;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.preview.FluidCraftingPreviewElement;
|
||||
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 java.util.ArrayList;
|
||||
@@ -38,7 +38,7 @@ public class CraftingPreviewElementFactory {
|
||||
for (ItemStack stack : ImmutableList.copyOf(info.getToCraft()).reverse()) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.preview;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -35,15 +35,15 @@ import com.refinedmods.refinedstorage.tile.ControllerTile;
|
||||
import com.refinedmods.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.refinedmods.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
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 BaseEnergyStorage energy = new BaseEnergyStorage(RS.SERVER_CONFIG.getController().getCapacity(), RS.SERVER_CONFIG.getController().getMaxTransfer(), 0);
|
||||
private final RootNetworkNode root;
|
||||
|
||||
|
||||
private final BlockPos pos;
|
||||
private final Level world;
|
||||
private final NetworkType type;
|
||||
private ItemStorageTracker itemStorageTracker;
|
||||
private UUID itemStorageTrackerId;
|
||||
private FluidStorageTracker fluidStorageTracker;
|
||||
private UUID fluidStorageTrackerId;
|
||||
|
||||
private final BlockPos pos;
|
||||
private final World world;
|
||||
private final NetworkType type;
|
||||
private ControllerBlock.EnergyType lastEnergyType = ControllerBlock.EnergyType.OFF;
|
||||
private int lastEnergyUsage;
|
||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
@@ -99,13 +96,13 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
private long[] tickTimes = new long[100];
|
||||
private int tickCounter = 0;
|
||||
|
||||
public Network(World world, BlockPos pos, NetworkType type) {
|
||||
public Network(Level world, BlockPos pos, NetworkType type) {
|
||||
this.pos = pos;
|
||||
this.world = world;
|
||||
this.type = type;
|
||||
this.root = new RootNetworkNode(this, world, pos);
|
||||
this.nodeGraph.addListener(() -> {
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof ControllerTile) {
|
||||
((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() {
|
||||
return root;
|
||||
}
|
||||
@@ -236,8 +251,8 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
}
|
||||
|
||||
nodeGraph.disconnectAll();
|
||||
API.instance().getStorageTrackerManager((ServerWorld) getWorld()).remove(itemStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerWorld) getWorld()).remove(fluidStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(itemStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(fluidStorageTrackerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -471,7 +486,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
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;
|
||||
@@ -484,19 +499,19 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public Level getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetwork readFromNbt(CompoundNBT tag) {
|
||||
public INetwork readFromNbt(CompoundTag tag) {
|
||||
if (tag.contains(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);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
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
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
public CompoundTag writeToNbt(CompoundTag tag) {
|
||||
tag.putInt(NBT_ENERGY, this.energy.getEnergyStored());
|
||||
|
||||
redstoneMode.write(tag);
|
||||
@@ -549,11 +564,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
API.instance().getNetworkManager((ServerWorld) world).markForSaving();
|
||||
}
|
||||
|
||||
public static int getEnergyScaled(int stored, int capacity, int scale) {
|
||||
return (int) ((float) stored / (float) capacity * (float) scale);
|
||||
API.instance().getNetworkManager((ServerLevel) world).markForSaving();
|
||||
}
|
||||
|
||||
public ControllerBlock.EnergyType getEnergyType() {
|
||||
@@ -564,20 +575,6 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
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
|
||||
public RedstoneMode getRedstoneMode() {
|
||||
return redstoneMode;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.refinedmods.refinedstorage.apiimpl.network;
|
||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
|
||||
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.eventbus.api.SubscribeEvent;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class NetworkListener {
|
||||
if (!e.world.isClientSide() && e.phase == TickEvent.Phase.END) {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class NetworkListener {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkManager;
|
||||
import com.refinedmods.refinedstorage.api.network.NetworkType;
|
||||
import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
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_POS = "Pos";
|
||||
|
||||
private final World world;
|
||||
private final Level world;
|
||||
|
||||
private final Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
private final ConcurrentHashMap<BlockPos, INetwork> networks = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkManager(String name, World world) {
|
||||
super(name);
|
||||
|
||||
public NetworkManager(Level world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundNBT tag) {
|
||||
public void load(CompoundTag tag) {
|
||||
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();
|
||||
|
||||
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));
|
||||
int type = networkTag.getInt(NBT_TYPE);
|
||||
|
||||
@@ -64,15 +62,15 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT save(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for (INetwork network : all()) {
|
||||
try {
|
||||
CompoundNBT networkTag = new CompoundNBT();
|
||||
CompoundTag networkTag = new CompoundTag();
|
||||
|
||||
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());
|
||||
|
||||
list.add(networkTag);
|
||||
|
||||
@@ -5,25 +5,21 @@ import com.refinedmods.refinedstorage.api.network.*;
|
||||
import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
|
||||
|
||||
public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
private final INetwork network;
|
||||
private Set<INetworkNodeGraphEntry> entries = Sets.newConcurrentHashSet();
|
||||
private final List<INetworkNodeGraphListener> listeners = new LinkedList<>();
|
||||
|
||||
private final Set<Consumer<INetwork>> actions = new HashSet<>();
|
||||
|
||||
private Set<INetworkNodeGraphEntry> entries = Sets.newConcurrentHashSet();
|
||||
private boolean invalidating = false;
|
||||
|
||||
public NetworkNodeGraph(INetwork network) {
|
||||
@@ -31,7 +27,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(Action action, World world, BlockPos origin) {
|
||||
public void invalidate(Action action, Level world, BlockPos origin) {
|
||||
this.invalidating = true;
|
||||
|
||||
Operator operator = new Operator(action);
|
||||
@@ -95,10 +91,43 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
listeners.forEach(INetworkNodeGraphListener::onChanged);
|
||||
}
|
||||
|
||||
protected World getWorld() {
|
||||
protected Level 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 final Set<INetworkNodeGraphEntry> foundNodes = Sets.newConcurrentHashSet(); // All scanned entries
|
||||
|
||||
@@ -114,8 +143,8 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(World world, BlockPos pos, @Nullable Direction side) {
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
public void apply(Level world, BlockPos pos, @Nullable Direction side) {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile);
|
||||
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)) {
|
||||
Block.dropResources(world.getBlockState(pos), world, pos, world.getBlockEntity(pos));
|
||||
|
||||
@@ -157,37 +186,4 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import com.refinedmods.refinedstorage.util.PlayerUtils;
|
||||
import com.refinedmods.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class NetworkNodeListener {
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
||||
if (!e.getWorld().isClientSide() && e.getEntity() instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) e.getEntity();
|
||||
if (!e.getWorld().isClientSide() && e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
|
||||
INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getPos()));
|
||||
|
||||
@@ -32,7 +32,7 @@ public class NetworkNodeListener {
|
||||
e.setCanceled(true);
|
||||
|
||||
//Fixes desync as we do not cancel the event clientside
|
||||
PlayerUtils.updateHeldItems((ServerPlayerEntity) player);
|
||||
PlayerUtils.updateHeldItems((ServerPlayer) player);
|
||||
|
||||
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()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ import com.refinedmods.refinedstorage.api.network.node.INetworkNodeFactory;
|
||||
import com.refinedmods.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
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_POS = "Pos";
|
||||
|
||||
private final World world;
|
||||
private final Level world;
|
||||
|
||||
private final Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
private final ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkNodeManager(String name, World world) {
|
||||
super(name);
|
||||
|
||||
public NetworkNodeManager(Level world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundNBT tag) {
|
||||
public void load(CompoundTag tag) {
|
||||
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();
|
||||
|
||||
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));
|
||||
CompoundNBT data = nodeTag.getCompound(NBT_NODE_DATA);
|
||||
CompoundTag data = nodeTag.getCompound(NBT_NODE_DATA);
|
||||
BlockPos pos = BlockPos.of(nodeTag.getLong(NBT_NODE_POS));
|
||||
|
||||
INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id);
|
||||
@@ -74,16 +72,16 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT save(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
ListTag list = new ListTag();
|
||||
|
||||
for (INetworkNode node : all()) {
|
||||
try {
|
||||
CompoundNBT nodeTag = new CompoundNBT();
|
||||
CompoundTag nodeTag = new CompoundTag();
|
||||
|
||||
nodeTag.putString(NBT_NODE_ID, node.getId().toString());
|
||||
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);
|
||||
} catch (Throwable t) {
|
||||
|
||||
@@ -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.INetworkNodeRegistry;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -13,15 +13,15 @@ import com.refinedmods.refinedstorage.api.util.IStackList;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -30,12 +30,12 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
@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());
|
||||
|
||||
INetwork network = grid.getNetwork();
|
||||
|
||||
CraftingInventory matrix = grid.getCraftingMatrix();
|
||||
CraftingContainer matrix = grid.getCraftingMatrix();
|
||||
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) {
|
||||
ItemStack slot = matrix.getItem(i);
|
||||
@@ -44,12 +44,12 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
if (i < remainder.size() && !remainder.get(i).isEmpty()) {
|
||||
// If there is no space for the remainder, dump it in the player inventory.
|
||||
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);
|
||||
|
||||
// If there is no space in the network, just dump it in the world.
|
||||
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
|
||||
public void onCraftedShift(INetworkAwareGrid grid, PlayerEntity player) {
|
||||
CraftingInventory matrix = grid.getCraftingMatrix();
|
||||
public void onCraftedShift(INetworkAwareGrid grid, Player player) {
|
||||
CraftingContainer matrix = grid.getCraftingMatrix();
|
||||
INetwork network = grid.getNetwork();
|
||||
List<ItemStack> craftedItemsList = new ArrayList<>();
|
||||
ItemStack crafted = grid.getCraftingResult().getItem(0);
|
||||
@@ -123,8 +123,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
|
||||
for (ItemStack craftedItem : craftedItemsList) {
|
||||
if (!player.inventory.add(craftedItem.copy())) {
|
||||
|
||||
if (!player.getInventory().add(craftedItem.copy())) {
|
||||
ItemStack remainder = craftedItem;
|
||||
|
||||
if (useNetwork) {
|
||||
@@ -132,7 +131,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
|
||||
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.
|
||||
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
ItemStack stack = network.getItemStorageCache().getList().get(matrix.getItem(i));
|
||||
|
||||
@@ -157,7 +156,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeTransfer(INetworkAwareGrid grid, PlayerEntity player, ItemStack[][] recipe) {
|
||||
public void onRecipeTransfer(INetworkAwareGrid grid, Player player, ItemStack[][] recipe) {
|
||||
INetwork network = grid.getNetwork();
|
||||
|
||||
if (network != null && grid.getGridType() == GridType.CRAFTING && !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
|
||||
@@ -182,7 +181,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -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 (!found) {
|
||||
for (ItemStack possibility : possibilities) {
|
||||
for (int j = 0; j < player.inventory.getContainerSize(); ++j) {
|
||||
if (API.instance().getComparer().isEqual(possibility, player.inventory.getItem(j), IComparer.COMPARE_NBT)) {
|
||||
grid.getCraftingMatrix().setItem(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getItem(j), 1));
|
||||
for (int j = 0; j < player.getInventory().getContainerSize(); ++j) {
|
||||
if (API.instance().getComparer().isEqual(possibility, player.getInventory().getItem(j), IComparer.COMPARE_NBT)) {
|
||||
grid.getCraftingMatrix().setItem(i, ItemHandlerHelper.copyStackWithSize(player.getInventory().getItem(j), 1));
|
||||
|
||||
player.inventory.removeItem(j, 1);
|
||||
player.getInventory().removeItem(j, 1);
|
||||
|
||||
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) -> {
|
||||
|
||||
ItemStack stack = network.getItemStorageCache().getList().get(itemStack);
|
||||
@@ -282,10 +281,10 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}).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<>();
|
||||
for (int j = 0; j < player.inventory.getContainerSize(); j++) {
|
||||
ItemStack inventoryStack = player.inventory.getItem(j);
|
||||
for (int j = 0; j < player.getInventory().getContainerSize(); j++) {
|
||||
ItemStack inventoryStack = player.getInventory().getItem(j);
|
||||
|
||||
if (inventoryStack.getItem() instanceof ICraftingPatternProvider) {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(network.getWorld(), inventoryStack);
|
||||
|
||||
@@ -6,13 +6,13 @@ import com.refinedmods.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGridManager;
|
||||
import com.refinedmods.refinedstorage.container.factory.GridContainerProvider;
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -28,17 +28,17 @@ public class GridManager implements IGridManager {
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
private void openGrid(ResourceLocation id, ServerPlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) {
|
||||
Pair<IGrid, TileEntity> grid = createGrid(id, player, stack, pos, slot);
|
||||
private void openGrid(ResourceLocation id, ServerPlayer player, @Nullable ItemStack stack, @Nullable BlockPos pos, PlayerSlot slot) {
|
||||
Pair<IGrid, BlockEntity> grid = createGrid(id, player, stack, pos, slot);
|
||||
if (grid == null) {
|
||||
return;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class GridManager implements IGridManager {
|
||||
|
||||
@Override
|
||||
@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);
|
||||
|
||||
if (factory == null) {
|
||||
@@ -70,7 +70,7 @@ public class GridManager implements IGridManager {
|
||||
}
|
||||
|
||||
IGrid grid = null;
|
||||
TileEntity tile = factory.getRelevantTile(player.level, pos);
|
||||
BlockEntity tile = factory.getRelevantTile(player.level, pos);
|
||||
|
||||
if (factory.getType() == GridFactoryType.STACK) {
|
||||
grid = factory.createFromStack(player, stack, slot);
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
package com.refinedmods.refinedstorage.apiimpl.network.grid;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGridTab;
|
||||
import com.refinedmods.refinedstorage.api.render.IElementDrawer;
|
||||
import com.refinedmods.refinedstorage.api.util.IFilter;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GridTab implements IGridTab {
|
||||
private final List<IFilter> filters;
|
||||
private final String name;
|
||||
@Nullable
|
||||
private final TextComponent name;
|
||||
@Nonnull
|
||||
private final ItemStack icon;
|
||||
@Nullable
|
||||
@@ -27,7 +28,7 @@ public class GridTab implements IGridTab {
|
||||
|
||||
public GridTab(List<IFilter> filters, String name, @Nonnull ItemStack icon, @Nullable FluidStack fluidIcon) {
|
||||
this.filters = filters;
|
||||
this.name = name;
|
||||
this.name = name.trim().isEmpty() ? null : new TextComponent(name);
|
||||
this.icon = icon;
|
||||
this.fluidIcon = fluidIcon;
|
||||
}
|
||||
@@ -38,22 +39,23 @@ public class GridTab implements IGridTab {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, FontRenderer fontRenderer) {
|
||||
if (!name.trim().equals("")) {
|
||||
GuiUtils.drawHoveringText(matrixStack, Collections.singletonList(new StringTextComponent(name)), x, y, screenWidth, screenHeight, -1, fontRenderer);
|
||||
public void drawTooltip(PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, Font fontRenderer) {
|
||||
if (name != null) {
|
||||
Screen screen = Minecraft.getInstance().screen;
|
||||
if (screen != null) {
|
||||
screen.renderTooltip(matrixStack, name, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(MatrixStack matrixStack, int x, int y, IElementDrawer<ItemStack> itemDrawer, IElementDrawer<FluidStack> fluidDrawer) {
|
||||
public void drawIcon(PoseStack matrixStack, int x, int y, IElementDrawer<ItemStack> itemDrawer, IElementDrawer<FluidStack> fluidDrawer) {
|
||||
if (!icon.isEmpty()) {
|
||||
RenderHelper.setupFor3DItems();
|
||||
Lighting.setupFor3DItems();
|
||||
|
||||
itemDrawer.draw(matrixStack, x, y, icon);
|
||||
} else {
|
||||
fluidDrawer.draw(matrixStack, x, y, fluidIcon);
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user