Port to 1.19.2 - v1.11.0
This commit is contained in:
@@ -10,10 +10,8 @@ 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.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;
|
||||
@@ -36,8 +34,11 @@ public final class RS {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onClientSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onModelBake);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onModelRegistry);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onRegisterAdditionalModels);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onTextureStitch);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onRegisterModelGeometry);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onRegisterKeymappings);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onRegisterColorBindings);
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientSetup::addReloadListener);
|
||||
});
|
||||
|
||||
@@ -51,13 +52,14 @@ public final class RS {
|
||||
RSLootFunctions.register();
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(CommonSetup::onCommonSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(BlockEntityType.class, CommonSetup::onRegisterBlockEntities);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(RecipeSerializer.class, CommonSetup::onRegisterRecipeSerializers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(MenuType.class, CommonSetup::onRegisterMenus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(CommonSetup::onRegisterCapabilities);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new DataGenerators());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new CuriosIntegration());
|
||||
|
||||
RSContainerMenus.REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
RSBlockEntities.REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
RSRecipeSerializers.REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
API.deliver();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +1,106 @@
|
||||
package com.refinedmods.refinedstorage;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.NetworkType;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.GridType;
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.FluidStorageType;
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.refinedmods.refinedstorage.blockentity.*;
|
||||
import com.refinedmods.refinedstorage.blockentity.craftingmonitor.CraftingMonitorBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.portable.PortableGridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.item.blockitem.PortableGridBlockItem;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@ObjectHolder(RS.ID)
|
||||
public final class RSBlockEntities {
|
||||
@ObjectHolder("controller")
|
||||
public static final BlockEntityType<ControllerBlockEntity> CONTROLLER = null;
|
||||
@ObjectHolder("creative_controller")
|
||||
public static final BlockEntityType<ControllerBlockEntity> CREATIVE_CONTROLLER = null;
|
||||
@ObjectHolder("detector")
|
||||
public static final BlockEntityType<DetectorBlockEntity> DETECTOR = null;
|
||||
@ObjectHolder("disk_drive")
|
||||
public static final BlockEntityType<DiskDriveBlockEntity> DISK_DRIVE = null;
|
||||
@ObjectHolder("exporter")
|
||||
public static final BlockEntityType<ExporterBlockEntity> EXPORTER = null;
|
||||
@ObjectHolder("external_storage")
|
||||
public static final BlockEntityType<ExternalStorageBlockEntity> EXTERNAL_STORAGE = null;
|
||||
@ObjectHolder("grid")
|
||||
public static final BlockEntityType<GridBlockEntity> GRID = null;
|
||||
@ObjectHolder("crafting_grid")
|
||||
public static final BlockEntityType<GridBlockEntity> CRAFTING_GRID = null;
|
||||
@ObjectHolder("pattern_grid")
|
||||
public static final BlockEntityType<GridBlockEntity> PATTERN_GRID = null;
|
||||
@ObjectHolder("fluid_grid")
|
||||
public static final BlockEntityType<GridBlockEntity> FLUID_GRID = null;
|
||||
@ObjectHolder("importer")
|
||||
public static final BlockEntityType<ImporterBlockEntity> IMPORTER = null;
|
||||
@ObjectHolder("network_transmitter")
|
||||
public static final BlockEntityType<NetworkTransmitterBlockEntity> NETWORK_TRANSMITTER = null;
|
||||
@ObjectHolder("network_receiver")
|
||||
public static final BlockEntityType<NetworkReceiverBlockEntity> NETWORK_RECEIVER = null;
|
||||
@ObjectHolder("relay")
|
||||
public static final BlockEntityType<RelayBlockEntity> RELAY = null;
|
||||
@ObjectHolder("cable")
|
||||
public static final BlockEntityType<CableBlockEntity> CABLE = null;
|
||||
@ObjectHolder("1k_storage_block")
|
||||
public static final BlockEntityType<StorageBlockEntity> ONE_K_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("4k_storage_block")
|
||||
public static final BlockEntityType<StorageBlockEntity> FOUR_K_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("16k_storage_block")
|
||||
public static final BlockEntityType<StorageBlockEntity> SIXTEEN_K_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("64k_storage_block")
|
||||
public static final BlockEntityType<StorageBlockEntity> SIXTY_FOUR_K_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("creative_storage_block")
|
||||
public static final BlockEntityType<StorageBlockEntity> CREATIVE_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("64k_fluid_storage_block")
|
||||
public static final BlockEntityType<FluidStorageBlockEntity> SIXTY_FOUR_K_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("256k_fluid_storage_block")
|
||||
public static final BlockEntityType<FluidStorageBlockEntity> TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("1024k_fluid_storage_block")
|
||||
public static final BlockEntityType<FluidStorageBlockEntity> THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("4096k_fluid_storage_block")
|
||||
public static final BlockEntityType<FluidStorageBlockEntity> FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("creative_fluid_storage_block")
|
||||
public static final BlockEntityType<FluidStorageBlockEntity> CREATIVE_FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("security_manager")
|
||||
public static final BlockEntityType<SecurityManagerBlockEntity> SECURITY_MANAGER = null;
|
||||
@ObjectHolder("interface")
|
||||
public static final BlockEntityType<InterfaceBlockEntity> INTERFACE = null;
|
||||
@ObjectHolder("fluid_interface")
|
||||
public static final BlockEntityType<FluidInterfaceBlockEntity> FLUID_INTERFACE = null;
|
||||
@ObjectHolder("wireless_transmitter")
|
||||
public static final BlockEntityType<WirelessTransmitterBlockEntity> WIRELESS_TRANSMITTER = null;
|
||||
@ObjectHolder("storage_monitor")
|
||||
public static final BlockEntityType<StorageMonitorBlockEntity> STORAGE_MONITOR = null;
|
||||
@ObjectHolder("constructor")
|
||||
public static final BlockEntityType<ConstructorBlockEntity> CONSTRUCTOR = null;
|
||||
@ObjectHolder("destructor")
|
||||
public static final BlockEntityType<DestructorBlockEntity> DESTRUCTOR = null;
|
||||
@ObjectHolder("disk_manipulator")
|
||||
public static final BlockEntityType<DiskManipulatorBlockEntity> DISK_MANIPULATOR = null;
|
||||
@ObjectHolder("portable_grid")
|
||||
public static final BlockEntityType<PortableGridBlockEntity> PORTABLE_GRID = null;
|
||||
@ObjectHolder("creative_portable_grid")
|
||||
public static final BlockEntityType<PortableGridBlockEntity> CREATIVE_PORTABLE_GRID = null;
|
||||
@ObjectHolder("crafter")
|
||||
public static final BlockEntityType<CrafterBlockEntity> CRAFTER = null;
|
||||
@ObjectHolder("crafter_manager")
|
||||
public static final BlockEntityType<CrafterManagerBlockEntity> CRAFTER_MANAGER = null;
|
||||
@ObjectHolder("crafting_monitor")
|
||||
public static final BlockEntityType<CraftingMonitorBlockEntity> CRAFTING_MONITOR = null;
|
||||
public static final DeferredRegister<BlockEntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, RS.ID);
|
||||
|
||||
public static final RegistryObject<BlockEntityType<ControllerBlockEntity>> CONTROLLER =
|
||||
REGISTRY.register("controller", () -> registerSynchronizationParameters(ControllerBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new ControllerBlockEntity(NetworkType.NORMAL, pos, state), RSBlocks.CONTROLLER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<ControllerBlockEntity>> CREATIVE_CONTROLLER =
|
||||
REGISTRY.register("creative_controller", () -> registerSynchronizationParameters(ControllerBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new ControllerBlockEntity(NetworkType.CREATIVE, pos, state), RSBlocks.CREATIVE_CONTROLLER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<DetectorBlockEntity>> DETECTOR =
|
||||
REGISTRY.register("detector", () -> registerSynchronizationParameters(DetectorBlockEntity.SPEC, BlockEntityType.Builder.of(DetectorBlockEntity::new, RSBlocks.DETECTOR.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<DiskDriveBlockEntity>> DISK_DRIVE =
|
||||
REGISTRY.register("disk_drive", () -> registerSynchronizationParameters(DiskDriveBlockEntity.SPEC, BlockEntityType.Builder.of(DiskDriveBlockEntity::new, RSBlocks.DISK_DRIVE.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<ExporterBlockEntity>> EXPORTER =
|
||||
REGISTRY.register("exporter", () -> registerSynchronizationParameters(ExporterBlockEntity.SPEC, BlockEntityType.Builder.of(ExporterBlockEntity::new, RSBlocks.EXPORTER.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<ExternalStorageBlockEntity>> EXTERNAL_STORAGE =
|
||||
REGISTRY.register("external_storage", () -> registerSynchronizationParameters(ExternalStorageBlockEntity.SPEC, BlockEntityType.Builder.of(ExternalStorageBlockEntity::new, RSBlocks.EXTERNAL_STORAGE.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<GridBlockEntity>> GRID =
|
||||
REGISTRY.register("grid", () -> registerSynchronizationParameters(GridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new GridBlockEntity(GridType.NORMAL, pos, state), RSBlocks.GRID.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<GridBlockEntity>> CRAFTING_GRID =
|
||||
REGISTRY.register("crafting_grid", () -> registerSynchronizationParameters(GridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new GridBlockEntity(GridType.CRAFTING, pos, state), RSBlocks.CRAFTING_GRID.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<GridBlockEntity>> PATTERN_GRID =
|
||||
REGISTRY.register("pattern_grid", () -> registerSynchronizationParameters(GridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new GridBlockEntity(GridType.PATTERN, pos, state), RSBlocks.PATTERN_GRID.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<GridBlockEntity>> FLUID_GRID =
|
||||
REGISTRY.register("fluid_grid", () -> registerSynchronizationParameters(GridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new GridBlockEntity(GridType.FLUID, pos, state), RSBlocks.FLUID_GRID.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<ImporterBlockEntity>> IMPORTER =
|
||||
REGISTRY.register("importer", () -> registerSynchronizationParameters(ImporterBlockEntity.SPEC, BlockEntityType.Builder.of(ImporterBlockEntity::new, RSBlocks.IMPORTER.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<NetworkTransmitterBlockEntity>> NETWORK_TRANSMITTER =
|
||||
REGISTRY.register("network_transmitter", () -> registerSynchronizationParameters(NetworkTransmitterBlockEntity.SPEC, BlockEntityType.Builder.of(NetworkTransmitterBlockEntity::new, RSBlocks.NETWORK_TRANSMITTER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<NetworkReceiverBlockEntity>> NETWORK_RECEIVER =
|
||||
REGISTRY.register("network_receiver", () -> registerSynchronizationParameters(NetworkReceiverBlockEntity.SPEC, BlockEntityType.Builder.of(NetworkReceiverBlockEntity::new, RSBlocks.NETWORK_RECEIVER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<RelayBlockEntity>> RELAY =
|
||||
REGISTRY.register("relay", () -> registerSynchronizationParameters(RelayBlockEntity.SPEC, BlockEntityType.Builder.of(RelayBlockEntity::new, RSBlocks.RELAY.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<CableBlockEntity>> CABLE =
|
||||
REGISTRY.register("cable", () -> registerSynchronizationParameters(CableBlockEntity.SPEC, BlockEntityType.Builder.of(CableBlockEntity::new, RSBlocks.CABLE.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageBlockEntity>> ONE_K_STORAGE_BLOCK =
|
||||
REGISTRY.register("1k_storage_block", () -> registerSynchronizationParameters(StorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new StorageBlockEntity(ItemStorageType.ONE_K, pos, state), RSBlocks.STORAGE_BLOCKS.get(ItemStorageType.ONE_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageBlockEntity>> FOUR_K_STORAGE_BLOCK =
|
||||
REGISTRY.register("4k_storage_block", () -> registerSynchronizationParameters(StorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new StorageBlockEntity(ItemStorageType.FOUR_K, pos, state), RSBlocks.STORAGE_BLOCKS.get(ItemStorageType.FOUR_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageBlockEntity>> SIXTEEN_K_STORAGE_BLOCK =
|
||||
REGISTRY.register("16k_storage_block", () -> registerSynchronizationParameters(StorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new StorageBlockEntity(ItemStorageType.SIXTEEN_K, pos, state), RSBlocks.STORAGE_BLOCKS.get(ItemStorageType.SIXTEEN_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageBlockEntity>> SIXTY_FOUR_K_STORAGE_BLOCK =
|
||||
REGISTRY.register("64k_storage_block", () -> registerSynchronizationParameters(StorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new StorageBlockEntity(ItemStorageType.SIXTY_FOUR_K, pos, state), RSBlocks.STORAGE_BLOCKS.get(ItemStorageType.SIXTY_FOUR_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageBlockEntity>> CREATIVE_STORAGE_BLOCK =
|
||||
REGISTRY.register("creative_storage_block", () -> registerSynchronizationParameters(StorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new StorageBlockEntity(ItemStorageType.CREATIVE, pos, state), RSBlocks.STORAGE_BLOCKS.get(ItemStorageType.CREATIVE).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidStorageBlockEntity>> SIXTY_FOUR_K_FLUID_STORAGE_BLOCK =
|
||||
REGISTRY.register("64k_fluid_storage_block", () -> registerSynchronizationParameters(FluidStorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new FluidStorageBlockEntity(FluidStorageType.SIXTY_FOUR_K, pos, state), RSBlocks.FLUID_STORAGE_BLOCKS.get(FluidStorageType.SIXTY_FOUR_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidStorageBlockEntity>> TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK =
|
||||
REGISTRY.register("256k_fluid_storage_block", () -> registerSynchronizationParameters(FluidStorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new FluidStorageBlockEntity(FluidStorageType.TWO_HUNDRED_FIFTY_SIX_K, pos, state), RSBlocks.FLUID_STORAGE_BLOCKS.get(FluidStorageType.TWO_HUNDRED_FIFTY_SIX_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidStorageBlockEntity>> THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK =
|
||||
REGISTRY.register("1024k_fluid_storage_block", () -> registerSynchronizationParameters(FluidStorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new FluidStorageBlockEntity(FluidStorageType.THOUSAND_TWENTY_FOUR_K, pos, state), RSBlocks.FLUID_STORAGE_BLOCKS.get(FluidStorageType.THOUSAND_TWENTY_FOUR_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidStorageBlockEntity>> FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK =
|
||||
REGISTRY.register("4096k_fluid_storage_block", () -> registerSynchronizationParameters(FluidStorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new FluidStorageBlockEntity(FluidStorageType.FOUR_THOUSAND_NINETY_SIX_K, pos, state), RSBlocks.FLUID_STORAGE_BLOCKS.get(FluidStorageType.FOUR_THOUSAND_NINETY_SIX_K).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidStorageBlockEntity>> CREATIVE_FLUID_STORAGE_BLOCK =
|
||||
REGISTRY.register("creative_fluid_storage_block", () -> registerSynchronizationParameters(FluidStorageBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new FluidStorageBlockEntity(FluidStorageType.CREATIVE, pos, state), RSBlocks.FLUID_STORAGE_BLOCKS.get(FluidStorageType.CREATIVE).get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<SecurityManagerBlockEntity>> SECURITY_MANAGER =
|
||||
REGISTRY.register("security_manager", () -> registerSynchronizationParameters(SecurityManagerBlockEntity.SPEC, BlockEntityType.Builder.of(SecurityManagerBlockEntity::new, RSBlocks.SECURITY_MANAGER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<InterfaceBlockEntity>> INTERFACE =
|
||||
REGISTRY.register("interface", () -> registerSynchronizationParameters(InterfaceBlockEntity.SPEC, BlockEntityType.Builder.of(InterfaceBlockEntity::new, RSBlocks.INTERFACE.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<FluidInterfaceBlockEntity>> FLUID_INTERFACE =
|
||||
REGISTRY.register("fluid_interface", () -> registerSynchronizationParameters(FluidInterfaceBlockEntity.SPEC, BlockEntityType.Builder.of(FluidInterfaceBlockEntity::new, RSBlocks.FLUID_INTERFACE.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<WirelessTransmitterBlockEntity>> WIRELESS_TRANSMITTER =
|
||||
REGISTRY.register("wireless_transmitter", () -> registerSynchronizationParameters(WirelessTransmitterBlockEntity.SPEC, BlockEntityType.Builder.of(WirelessTransmitterBlockEntity::new, RSBlocks.WIRELESS_TRANSMITTER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<StorageMonitorBlockEntity>> STORAGE_MONITOR =
|
||||
REGISTRY.register("storage_monitor", () -> registerSynchronizationParameters(StorageMonitorBlockEntity.SPEC, BlockEntityType.Builder.of(StorageMonitorBlockEntity::new, RSBlocks.STORAGE_MONITOR.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<ConstructorBlockEntity>> CONSTRUCTOR =
|
||||
REGISTRY.register("constructor", () -> registerSynchronizationParameters(ConstructorBlockEntity.SPEC, BlockEntityType.Builder.of(ConstructorBlockEntity::new, RSBlocks.CONSTRUCTOR.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<DestructorBlockEntity>> DESTRUCTOR =
|
||||
REGISTRY.register("destructor", () -> registerSynchronizationParameters(DestructorBlockEntity.SPEC, BlockEntityType.Builder.of(DestructorBlockEntity::new, RSBlocks.DESTRUCTOR.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<DiskManipulatorBlockEntity>> DISK_MANIPULATOR =
|
||||
REGISTRY.register("disk_manipulator", () -> registerSynchronizationParameters(DiskManipulatorBlockEntity.SPEC, BlockEntityType.Builder.of(DiskManipulatorBlockEntity::new, RSBlocks.DISK_MANIPULATOR.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<PortableGridBlockEntity>> PORTABLE_GRID =
|
||||
REGISTRY.register("portable_grid", () -> registerSynchronizationParameters(PortableGridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new PortableGridBlockEntity(PortableGridBlockItem.Type.NORMAL, pos, state), RSBlocks.PORTABLE_GRID.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<PortableGridBlockEntity>> CREATIVE_PORTABLE_GRID =
|
||||
REGISTRY.register("creative_portable_grid", () -> registerSynchronizationParameters(PortableGridBlockEntity.SPEC, BlockEntityType.Builder.of((pos, state) -> new PortableGridBlockEntity(PortableGridBlockItem.Type.CREATIVE, pos, state), RSBlocks.CREATIVE_PORTABLE_GRID.get()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<CrafterBlockEntity>> CRAFTER =
|
||||
REGISTRY.register("crafter", () -> registerSynchronizationParameters(CrafterBlockEntity.SPEC, BlockEntityType.Builder.of(CrafterBlockEntity::new, RSBlocks.CRAFTER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<CrafterManagerBlockEntity>> CRAFTER_MANAGER =
|
||||
REGISTRY.register("crafter_manager", () -> registerSynchronizationParameters(CrafterManagerBlockEntity.SPEC, BlockEntityType.Builder.of(CrafterManagerBlockEntity::new, RSBlocks.CRAFTER_MANAGER.getBlocks()).build(null)));
|
||||
public static final RegistryObject<BlockEntityType<CraftingMonitorBlockEntity>> CRAFTING_MONITOR =
|
||||
REGISTRY.register("crafting_monitor", () -> registerSynchronizationParameters(CraftingMonitorBlockEntity.SPEC, BlockEntityType.Builder.of(CraftingMonitorBlockEntity::new, RSBlocks.CRAFTING_MONITOR.getBlocks()).build(null)));
|
||||
|
||||
private static <T extends BlockEntity> BlockEntityType<T> registerSynchronizationParameters(BlockEntitySynchronizationSpec spec, BlockEntityType<T> t) {
|
||||
spec.getParameters().forEach(BlockEntitySynchronizationManager::registerParameter);
|
||||
return t;
|
||||
}
|
||||
|
||||
private RSBlockEntities() {
|
||||
}
|
||||
|
||||
@@ -1,59 +1,41 @@
|
||||
package com.refinedmods.refinedstorage;
|
||||
|
||||
import com.refinedmods.refinedstorage.blockentity.*;
|
||||
import com.refinedmods.refinedstorage.container.*;
|
||||
import com.refinedmods.refinedstorage.container.factory.*;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@ObjectHolder(RS.ID)
|
||||
public final class RSContainerMenus {
|
||||
@ObjectHolder("controller")
|
||||
public static final MenuType<ControllerContainerMenu> CONTROLLER = null;
|
||||
@ObjectHolder("grid")
|
||||
public static final MenuType<GridContainerMenu> GRID = null;
|
||||
@ObjectHolder("detector")
|
||||
public static final MenuType<DetectorContainerMenu> DETECTOR = null;
|
||||
@ObjectHolder("exporter")
|
||||
public static final MenuType<ExporterContainerMenu> EXPORTER = null;
|
||||
@ObjectHolder("external_storage")
|
||||
public static final MenuType<ExternalStorageContainerMenu> EXTERNAL_STORAGE = null;
|
||||
@ObjectHolder("filter")
|
||||
public static final MenuType<FilterContainerMenu> FILTER = null;
|
||||
@ObjectHolder("importer")
|
||||
public static final MenuType<ImporterContainerMenu> IMPORTER = null;
|
||||
@ObjectHolder("network_transmitter")
|
||||
public static final MenuType<NetworkTransmitterContainerMenu> NETWORK_TRANSMITTER = null;
|
||||
@ObjectHolder("relay")
|
||||
public static final MenuType<RelayContainerMenu> RELAY = null;
|
||||
@ObjectHolder("disk_drive")
|
||||
public static final MenuType<DiskDriveContainerMenu> DISK_DRIVE = null;
|
||||
@ObjectHolder("storage_block")
|
||||
public static final MenuType<StorageContainerMenu> STORAGE_BLOCK = null;
|
||||
@ObjectHolder("fluid_storage_block")
|
||||
public static final MenuType<FluidStorageContainerMenu> FLUID_STORAGE_BLOCK = null;
|
||||
@ObjectHolder("security_manager")
|
||||
public static final MenuType<SecurityManagerContainerMenu> SECURITY_MANAGER = null;
|
||||
@ObjectHolder("interface")
|
||||
public static final MenuType<InterfaceContainerMenu> INTERFACE = null;
|
||||
@ObjectHolder("fluid_interface")
|
||||
public static final MenuType<FluidInterfaceContainerMenu> FLUID_INTERFACE = null;
|
||||
@ObjectHolder("wireless_transmitter")
|
||||
public static final MenuType<WirelessTransmitterContainerMenu> WIRELESS_TRANSMITTER = null;
|
||||
@ObjectHolder("storage_monitor")
|
||||
public static final MenuType<StorageMonitorContainerMenu> STORAGE_MONITOR = null;
|
||||
@ObjectHolder("constructor")
|
||||
public static final MenuType<ConstructorContainerMenu> CONSTRUCTOR = null;
|
||||
@ObjectHolder("destructor")
|
||||
public static final MenuType<DestructorContainerMenu> DESTRUCTOR = null;
|
||||
@ObjectHolder("disk_manipulator")
|
||||
public static final MenuType<DiskManipulatorContainerMenu> DISK_MANIPULATOR = null;
|
||||
@ObjectHolder("crafter")
|
||||
public static final MenuType<CrafterContainerMenu> CRAFTER = null;
|
||||
@ObjectHolder("crafter_manager")
|
||||
public static final MenuType<CrafterManagerContainerMenu> CRAFTER_MANAGER = null;
|
||||
@ObjectHolder("crafting_monitor")
|
||||
public static final MenuType<CraftingMonitorContainerMenu> CRAFTING_MONITOR = null;
|
||||
@ObjectHolder("wireless_crafting_monitor")
|
||||
public static final MenuType<CraftingMonitorContainerMenu> WIRELESS_CRAFTING_MONITOR = null;
|
||||
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, RS.ID);
|
||||
|
||||
public static final RegistryObject<MenuType<ControllerContainerMenu>> CONTROLLER = REGISTRY.register("controller", () -> IForgeMenuType.create(((windowId, inv, data) -> new ControllerContainerMenu(null, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<GridContainerMenu>> GRID = REGISTRY.register("grid", () -> IForgeMenuType.create(new GridContainerFactory()));
|
||||
public static final RegistryObject<MenuType<DetectorContainerMenu>> DETECTOR = REGISTRY.register("detector", () -> IForgeMenuType.create(new BlockEntityContainerFactory<DetectorContainerMenu, DetectorBlockEntity>((windowId, inv, blockEntity) -> new DetectorContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<ExporterContainerMenu>> EXPORTER = REGISTRY.register("exporter", () -> IForgeMenuType.create(new BlockEntityContainerFactory<ExporterContainerMenu, ExporterBlockEntity>((windowId, inv, blockEntity) -> new ExporterContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<ExternalStorageContainerMenu>> EXTERNAL_STORAGE = REGISTRY.register("external_storage", () -> IForgeMenuType.create(new BlockEntityContainerFactory<ExternalStorageContainerMenu, ExternalStorageBlockEntity>((windowId, inv, blockEntity) -> new ExternalStorageContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<FilterContainerMenu>> FILTER = REGISTRY.register("filter", () -> IForgeMenuType.create((windowId, inv, data) -> new FilterContainerMenu(inv.player, inv.getSelected(), windowId)));
|
||||
public static final RegistryObject<MenuType<ImporterContainerMenu>> IMPORTER = REGISTRY.register("importer", () -> IForgeMenuType.create(new BlockEntityContainerFactory<ImporterContainerMenu, ImporterBlockEntity>((windowId, inv, blockEntity) -> new ImporterContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<NetworkTransmitterContainerMenu>> NETWORK_TRANSMITTER = REGISTRY.register("network_transmitter", () -> IForgeMenuType.create(new BlockEntityContainerFactory<NetworkTransmitterContainerMenu, NetworkTransmitterBlockEntity>((windowId, inv, blockEntity) -> new NetworkTransmitterContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<RelayContainerMenu>> RELAY = REGISTRY.register("relay", () -> IForgeMenuType.create(new BlockEntityContainerFactory<RelayContainerMenu, RelayBlockEntity>((windowId, inv, blockEntity) -> new RelayContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<DiskDriveContainerMenu>> DISK_DRIVE = REGISTRY.register("disk_drive", () -> IForgeMenuType.create(new BlockEntityContainerFactory<DiskDriveContainerMenu, DiskDriveBlockEntity>((windowId, inv, blockEntity) -> new DiskDriveContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<StorageContainerMenu>> STORAGE_BLOCK = REGISTRY.register("storage_block", () -> IForgeMenuType.create(new BlockEntityContainerFactory<StorageContainerMenu, StorageBlockEntity>((windowId, inv, blockEntity) -> new StorageContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<FluidStorageContainerMenu>> FLUID_STORAGE_BLOCK = REGISTRY.register("fluid_storage_block", () -> IForgeMenuType.create(new BlockEntityContainerFactory<FluidStorageContainerMenu, FluidStorageBlockEntity>((windowId, inv, blockEntity) -> new FluidStorageContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<SecurityManagerContainerMenu>> SECURITY_MANAGER = REGISTRY.register("security_manager", () -> IForgeMenuType.create(new BlockEntityContainerFactory<SecurityManagerContainerMenu, SecurityManagerBlockEntity>((windowId, inv, blockEntity) -> new SecurityManagerContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<InterfaceContainerMenu>> INTERFACE = REGISTRY.register("interface", () -> IForgeMenuType.create(new BlockEntityContainerFactory<InterfaceContainerMenu, InterfaceBlockEntity>((windowId, inv, blockEntity) -> new InterfaceContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<FluidInterfaceContainerMenu>> FLUID_INTERFACE = REGISTRY.register("fluid_interface", () -> IForgeMenuType.create(new BlockEntityContainerFactory<FluidInterfaceContainerMenu, FluidInterfaceBlockEntity>((windowId, inv, blockEntity) -> new FluidInterfaceContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<WirelessTransmitterContainerMenu>> WIRELESS_TRANSMITTER = REGISTRY.register("wireless_transmitter", () -> IForgeMenuType.create(new BlockEntityContainerFactory<WirelessTransmitterContainerMenu, WirelessTransmitterBlockEntity>((windowId, inv, blockEntity) -> new WirelessTransmitterContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<StorageMonitorContainerMenu>> STORAGE_MONITOR = REGISTRY.register("storage_monitor", () -> IForgeMenuType.create(new BlockEntityContainerFactory<StorageMonitorContainerMenu, StorageMonitorBlockEntity>((windowId, inv, blockEntity) -> new StorageMonitorContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<ConstructorContainerMenu>> CONSTRUCTOR = REGISTRY.register("constructor", () -> IForgeMenuType.create(new BlockEntityContainerFactory<ConstructorContainerMenu, ConstructorBlockEntity>((windowId, inv, blockEntity) -> new ConstructorContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<DestructorContainerMenu>> DESTRUCTOR = REGISTRY.register("destructor", () -> IForgeMenuType.create(new BlockEntityContainerFactory<DestructorContainerMenu, DestructorBlockEntity>((windowId, inv, blockEntity) -> new DestructorContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<DiskManipulatorContainerMenu>> DISK_MANIPULATOR = REGISTRY.register("disk_manipulator", () -> IForgeMenuType.create(new BlockEntityContainerFactory<DiskManipulatorContainerMenu, DiskManipulatorBlockEntity>((windowId, inv, blockEntity) -> new DiskManipulatorContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<CrafterContainerMenu>> CRAFTER = REGISTRY.register("crafter", () -> IForgeMenuType.create(new BlockEntityContainerFactory<CrafterContainerMenu, CrafterBlockEntity>((windowId, inv, blockEntity) -> new CrafterContainerMenu(blockEntity, inv.player, windowId))));
|
||||
public static final RegistryObject<MenuType<CrafterManagerContainerMenu>> CRAFTER_MANAGER = REGISTRY.register("crafter_manager", () -> IForgeMenuType.create(new CrafterManagerContainerFactory()));
|
||||
public static final RegistryObject<MenuType<CraftingMonitorContainerMenu>> CRAFTING_MONITOR = REGISTRY.register("crafting_monitor", () -> IForgeMenuType.create(new CraftingMonitorContainerFactory()));
|
||||
public static final RegistryObject<MenuType<CraftingMonitorContainerMenu>> WIRELESS_CRAFTING_MONITOR = REGISTRY.register("wireless_crafting_monitor", () -> IForgeMenuType.create(new WirelessCraftingMonitorContainerFactory()));
|
||||
|
||||
private RSContainerMenus() {
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ 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.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
@@ -167,13 +168,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 TranslatableComponent(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, Component.translatable(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 TranslatableComponent(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, Component.translatable(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId()))));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.refinedmods.refinedstorage;
|
||||
|
||||
import com.refinedmods.refinedstorage.recipe.CoverRecipe;
|
||||
import com.refinedmods.refinedstorage.recipe.HollowCoverRecipe;
|
||||
import com.refinedmods.refinedstorage.recipe.UpgradeWithEnchantedBookRecipeSerializer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
public final class RSRecipeSerializers {
|
||||
public static final DeferredRegister<RecipeSerializer<?>> REGISTRY = DeferredRegister.create(Registry.RECIPE_SERIALIZER_REGISTRY, RS.ID);
|
||||
|
||||
static {
|
||||
REGISTRY.register("upgrade_with_enchanted_book", UpgradeWithEnchantedBookRecipeSerializer::new);
|
||||
REGISTRY.register("cover_recipe", () -> CoverRecipe.SERIALIZER);
|
||||
REGISTRY.register("hollow_cover_recipe", () -> HollowCoverRecipe.SERIALIZER);
|
||||
}
|
||||
|
||||
private RSRecipeSerializers() {
|
||||
}
|
||||
}
|
||||
@@ -268,6 +268,11 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
public static class DummyCraftingContainer extends CraftingContainer {
|
||||
public DummyCraftingContainer() {
|
||||
super(new AbstractContainerMenu(null, 0) {
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player p_38941_, int p_38942_) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
@@ -48,7 +48,7 @@ public class CraftingPatternFactory {
|
||||
}
|
||||
|
||||
if (outputs.isEmpty() && fluidOutputs.isEmpty()) {
|
||||
throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.processing_no_outputs"));
|
||||
throw new CraftingPatternFactoryException(Component.translatable("misc.refinedstorage.pattern.error.processing_no_outputs"));
|
||||
}
|
||||
} else {
|
||||
CraftingContainer craftingContainer = new CraftingPattern.DummyCraftingContainer();
|
||||
@@ -72,10 +72,10 @@ public class CraftingPatternFactory {
|
||||
modifyCraftingInputsToUseAlternatives(recipe, inputs);
|
||||
}
|
||||
} else {
|
||||
throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.no_output"));
|
||||
throw new CraftingPatternFactoryException(Component.translatable("misc.refinedstorage.pattern.error.no_output"));
|
||||
}
|
||||
} else {
|
||||
throw new CraftingPatternFactoryException(new TranslatableComponent("misc.refinedstorage.pattern.error.recipe_does_not_exist"));
|
||||
throw new CraftingPatternFactoryException(Component.translatable("misc.refinedstorage.pattern.error.recipe_does_not_exist"));
|
||||
}
|
||||
}
|
||||
} catch (CraftingPatternFactoryException e) {
|
||||
@@ -116,7 +116,7 @@ public class CraftingPatternFactory {
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
if (!tagsOfItem.contains(declaredAllowedTag)) {
|
||||
throw new CraftingPatternFactoryException(
|
||||
new TranslatableComponent(
|
||||
Component.translatable(
|
||||
"misc.refinedstorage.pattern.error.tag_no_longer_applicable",
|
||||
declaredAllowedTag.toString(),
|
||||
input.getHoverName()
|
||||
@@ -162,7 +162,7 @@ public class CraftingPatternFactory {
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
if (!tagsOfFluid.contains(declaredAllowedTag)) {
|
||||
throw new CraftingPatternFactoryException(
|
||||
new TranslatableComponent(
|
||||
Component.translatable(
|
||||
"misc.refinedstorage.pattern.error.tag_no_longer_applicable",
|
||||
declaredAllowedTag.toString(),
|
||||
input.getDisplayName()
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.refinedmods.refinedstorage.render.Styles;
|
||||
import com.refinedmods.refinedstorage.util.PacketBufferUtils;
|
||||
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;
|
||||
@@ -48,7 +47,7 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
@Override
|
||||
public List<Component> getTooltip() {
|
||||
List<Component> items = new ArrayList<>(base.getTooltip());
|
||||
items.add(new TranslatableComponent(message).setStyle(Styles.RED));
|
||||
items.add(Component.translatable(message).setStyle(Styles.RED));
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Component> getTooltip() {
|
||||
return Collections.singletonList(stack.getFluid().getAttributes().getDisplayName(stack));
|
||||
return Collections.singletonList(stack.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,23 +9,23 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class NetworkListener {
|
||||
@SubscribeEvent
|
||||
public void onLevelTick(TickEvent.WorldTickEvent e) {
|
||||
if (!e.world.isClientSide() && e.phase == TickEvent.Phase.END) {
|
||||
e.world.getProfiler().push("network ticking");
|
||||
public void onLevelTick(TickEvent.LevelTickEvent e) {
|
||||
if (!e.level.isClientSide() && e.phase == TickEvent.Phase.END) {
|
||||
e.level.getProfiler().push("network ticking");
|
||||
|
||||
for (INetwork network : API.instance().getNetworkManager((ServerLevel) e.world).all()) {
|
||||
for (INetwork network : API.instance().getNetworkManager((ServerLevel) e.level).all()) {
|
||||
network.update();
|
||||
}
|
||||
|
||||
e.world.getProfiler().pop();
|
||||
e.level.getProfiler().pop();
|
||||
|
||||
e.world.getProfiler().push("network node ticking");
|
||||
e.level.getProfiler().push("network node ticking");
|
||||
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager((ServerLevel) e.world).all()) {
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager((ServerLevel) e.level).all()) {
|
||||
node.update();
|
||||
}
|
||||
|
||||
e.world.getProfiler().pop();
|
||||
e.level.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,28 @@ package com.refinedmods.refinedstorage.apiimpl.network;
|
||||
import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.refinedmods.refinedstorage.api.network.security.Permission;
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import com.refinedmods.refinedstorage.util.PlayerUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
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.event.level.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class NetworkNodeListener {
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
||||
if (!e.getWorld().isClientSide() && e.getEntity() instanceof Player) {
|
||||
if (!e.getLevel().isClientSide() && e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
|
||||
INetworkNode placed = NetworkUtils.getNodeFromBlockEntity(e.getWorld().getBlockEntity(e.getPos()));
|
||||
INetworkNode placed = NetworkUtils.getNodeFromBlockEntity(e.getLevel().getBlockEntity(e.getPos()));
|
||||
|
||||
if (placed != null) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromBlockEntity(e.getWorld().getBlockEntity(e.getBlockSnapshot().getPos().relative(facing)));
|
||||
INetworkNode node = NetworkUtils.getNodeFromBlockEntity(e.getLevel().getBlockEntity(e.getBlockSnapshot().getPos().relative(facing)));
|
||||
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
LevelUtils.sendNoPermissionMessage(player);
|
||||
@@ -38,7 +38,7 @@ public class NetworkNodeListener {
|
||||
}
|
||||
}
|
||||
|
||||
discoverNode(e.getWorld(), e.getPos());
|
||||
discoverNode(e.getLevel(), e.getPos());
|
||||
|
||||
placed.setOwner(player.getGameProfile().getId());
|
||||
}
|
||||
@@ -59,8 +59,8 @@ public class NetworkNodeListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(BlockEvent.BreakEvent e) {
|
||||
if (!e.getWorld().isClientSide()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromBlockEntity(e.getWorld().getBlockEntity(e.getPos()));
|
||||
if (!e.getLevel().isClientSide()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromBlockEntity(e.getLevel().getBlockEntity(e.getPos()));
|
||||
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
|
||||
LevelUtils.sendNoPermissionMessage(e.getPlayer());
|
||||
|
||||
@@ -43,7 +43,7 @@ public class GridManager implements IGridManager {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkHooks.openGui(player, new GridMenuProvider(grid.getLeft(), grid.getRight()), buf -> {
|
||||
NetworkHooks.openScreen(player, new GridMenuProvider(grid.getLeft(), grid.getRight()), buf -> {
|
||||
buf.writeResourceLocation(id);
|
||||
|
||||
buf.writeBoolean(pos != null);
|
||||
|
||||
@@ -6,7 +6,8 @@ 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.screens.Screen;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -17,7 +18,7 @@ import java.util.List;
|
||||
public class GridTab implements IGridTab {
|
||||
private final List<IFilter> filters;
|
||||
@Nullable
|
||||
private final TextComponent name;
|
||||
private final MutableComponent name;
|
||||
@Nonnull
|
||||
private final ItemStack icon;
|
||||
@Nullable
|
||||
@@ -25,7 +26,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.trim().isEmpty() ? null : new TextComponent(name);
|
||||
this.name = name.trim().isEmpty() ? null : Component.literal(name);
|
||||
this.icon = icon;
|
||||
this.fluidIcon = fluidIcon;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -36,14 +36,14 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
public void onExtract(ServerPlayer player, UUID id, boolean shift) {
|
||||
FluidStack stack = network.getFluidStorageCache().getList().get(id);
|
||||
|
||||
if (stack == null || stack.getAmount() < FluidAttributes.BUCKET_VOLUME || !network.getSecurityManager().hasPermission(Permission.EXTRACT, player) || !network.canRun()) {
|
||||
if (stack == null || stack.getAmount() < FluidType.BUCKET_VOLUME || !network.getSecurityManager().hasPermission(Permission.EXTRACT, player) || !network.canRun()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
FluidStack extracted = network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM);
|
||||
FluidStack extracted = network.extractFluid(stack, FluidType.BUCKET_VOLUME, Action.PERFORM);
|
||||
|
||||
fluidHandler.fill(extracted, IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
int itemSize = item.getCount();
|
||||
// We copy here because some mods change the NBT tag of an item after getting the stack limit
|
||||
int maxItemSize = item.getItem().getItemStackLimit(item.copy());
|
||||
int maxItemSize = item.getItem().getMaxStackSize(item.copy());
|
||||
|
||||
boolean single = (flags & EXTRACT_SINGLE) == EXTRACT_SINGLE;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -34,7 +34,7 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
FluidStack stack = portableGrid.getFluidCache().getList().get(id);
|
||||
|
||||
if (stack == null || stack.getAmount() < FluidAttributes.BUCKET_VOLUME) {
|
||||
if (stack == null || stack.getAmount() < FluidType.BUCKET_VOLUME) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
portableGrid.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, FluidAttributes.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, FluidType.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (shift) {
|
||||
if (!player.getInventory().add(fluidHandler.getContainer().copy())) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
|
||||
int itemSize = item.getCount();
|
||||
// We copy here because some mods change the NBT tag of an item after getting the stack limit
|
||||
int maxItemSize = item.getItem().getItemStackLimit(item.copy());
|
||||
int maxItemSize = item.getItem().getMaxStackSize(item.copy());
|
||||
|
||||
boolean single = (flags & EXTRACT_SINGLE) == EXTRACT_SINGLE;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.refinedmods.refinedstorage.api.network.item.INetworkItemManager;
|
||||
import com.refinedmods.refinedstorage.api.network.item.INetworkItemProvider;
|
||||
import com.refinedmods.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -50,7 +50,7 @@ public class NetworkItemManager implements INetworkItemManager {
|
||||
}
|
||||
|
||||
if (!inRange) {
|
||||
player.sendMessage(new TranslatableComponent("misc.refinedstorage.network_item.out_of_range"), player.getUUID());
|
||||
player.sendSystemMessage(Component.translatable("misc.refinedstorage.network_item.out_of_range"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.refinedmods.refinedstorage.container.factory.CraftingMonitorMenuProvi
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import com.refinedmods.refinedstorage.item.WirelessCraftingMonitorItem;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -59,9 +59,11 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
|
||||
WirelessCraftingMonitor wirelessCraftingMonitor = new WirelessCraftingMonitor(stack, player.getServer(), slot);
|
||||
|
||||
NetworkHooks.openGui(
|
||||
NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new CraftingMonitorMenuProvider(RSContainerMenus.WIRELESS_CRAFTING_MONITOR, wirelessCraftingMonitor, null), slot::writePlayerSlot);
|
||||
new CraftingMonitorMenuProvider(RSContainerMenus.WIRELESS_CRAFTING_MONITOR.get(), wirelessCraftingMonitor, null),
|
||||
slot::writePlayerSlot
|
||||
);
|
||||
|
||||
drainEnergy(RS.SERVER_CONFIG.getWirelessCraftingMonitor().getOpenUsage());
|
||||
|
||||
@@ -86,6 +88,6 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslatableComponent("misc.refinedstorage.network_item.out_of_energy", new TranslatableComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
player.sendSystemMessage(Component.translatable("misc.refinedstorage.network_item.out_of_energy", Component.translatable(stack.getItem().getDescriptionId())));
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.grid.factory.WirelessFluid
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import com.refinedmods.refinedstorage.item.WirelessFluidGridItem;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -79,6 +79,6 @@ public class WirelessFluidGridNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslatableComponent("misc.refinedstorage.network_item.out_of_energy", new TranslatableComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
player.sendSystemMessage(Component.translatable("misc.refinedstorage.network_item.out_of_energy", Component.translatable(stack.getItem().getDescriptionId())));
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.grid.factory.WirelessGridG
|
||||
import com.refinedmods.refinedstorage.inventory.player.PlayerSlot;
|
||||
import com.refinedmods.refinedstorage.item.WirelessGridItem;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -79,6 +79,6 @@ public class WirelessGridNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslatableComponent("misc.refinedstorage.network_item.out_of_energy", new TranslatableComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
player.sendSystemMessage(Component.translatable("misc.refinedstorage.network_item.out_of_energy", Component.translatable(stack.getItem().getDescriptionId())));
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,8 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -100,12 +100,12 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
private void extractAndPlaceFluid(FluidStack stack) {
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
|
||||
if (network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, compare, Action.SIMULATE).getAmount() < FluidAttributes.BUCKET_VOLUME) {
|
||||
if (network.extractFluid(stack, FluidType.BUCKET_VOLUME, compare, Action.SIMULATE).getAmount() < FluidType.BUCKET_VOLUME) {
|
||||
if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
network.getCraftingManager().request(this, stack, FluidAttributes.BUCKET_VOLUME);
|
||||
network.getCraftingManager().request(this, stack, FluidType.BUCKET_VOLUME);
|
||||
}
|
||||
} else if (!level.getBlockState(front).getFluidState().isSource()) {
|
||||
FluidUtil.tryPlaceFluid(LevelUtils.getFakePlayer((ServerLevel) level, getOwner()), level, InteractionHand.MAIN_HAND, front, new NetworkFluidHandler(StackUtils.copy(stack, FluidAttributes.BUCKET_VOLUME)), stack);
|
||||
FluidUtil.tryPlaceFluid(LevelUtils.getFakePlayer((ServerLevel) level, getOwner()), level, InteractionHand.MAIN_HAND, front, new NetworkFluidHandler(StackUtils.copy(stack, FluidType.BUCKET_VOLUME)), stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,12 @@ import com.refinedmods.refinedstorage.inventory.item.UpgradeItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.item.validator.PatternItemValidator;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeInventoryListener;
|
||||
import com.refinedmods.refinedstorage.item.UpgradeItem;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.Nameable;
|
||||
@@ -40,7 +39,7 @@ import java.util.UUID;
|
||||
public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternContainer {
|
||||
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "crafter");
|
||||
private static final Component DEFAULT_NAME = new TranslatableComponent("gui.refinedstorage.crafter");
|
||||
private static final Component DEFAULT_NAME = Component.translatable("gui.refinedstorage.crafter");
|
||||
private static final String NBT_DISPLAY_NAME = "DisplayName";
|
||||
private static final String NBT_UUID = "CrafterUuid";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
@@ -50,7 +49,8 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED)
|
||||
.addListener(new NetworkNodeInventoryListener(this));
|
||||
// Used to prevent infinite recursion on getRootContainer() when there's e.g. two crafters facing each other.
|
||||
private boolean visited = false; private final BaseItemHandler patternsInventory = new BaseItemHandler(9) {
|
||||
private boolean visited = false;
|
||||
private final BaseItemHandler patternsInventory = new BaseItemHandler(9) {
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return 1;
|
||||
@@ -86,6 +86,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
private Component displayName;
|
||||
@Nullable
|
||||
private UUID uuid = null;
|
||||
|
||||
public CrafterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
@@ -309,7 +310,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
if (facing != null) {
|
||||
return new TranslatableComponent(level.getBlockState(facing.getBlockPos()).getBlock().getDescriptionId());
|
||||
return Component.translatable(level.getBlockState(facing.getBlockPos()).getBlock().getDescriptionId());
|
||||
}
|
||||
|
||||
return DEFAULT_NAME;
|
||||
@@ -448,6 +449,4 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizatio
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -51,7 +50,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.crafting_monitor");
|
||||
return Component.translatable("gui.refinedstorage.crafting_monitor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,9 +37,9 @@ import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -61,12 +61,14 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
private final BaseItemHandler itemFilters = new BaseItemHandler(9).addListener(new NetworkNodeInventoryListener(this));
|
||||
private final FluidInventory fluidFilters = new FluidInventory(9).addListener(new NetworkNodeFluidInventoryListener(this));
|
||||
private final CoverManager coverManager;
|
||||
private int compare = IComparer.COMPARE_NBT; private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.SILK_TOUCH, UpgradeItem.Type.FORTUNE_1, UpgradeItem.Type.FORTUNE_2, UpgradeItem.Type.FORTUNE_3)
|
||||
private int compare = IComparer.COMPARE_NBT;
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.SILK_TOUCH, UpgradeItem.Type.FORTUNE_1, UpgradeItem.Type.FORTUNE_2, UpgradeItem.Type.FORTUNE_3)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> tool = createTool());
|
||||
private int mode = IWhitelistBlacklist.BLACKLIST;
|
||||
private int type = IType.ITEMS;
|
||||
private boolean pickupItem = false;
|
||||
|
||||
public DestructorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
@@ -92,7 +94,9 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
breakFluid();
|
||||
}
|
||||
}
|
||||
} private ItemStack tool = createTool();
|
||||
}
|
||||
|
||||
private ItemStack tool = createTool();
|
||||
|
||||
private void pickupItems() {
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
@@ -178,7 +182,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
if (frontBlockState.getValue(LiquidBlock.LEVEL) == 0) {
|
||||
Fluid fluid = ((LiquidBlock) frontBlock).getFluid();
|
||||
|
||||
FluidStack stack = new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
|
||||
FluidStack stack = new FluidStack(fluid, FluidType.BUCKET_VOLUME);
|
||||
|
||||
if (IWhitelistBlacklist.acceptsFluid(fluidFilters, mode, compare, stack) &&
|
||||
network.insertFluid(stack, stack.getAmount(), Action.SIMULATE).isEmpty()) {
|
||||
@@ -358,8 +362,4 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,15 +15,15 @@ import com.refinedmods.refinedstorage.inventory.item.UpgradeItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeFluidInventoryListener;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeInventoryListener;
|
||||
import com.refinedmods.refinedstorage.item.UpgradeItem;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
@@ -39,7 +39,8 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
private final BaseItemHandler itemFilters = new BaseItemHandler(9).addListener(new NetworkNodeInventoryListener(this));
|
||||
private final FluidInventory fluidFilters = new FluidInventory(9).addListener(new NetworkNodeFluidInventoryListener(this));
|
||||
private final CoverManager coverManager;
|
||||
private int compare = IComparer.COMPARE_NBT; private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.CRAFTING, UpgradeItem.Type.STACK, UpgradeItem.Type.REGULATOR)
|
||||
private int compare = IComparer.COMPARE_NBT;
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.CRAFTING, UpgradeItem.Type.STACK, UpgradeItem.Type.REGULATOR)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && !getUpgrades().hasUpgrade(UpgradeItem.Type.REGULATOR)) {
|
||||
@@ -57,8 +58,8 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
for (int i = 0; i < fluidFilters.getSlots(); ++i) {
|
||||
FluidStack filteredFluid = fluidFilters.getFluid(i);
|
||||
|
||||
if (!filteredFluid.isEmpty() && filteredFluid.getAmount() != FluidAttributes.BUCKET_VOLUME) {
|
||||
filteredFluid.setAmount(FluidAttributes.BUCKET_VOLUME);
|
||||
if (!filteredFluid.isEmpty() && filteredFluid.getAmount() != FluidType.BUCKET_VOLUME) {
|
||||
filteredFluid.setAmount(FluidType.BUCKET_VOLUME);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +174,7 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
FluidStack stack = fluids[filterSlot];
|
||||
|
||||
if (stack != null) {
|
||||
int toExtract = FluidAttributes.BUCKET_VOLUME * upgrades.getStackInteractCount();
|
||||
int toExtract = FluidType.BUCKET_VOLUME * upgrades.getStackInteractCount();
|
||||
|
||||
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
|
||||
|
||||
@@ -332,6 +333,4 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -248,7 +248,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage:external_storage");
|
||||
return Component.translatable("gui.refinedstorage:external_storage");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
@@ -85,7 +85,7 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
if (ticks % upgrades.getSpeed() == 0) {
|
||||
FluidStack drained = tankIn.drain(FluidAttributes.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.EXECUTE);
|
||||
FluidStack drained = tankIn.drain(FluidType.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
// Drain in tank
|
||||
if (!drained.isEmpty()) {
|
||||
|
||||
@@ -17,6 +17,9 @@ import com.refinedmods.refinedstorage.apiimpl.storage.cache.listener.FluidGridSt
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.cache.listener.ItemGridStorageCacheListener;
|
||||
import com.refinedmods.refinedstorage.block.GridBlock;
|
||||
import com.refinedmods.refinedstorage.block.NetworkNodeBlock;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.inventory.fluid.FluidInventory;
|
||||
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.item.FilterItemHandler;
|
||||
@@ -24,14 +27,10 @@ import com.refinedmods.refinedstorage.inventory.item.validator.ItemValidator;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeFluidInventoryListener;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeInventoryListener;
|
||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Container;
|
||||
@@ -46,8 +45,8 @@ import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
@@ -94,6 +93,11 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player p_38941_, int p_38942_) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slotsChanged(Container inventory) {
|
||||
if (!level.isClientSide) {
|
||||
@@ -101,7 +105,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
}
|
||||
};
|
||||
private final FluidInventory processingMatrixFluids = new FluidInventory(PROCESSING_MATRIX_SIZE * 2, FluidAttributes.BUCKET_VOLUME * 64)
|
||||
private final FluidInventory processingMatrixFluids = new FluidInventory(PROCESSING_MATRIX_SIZE * 2, FluidType.BUCKET_VOLUME * 64)
|
||||
.addListener(new NetworkNodeFluidInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && slot < PROCESSING_MATRIX_SIZE) {
|
||||
@@ -179,6 +183,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
private boolean exactPattern = true;
|
||||
private boolean processingPattern = false;
|
||||
private int processingType = IType.ITEMS;
|
||||
|
||||
public GridNetworkNode(Level level, BlockPos pos, GridType type) {
|
||||
super(level, pos);
|
||||
|
||||
@@ -293,13 +298,13 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
public Component getTitle() {
|
||||
switch (type) {
|
||||
case CRAFTING:
|
||||
return new TranslatableComponent("gui.refinedstorage.crafting_grid");
|
||||
return Component.translatable("gui.refinedstorage.crafting_grid");
|
||||
case PATTERN:
|
||||
return new TranslatableComponent("gui.refinedstorage.pattern_grid");
|
||||
return Component.translatable("gui.refinedstorage.pattern_grid");
|
||||
case FLUID:
|
||||
return new TranslatableComponent("gui.refinedstorage.fluid_grid");
|
||||
return Component.translatable("gui.refinedstorage.fluid_grid");
|
||||
default:
|
||||
return new TranslatableComponent("gui.refinedstorage.grid");
|
||||
return Component.translatable("gui.refinedstorage.grid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,10 +780,4 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,27 +5,27 @@ import com.refinedmods.refinedstorage.api.network.node.ICoverable;
|
||||
import com.refinedmods.refinedstorage.api.util.Action;
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.DiskDriveBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.ImporterBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.inventory.fluid.FluidInventory;
|
||||
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.item.UpgradeItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeFluidInventoryListener;
|
||||
import com.refinedmods.refinedstorage.inventory.listener.NetworkNodeInventoryListener;
|
||||
import com.refinedmods.refinedstorage.item.UpgradeItem;
|
||||
import com.refinedmods.refinedstorage.blockentity.DiskDriveBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.ImporterBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
@@ -103,12 +103,12 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
IFluidHandler handler = LevelUtils.getFluidHandler(getFacingBlockEntity(), getDirection().getOpposite());
|
||||
|
||||
if (handler != null) {
|
||||
FluidStack stack = handler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE);
|
||||
FluidStack stack = handler.drain(FluidType.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE);
|
||||
|
||||
if (!stack.isEmpty() &&
|
||||
IWhitelistBlacklist.acceptsFluid(fluidFilters, mode, compare, stack) &&
|
||||
network.insertFluid(stack, stack.getAmount(), Action.SIMULATE).isEmpty()) {
|
||||
FluidStack toDrain = handler.drain(FluidAttributes.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.SIMULATE);
|
||||
FluidStack toDrain = handler.drain(FluidType.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.SIMULATE);
|
||||
|
||||
if (!toDrain.isEmpty()) {
|
||||
FluidStack remainder = network.insertFluidTracked(toDrain, toDrain.getAmount());
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -50,7 +50,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
}
|
||||
});
|
||||
|
||||
private final FluidInventory fluidFilter = new FluidInventory(1, FluidAttributes.BUCKET_VOLUME)
|
||||
private final FluidInventory fluidFilter = new FluidInventory(1, FluidType.BUCKET_VOLUME)
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading) {
|
||||
LevelUtils.updateBlock(level, pos);
|
||||
@@ -212,7 +212,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
}
|
||||
|
||||
FluidStack stack = network.getFluidStorageCache().getList().get(filter);
|
||||
if (stack == null || stack.getAmount() < FluidAttributes.BUCKET_VOLUME) {
|
||||
if (stack == null || stack.getAmount() < FluidType.BUCKET_VOLUME) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
NetworkUtils.extractBucketFromPlayerInventoryOrNetwork(player, network, bucket -> bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
fluidHandler.fill(network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
fluidHandler.fill(network.extractFluid(stack, FluidType.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (!player.getInventory().add(fluidHandler.getContainer().copy())) {
|
||||
Containers.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), fluidHandler.getContainer());
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
@@ -104,7 +104,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
int count = super.getStackInteractCount();
|
||||
|
||||
if (type == IType.FLUIDS) {
|
||||
count *= FluidAttributes.BUCKET_VOLUME;
|
||||
count *= FluidType.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.refinedmods.refinedstorage.util.AccessTypeUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -247,7 +247,7 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("block.refinedstorage." + type.getName() + "_fluid_storage_block");
|
||||
return Component.translatable("block.refinedstorage." + type.getName() + "_fluid_storage_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -246,7 +246,7 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("block.refinedstorage." + type.getName() + "_storage_block");
|
||||
return Component.translatable("block.refinedstorage." + type.getName() + "_storage_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.refinedmods.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.IQuantityFormatter;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -60,12 +60,12 @@ public class QuantityFormatter implements IQuantityFormatter {
|
||||
|
||||
@Override
|
||||
public String formatInBucketForm(int qty) {
|
||||
return bucketFormatter.format((float) qty / (float) FluidAttributes.BUCKET_VOLUME) + " B";
|
||||
return bucketFormatter.format((float) qty / (float) FluidType.BUCKET_VOLUME) + " B";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatInBucketFormWithOnlyTrailingDigitsIfZero(int qty) {
|
||||
float amountRaw = ((float) qty / (float) FluidAttributes.BUCKET_VOLUME);
|
||||
float amountRaw = ((float) qty / (float) FluidType.BUCKET_VOLUME);
|
||||
int amount = (int) amountRaw;
|
||||
|
||||
if (amount >= 1) {
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -92,10 +93,10 @@ public class ConstructorBlock extends CableBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<ConstructorBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.constructor"),
|
||||
Component.translatable("gui.refinedstorage.constructor"),
|
||||
(blockEntity, windowId, inventory, p) -> new ConstructorContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -5,14 +5,13 @@ import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||
import com.refinedmods.refinedstorage.api.network.NetworkType;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.Network;
|
||||
import com.refinedmods.refinedstorage.container.ControllerContainerMenu;
|
||||
import com.refinedmods.refinedstorage.blockentity.ControllerBlockEntity;
|
||||
import com.refinedmods.refinedstorage.container.ControllerContainerMenu;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
@@ -106,12 +105,12 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new MenuProvider() {
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent("gui.refinedstorage." + (ControllerBlock.this.getType() == NetworkType.CREATIVE ? "creative_" : "") + "controller");
|
||||
return Component.translatable("gui.refinedstorage." + (ControllerBlock.this.getType() == NetworkType.CREATIVE ? "creative_" : "") + "controller");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CrafterBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<CrafterBlockEntity>(
|
||||
((CrafterBlockEntity) level.getBlockEntity(pos)).getNode().getName(),
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CrafterManagerBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new CrafterManagerMenuProvider((CrafterManagerBlockEntity) level.getBlockEntity(pos)),
|
||||
buf -> CrafterManagerMenuProvider.writeToBuffer(buf, level, pos)
|
||||
|
||||
@@ -44,9 +44,9 @@ public class CraftingMonitorBlock extends ColoredNetworkBlock {
|
||||
if (!level.isClientSide) {
|
||||
CraftingMonitorBlockEntity blockEntity = (CraftingMonitorBlockEntity) level.getBlockEntity(pos);
|
||||
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new CraftingMonitorMenuProvider(RSContainerMenus.CRAFTING_MONITOR, blockEntity.getNode(), blockEntity),
|
||||
new CraftingMonitorMenuProvider(RSContainerMenus.CRAFTING_MONITOR.get(), blockEntity.getNode(), blockEntity),
|
||||
pos
|
||||
), Permission.MODIFY, Permission.AUTOCRAFTING);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -92,10 +93,10 @@ public class DestructorBlock extends CableBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<DestructorBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.destructor"),
|
||||
Component.translatable("gui.refinedstorage.destructor"),
|
||||
(blockEntity, windowId, inventory, p) -> new DestructorContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -9,7 +9,8 @@ import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -78,10 +79,10 @@ public class DetectorBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<DetectorBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.detector"),
|
||||
Component.translatable("gui.refinedstorage.detector"),
|
||||
(blockEntity, windowId, inventory, p) -> new DetectorContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -6,7 +6,8 @@ import com.refinedmods.refinedstorage.blockentity.DiskDriveBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -36,10 +37,10 @@ public class DiskDriveBlock extends NetworkNodeBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<DiskDriveBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.disk_drive"),
|
||||
Component.translatable("gui.refinedstorage.disk_drive"),
|
||||
(blockEntity, windowId, inventory, p) -> new DiskDriveContainerMenu(blockEntity, p, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -7,7 +7,8 @@ import com.refinedmods.refinedstorage.blockentity.DiskManipulatorBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -37,10 +38,10 @@ public class DiskManipulatorBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<DiskManipulatorBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.disk_manipulator"),
|
||||
Component.translatable("gui.refinedstorage.disk_manipulator"),
|
||||
(blockEntity, windowId, inventory, p) -> new DiskManipulatorContainerMenu(blockEntity, p, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -116,10 +117,10 @@ public class ExporterBlock extends CableBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<ExporterBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.exporter"),
|
||||
Component.translatable("gui.refinedstorage.exporter"),
|
||||
(blockEntity, windowId, inventory, p) -> new ExporterContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -13,7 +13,8 @@ import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -96,10 +97,10 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<ExternalStorageBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.external_storage"),
|
||||
Component.translatable("gui.refinedstorage.external_storage"),
|
||||
(blockEntity, windowId, inventory, p) -> new ExternalStorageContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -7,7 +7,8 @@ import com.refinedmods.refinedstorage.blockentity.FluidInterfaceBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -32,10 +33,10 @@ public class FluidInterfaceBlock extends NetworkNodeBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<FluidInterfaceBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.fluid_interface"),
|
||||
Component.translatable("gui.refinedstorage.fluid_interface"),
|
||||
(blockEntity, windowId, inventory, p) -> new FluidInterfaceContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -58,7 +58,7 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new BlockEntityMenuProvider<FluidStorageBlockEntity>(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen((ServerPlayer) player, new BlockEntityMenuProvider<FluidStorageBlockEntity>(
|
||||
((FluidStorageBlockEntity) level.getBlockEntity(pos)).getNode().getTitle(),
|
||||
(blockEntity, windowId, inventory, p) -> new FluidStorageContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -115,10 +116,10 @@ public class ImporterBlock extends CableBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<ImporterBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.importer"),
|
||||
Component.translatable("gui.refinedstorage.importer"),
|
||||
(blockEntity, windowId, inventory, p) -> new ImporterContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -7,7 +7,8 @@ import com.refinedmods.refinedstorage.blockentity.InterfaceBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -32,10 +33,10 @@ public class InterfaceBlock extends NetworkNodeBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<InterfaceBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.interface"),
|
||||
Component.translatable("gui.refinedstorage.interface"),
|
||||
(blockEntity, windowId, inventory, p) -> new InterfaceContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.refinedmods.refinedstorage.block;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkTransmitterBlockEntity;
|
||||
import com.refinedmods.refinedstorage.container.NetworkTransmitterContainerMenu;
|
||||
import com.refinedmods.refinedstorage.container.factory.BlockEntityMenuProvider;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkTransmitterBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -37,10 +37,10 @@ public class NetworkTransmitterBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<NetworkTransmitterBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.network_transmitter"),
|
||||
Component.translatable("gui.refinedstorage.network_transmitter"),
|
||||
(blockEntity, windowId, inventory, p) -> new NetworkTransmitterContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -7,7 +7,8 @@ import com.refinedmods.refinedstorage.blockentity.RelayBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -37,10 +38,10 @@ public class RelayBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<RelayBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.relay"),
|
||||
Component.translatable("gui.refinedstorage.relay"),
|
||||
(blockEntity, windowId, inventory, p) -> new RelayContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -8,7 +8,8 @@ import com.refinedmods.refinedstorage.blockentity.SecurityManagerBlockEntity;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -38,10 +39,10 @@ public class SecurityManagerBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
Runnable action = () -> NetworkHooks.openGui(
|
||||
Runnable action = () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<SecurityManagerBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.security_manager"),
|
||||
Component.translatable("gui.refinedstorage.security_manager"),
|
||||
(blockEntity, windowId, inventory, p) -> new SecurityManagerContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -60,7 +60,7 @@ public class StorageBlock extends NetworkNodeBlock {
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new BlockEntityMenuProvider<StorageBlockEntity>(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen((ServerPlayer) player, new BlockEntityMenuProvider<StorageBlockEntity>(
|
||||
((StorageBlockEntity) level.getBlockEntity(pos)).getNode().getTitle(),
|
||||
(blockEntity, windowId, inventory, p) -> new StorageContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
|
||||
@@ -8,7 +8,8 @@ import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -43,10 +44,10 @@ public class StorageMonitorBlock extends NetworkNodeBlock {
|
||||
ItemStack held = player.getItemInHand(handIn);
|
||||
|
||||
if (player.isCrouching()) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<StorageMonitorBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.storage_monitor"),
|
||||
Component.translatable("gui.refinedstorage.storage_monitor"),
|
||||
(blockEntity, windowId, inventory, p) -> new StorageMonitorContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -7,7 +7,8 @@ import com.refinedmods.refinedstorage.blockentity.WirelessTransmitterBlockEntity
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -79,10 +80,10 @@ public class WirelessTransmitterBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openScreen(
|
||||
(ServerPlayer) player,
|
||||
new BlockEntityMenuProvider<WirelessTransmitterBlockEntity>(
|
||||
new TranslatableComponent("gui.refinedstorage.wireless_transmitter"),
|
||||
Component.translatable("gui.refinedstorage.wireless_transmitter"),
|
||||
(blockEntity, windowId, inventory, p) -> new WirelessTransmitterContainerMenu(blockEntity, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
@@ -10,12 +11,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public abstract class BaseBlockEntity extends BlockEntity {
|
||||
protected final BlockEntitySynchronizationManager dataManager = new BlockEntitySynchronizationManager(this);
|
||||
|
||||
private final BlockEntitySynchronizationManager dataManager;
|
||||
private boolean unloaded;
|
||||
|
||||
public BaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
protected BaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, BlockEntitySynchronizationSpec syncSpec) {
|
||||
super(type, pos, state);
|
||||
this.dataManager = new BlockEntitySynchronizationManager(this, syncSpec);
|
||||
}
|
||||
|
||||
public BlockEntitySynchronizationManager getDataManager() {
|
||||
|
||||
@@ -4,14 +4,14 @@ import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.CableNetworkNode;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -19,9 +19,13 @@ public class CableBlockEntity extends NetworkNodeBlockEntity<CableNetworkNode> {
|
||||
public static final BlockEntitySynchronizationParameter<CompoundTag, CableBlockEntity> COVER_MANAGER = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.COMPOUND_TAG, new CompoundTag(), t -> t.getNode().getCoverManager().writeToNbt(), (t, v) -> t.getNode().getCoverManager().readFromNbt(v), (initial, p) -> {
|
||||
});
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
public CableBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CABLE, pos, state);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
super(RSBlockEntities.CABLE.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,8 +36,8 @@ public class CableBlockEntity extends NetworkNodeBlockEntity<CableNetworkNode> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,14 +6,14 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -31,13 +31,16 @@ public class ConstructorBlockEntity extends NetworkNodeBlockEntity<ConstructorNe
|
||||
(initial, p) -> {
|
||||
});
|
||||
|
||||
public ConstructorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CONSTRUCTOR, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(DROP)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(DROP);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
public ConstructorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CONSTRUCTOR.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,8 +51,8 @@ public class ConstructorBlockEntity extends NetworkNodeBlockEntity<ConstructorNe
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.RootNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IRedstoneConfigurable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.RedstoneMode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -37,6 +38,14 @@ public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNo
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ControllerBlockEntity> ENERGY_CAPACITY = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNetwork().getEnergyStorage().getMaxEnergyStored());
|
||||
public static final BlockEntitySynchronizationParameter<List<ClientNode>, ControllerBlockEntity> NODES = new BlockEntitySynchronizationParameter<>(RSSerializers.CLIENT_NODE_SERIALIZER, new ArrayList<>(), ControllerBlockEntity::collectClientNodes);
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(ENERGY_USAGE)
|
||||
.addWatchedParameter(ENERGY_STORED)
|
||||
.addParameter(ENERGY_CAPACITY)
|
||||
.addParameter(NODES)
|
||||
.build();
|
||||
|
||||
private final LazyOptional<INetworkNodeProxy<RootNetworkNode>> networkNodeProxyCap = LazyOptional.of(() -> this);
|
||||
private final NetworkType type;
|
||||
private INetwork removedNetwork;
|
||||
@@ -44,14 +53,7 @@ public class ControllerBlockEntity extends BaseBlockEntity implements INetworkNo
|
||||
private final LazyOptional<IEnergyStorage> energyProxyCap = LazyOptional.of(() -> getNetwork().getEnergyStorage());
|
||||
|
||||
public ControllerBlockEntity(NetworkType type, BlockPos pos, BlockState state) {
|
||||
super(type == NetworkType.CREATIVE ? RSBlockEntities.CREATIVE_CONTROLLER : RSBlockEntities.CONTROLLER, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||
dataManager.addWatchedParameter(ENERGY_USAGE);
|
||||
dataManager.addWatchedParameter(ENERGY_STORED);
|
||||
dataManager.addParameter(ENERGY_CAPACITY);
|
||||
dataManager.addParameter(NODES);
|
||||
|
||||
super(type == NetworkType.CREATIVE ? RSBlockEntities.CREATIVE_CONTROLLER.get() : RSBlockEntities.CONTROLLER.get(), pos, state, SPEC);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.CrafterNetworkNode;
|
||||
import com.refinedmods.refinedstorage.screen.CrafterBlockEntitySynchronizationClientListener;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.screen.CrafterBlockEntitySynchronizationClientListener;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -21,13 +22,16 @@ public class CrafterBlockEntity extends NetworkNodeBlockEntity<CrafterNetworkNod
|
||||
public static final BlockEntitySynchronizationParameter<Integer, CrafterBlockEntity> MODE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, CrafterNetworkNode.CrafterMode.IGNORE.ordinal(), t -> t.getNode().getMode().ordinal(), (t, v) -> t.getNode().setMode(CrafterNetworkNode.CrafterMode.getById(v)));
|
||||
private static final BlockEntitySynchronizationParameter<Boolean, CrafterBlockEntity> HAS_ROOT = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.BOOLEAN, false, t -> t.getNode().getRootContainerNotSelf().isPresent(), null, (t, v) -> new CrafterBlockEntitySynchronizationClientListener().onChanged(t, v));
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(MODE)
|
||||
.addParameter(HAS_ROOT)
|
||||
.build();
|
||||
|
||||
private final LazyOptional<IItemHandler> patternsCapability = LazyOptional.of(() -> getNode().getPatternInventory());
|
||||
|
||||
public CrafterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CRAFTER, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(MODE);
|
||||
dataManager.addParameter(HAS_ROOT);
|
||||
super(RSBlockEntities.CRAFTER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,38 +3,41 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.CrafterManagerNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.CrafterManagerScreen;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class CrafterManagerBlockEntity extends NetworkNodeBlockEntity<CrafterManagerNetworkNode> {
|
||||
public CrafterManagerBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CRAFTER_MANAGER, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(SIZE);
|
||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||
} public static final BlockEntitySynchronizationParameter<Integer, CrafterManagerBlockEntity> SIZE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, IGrid.SIZE_STRETCH, t -> t.getNode().getSize(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, CrafterManagerBlockEntity> SEARCH_BOX_MODE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(CrafterManagerScreen.class, crafterManager -> crafterManager.getSearchField().setMode(p)));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, CrafterManagerBlockEntity> SIZE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, IGrid.SIZE_STRETCH, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(CrafterManagerScreen.class, BaseScreen::init));
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(SIZE)
|
||||
.addWatchedParameter(SEARCH_BOX_MODE)
|
||||
.build();
|
||||
|
||||
public CrafterManagerBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CRAFTER_MANAGER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrafterManagerNetworkNode createNode(Level level, BlockPos pos) {
|
||||
return new CrafterManagerNetworkNode(level, pos);
|
||||
} public static final BlockEntitySynchronizationParameter<Integer, CrafterManagerBlockEntity> SEARCH_BOX_MODE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(CrafterManagerScreen.class, crafterManager -> crafterManager.getSearchField().setMode(p)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -33,14 +33,17 @@ public class DestructorBlockEntity extends NetworkNodeBlockEntity<DestructorNetw
|
||||
(initial, p) -> {
|
||||
});
|
||||
|
||||
public DestructorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.DESTRUCTOR, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(PICKUP)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(PICKUP);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
public DestructorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.DESTRUCTOR.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,8 +54,8 @@ public class DestructorBlockEntity extends NetworkNodeBlockEntity<DestructorNetw
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.DetectorNetworkNode;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.DetectorScreen;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.DetectorScreen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -29,15 +30,18 @@ public class DetectorBlockEntity extends NetworkNodeBlockEntity<DetectorNetworkN
|
||||
t.getNode().markDirty();
|
||||
}, (initial, value) -> BaseScreen.executeLater(DetectorScreen.class, detectorScreen -> detectorScreen.updateAmountField(value)));
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(MODE)
|
||||
.addWatchedParameter(AMOUNT)
|
||||
.build();
|
||||
|
||||
private static final String NBT_POWERED = "Powered";
|
||||
|
||||
public DetectorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.DETECTOR, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(MODE);
|
||||
dataManager.addWatchedParameter(AMOUNT);
|
||||
super(RSBlockEntities.DETECTOR.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,8 +6,9 @@ import com.refinedmods.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.DiskState;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.*;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -17,8 +18,7 @@ import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -77,9 +77,19 @@ public class DiskDriveBlockEntity extends NetworkNodeBlockEntity<DiskDriveNetwor
|
||||
|
||||
return capacity;
|
||||
});
|
||||
|
||||
public static final ModelProperty<DiskState[]> DISK_STATE_PROPERTY = new ModelProperty<>();
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(PRIORITY)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(ACCESS_TYPE)
|
||||
.addWatchedParameter(STORED)
|
||||
.addWatchedParameter(CAPACITY)
|
||||
.build();
|
||||
|
||||
private static final String NBT_DISK_STATE = "DiskStates";
|
||||
|
||||
private final LazyOptional<IItemHandler> diskCapability = LazyOptional.of(() -> getNode().getDisks());
|
||||
@@ -87,16 +97,7 @@ public class DiskDriveBlockEntity extends NetworkNodeBlockEntity<DiskDriveNetwor
|
||||
private final DiskState[] diskState = new DiskState[8];
|
||||
|
||||
public DiskDriveBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.DISK_DRIVE, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(PRIORITY);
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(ACCESS_TYPE);
|
||||
dataManager.addWatchedParameter(STORED);
|
||||
dataManager.addWatchedParameter(CAPACITY);
|
||||
|
||||
super(RSBlockEntities.DISK_DRIVE.get(), pos, state, SPEC);
|
||||
Arrays.fill(diskState, DiskState.NONE);
|
||||
}
|
||||
|
||||
@@ -132,8 +133,8 @@ public class DiskDriveBlockEntity extends NetworkNodeBlockEntity<DiskDriveNetwor
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(DISK_STATE_PROPERTY, diskState).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(DISK_STATE_PROPERTY, diskState).build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -17,8 +18,7 @@ import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -40,6 +40,14 @@ public class DiskManipulatorBlockEntity extends NetworkNodeBlockEntity<DiskManip
|
||||
|
||||
public static final ModelProperty<DiskState[]> DISK_STATE_PROPERTY = new ModelProperty<>();
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(IO_MODE)
|
||||
.build();
|
||||
|
||||
private static final String NBT_DISK_STATE = "DiskStates";
|
||||
|
||||
private final LazyOptional<IItemHandler> diskCapability = LazyOptional.of(() -> getNode().getDisks());
|
||||
@@ -47,13 +55,7 @@ public class DiskManipulatorBlockEntity extends NetworkNodeBlockEntity<DiskManip
|
||||
private final DiskState[] diskState = new DiskState[6];
|
||||
|
||||
public DiskManipulatorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.DISK_MANIPULATOR, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(IO_MODE);
|
||||
|
||||
super(RSBlockEntities.DISK_MANIPULATOR.get(), pos, state, SPEC);
|
||||
Arrays.fill(diskState, DiskState.NONE);
|
||||
}
|
||||
|
||||
@@ -89,8 +91,8 @@ public class DiskManipulatorBlockEntity extends NetworkNodeBlockEntity<DiskManip
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(DISK_STATE_PROPERTY, diskState).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(DISK_STATE_PROPERTY, diskState).build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -6,14 +6,14 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -28,12 +28,15 @@ public class ExporterBlockEntity extends NetworkNodeBlockEntity<ExporterNetworkN
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ExporterBlockEntity> COMPARE = IComparable.createParameter();
|
||||
public static final BlockEntitySynchronizationParameter<Integer, ExporterBlockEntity> TYPE = IType.createParameter();
|
||||
|
||||
public ExporterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.EXPORTER, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
public ExporterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.EXPORTER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +47,8 @@ public class ExporterBlockEntity extends NetworkNodeBlockEntity<ExporterNetworkN
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,8 +6,9 @@ import com.refinedmods.refinedstorage.api.storage.externalstorage.IExternalStora
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.ExternalStorageNetworkNode;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.*;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -15,8 +16,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -57,17 +57,20 @@ public class ExternalStorageBlockEntity extends NetworkNodeBlockEntity<ExternalS
|
||||
public static final BlockEntitySynchronizationParameter<CompoundTag, ExternalStorageBlockEntity> COVER_MANAGER = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.COMPOUND_TAG, new CompoundTag(), t -> t.getNode().getCoverManager().writeToNbt(), (t, v) -> t.getNode().getCoverManager().readFromNbt(v), (initial, p) -> {
|
||||
});
|
||||
|
||||
public ExternalStorageBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.EXTERNAL_STORAGE, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(PRIORITY)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(STORED)
|
||||
.addWatchedParameter(CAPACITY)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(ACCESS_TYPE)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(PRIORITY);
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(STORED);
|
||||
dataManager.addWatchedParameter(CAPACITY);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(ACCESS_TYPE);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
public ExternalStorageBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.EXTERNAL_STORAGE.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,8 +81,8 @@ public class ExternalStorageBlockEntity extends NetworkNodeBlockEntity<ExternalS
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.FluidInterfaceNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -23,14 +24,17 @@ public class FluidInterfaceBlockEntity extends NetworkNodeBlockEntity<FluidInter
|
||||
public static final BlockEntitySynchronizationParameter<FluidStack, FluidInterfaceBlockEntity> TANK_IN = new BlockEntitySynchronizationParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, FluidStack.EMPTY, t -> t.getNode().getTankIn().getFluid());
|
||||
public static final BlockEntitySynchronizationParameter<FluidStack, FluidInterfaceBlockEntity> TANK_OUT = new BlockEntitySynchronizationParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, FluidStack.EMPTY, t -> t.getNode().getTankOut().getFluid());
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addParameter(TANK_IN)
|
||||
.addParameter(TANK_OUT)
|
||||
.build();
|
||||
|
||||
private final LazyOptional<IFluidHandler> tankCapability = LazyOptional.of(() -> getNode().getTank());
|
||||
private final LazyOptional<IItemHandler> inCapability = LazyOptional.of(() -> getNode().getIn());
|
||||
|
||||
public FluidInterfaceBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.FLUID_INTERFACE, pos, state);
|
||||
|
||||
dataManager.addParameter(TANK_IN);
|
||||
dataManager.addParameter(TANK_OUT);
|
||||
super(RSBlockEntities.FLUID_INTERFACE.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -8,8 +8,9 @@ import com.refinedmods.refinedstorage.blockentity.config.IAccessType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IPrioritizable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
@@ -24,35 +25,30 @@ public class FluidStorageBlockEntity extends NetworkNodeBlockEntity<FluidStorage
|
||||
public static final BlockEntitySynchronizationParameter<AccessType, FluidStorageBlockEntity> ACCESS_TYPE = IAccessType.createParameter();
|
||||
public static final BlockEntitySynchronizationParameter<Long, FluidStorageBlockEntity> STORED = new BlockEntitySynchronizationParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(PRIORITY)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(STORED)
|
||||
.addWatchedParameter(ACCESS_TYPE)
|
||||
.build();
|
||||
|
||||
private final FluidStorageType type;
|
||||
|
||||
public FluidStorageBlockEntity(FluidStorageType type, BlockPos pos, BlockState state) {
|
||||
super(getType(type), pos, state);
|
||||
|
||||
super(getType(type), pos, state, SPEC);
|
||||
this.type = type;
|
||||
|
||||
dataManager.addWatchedParameter(PRIORITY);
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(STORED);
|
||||
dataManager.addWatchedParameter(ACCESS_TYPE);
|
||||
}
|
||||
|
||||
public static BlockEntityType<FluidStorageBlockEntity> getType(FluidStorageType type) {
|
||||
switch (type) {
|
||||
case SIXTY_FOUR_K:
|
||||
return RSBlockEntities.SIXTY_FOUR_K_FLUID_STORAGE_BLOCK;
|
||||
case TWO_HUNDRED_FIFTY_SIX_K:
|
||||
return RSBlockEntities.TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK;
|
||||
case THOUSAND_TWENTY_FOUR_K:
|
||||
return RSBlockEntities.THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK;
|
||||
case FOUR_THOUSAND_NINETY_SIX_K:
|
||||
return RSBlockEntities.FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK;
|
||||
case CREATIVE:
|
||||
return RSBlockEntities.CREATIVE_FLUID_STORAGE_BLOCK;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown storage type " + type);
|
||||
}
|
||||
return switch (type) {
|
||||
case SIXTY_FOUR_K -> RSBlockEntities.SIXTY_FOUR_K_FLUID_STORAGE_BLOCK.get();
|
||||
case TWO_HUNDRED_FIFTY_SIX_K -> RSBlockEntities.TWO_HUNDRED_FIFTY_SIX_K_FLUID_STORAGE_BLOCK.get();
|
||||
case THOUSAND_TWENTY_FOUR_K -> RSBlockEntities.THOUSAND_TWENTY_FOUR_K_FLUID_STORAGE_BLOCK.get();
|
||||
case FOUR_THOUSAND_NINETY_SIX_K -> RSBlockEntities.FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK.get();
|
||||
case CREATIVE -> RSBlockEntities.CREATIVE_FLUID_STORAGE_BLOCK.get();
|
||||
};
|
||||
}
|
||||
|
||||
public FluidStorageType getFluidStorageType() {
|
||||
|
||||
@@ -7,14 +7,14 @@ import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -25,13 +25,16 @@ public class ImporterBlockEntity extends NetworkNodeBlockEntity<ImporterNetworkN
|
||||
public static final BlockEntitySynchronizationParameter<CompoundTag, ImporterBlockEntity> COVER_MANAGER = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.COMPOUND_TAG, new CompoundTag(), t -> t.getNode().getCoverManager().writeToNbt(), (t, v) -> t.getNode().getCoverManager().readFromNbt(v), (initial, p) -> {
|
||||
});
|
||||
|
||||
public ImporterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.IMPORTER, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(TYPE)
|
||||
.addWatchedParameter(COVER_MANAGER)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
dataManager.addWatchedParameter(COVER_MANAGER);
|
||||
public ImporterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.IMPORTER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,8 +45,8 @@ public class ImporterBlockEntity extends NetworkNodeBlockEntity<ImporterNetworkN
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder().withInitial(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
public ModelData getModelData() {
|
||||
return ModelData.builder().with(CoverManager.PROPERTY, this.getNode().getCoverManager()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.InterfaceNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -19,12 +20,15 @@ import javax.annotation.Nullable;
|
||||
public class InterfaceBlockEntity extends NetworkNodeBlockEntity<InterfaceNetworkNode> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, InterfaceBlockEntity> COMPARE = IComparable.createParameter();
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.build();
|
||||
|
||||
private final LazyOptional<IItemHandler> itemsCapability = LazyOptional.of(() -> getNode().getItems());
|
||||
|
||||
public InterfaceBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.INTERFACE, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
super(RSBlockEntities.INTERFACE.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IRedstoneConfigurable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.RedstoneMode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -26,16 +27,15 @@ import javax.annotation.Nullable;
|
||||
|
||||
public abstract class NetworkNodeBlockEntity<N extends NetworkNode> extends BaseBlockEntity implements INetworkNodeProxy<N>, IRedstoneConfigurable {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, NetworkNodeBlockEntity> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
|
||||
private final LazyOptional<INetworkNodeProxy<N>> networkNodeProxy = LazyOptional.of(() -> this);
|
||||
private N clientNode;
|
||||
private N removedNode;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
protected NetworkNodeBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||
protected NetworkNodeBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, BlockEntitySynchronizationSpec syncSpec) {
|
||||
super(type, pos, state, syncSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkReceiverNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -9,8 +10,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class NetworkReceiverBlockEntity extends NetworkNodeBlockEntity<NetworkReceiverNetworkNode> {
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.build();
|
||||
|
||||
public NetworkReceiverBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.NETWORK_RECEIVER, pos, state);
|
||||
super(RSBlockEntities.NETWORK_RECEIVER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkTransmitterNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -29,13 +30,16 @@ public class NetworkTransmitterBlockEntity extends NetworkNodeBlockEntity<Networ
|
||||
return Optional.empty();
|
||||
});
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(DISTANCE)
|
||||
.addWatchedParameter(RECEIVER_DIMENSION)
|
||||
.build();
|
||||
|
||||
private final LazyOptional<IItemHandler> networkCardCapability = LazyOptional.of(() -> getNode().getNetworkCard());
|
||||
|
||||
public NetworkTransmitterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.NETWORK_TRANSMITTER, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(DISTANCE);
|
||||
dataManager.addWatchedParameter(RECEIVER_DIMENSION);
|
||||
super(RSBlockEntities.NETWORK_TRANSMITTER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.RelayNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -9,8 +10,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RelayBlockEntity extends NetworkNodeBlockEntity<RelayNetworkNode> {
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.build();
|
||||
|
||||
public RelayBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.RELAY, pos, state);
|
||||
super(RSBlockEntities.RELAY.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.SecurityManagerNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -9,8 +10,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SecurityManagerBlockEntity extends NetworkNodeBlockEntity<SecurityManagerNetworkNode> {
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.build();
|
||||
|
||||
public SecurityManagerBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.SECURITY_MANAGER, pos, state);
|
||||
super(RSBlockEntities.SECURITY_MANAGER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,9 @@ import com.refinedmods.refinedstorage.blockentity.config.IAccessType;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IPrioritizable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IWhitelistBlacklist;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
@@ -24,35 +25,30 @@ public class StorageBlockEntity extends NetworkNodeBlockEntity<StorageNetworkNod
|
||||
public static final BlockEntitySynchronizationParameter<AccessType, StorageBlockEntity> ACCESS_TYPE = IAccessType.createParameter();
|
||||
public static final BlockEntitySynchronizationParameter<Long, StorageBlockEntity> STORED = new BlockEntitySynchronizationParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(PRIORITY)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(WHITELIST_BLACKLIST)
|
||||
.addWatchedParameter(STORED)
|
||||
.addWatchedParameter(ACCESS_TYPE)
|
||||
.build();
|
||||
|
||||
private final ItemStorageType type;
|
||||
|
||||
public StorageBlockEntity(ItemStorageType type, BlockPos pos, BlockState state) {
|
||||
super(getType(type), pos, state);
|
||||
|
||||
super(getType(type), pos, state, SPEC);
|
||||
this.type = type;
|
||||
|
||||
dataManager.addWatchedParameter(PRIORITY);
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(WHITELIST_BLACKLIST);
|
||||
dataManager.addWatchedParameter(STORED);
|
||||
dataManager.addWatchedParameter(ACCESS_TYPE);
|
||||
}
|
||||
|
||||
public static BlockEntityType<StorageBlockEntity> getType(ItemStorageType type) {
|
||||
switch (type) {
|
||||
case ONE_K:
|
||||
return RSBlockEntities.ONE_K_STORAGE_BLOCK;
|
||||
case FOUR_K:
|
||||
return RSBlockEntities.FOUR_K_STORAGE_BLOCK;
|
||||
case SIXTEEN_K:
|
||||
return RSBlockEntities.SIXTEEN_K_STORAGE_BLOCK;
|
||||
case SIXTY_FOUR_K:
|
||||
return RSBlockEntities.SIXTY_FOUR_K_STORAGE_BLOCK;
|
||||
case CREATIVE:
|
||||
return RSBlockEntities.CREATIVE_STORAGE_BLOCK;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown storage type " + type);
|
||||
}
|
||||
return switch (type) {
|
||||
case ONE_K -> RSBlockEntities.ONE_K_STORAGE_BLOCK.get();
|
||||
case FOUR_K -> RSBlockEntities.FOUR_K_STORAGE_BLOCK.get();
|
||||
case SIXTEEN_K -> RSBlockEntities.SIXTEEN_K_STORAGE_BLOCK.get();
|
||||
case SIXTY_FOUR_K -> RSBlockEntities.SIXTY_FOUR_K_STORAGE_BLOCK.get();
|
||||
case CREATIVE -> RSBlockEntities.CREATIVE_STORAGE_BLOCK.get();
|
||||
};
|
||||
}
|
||||
|
||||
public ItemStorageType getItemStorageType() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.StorageMonitorNetwork
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IComparable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -23,6 +24,12 @@ public class StorageMonitorBlockEntity extends NetworkNodeBlockEntity<StorageMon
|
||||
private static final String NBT_STACK = "Stack";
|
||||
private static final String NBT_AMOUNT = "Amount";
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(COMPARE)
|
||||
.addWatchedParameter(TYPE)
|
||||
.build();
|
||||
|
||||
private int type;
|
||||
private int amount;
|
||||
@Nullable
|
||||
@@ -31,10 +38,7 @@ public class StorageMonitorBlockEntity extends NetworkNodeBlockEntity<StorageMon
|
||||
private FluidStack fluidStack = FluidStack.EMPTY;
|
||||
|
||||
public StorageMonitorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.STORAGE_MONITOR, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(TYPE);
|
||||
super(RSBlockEntities.STORAGE_MONITOR.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.blockentity;
|
||||
import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.WirelessTransmitterNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -13,10 +14,13 @@ import javax.annotation.Nonnull;
|
||||
public class WirelessTransmitterBlockEntity extends NetworkNodeBlockEntity<WirelessTransmitterNetworkNode> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, WirelessTransmitterBlockEntity> RANGE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getRange());
|
||||
|
||||
public WirelessTransmitterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.WIRELESS_TRANSMITTER, pos, state);
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(RANGE)
|
||||
.build();
|
||||
|
||||
dataManager.addWatchedParameter(RANGE);
|
||||
public WirelessTransmitterBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.WIRELESS_TRANSMITTER.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.CraftingMonitorNetworkNode;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkNodeBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -14,12 +15,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CraftingMonitorBlockEntity extends NetworkNodeBlockEntity<CraftingMonitorNetworkNode> {
|
||||
public CraftingMonitorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CRAFTING_MONITOR, pos, state);
|
||||
|
||||
dataManager.addWatchedParameter(TAB_SELECTED);
|
||||
dataManager.addWatchedParameter(TAB_PAGE);
|
||||
} public static final BlockEntitySynchronizationParameter<Optional<UUID>, CraftingMonitorBlockEntity> TAB_SELECTED = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.OPTIONAL_UUID, Optional.empty(), t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<Optional<UUID>, CraftingMonitorBlockEntity> TAB_SELECTED = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.OPTIONAL_UUID, Optional.empty(), t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||
if (v.isPresent() && t.getNode().getTabSelected().isPresent() && v.get().equals(t.getNode().getTabSelected().get())) {
|
||||
t.getNode().setTabSelected(Optional.empty());
|
||||
} else {
|
||||
@@ -29,18 +25,26 @@ public class CraftingMonitorBlockEntity extends NetworkNodeBlockEntity<CraftingM
|
||||
t.getNode().markDirty();
|
||||
});
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public CraftingMonitorNetworkNode createNode(Level level, BlockPos pos) {
|
||||
return new CraftingMonitorNetworkNode(level, pos);
|
||||
} public static final BlockEntitySynchronizationParameter<Integer, CraftingMonitorBlockEntity> TAB_PAGE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getTabPage(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, CraftingMonitorBlockEntity> TAB_PAGE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getTabPage(), (t, v) -> {
|
||||
if (v >= 0) {
|
||||
t.getNode().setTabPage(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
});
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(TAB_SELECTED)
|
||||
.addWatchedParameter(TAB_PAGE)
|
||||
.build();
|
||||
|
||||
public CraftingMonitorBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(RSBlockEntities.CRAFTING_MONITOR.get(), pos, state, SPEC);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public CraftingMonitorNetworkNode createNode(Level level, BlockPos pos) {
|
||||
return new CraftingMonitorNetworkNode(level, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizatio
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -57,7 +57,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.wireless_crafting_monitor");
|
||||
return Component.translatable("gui.refinedstorage.wireless_crafting_monitor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.refinedmods.refinedstorage.RS;
|
||||
import com.refinedmods.refinedstorage.network.sync.BlockEntitySynchronizationParamaterUpdateMessage;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,49 +12,26 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class BlockEntitySynchronizationManager {
|
||||
private static final Map<Integer, BlockEntitySynchronizationParameter> REGISTRY = new HashMap<>();
|
||||
private static int lastId = 0;
|
||||
|
||||
private final BlockEntity blockEntity;
|
||||
|
||||
private final List<BlockEntitySynchronizationParameter> parameters = new ArrayList<>();
|
||||
private final List<BlockEntitySynchronizationParameter> watchedParameters = new ArrayList<>();
|
||||
|
||||
private final List<BlockEntitySynchronizationParameter> parameters;
|
||||
private final List<BlockEntitySynchronizationParameter> watchedParameters;
|
||||
private final List<BlockEntitySynchronizationWatcher> watchers = new CopyOnWriteArrayList<>();
|
||||
|
||||
public BlockEntitySynchronizationManager(BlockEntity blockEntity) {
|
||||
public BlockEntitySynchronizationManager(BlockEntity blockEntity, BlockEntitySynchronizationSpec spec) {
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
public static void registerParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
parameter.setId(lastId);
|
||||
|
||||
REGISTRY.put(lastId++, parameter);
|
||||
}
|
||||
|
||||
public static BlockEntitySynchronizationParameter getParameter(int id) {
|
||||
return REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static void setParameter(BlockEntitySynchronizationParameter parameter, Object value) {
|
||||
RS.NETWORK_HANDLER.sendToServer(new BlockEntitySynchronizationParamaterUpdateMessage(parameter, value));
|
||||
this.parameters = spec.getParameters();
|
||||
this.watchedParameters = spec.getWatchedParameters();
|
||||
}
|
||||
|
||||
public BlockEntity getBlockEntity() {
|
||||
return blockEntity;
|
||||
}
|
||||
|
||||
public void addParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
parameters.add(parameter);
|
||||
}
|
||||
|
||||
public List<BlockEntitySynchronizationParameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void addWatchedParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
addParameter(parameter);
|
||||
|
||||
watchedParameters.add(parameter);
|
||||
}
|
||||
|
||||
public List<BlockEntitySynchronizationParameter> getWatchedParameters() {
|
||||
return watchedParameters;
|
||||
}
|
||||
@@ -71,4 +47,19 @@ public class BlockEntitySynchronizationManager {
|
||||
public void sendParameterToWatchers(BlockEntitySynchronizationParameter parameter) {
|
||||
watchers.forEach(l -> l.sendParameter(false, parameter));
|
||||
}
|
||||
|
||||
// Synchronized so we don't conflict with addons that reuse this register method in parallel.
|
||||
public synchronized static void registerParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
parameter.setId(lastId);
|
||||
|
||||
REGISTRY.put(lastId++, parameter);
|
||||
}
|
||||
|
||||
public static BlockEntitySynchronizationParameter getParameter(int id) {
|
||||
return REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static void setParameter(BlockEntitySynchronizationParameter parameter, Object value) {
|
||||
RS.NETWORK_HANDLER.sendToServer(new BlockEntitySynchronizationParamaterUpdateMessage(parameter, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.refinedmods.refinedstorage.blockentity.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class BlockEntitySynchronizationSpec {
|
||||
private final List<BlockEntitySynchronizationParameter> parameters;
|
||||
private final List<BlockEntitySynchronizationParameter> watchedParameters;
|
||||
|
||||
public BlockEntitySynchronizationSpec(List<BlockEntitySynchronizationParameter> parameters, List<BlockEntitySynchronizationParameter> watchedParameters) {
|
||||
this.parameters = Collections.unmodifiableList(parameters);
|
||||
this.watchedParameters = Collections.unmodifiableList(watchedParameters);
|
||||
}
|
||||
|
||||
public List<BlockEntitySynchronizationParameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public List<BlockEntitySynchronizationParameter> getWatchedParameters() {
|
||||
return watchedParameters;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final List<BlockEntitySynchronizationParameter> parameters = new ArrayList<>();
|
||||
private final List<BlockEntitySynchronizationParameter> watchedParameters = new ArrayList<>();
|
||||
|
||||
public Builder addParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
parameters.add(parameter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addWatchedParameter(BlockEntitySynchronizationParameter parameter) {
|
||||
addParameter(parameter);
|
||||
watchedParameters.add(parameter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockEntitySynchronizationSpec build() {
|
||||
return new BlockEntitySynchronizationSpec(parameters, watchedParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import com.refinedmods.refinedstorage.RSBlockEntities;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.GridType;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.blockentity.NetworkNodeBlockEntity;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.IType;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.RSSerializers;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -33,91 +34,27 @@ public class GridBlockEntity extends NetworkNodeBlockEntity<GridNetworkNode> {
|
||||
t.getNode().setExactPattern(v);
|
||||
t.getNode().markDirty();
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, grid -> grid.updateExactPattern(p)));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> PROCESSING_TYPE = IType.createParameter((initial, p) -> BaseScreen.executeLater(GridScreen.class, BaseScreen::init)); public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> VIEW_TYPE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getViewType(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> PROCESSING_TYPE = IType.createParameter((initial, p) -> BaseScreen.executeLater(GridScreen.class, BaseScreen::init));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> VIEW_TYPE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getViewType(), (t, v) -> {
|
||||
if (IGrid.isValidViewType(v)) {
|
||||
t.getNode().setViewType(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
public static final BlockEntitySynchronizationParameter<List<Set<ResourceLocation>>, GridBlockEntity> ALLOWED_ITEM_TAGS = new BlockEntitySynchronizationParameter<>(RSSerializers.LIST_OF_SET_SERIALIZER, new ArrayList<>(), t -> t.getNode().getAllowedTagList().getAllowedItemTags(), (t, v) -> t.getNode().getAllowedTagList().setAllowedItemTags(v));
|
||||
public static final BlockEntitySynchronizationParameter<List<Set<ResourceLocation>>, GridBlockEntity> ALLOWED_FLUID_TAGS = new BlockEntitySynchronizationParameter<>(RSSerializers.LIST_OF_SET_SERIALIZER, new ArrayList<>(), t -> t.getNode().getAllowedTagList().getAllowedFluidTags(), (t, v) -> t.getNode().getAllowedTagList().setAllowedFluidTags(v)); public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SORTING_DIRECTION = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSortingDirection(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<List<Set<ResourceLocation>>, GridBlockEntity> ALLOWED_FLUID_TAGS = new BlockEntitySynchronizationParameter<>(RSSerializers.LIST_OF_SET_SERIALIZER, new ArrayList<>(), t -> t.getNode().getAllowedTagList().getAllowedFluidTags(), (t, v) -> t.getNode().getAllowedTagList().setAllowedFluidTags(v));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SORTING_DIRECTION = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSortingDirection(), (t, v) -> {
|
||||
if (IGrid.isValidSortingDirection(v)) {
|
||||
t.getNode().setSortingDirection(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
private final GridType type;
|
||||
private final LazyOptional<IItemHandler> diskCapability = LazyOptional.of(() -> getNode().getPatterns()); public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SORTING_TYPE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSortingType(), (t, v) -> {
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SORTING_TYPE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSortingType(), (t, v) -> {
|
||||
if (IGrid.isValidSortingType(v)) {
|
||||
t.getNode().setSortingType(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
public GridBlockEntity(GridType type, BlockPos pos, BlockState state) {
|
||||
super(getType(type), pos, state);
|
||||
|
||||
this.type = type;
|
||||
|
||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||
dataManager.addWatchedParameter(SORTING_TYPE);
|
||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||
dataManager.addWatchedParameter(SIZE);
|
||||
dataManager.addWatchedParameter(TAB_SELECTED);
|
||||
dataManager.addWatchedParameter(TAB_PAGE);
|
||||
dataManager.addWatchedParameter(EXACT_PATTERN);
|
||||
dataManager.addWatchedParameter(PROCESSING_PATTERN);
|
||||
dataManager.addWatchedParameter(PROCESSING_TYPE);
|
||||
dataManager.addParameter(ALLOWED_ITEM_TAGS);
|
||||
dataManager.addParameter(ALLOWED_FLUID_TAGS);
|
||||
}
|
||||
|
||||
public static void trySortGrid(boolean initial) {
|
||||
if (!initial) {
|
||||
BaseScreen.executeLater(GridScreen.class, grid -> grid.getView().sort());
|
||||
}
|
||||
} public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SEARCH_BOX_MODE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, grid -> grid.getSearchField().setMode(p)));
|
||||
|
||||
public static BlockEntityType<GridBlockEntity> getType(GridType type) {
|
||||
switch (type) {
|
||||
case NORMAL:
|
||||
return RSBlockEntities.GRID;
|
||||
case CRAFTING:
|
||||
return RSBlockEntities.CRAFTING_GRID;
|
||||
case PATTERN:
|
||||
return RSBlockEntities.PATTERN_GRID;
|
||||
case FLUID:
|
||||
return RSBlockEntities.FLUID_GRID;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown grid type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public GridNetworkNode createNode(Level level, BlockPos pos) {
|
||||
return new GridNetworkNode(level, pos, type);
|
||||
} public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SIZE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, grid -> grid.resize(grid.getMinecraft(), grid.width, grid.height)));
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && type == GridType.PATTERN) {
|
||||
return diskCapability.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap, direction);
|
||||
}
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> TAB_SELECTED = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
||||
t.getNode().markDirty();
|
||||
@@ -133,15 +70,71 @@ public class GridBlockEntity extends NetworkNodeBlockEntity<GridNetworkNode> {
|
||||
t.getNode().clearMatrix();
|
||||
t.getNode().markDirty();
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, BaseScreen::init));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SIZE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, grid -> grid.resize(grid.getMinecraft(), grid.width, grid.height)));
|
||||
public static final BlockEntitySynchronizationParameter<Integer, GridBlockEntity> SEARCH_BOX_MODE = new BlockEntitySynchronizationParameter<>(EntityDataSerializers.INT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> BaseScreen.executeLater(GridScreen.class, grid -> grid.getSearchField().setMode(p)));
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(VIEW_TYPE)
|
||||
.addWatchedParameter(SORTING_DIRECTION)
|
||||
.addWatchedParameter(SORTING_TYPE)
|
||||
.addWatchedParameter(SEARCH_BOX_MODE)
|
||||
.addWatchedParameter(SIZE)
|
||||
.addWatchedParameter(TAB_SELECTED)
|
||||
.addWatchedParameter(TAB_PAGE)
|
||||
.addWatchedParameter(EXACT_PATTERN)
|
||||
.addWatchedParameter(PROCESSING_PATTERN)
|
||||
.addWatchedParameter(PROCESSING_TYPE)
|
||||
.addParameter(ALLOWED_ITEM_TAGS)
|
||||
.addParameter(ALLOWED_FLUID_TAGS)
|
||||
.build();
|
||||
|
||||
public static BlockEntityType<GridBlockEntity> getType(GridType type) {
|
||||
return switch (type) {
|
||||
case NORMAL -> RSBlockEntities.GRID.get();
|
||||
case CRAFTING -> RSBlockEntities.CRAFTING_GRID.get();
|
||||
case PATTERN -> RSBlockEntities.PATTERN_GRID.get();
|
||||
case FLUID -> RSBlockEntities.FLUID_GRID.get();
|
||||
};
|
||||
}
|
||||
|
||||
public static void trySortGrid(boolean initial) {
|
||||
if (!initial) {
|
||||
BaseScreen.executeLater(GridScreen.class, grid -> grid.getView().sort());
|
||||
}
|
||||
}
|
||||
|
||||
private final GridType type;
|
||||
private final LazyOptional<IItemHandler> diskCapability = LazyOptional.of(() -> getNode().getPatterns());
|
||||
|
||||
public GridBlockEntity(GridType type, BlockPos pos, BlockState state) {
|
||||
super(getType(type), pos, state, SPEC);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public GridNetworkNode createNode(Level level, BlockPos pos) {
|
||||
return new GridNetworkNode(level, pos, type);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && type == GridType.PATTERN) {
|
||||
return diskCapability.cast();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return super.getCapability(cap, direction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -138,7 +138,7 @@ public class WirelessFluidGrid implements INetworkAwareGrid {
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.fluid_grid");
|
||||
return Component.translatable("gui.refinedstorage.fluid_grid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -140,7 +140,7 @@ public class WirelessGrid implements INetworkAwareGrid {
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.grid");
|
||||
return Component.translatable("gui.refinedstorage.grid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -254,7 +254,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.portable_grid");
|
||||
return Component.translatable("gui.refinedstorage.portable_grid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.refinedmods.refinedstorage.blockentity.config.IRedstoneConfigurable;
|
||||
import com.refinedmods.refinedstorage.blockentity.config.RedstoneMode;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationManager;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationParameter;
|
||||
import com.refinedmods.refinedstorage.blockentity.data.BlockEntitySynchronizationSpec;
|
||||
import com.refinedmods.refinedstorage.blockentity.grid.GridBlockEntity;
|
||||
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
||||
import com.refinedmods.refinedstorage.inventory.item.FilterItemHandler;
|
||||
@@ -47,15 +48,14 @@ import com.refinedmods.refinedstorage.item.WirelessGridItem;
|
||||
import com.refinedmods.refinedstorage.item.blockitem.PortableGridBlockItem;
|
||||
import com.refinedmods.refinedstorage.screen.BaseScreen;
|
||||
import com.refinedmods.refinedstorage.screen.grid.GridScreen;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import com.refinedmods.refinedstorage.util.LevelUtils;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -128,6 +128,16 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
}
|
||||
});
|
||||
|
||||
public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder()
|
||||
.addWatchedParameter(REDSTONE_MODE)
|
||||
.addWatchedParameter(SORTING_DIRECTION)
|
||||
.addWatchedParameter(SORTING_TYPE)
|
||||
.addWatchedParameter(SEARCH_BOX_MODE)
|
||||
.addWatchedParameter(SIZE)
|
||||
.addWatchedParameter(TAB_SELECTED)
|
||||
.addWatchedParameter(TAB_PAGE)
|
||||
.build();
|
||||
|
||||
private final PortableGridBlockItem.Type type;
|
||||
private final List<IFilter> filters = new ArrayList<>();
|
||||
private final List<IGridTab> tabs = new ArrayList<>();
|
||||
@@ -158,17 +168,8 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
private boolean loadNextTick;
|
||||
|
||||
public PortableGridBlockEntity(PortableGridBlockItem.Type type, BlockPos pos, BlockState state) {
|
||||
super(type == PortableGridBlockItem.Type.CREATIVE ? RSBlockEntities.CREATIVE_PORTABLE_GRID : RSBlockEntities.PORTABLE_GRID, pos, state);
|
||||
|
||||
super(type == PortableGridBlockItem.Type.CREATIVE ? RSBlockEntities.CREATIVE_PORTABLE_GRID.get() : RSBlockEntities.PORTABLE_GRID.get(), pos, state, SPEC);
|
||||
this.type = type;
|
||||
|
||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||
dataManager.addWatchedParameter(SORTING_TYPE);
|
||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||
dataManager.addWatchedParameter(SIZE);
|
||||
dataManager.addWatchedParameter(TAB_SELECTED);
|
||||
dataManager.addWatchedParameter(TAB_PAGE);
|
||||
}
|
||||
|
||||
public static void serverTick(PortableGridBlockEntity blockEntity) {
|
||||
@@ -354,7 +355,7 @@ public class PortableGridBlockEntity extends BaseBlockEntity implements IGrid, I
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return new TranslatableComponent("gui.refinedstorage.portable_grid");
|
||||
return Component.translatable("gui.refinedstorage.portable_grid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,7 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -40,7 +39,7 @@ public class CreateDiskCommand implements Command<CommandSourceStack> {
|
||||
|
||||
IStorageDisk<?> disk = API.instance().getStorageDiskManager(context.getSource().getLevel()).get(id);
|
||||
if (disk == null) {
|
||||
context.getSource().sendFailure(new TranslatableComponent("commands.refinedstorage.disk.create.error.disk_not_found", id));
|
||||
context.getSource().sendFailure(Component.translatable("commands.refinedstorage.disk.create.error.disk_not_found", id));
|
||||
} else {
|
||||
IStorageDiskFactory factory = API.instance().getStorageDiskRegistry().get(disk.getFactoryId());
|
||||
|
||||
@@ -67,9 +66,9 @@ public class CreateDiskCommand implements Command<CommandSourceStack> {
|
||||
}
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TranslatableComponent(
|
||||
context.getSource().sendSuccess(Component.translatable(
|
||||
"commands.refinedstorage.disk.create.success",
|
||||
new TextComponent(id.toString()).setStyle(Styles.YELLOW),
|
||||
Component.literal(id.toString()).setStyle(Styles.YELLOW),
|
||||
context.getSource().getDisplayName().copy().setStyle(Styles.YELLOW)
|
||||
), false);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ListDiskCommand implements Command<CommandSourceStack> {
|
||||
public static ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||
@@ -21,7 +21,7 @@ public class ListDiskCommand implements Command<CommandSourceStack> {
|
||||
API.instance().getStorageDiskManager(context.getSource().getLevel())
|
||||
.getAll()
|
||||
.keySet()
|
||||
.forEach(id -> context.getSource().sendSuccess(new TextComponent(id.toString()), false));
|
||||
.forEach(id -> context.getSource().sendSuccess(Component.literal(id.toString()), false));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -28,7 +28,7 @@ public class ListDiskForPlayerCommand implements Command<CommandSourceStack> {
|
||||
.stream()
|
||||
.filter(entry -> player.getGameProfile().getId().equals(entry.getValue().getOwner()))
|
||||
.map(Map.Entry::getKey)
|
||||
.forEach(id -> context.getSource().sendSuccess(new TextComponent(id.toString()), false));
|
||||
.forEach(id -> context.getSource().sendSuccess(Component.literal(id.toString()), false));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
@@ -29,31 +29,31 @@ public class ListNetworkCommand implements Command<CommandSourceStack> {
|
||||
|
||||
public static void sendInfo(CommandContext<CommandSourceStack> context, NetworkInList listItem, boolean detailed) {
|
||||
context.getSource().sendSuccess(
|
||||
new TranslatableComponent(
|
||||
Component.translatable(
|
||||
"commands.refinedstorage.network.list.pos",
|
||||
listItem.network.getPosition().getX(),
|
||||
listItem.network.getPosition().getY(),
|
||||
listItem.network.getPosition().getZ()
|
||||
)
|
||||
.append(" [")
|
||||
.append(new TranslatableComponent(
|
||||
.append(Component.translatable(
|
||||
"commands.refinedstorage.network.list.tick_times",
|
||||
new TextComponent(TIME_FORMATTER.format(listItem.tickTime)).setStyle(Styles.YELLOW),
|
||||
new TextComponent(TIME_FORMATTER.format(listItem.tps)).setStyle(Styles.YELLOW)
|
||||
Component.literal(TIME_FORMATTER.format(listItem.tickTime)).setStyle(Styles.YELLOW),
|
||||
Component.literal(TIME_FORMATTER.format(listItem.tps)).setStyle(Styles.YELLOW)
|
||||
))
|
||||
.append("]"), false);
|
||||
|
||||
if (detailed) {
|
||||
context.getSource().sendSuccess(new TranslatableComponent("commands.refinedstorage.network.list.autocrafting_tasks",
|
||||
new TextComponent(listItem.network.getCraftingManager().getTasks().size() + "").setStyle(Styles.YELLOW)
|
||||
context.getSource().sendSuccess(Component.translatable("commands.refinedstorage.network.list.autocrafting_tasks",
|
||||
Component.literal(listItem.network.getCraftingManager().getTasks().size() + "").setStyle(Styles.YELLOW)
|
||||
), false);
|
||||
|
||||
context.getSource().sendSuccess(new TranslatableComponent("commands.refinedstorage.network.list.nodes",
|
||||
new TextComponent(listItem.network.getNodeGraph().all().size() + "").setStyle(Styles.YELLOW)
|
||||
context.getSource().sendSuccess(Component.translatable("commands.refinedstorage.network.list.nodes",
|
||||
Component.literal(listItem.network.getNodeGraph().all().size() + "").setStyle(Styles.YELLOW)
|
||||
), false);
|
||||
|
||||
context.getSource().sendSuccess(new TranslatableComponent("commands.refinedstorage.network.list.energy_usage",
|
||||
new TextComponent(listItem.network.getEnergyUsage() + "").setStyle(Styles.YELLOW)
|
||||
context.getSource().sendSuccess(Component.translatable("commands.refinedstorage.network.list.energy_usage",
|
||||
Component.literal(listItem.network.getEnergyUsage() + "").setStyle(Styles.YELLOW)
|
||||
), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
public abstract class NetworkCommand implements Command<CommandSourceStack> {
|
||||
@@ -21,7 +22,7 @@ public abstract class NetworkCommand implements Command<CommandSourceStack> {
|
||||
INetwork network = API.instance().getNetworkManager(level).getNetwork(pos);
|
||||
|
||||
if (network == null) {
|
||||
context.getSource().sendFailure(new TranslatableComponent("commands.refinedstorage.network.get.error.not_found"));
|
||||
context.getSource().sendFailure(Component.translatable("commands.refinedstorage.network.get.error.not_found"));
|
||||
return 0;
|
||||
} else {
|
||||
return run(context, network);
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.refinedmods.refinedstorage.command.network.NetworkCommand;
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
||||
public class CancelAllAutocraftingCommand extends NetworkCommand {
|
||||
public static ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||
@@ -23,7 +23,7 @@ public class CancelAllAutocraftingCommand extends NetworkCommand {
|
||||
translationKey = "commands.refinedstorage.network.autocrafting.cancel.single";
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TranslatableComponent(translationKey, new TextComponent("" + count).setStyle(Styles.YELLOW)), false);
|
||||
context.getSource().sendSuccess(Component.translatable(translationKey, Component.literal("" + count).setStyle(Styles.YELLOW)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,7 +8,8 @@ import com.refinedmods.refinedstorage.command.network.NetworkCommand;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class GetAutocraftingCommand extends NetworkCommand {
|
||||
|
||||
ICraftingTask task = network.getCraftingManager().getTask(id);
|
||||
if (task == null) {
|
||||
context.getSource().sendFailure(new TranslatableComponent("commands.refinedstorage.network.autocrafting.get.error.not_found"));
|
||||
context.getSource().sendFailure(Component.translatable("commands.refinedstorage.network.autocrafting.get.error.not_found"));
|
||||
} else {
|
||||
ListAutocraftingCommand.addInfo(context, task);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class ListAutocraftingCommand extends NetworkCommand {
|
||||
public static ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||
@@ -19,12 +18,12 @@ public class ListAutocraftingCommand extends NetworkCommand {
|
||||
|
||||
public static void addInfo(CommandContext<CommandSourceStack> context, ICraftingTask task) {
|
||||
context.getSource().sendSuccess(
|
||||
new TextComponent(getAmount(task.getRequested()) + "x ")
|
||||
Component.literal(getAmount(task.getRequested()) + "x ")
|
||||
.append(getName(task.getRequested()).copy().setStyle(Styles.YELLOW))
|
||||
.append(" ")
|
||||
.append("(" + task.getCompletionPercentage() + "%)")
|
||||
.append(" ")
|
||||
.append(new TextComponent("[" + task.getId().toString() + "]").setStyle(Styles.GRAY)),
|
||||
.append(Component.literal("[" + task.getId().toString() + "]").setStyle(Styles.GRAY)),
|
||||
false
|
||||
);
|
||||
}
|
||||
@@ -50,7 +49,7 @@ public class ListAutocraftingCommand extends NetworkCommand {
|
||||
return info.getFluid().getDisplayName();
|
||||
}
|
||||
|
||||
return TextComponent.EMPTY;
|
||||
return Component.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.item.PatternItem;
|
||||
import com.refinedmods.refinedstorage.render.Styles;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -32,71 +32,71 @@ public class PatternDumpCommand implements Command<CommandSourceStack> {
|
||||
|
||||
ICraftingPattern pattern = PatternItem.fromCache(context.getSource().getLevel(), stack);
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("Crafting task factory ID: ").setStyle(Styles.YELLOW).append(new TextComponent(pattern.getCraftingTaskFactoryId().toString()).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(Component.literal("Crafting task factory ID: ").setStyle(Styles.YELLOW).append(Component.literal(pattern.getCraftingTaskFactoryId().toString()).setStyle(Styles.WHITE)), false);
|
||||
|
||||
if (!pattern.isValid()) {
|
||||
context.getSource().sendFailure(new TextComponent("Pattern is invalid! Reason: ").append(pattern.getErrorMessage()));
|
||||
context.getSource().sendFailure(Component.literal("Pattern is invalid! Reason: ").append(pattern.getErrorMessage()));
|
||||
} else {
|
||||
context.getSource().sendSuccess(new TextComponent("Processing: ").setStyle(Styles.YELLOW).append(new TextComponent(String.valueOf(processing)).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(new TextComponent("Exact: ").setStyle(Styles.YELLOW).append(new TextComponent(String.valueOf(exact)).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(new TextComponent("Has allowed tag list: ").setStyle(Styles.YELLOW).append(new TextComponent(String.valueOf(allowedTagList != null)).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(Component.literal("Processing: ").setStyle(Styles.YELLOW).append(Component.literal(String.valueOf(processing)).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(Component.literal("Exact: ").setStyle(Styles.YELLOW).append(Component.literal(String.valueOf(exact)).setStyle(Styles.WHITE)), false);
|
||||
context.getSource().sendSuccess(Component.literal("Has allowed tag list: ").setStyle(Styles.YELLOW).append(Component.literal(String.valueOf(allowedTagList != null)).setStyle(Styles.WHITE)), false);
|
||||
|
||||
if (pattern.isProcessing()) {
|
||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
||||
if (!pattern.getInputs().get(i).isEmpty()) {
|
||||
context.getSource().sendSuccess(new TextComponent("Item inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Item inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
|
||||
for (int j = 0; j < pattern.getInputs().get(i).size(); ++j) {
|
||||
context.getSource().sendSuccess(new TextComponent("- Possibility #" + j + ": " + pattern.getInputs().get(i).get(j).getCount() + "x ").append(pattern.getInputs().get(i).get(j).getHoverName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- Possibility #" + j + ": " + pattern.getInputs().get(i).get(j).getCount() + "x ").append(pattern.getInputs().get(i).get(j).getHoverName()), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (allowedTagList != null) {
|
||||
for (ResourceLocation allowed : allowedTagList.getAllowedItemTags().get(i)) {
|
||||
context.getSource().sendSuccess(new TextComponent("- Allowed item tag: " + allowed.toString()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- Allowed item tag: " + allowed.toString()), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < pattern.getFluidInputs().size(); ++i) {
|
||||
if (!pattern.getFluidInputs().get(i).isEmpty()) {
|
||||
context.getSource().sendSuccess(new TextComponent("Fluid inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Fluid inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
|
||||
for (int j = 0; j < pattern.getFluidInputs().get(i).size(); ++j) {
|
||||
context.getSource().sendSuccess(new TextComponent("- Possibility #" + j + ": " + pattern.getFluidInputs().get(i).get(j).getAmount() + " mB ").append(pattern.getFluidInputs().get(i).get(j).getDisplayName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- Possibility #" + j + ": " + pattern.getFluidInputs().get(i).get(j).getAmount() + " mB ").append(pattern.getFluidInputs().get(i).get(j).getDisplayName()), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (allowedTagList != null) {
|
||||
for (ResourceLocation allowed : allowedTagList.getAllowedFluidTags().get(i)) {
|
||||
context.getSource().sendSuccess(new TextComponent("- Allowed fluid tag: " + allowed.toString()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- Allowed fluid tag: " + allowed.toString()), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("Outputs").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Outputs").setStyle(Styles.YELLOW), false);
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
context.getSource().sendSuccess(new TextComponent("- " + output.getCount() + "x ").append(output.getHoverName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- " + output.getCount() + "x ").append(output.getHoverName()), false);
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("Fluid outputs").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Fluid outputs").setStyle(Styles.YELLOW), false);
|
||||
for (FluidStack output : pattern.getFluidOutputs()) {
|
||||
context.getSource().sendSuccess(new TextComponent("- " + output.getAmount() + " mB ").append(output.getDisplayName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- " + output.getAmount() + " mB ").append(output.getDisplayName()), false);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
||||
if (!pattern.getInputs().get(i).isEmpty()) {
|
||||
context.getSource().sendSuccess(new TextComponent("Inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Inputs in slot " + i + ":").setStyle(Styles.YELLOW), false);
|
||||
|
||||
for (int j = 0; j < pattern.getInputs().get(i).size(); ++j) {
|
||||
context.getSource().sendSuccess(new TextComponent("- Possibility #" + j + ": " + pattern.getInputs().get(i).get(j).getCount() + "x ").append(pattern.getInputs().get(i).get(j).getHoverName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- Possibility #" + j + ": " + pattern.getInputs().get(i).get(j).getCount() + "x ").append(pattern.getInputs().get(i).get(j).getHoverName()), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("Outputs").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Outputs").setStyle(Styles.YELLOW), false);
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
context.getSource().sendSuccess(new TextComponent("- " + output.getCount() + "x ").append(output.getHoverName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- " + output.getCount() + "x ").append(output.getHoverName()), false);
|
||||
}
|
||||
|
||||
boolean anyByproducts = false;
|
||||
@@ -104,18 +104,18 @@ public class PatternDumpCommand implements Command<CommandSourceStack> {
|
||||
for (ItemStack byproduct : pattern.getByproducts()) {
|
||||
if (!byproduct.isEmpty()) {
|
||||
if (!anyByproducts) {
|
||||
context.getSource().sendSuccess(new TextComponent("Byproducts").setStyle(Styles.YELLOW), false);
|
||||
context.getSource().sendSuccess(Component.literal("Byproducts").setStyle(Styles.YELLOW), false);
|
||||
|
||||
anyByproducts = true;
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("- " + byproduct.getCount() + "x ").append(byproduct.getHoverName()), false);
|
||||
context.getSource().sendSuccess(Component.literal("- " + byproduct.getCount() + "x ").append(byproduct.getHoverName()), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
context.getSource().sendFailure(new TextComponent("You need to be holding a pattern in your hand."));
|
||||
context.getSource().sendFailure(Component.literal("You need to be holding a pattern in your hand."));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ConstructorContainerMenu extends BaseContainerMenu {
|
||||
public ConstructorContainerMenu(ConstructorBlockEntity constructor, Player player, int windowId) {
|
||||
super(RSContainerMenus.CONSTRUCTOR, constructor, player, windowId);
|
||||
super(RSContainerMenus.CONSTRUCTOR.get(), constructor, player, windowId);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlot(new SlotItemHandler(constructor.getNode().getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class ControllerContainerMenu extends BaseContainerMenu {
|
||||
public ControllerContainerMenu(ControllerBlockEntity controller, Player player, int windowId) {
|
||||
super(RSContainerMenus.CONTROLLER, controller, player, windowId);
|
||||
super(RSContainerMenus.CONTROLLER.get(), controller, player, windowId);
|
||||
|
||||
addPlayerInventory(8, 99);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user