Skip to content

Commit

Permalink
Fix compiling errors and apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Dec 22, 2024
1 parent ed2566e commit 87d4444
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@

import net.legacyfabric.fabric.api.registry.v2.RegistryIds;
import net.legacyfabric.fabric.api.registry.v2.event.RegistryInitializedEvent;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.Registry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.SyncedRegistry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.FabricRegistry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.SyncedFabricRegistry;

public class EarlyInitializer implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
RegistryInitializedEvent.event(RegistryIds.ITEMS).register(EarlyInitializer::itemRegistryInit);
}

private static void itemRegistryInit(Registry<?> holder) {
SyncedRegistry<Item> registry = (SyncedRegistry<Item>) holder;
private static void itemRegistryInit(FabricRegistry<?> holder) {
SyncedFabricRegistry<Item> registry = (SyncedFabricRegistry<Item>) holder;

if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) registry.fabric$getRegistryRemapCallback().register(new ItemModelsRemapper());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import net.legacyfabric.fabric.api.registry.v2.RegistryHelper;
import net.legacyfabric.fabric.api.registry.v2.event.RegistryRemapCallback;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.RegistryEntry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.FabricRegistryEntry;
import net.legacyfabric.fabric.api.util.Identifier;
import net.legacyfabric.fabric.mixin.item.versioned.ItemModelsAccessor;

Expand All @@ -48,7 +48,7 @@ private ItemModels getModelRegistry() {
}

@Override
public void callback(Map<Integer, RegistryEntry<Item>> changedIdsMap) {
public void callback(Map<Integer, FabricRegistryEntry<Item>> changedIdsMap) {
((ItemModelsAccessor) getModelRegistry()).getModelIds().clear();

for (Map.Entry<Identifier, Map<Integer, ModelIdentifier>> entry : modelIds.entrySet()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

import net.legacyfabric.fabric.api.registry.v2.RegistryIds;
import net.legacyfabric.fabric.api.registry.v2.event.RegistryInitializedEvent;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.Registry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.FabricRegistry;

public class EarlyInitializer implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
RegistryInitializedEvent.event(RegistryIds.ITEMS).register(EarlyInitializer::itemRegistryInit);
}

private static void itemRegistryInit(Registry<?> holder) {
Registry<Item> registry = (Registry<Item>) holder;
private static void itemRegistryInit(FabricRegistry<?> holder) {
FabricRegistry<Item> registry = (FabricRegistry<Item>) holder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@

import net.legacyfabric.fabric.api.registry.v2.RegistryIds;
import net.legacyfabric.fabric.api.registry.v2.event.RegistryInitializedEvent;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.Registry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.FabricRegistry;

public class EarlyInitializer implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
RegistryInitializedEvent.event(RegistryIds.ITEMS).register(EarlyInitializer::itemRegistryInit);
}

private static void itemRegistryInit(Registry<?> holder) {
Registry<Item> registry = (Registry<Item>) holder;
private static void itemRegistryInit(FabricRegistry<?> holder) {
FabricRegistry<Item> registry = (FabricRegistry<Item>) holder;

registry.fabric$getBeforeAddedCallback().register((rawId, id, item) -> item.setTranslationKey(id.toTranslationKey()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import net.legacyfabric.fabric.api.registry.v2.RegistryHelper;
import net.legacyfabric.fabric.api.registry.v2.RegistryIds;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.Registry;
import net.legacyfabric.fabric.api.registry.v2.registry.holder.FabricRegistry;

@Mixin(Item.class)
public class ItemMixin {
Expand All @@ -39,6 +39,6 @@ public class ItemMixin {

@Inject(method = "setup", at = @At("RETURN"))
private static void registerRegistry(CallbackInfo ci) {
RegistryHelper.addRegistry(RegistryIds.ITEMS, (Registry<?>) REGISTRY);
RegistryHelper.addRegistry(RegistryIds.ITEMS, (FabricRegistry<?>) REGISTRY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.test.registry;

import net.minecraft.item.Item;
import net.minecraft.item.itemgroup.ItemGroup;

import net.fabricmc.api.ModInitializer;

import net.legacyfabric.fabric.api.registry.v2.RegistryHelper;
import net.legacyfabric.fabric.api.resource.ItemModelRegistry;
import net.legacyfabric.fabric.api.util.Identifier;

public class RegistryTest implements ModInitializer {
@Override
public void onInitialize() {
this.registerItems();
}

private void registerItems() {
Item testItem = new Item().setItemGroup(ItemGroup.FOOD);
RegistryHelper.register(
Item.REGISTRY,
new Identifier("legacy-fabric-api", "test_item"), testItem
);
ItemModelRegistry.registerItemModel(testItem, new Identifier("legacy-fabric-api:test_item"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@
package net.legacyfabric.fabric.testing;

Check failure on line 18 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

adjacent blank lines

Check failure on line 18 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

Name 'net.legacyfabric.fabric.testing' must match pattern '^net\.legacyfabric\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+\.v[1-9][0-9]*|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+|api\.(event|util|biomes\.v1|registry|client\.screen|command|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$'.

Check failure on line 18 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

adjacent blank lines

Check failure on line 18 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

Name 'net.legacyfabric.fabric.testing' must match pattern '^net\.legacyfabric\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+\.v[1-9][0-9]*|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+|api\.(event|util|biomes\.v1|registry|client\.screen|command|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$'.


import net.minecraft.item.Item;
import net.minecraft.item.itemgroup.ItemGroup;

import net.fabricmc.api.ModInitializer;

Check failure on line 22 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

adjacent blank lines

Check failure on line 22 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

'import' has more than 1 empty lines before.

Check failure on line 22 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

adjacent blank lines

Check failure on line 22 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

'import' has more than 1 empty lines before.

import net.legacyfabric.fabric.api.registry.v2.RegistryHelper;
import net.legacyfabric.fabric.api.resource.ItemModelRegistry;
import net.legacyfabric.fabric.api.util.Identifier;

public class TestMod implements ModInitializer {

Check failure on line 25 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

'CLASS_DEF' has more than 1 empty lines before.

Check failure on line 25 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

'CLASS_DEF' has more than 1 empty lines before.
@Override
Expand All @@ -50,12 +45,5 @@ private void registerItem() {
// net.legacyfabric.fabric.api.registry.v1.RegistryHelper.registerBlock(block, identifier);
// net.legacyfabric.fabric.api.registry.v1.RegistryHelper.registerItem(new BlockItem(block), identifier);
// }

Check failure on line 47 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (17-jdk)

Comment has incorrect indentation level 0, expected is 1, indentation should be the same level as line 48.

Check failure on line 47 in legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/testing/TestMod.java

View workflow job for this annotation

GitHub Actions / build (21-jdk)

Comment has incorrect indentation level 0, expected is 1, indentation should be the same level as line 48.

Item testItem = new Item().setItemGroup(ItemGroup.FOOD);
RegistryHelper.register(
Item.REGISTRY,
new Identifier("legacy-fabric-api", "test_item"), testItem
);
ItemModelRegistry.registerItemModel(testItem, new Identifier("legacy-fabric-api:test_item"));
}
}

0 comments on commit 87d4444

Please sign in to comment.