Skip to content

Commit

Permalink
Update to MC 1.18.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Apr 7, 2022
1 parent 53cd30f commit 78ae75a
Show file tree
Hide file tree
Showing 34 changed files with 120 additions and 102 deletions.
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ java.toolchain {
vendor = JvmVendorSpec.ADOPTOPENJDK
}

compileJava.options.encoding = "utf-8"
compileTestJava.options.encoding = "utf-8"
tasks.withType(JavaCompile).configureEach {
options.encoding = 'utf-8'
}

repositories {
mavenCentral()
Expand All @@ -68,12 +69,12 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

implementation "li.cil.sedna:sedna-${minecraft_version}-forge:1.0.12"
implementation "li.cil.sedna:sedna-${minecraft_version}-forge:1.0.13"

implementation fg.deobf("curse.maven:markdownmanual-502485:3565800")
implementation fg.deobf("curse.maven:markdownmanual-502485:3738124")

compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:9.1.0.41:api")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:9.1.0.41")
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:9.7.0.180:api")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:9.7.0.180")

testImplementation 'org.mockito:mockito-inline:4.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

forge_version=39.0.66
forge_version=40.0.40

semver=0.0.0

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion minecraft.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ext {
minecraft_version = '1.18.1'
minecraft_version = '1.18.2'
minecraft_sdk = 'forge'
}
8 changes: 5 additions & 3 deletions src/main/java/li/cil/oc2/api/bus/device/DeviceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package li.cil.oc2.api.bus.device;

import li.cil.oc2.api.API;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.IForgeRegistryEntry;

Expand All @@ -20,14 +22,14 @@ public interface DeviceType extends IForgeRegistryEntry<DeviceType> {
/**
* The registry name of the registry holding device types.
*/
ResourceLocation REGISTRY = new ResourceLocation(API.MOD_ID, "device_type");
ResourceKey<Registry<DeviceType>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(API.MOD_ID, "device_type"));

/**
* The tag representing this device type.
*
* @return the item tag.
*/
Tag<Item> getTag();
TagKey<Item> getTag();

/**
* An icon rendered as background of empty slots, visually indicating the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import li.cil.oc2.api.API;
import li.cil.sedna.api.device.BlockDevice;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

Expand All @@ -31,7 +33,7 @@ public interface BlockDeviceData extends IForgeRegistryEntry<BlockDeviceData> {
/**
* The registry name of the registry holding block device bases.
*/
ResourceLocation REGISTRY = new ResourceLocation(API.MOD_ID, "block_device_data");
ResourceKey<Registry<BlockDeviceData>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(API.MOD_ID, "block_device_data"));

/**
* Gets the read-only base block device this implementation describes.
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/li/cil/oc2/api/bus/device/data/Firmware.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import li.cil.oc2.api.API;
import li.cil.sedna.api.memory.MemoryMap;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

Expand All @@ -26,7 +28,7 @@ public interface Firmware extends IForgeRegistryEntry<Firmware> {
/**
* The registry name of the registry holding firmwares.
*/
ResourceLocation REGISTRY = new ResourceLocation(API.MOD_ID, "firmware");
ResourceKey<Registry<Firmware>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(API.MOD_ID, "firmware"));

/**
* Runs this firmware.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

package li.cil.oc2.api.bus.device.provider;

import li.cil.oc2.api.API;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.util.Invalidatable;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

/**
Expand All @@ -30,7 +34,7 @@
* are registered. For example:
* <pre>
* class YourModInitialization {
* static DeferredRegister&lt;BlockDeviceProvider&gt; BLOCK_DEVICE_PROVIDERS = DeferredRegister.create(BlockDeviceProvider.class, "your_mod_id");
* static DeferredRegister&lt;BlockDeviceProvider&gt; BLOCK_DEVICE_PROVIDERS = DeferredRegister.create(BlockDeviceProvider.REGISTRY, "your_mod_id");
*
* static void initialize() {
* BLOCK_DEVICE_PROVIDERS.register("your_block_device_name", YourBlockDeviceProvider::new);
Expand All @@ -46,6 +50,11 @@
* @see BlockDeviceQuery
*/
public interface BlockDeviceProvider extends IForgeRegistryEntry<BlockDeviceProvider> {
/**
* The registry name of the registry holding block device providers.
*/
ResourceKey<Registry<BlockDeviceProvider>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(API.MOD_ID, "block_device_provider"));

/**
* Get a device for the specified query.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

package li.cil.oc2.api.bus.device.provider;

import li.cil.oc2.api.API;
import li.cil.oc2.api.bus.device.ItemDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

import javax.annotation.Nullable;
Expand All @@ -27,7 +31,7 @@
* are registered. For example:
* <pre>
* class YourModInitialization {
* static DeferredRegister&lt;ItemDeviceProvider&gt; ITEM_DEVICE_PROVIDERS = DeferredRegister.create(ItemDeviceProvider.class, "your_mod_id");
* static DeferredRegister&lt;ItemDeviceProvider&gt; ITEM_DEVICE_PROVIDERS = DeferredRegister.create(ItemDeviceProvider.REGISTRY, "your_mod_id");
*
* static void initialize() {
* ITEM_DEVICE_PROVIDERS.register("your_item_device_name", YourItemDeviceProvider::new);
Expand All @@ -43,6 +47,11 @@
* @see ItemDeviceQuery
*/
public interface ItemDeviceProvider extends IForgeRegistryEntry<ItemDeviceProvider> {
/**
* The registry name of the registry holding item device providers.
*/
ResourceKey<Registry<ItemDeviceProvider>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(API.MOD_ID, "item_device_provider"));

/**
* Get a device for the specified query.
*
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/li/cil/oc2/client/manual/Manuals.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import li.cil.manual.api.prefab.tab.TextureTab;
import li.cil.manual.api.provider.DocumentProvider;
import li.cil.manual.api.provider.PathProvider;
import li.cil.manual.api.util.Constants;
import li.cil.oc2.api.API;
import li.cil.oc2.common.block.Blocks;
import li.cil.oc2.common.item.Items;
Expand All @@ -25,7 +26,7 @@

@OnlyIn(Dist.CLIENT)
public final class Manuals {
private static final DeferredRegister<ManualModel> MANUALS = RegistryUtils.create(ManualModel.class);
private static final DeferredRegister<ManualModel> MANUALS = RegistryUtils.getInitializerFor(Constants.MANUAL_REGISTRY);

///////////////////////////////////////////////////////////////////

Expand All @@ -34,9 +35,9 @@ public final class Manuals {
///////////////////////////////////////////////////////////////////

public static void initialize() {
final DeferredRegister<PathProvider> pathProviders = RegistryUtils.create(PathProvider.class);
final DeferredRegister<DocumentProvider> contentProviders = RegistryUtils.create(DocumentProvider.class);
final DeferredRegister<Tab> tabs = RegistryUtils.create(Tab.class);
final DeferredRegister<PathProvider> pathProviders = RegistryUtils.getInitializerFor(Constants.PATH_PROVIDER_REGISTRY);
final DeferredRegister<DocumentProvider> contentProviders = RegistryUtils.getInitializerFor(Constants.DOCUMENT_PROVIDER_REGISTRY);
final DeferredRegister<Tab> tabs = RegistryUtils.getInitializerFor(Constants.TAB_REGISTRY);

pathProviders.register("path_provider", () -> new NamespacePathProvider(API.MOD_ID));
contentProviders.register("content_provider", () -> new NamespaceDocumentProvider(API.MOD_ID, "doc"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/li/cil/oc2/common/block/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraftforge.registries.RegistryObject;

public final class Blocks {
private static final DeferredRegister<Block> BLOCKS = RegistryUtils.create(ForgeRegistries.BLOCKS);
private static final DeferredRegister<Block> BLOCKS = RegistryUtils.getInitializerFor(ForgeRegistries.BLOCKS);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraftforge.registries.RegistryObject;

public final class BlockEntities {
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = RegistryUtils.create(ForgeRegistries.BLOCK_ENTITIES);
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = RegistryUtils.getInitializerFor(ForgeRegistries.BLOCK_ENTITIES);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public DiskDriveBlockEntity(final BlockPos pos, final BlockState state) {
///////////////////////////////////////////////////////////////////

public boolean canInsert(final ItemStack stack) {
return !stack.isEmpty() && ItemTags.DEVICES_FLOPPY.contains(stack.getItem());
return !stack.isEmpty() && stack.is(ItemTags.DEVICES_FLOPPY);
}

public ItemStack insert(final ItemStack stack, @Nullable final Player player) {
if (stack.isEmpty() || !ItemTags.DEVICES_FLOPPY.contains(stack.getItem())) {
if (!canInsert(stack)) {
return stack;
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/li/cil/oc2/common/bus/device/DeviceTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import li.cil.oc2.common.tags.ItemTags;
import li.cil.oc2.common.util.RegistryUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.Tags;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryBuilder;
Expand All @@ -19,11 +19,11 @@
import static li.cil.oc2.common.util.TranslationUtils.text;

public final class DeviceTypes {
private static final DeferredRegister<DeviceType> DEVICE_TYPES = RegistryUtils.create(DeviceType.class);
private static final DeferredRegister<DeviceType> DEVICE_TYPES = RegistryUtils.getInitializerFor(DeviceType.REGISTRY);

///////////////////////////////////////////////////////////////////

public static final Supplier<IForgeRegistry<DeviceType>> DEVICE_TYPE_REGISTRY = DEVICE_TYPES.makeRegistry("device_type", RegistryBuilder::new);
public static final Supplier<IForgeRegistry<DeviceType>> DEVICE_TYPE_REGISTRY = DEVICE_TYPES.makeRegistry(DeviceType.class, RegistryBuilder::new);

///////////////////////////////////////////////////////////////////

Expand All @@ -39,8 +39,8 @@ public static void initialize() {

///////////////////////////////////////////////////////////////////

private static void register(final Tags.IOptionalNamedTag<Item> tag) {
final String id = tag.getName().getPath().replaceFirst("^devices/", "");
private static void register(final TagKey<Item> tag) {
final String id = tag.location().getPath().replaceFirst("^devices/", "");
DEVICE_TYPES.register(id, () -> new DeviceTypeImpl(
tag,
new ResourceLocation(API.MOD_ID, "gui/icon/" + id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import java.util.stream.Stream;

public final class BlockDeviceDataRegistry {
private static final DeferredRegister<BlockDeviceData> INITIALIZER = RegistryUtils.create(BlockDeviceData.class);
private static final DeferredRegister<BlockDeviceData> INITIALIZER = RegistryUtils.getInitializerFor(BlockDeviceData.REGISTRY);

///////////////////////////////////////////////////////////////////

private static final Supplier<IForgeRegistry<BlockDeviceData>> REGISTRY = INITIALIZER.makeRegistry(BlockDeviceData.REGISTRY.getPath(), RegistryBuilder::new);
private static final Supplier<IForgeRegistry<BlockDeviceData>> REGISTRY = INITIALIZER.makeRegistry(BlockDeviceData.class, RegistryBuilder::new);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import java.util.stream.Stream;

public final class FirmwareRegistry {
private static final DeferredRegister<Firmware> INITIALIZER = RegistryUtils.create(Firmware.class);
private static final DeferredRegister<Firmware> INITIALIZER = RegistryUtils.getInitializerFor(Firmware.REGISTRY);

///////////////////////////////////////////////////////////////////

private static final Supplier<IForgeRegistry<Firmware>> REGISTRY = INITIALIZER.makeRegistry(Firmware.REGISTRY.getPath(), RegistryBuilder::new);
private static final Supplier<IForgeRegistry<Firmware>> REGISTRY = INITIALIZER.makeRegistry(Firmware.class, RegistryBuilder::new);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import java.util.function.Supplier;

public final class ProviderRegistry {
private static final DeferredRegister<BlockDeviceProvider> BLOCK_DEVICE_PROVIDERS = RegistryUtils.create(BlockDeviceProvider.class);
public static final Supplier<IForgeRegistry<BlockDeviceProvider>> BLOCK_DEVICE_PROVIDER_REGISTRY = BLOCK_DEVICE_PROVIDERS.makeRegistry("block_device_providers", RegistryBuilder::new);
private static final DeferredRegister<BlockDeviceProvider> BLOCK_DEVICE_PROVIDERS = RegistryUtils.getInitializerFor(BlockDeviceProvider.REGISTRY);
public static final Supplier<IForgeRegistry<BlockDeviceProvider>> BLOCK_DEVICE_PROVIDER_REGISTRY = BLOCK_DEVICE_PROVIDERS.makeRegistry(BlockDeviceProvider.class, RegistryBuilder::new);

///////////////////////////////////////////////////////////////////

private static final DeferredRegister<ItemDeviceProvider> ITEM_DEVICE_PROVIDERS = RegistryUtils.create(ItemDeviceProvider.class);
public static final Supplier<IForgeRegistry<ItemDeviceProvider>> ITEM_DEVICE_PROVIDER_REGISTRY = ITEM_DEVICE_PROVIDERS.makeRegistry("item_device_providers", RegistryBuilder::new);
private static final DeferredRegister<ItemDeviceProvider> ITEM_DEVICE_PROVIDERS = RegistryUtils.getInitializerFor(ItemDeviceProvider.REGISTRY);
public static final Supplier<IForgeRegistry<ItemDeviceProvider>> ITEM_DEVICE_PROVIDER_REGISTRY = ITEM_DEVICE_PROVIDERS.makeRegistry(ItemDeviceProvider.class, RegistryBuilder::new);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import li.cil.oc2.api.bus.device.DeviceType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.ForgeRegistryEntry;

public final class DeviceTypeImpl extends ForgeRegistryEntry<DeviceType> implements DeviceType {
private final Tag<Item> tag;
private final TagKey<Item> tag;
private final ResourceLocation icon;
private final Component name;

public DeviceTypeImpl(final Tag<Item> tag, final ResourceLocation icon, final Component name) {
public DeviceTypeImpl(final TagKey<Item> tag, final ResourceLocation icon, final Component name) {
this.tag = tag;
this.icon = icon;
this.name = name;
}

@Override
public Tag<Item> getTag() {
public TagKey<Item> getTag() {
return tag;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/li/cil/oc2/common/container/Containers.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraftforge.registries.RegistryObject;

public final class Containers {
private static final DeferredRegister<MenuType<?>> CONTAINERS = RegistryUtils.create(ForgeRegistries.CONTAINERS);
private static final DeferredRegister<MenuType<?>> CONTAINERS = RegistryUtils.getInitializerFor(ForgeRegistries.CONTAINERS);

///////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

package li.cil.oc2.common.container;

import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class TypedItemStackHandler extends FixedSizeItemStackHandler {
private final Tag<Item> deviceType;
private final TagKey<Item> deviceType;

///////////////////////////////////////////////////////////////////

public TypedItemStackHandler(final int size, final Tag<Item> deviceType) {
public TypedItemStackHandler(final int size, final TagKey<Item> deviceType) {
super(size);
this.deviceType = deviceType;
}
Expand All @@ -20,6 +20,6 @@ public TypedItemStackHandler(final int size, final Tag<Item> deviceType) {

@Override
public boolean isItemValid(final int slot, final ItemStack stack) {
return super.isItemValid(slot, stack) && !stack.isEmpty() && deviceType.contains(stack.getItem());
return super.isItemValid(slot, stack) && !stack.isEmpty() && stack.is(deviceType);
}
}
Loading

0 comments on commit 78ae75a

Please sign in to comment.