Fixed NBT and persistence
This commit is contained in:
@@ -10,14 +10,14 @@ import net.minecraftforge.registries.RegistryObject;
|
||||
* Lists built-in device types for convenience.
|
||||
*/
|
||||
public final class DeviceTypes {
|
||||
public static DeviceType MEMORY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "memory"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType MEMORY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "memory"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
|
||||
public static DeviceType HARD_DRIVE = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "hard_drive"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType HARD_DRIVE = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "hard_drive"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
|
||||
public static DeviceType FLASH_MEMORY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "flash_memory"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType CARD = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "card"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType ROBOT_MODULE = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "robot_module"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType FLASH_MEMORY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "flash_memory"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType CARD = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "card"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType ROBOT_MODULE = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "robot_module"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
|
||||
public static DeviceType FLOPPY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "floppy"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType NETWORK_TUNNEL = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "network_tunnel"), new ResourceLocation("minecraft", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType FLOPPY = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "floppy"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
public static DeviceType NETWORK_TUNNEL = (DeviceType) RegistryObject.create(new ResourceLocation(API.MOD_ID, "network_tunnel"), new ResourceLocation("oc2", "device_type"), API.MOD_ID).get();
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ package li.cil.oc2.api.bus.device.data;
|
||||
|
||||
import li.cil.sedna.api.device.BlockDevice;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Implementations of this interface that are registered with the registry for
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.function.Supplier;
|
||||
import static li.cil.oc2.common.util.TranslationUtils.text;
|
||||
|
||||
public final class DeviceTypes {
|
||||
private static final DeferredRegister<DeviceType> DEVICE_TYPES = DeferredRegister.create(new ResourceLocation("device_type"), API.MOD_ID);
|
||||
private static final DeferredRegister<DeviceType> DEVICE_TYPES = DeferredRegister.create(DeviceType.REGISTRY, API.MOD_ID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class BlockDeviceDataRegistry {
|
||||
private static final DeferredRegister<BlockDeviceData> INITIALIZER = DeferredRegister.create(new ResourceLocation("block_device_data"), API.MOD_ID);
|
||||
private static final DeferredRegister<BlockDeviceData> INITIALIZER = DeferredRegister.create(Registries.BLOCK_DEVICE_DATA, API.MOD_ID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class FirmwareRegistry {
|
||||
private static final DeferredRegister<Firmware> INITIALIZER = DeferredRegister.create(new ResourceLocation("firmware"), API.MOD_ID);
|
||||
private static final DeferredRegister<Firmware> INITIALIZER = DeferredRegister.create(Registries.FIRMWARE, API.MOD_ID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import net.minecraftforge.registries.RegistryBuilder;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class ProviderRegistry {
|
||||
private static final DeferredRegister<BlockDeviceProvider> BLOCK_DEVICE_PROVIDERS = DeferredRegister.create(new ResourceLocation("block_device_provider"), API.MOD_ID);
|
||||
private static final DeferredRegister<BlockDeviceProvider> BLOCK_DEVICE_PROVIDERS = DeferredRegister.create(Registries.BLOCK_DEVICE_PROVIDER, API.MOD_ID);
|
||||
public static final Supplier<IForgeRegistry<BlockDeviceProvider>> BLOCK_DEVICE_PROVIDER_REGISTRY = BLOCK_DEVICE_PROVIDERS.makeRegistry(RegistryBuilder::new);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private static final DeferredRegister<ItemDeviceProvider> ITEM_DEVICE_PROVIDERS = DeferredRegister.create(new ResourceLocation("item_device_provider"), API.MOD_ID);
|
||||
private static final DeferredRegister<ItemDeviceProvider> ITEM_DEVICE_PROVIDERS = DeferredRegister.create(Registries.ITEM_DEVICE_PROVIDER, API.MOD_ID);
|
||||
public static final Supplier<IForgeRegistry<ItemDeviceProvider>> ITEM_DEVICE_PROVIDER_REGISTRY = ITEM_DEVICE_PROVIDERS.makeRegistry(RegistryBuilder::new);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -67,15 +67,15 @@ public abstract class RegistryUtils {
|
||||
return Objects.requireNonNull(registryEntry.getName()).toString();
|
||||
}
|
||||
|
||||
public static <T> Optional<String> optionalKey(@Nullable final T registryEntry) {
|
||||
public static <T> Optional<String> optionalKey(final T registryEntry) {
|
||||
if(registryEntry == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String providerName = null;
|
||||
if (registryEntry.getClass() == BlockDeviceProvider.class) {
|
||||
providerName = ProviderRegistry.BLOCK_DEVICE_PROVIDER_REGISTRY.get().getKey((BlockDeviceProvider) registryEntry).toString();
|
||||
} else if (registryEntry.getClass() == ItemDeviceProvider.class) {
|
||||
providerName = ProviderRegistry.ITEM_DEVICE_PROVIDER_REGISTRY.get().getKey((ItemDeviceProvider) registryEntry).toString();
|
||||
if (BlockDeviceProvider.class.isAssignableFrom(registryEntry.getClass())) {
|
||||
providerName = ProviderRegistry.BLOCK_DEVICE_PROVIDER_REGISTRY.get().getRegistryName().toString();
|
||||
} else if (ItemDeviceProvider.class.isAssignableFrom(registryEntry.getClass())) {
|
||||
providerName = ProviderRegistry.ITEM_DEVICE_PROVIDER_REGISTRY.get().getRegistryName().toString();
|
||||
}
|
||||
|
||||
if(providerName == null) {
|
||||
|
||||
Reference in New Issue
Block a user