diff --git a/build.gradle b/build.gradle index 984990e09..7b9ba6783 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.134' + id 'net.neoforged.gradle.userdev' version '7.0.153' } def buildSuffix = System.getenv('BUILD_NUMBER') ? "-b${System.getenv('BUILD_NUMBER')}" : "" @@ -14,7 +14,7 @@ base { archivesName = "ActuallyAdditions" } -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) if (rootProject.file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') @@ -83,12 +83,12 @@ dependencies { runtimeOnly "mezz.jei:jei-${game_version}-neoforge:${jei_version}" compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}" - runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}" +// runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}" compileOnly "xyz.brassgoggledcoders:PatchouliProvider:${patchouli_provider_version}" - runtimeOnly "xyz.brassgoggledcoders:PatchouliProvider:${patchouli_provider_version}" +// runtimeOnly "xyz.brassgoggledcoders:PatchouliProvider:${patchouli_provider_version}" - runtimeOnly "curse.maven:jade-324717:5109393" - runtimeOnly "curse.maven:mekanism-268560:5155329" + runtimeOnly "curse.maven:jade-324717:5427817" + runtimeOnly "curse.maven:mekanism-268560:5433143" } jar { @@ -172,6 +172,10 @@ publishing { } } -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. +idea { + module { + downloadSources = true + downloadJavadoc = true + } } diff --git a/gradle.properties b/gradle.properties index 557708433..5f4a2c36d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,19 +5,20 @@ org.gradle.daemon=false mod_version=1.2.14 # Forge -game_version=1.20.4 -neo_version=20.4.232 +game_version=1.21 +neo_version=21.0.76-beta # mods.toml -loader=2 -neo_version_range=[20.4.212,) -minecraft_version_range=[1.20.4,1.21) +loader=4 +neo_version_range=[21.0.75-beta,) +minecraft_version_range=[1.21,1.22) # Parchment (Mappings) -neogradle.subsystems.parchment.minecraftVersion=1.20.4 -neogradle.subsystems.parchment.mappingsVersion=2024.04.14 +neogradle.subsystems.parchment.minecraftVersion=1.21 +neogradle.subsystems.parchment.mappingsVersion=2024.06.23 +neogradle.subsystems.conventions.runs.create-default-run-per-type=false # Other mods -jei_version=17.3.0.49 +jei_version=19.3.1.23 patchouli_version=1.20.4-85-NEOFORGE patchouli_provider_version=1.20.4-1.0.10-Snapshot.7 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..a4413138c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a426..b740cf133 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index cb4c97390..143ece197 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -152,7 +152,7 @@ public final class ActuallyAdditionsAPI { * @param outputTwoChance The chance of the second stack (0 won't occur at all, 100 will all the time) */ public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, BuiltInRegistries.ITEM.getKey(input.getItem()).getPath() + "_crushing"); + ResourceLocation id = ActuallyAdditions.modLoc(BuiltInRegistries.ITEM.getKey(input.getItem()).getPath() + "_crushing"); CRUSHER_RECIPES.add(new RecipeHolder<>(id, new CrushingRecipe(Ingredient.of(input), outputOne, 1.0f, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance))); @@ -167,7 +167,7 @@ public final class ActuallyAdditionsAPI { * @param outputTwoChance The chance of the second stack (0 won't occur at all, 100 will all the time) */ public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, BuiltInRegistries.ITEM.getKey(input.getItems()[0].getItem()).getPath() + "_crushing"); + ResourceLocation id = ActuallyAdditions.modLoc(BuiltInRegistries.ITEM.getKey(input.getItems()[0].getItem()).getPath() + "_crushing"); CRUSHER_RECIPES.add(new RecipeHolder<>(id, new CrushingRecipe(input, outputOne, 1.0f, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance))); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java index 471835c0e..375e7448d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java @@ -24,23 +24,23 @@ public final class ActuallyTags { public static final TagKey DRILLS = tag("drills"); public static final TagKey COFFEE_BEANS = tag("coffee_beans"); public static final TagKey TINY_COALS = tag("tiny_coals"); - public static final TagKey HOLDS_ITEMS = ItemTags.create(new ResourceLocation("forge", "holds_items")); + public static final TagKey HOLDS_ITEMS = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "holds_items")); public static final TagKey CRYSTALS = tag("crystals"); public static final TagKey CRYSTAL_BLOCKS = tag("crystal_blocks"); - public static final TagKey SEEDS_RICE = ItemTags.create(new ResourceLocation("forge", "seeds/rice")); - public static final TagKey SEEDS_COFFEE = ItemTags.create(new ResourceLocation("forge", "seeds/coffee")); - public static final TagKey SEEDS_CANOLA = ItemTags.create(new ResourceLocation("forge", "seeds/canola")); - public static final TagKey SEEDS_FLAX = ItemTags.create(new ResourceLocation("forge", "seeds/flax")); - public static final TagKey CROPS_RICE = ItemTags.create(new ResourceLocation("forge", "crops/rice")); - public static final TagKey CROPS_COFFEE = ItemTags.create(new ResourceLocation("forge", "crops/coffee")); - public static final TagKey CROPS_CANOLA = ItemTags.create(new ResourceLocation("forge", "crops/canola")); - public static final TagKey CROPS_FLAX = ItemTags.create(new ResourceLocation("forge", "crops/flax")); - public static final TagKey GEMS_BLACK_QUARTZ = ItemTags.create(new ResourceLocation("forge", "gems/black_quartz")); - public static final TagKey ORES_BLACK_QUARTZ = ItemTags.create(new ResourceLocation("forge", "ores/black_quartz")); - public static final TagKey STORAGE_BLOCKS_BLACK_QUARTZ = ItemTags.create(new ResourceLocation("forge", "storage_blocks/black_quartz")); + public static final TagKey SEEDS_RICE = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "seeds/rice")); + public static final TagKey SEEDS_COFFEE = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "seeds/coffee")); + public static final TagKey SEEDS_CANOLA = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "seeds/canola")); + public static final TagKey SEEDS_FLAX = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "seeds/flax")); + public static final TagKey CROPS_RICE = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "crops/rice")); + public static final TagKey CROPS_COFFEE = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "crops/coffee")); + public static final TagKey CROPS_CANOLA = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "crops/canola")); + public static final TagKey CROPS_FLAX = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "crops/flax")); + public static final TagKey GEMS_BLACK_QUARTZ = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "gems/black_quartz")); + public static final TagKey ORES_BLACK_QUARTZ = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "ores/black_quartz")); + public static final TagKey STORAGE_BLOCKS_BLACK_QUARTZ = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "storage_blocks/black_quartz")); private static TagKey tag(String name) { - return TagKey.create(Registries.ITEM, new ResourceLocation(ActuallyAdditions.MODID, name)); + return TagKey.create(Registries.ITEM, ActuallyAdditions.modLoc(name)); } } @@ -58,12 +58,12 @@ public final class ActuallyTags { public static final TagKey NEEDS_VOID_TOOL = tag("needs_void_tool"); public static final TagKey NEEDS_EMERADIC_TOOL = tag("needs_emeradic_tool"); public static final TagKey NEEDS_ENORI_TOOL = tag("needs_enori_tool"); - public static final TagKey ORES_BLACK_QUARTZ = BlockTags.create(new ResourceLocation("forge", "ores/black_quartz")); - public static final TagKey STORAGE_BLOCKS_BLACK_QUARTZ = BlockTags.create(new ResourceLocation("forge", "storage_blocks/black_quartz")); + public static final TagKey ORES_BLACK_QUARTZ = BlockTags.create(ResourceLocation.fromNamespaceAndPath("c", "ores/black_quartz")); + public static final TagKey STORAGE_BLOCKS_BLACK_QUARTZ = BlockTags.create(ResourceLocation.fromNamespaceAndPath("c", "storage_blocks/black_quartz")); private static TagKey tag(String name) { - return TagKey.create(Registries.BLOCK, new ResourceLocation(ActuallyAdditions.MODID, name)); + return TagKey.create(Registries.BLOCK, ActuallyAdditions.modLoc(name)); } } @@ -78,7 +78,7 @@ public final class ActuallyTags { public static final TagKey PATTERN_BOOK = tag("pattern_item/book"); private static TagKey tag(String name) { - return TagKey.create(Registries.BANNER_PATTERN, new ResourceLocation(ActuallyAdditions.MODID, name)); + return TagKey.create(Registries.BANNER_PATTERN, ActuallyAdditions.modLoc(name)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java index d493f2f46..72e1da836 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java @@ -11,18 +11,16 @@ package de.ellpeck.actuallyadditions.api.booklet; import net.minecraft.world.item.ItemStack; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; //TODO: We're using Patchouli API for the new booklets. Do we still need this? public interface IBookletChapter { IBookletPage[] getAllPages(); - @OnlyIn(Dist.CLIENT) + String getLocalizedName(); - @OnlyIn(Dist.CLIENT) + String getLocalizedNameWithFormatting(); IBookletEntry getEntry(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java index 5dcbe3f03..23454f07c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java @@ -10,9 +10,6 @@ package de.ellpeck.actuallyadditions.api.booklet; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; - import java.util.List; //TODO: We're using Patchouli API for the new booklets. Do we still need this? @@ -22,19 +19,19 @@ public interface IBookletEntry { String getIdentifier(); - @OnlyIn(Dist.CLIENT) + String getLocalizedName(); - @OnlyIn(Dist.CLIENT) + String getLocalizedNameWithFormatting(); void addChapter(IBookletChapter chapter); - @OnlyIn(Dist.CLIENT) + List getChaptersForDisplay(String searchBarText); int getSortingPriority(); - @OnlyIn(Dist.CLIENT) + boolean visibleOnFrontPage(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java index 011f768fa..da7832656 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java @@ -13,8 +13,6 @@ package de.ellpeck.actuallyadditions.api.booklet; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import net.minecraft.client.gui.components.Button; import net.minecraft.world.item.ItemStack; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.fluids.FluidStack; import java.util.List; @@ -30,31 +28,31 @@ public interface IBookletPage { void setChapter(IBookletChapter chapter); - @OnlyIn(Dist.CLIENT) + String getInfoText(); - @OnlyIn(Dist.CLIENT) + void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton); - @OnlyIn(Dist.CLIENT) + void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state); - @OnlyIn(Dist.CLIENT) + void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick); - @OnlyIn(Dist.CLIENT) + void actionPerformed(GuiBookletBase gui, Button button); - @OnlyIn(Dist.CLIENT) + void init(GuiBookletBase gui, int startX, int startY); - @OnlyIn(Dist.CLIENT) + void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer); - @OnlyIn(Dist.CLIENT) + void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks); - @OnlyIn(Dist.CLIENT) + void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks); boolean shouldBeOnLeftSide(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java index 164c79707..d750933b8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java @@ -1,12 +1,12 @@ package de.ellpeck.actuallyadditions.data; -import de.ellpeck.actuallyadditions.data.patchouli.PachouliGenerator; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.gen.ActuallyBiomeModifiers; import de.ellpeck.actuallyadditions.mod.gen.ActuallyConfiguredFeatures; import de.ellpeck.actuallyadditions.mod.gen.ActuallyPlacedFeatures; import de.ellpeck.actuallyadditions.mod.gen.ActuallyProcessorLists; import de.ellpeck.actuallyadditions.mod.misc.ActuallyDamageTypes; +import de.ellpeck.actuallyadditions.mod.misc.BannerHelper; import net.minecraft.core.Cloner; import net.minecraft.core.HolderLookup; import net.minecraft.core.RegistryAccess; @@ -18,7 +18,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.world.damagesource.DamageType; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.neoforged.neoforge.data.event.GatherDataEvent; @@ -27,7 +27,7 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries; import java.util.Set; import java.util.concurrent.CompletableFuture; -@Mod.EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = EventBusSubscriber.Bus.MOD) public class ActuallyAdditionsData { @SubscribeEvent @@ -41,9 +41,9 @@ public class ActuallyAdditionsData { // generator.addProvider(new GeneratorLanguage(generator)); BlockTagsGenerator generatorBlockTags = new BlockTagsGenerator(packOutput, lookupProvider, helper); - generator.addProvider(true, new LootTableGenerator(packOutput)); - generator.addProvider(true, new BlockRecipeGenerator(packOutput)); - generator.addProvider(true, new ItemRecipeGenerator(packOutput)); + generator.addProvider(true, new LootTableGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new BlockRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new ItemRecipeGenerator(packOutput, lookupProvider)); generator.addProvider(true, generatorBlockTags); generator.addProvider(true, new ItemTagsGenerator(packOutput, lookupProvider, generatorBlockTags, helper)); generator.addProvider(true, new PoiTypeTagsGenerator(packOutput, lookupProvider, helper)); @@ -54,20 +54,20 @@ public class ActuallyAdditionsData { generator.addProvider(true, new ItemModelGenerator(packOutput, helper)); generator.addProvider(true, new AdvancementGenerator(packOutput, lookupProvider, helper)); - generator.addProvider(true, new LaserRecipeGenerator(packOutput)); - generator.addProvider(true, new ColorChangeGenerator(packOutput)); - generator.addProvider(true, new EmpoweringRecipeGenerator(packOutput)); - generator.addProvider(true, new CrushingRecipeGenerator(packOutput)); - generator.addProvider(true, new FuelRecipeGenerator(packOutput)); - generator.addProvider(true, new MiscMachineRecipeGenerator(packOutput)); - generator.addProvider(true, new MiningLensGenerator(packOutput)); - generator.addProvider(true, new CoffeeIngredientGenerator(packOutput)); + generator.addProvider(true, new LaserRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new ColorChangeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new EmpoweringRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new CrushingRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new FuelRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new MiscMachineRecipeGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new MiningLensGenerator(packOutput, lookupProvider)); + generator.addProvider(true, new CoffeeIngredientGenerator(packOutput, lookupProvider)); generator.addProvider(true, new SoundsGenerator(packOutput, helper)); - generator.addProvider(true, new PachouliGenerator(packOutput)); +// generator.addProvider(true, new PachouliGenerator(packOutput)); - generator.addProvider(true, new GlobalLootModifierGenerator(packOutput)); + generator.addProvider(true, new GlobalLootModifierGenerator(packOutput, lookupProvider)); generator.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider( packOutput, patchedProvider, Set.of(ActuallyAdditions.MODID))); @@ -81,6 +81,7 @@ public class ActuallyAdditionsData { registryBuilder.add(Registries.CONFIGURED_FEATURE, ActuallyConfiguredFeatures::bootstrap); registryBuilder.add(Registries.PLACED_FEATURE, ActuallyPlacedFeatures::bootstrap); registryBuilder.add(Registries.PROCESSOR_LIST, ActuallyProcessorLists::bootstrap); + registryBuilder.add(Registries.BANNER_PATTERN, BannerHelper::bootstrap); registryBuilder.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ActuallyBiomeModifiers::bootstrap); // We need the BIOME registry to be present, so we can use a biome tag, doesn't matter that it's empty registryBuilder.add(Registries.BIOME, $ -> { diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/AdvancementGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/AdvancementGenerator.java index a64d63c4e..7a53cf61f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/AdvancementGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/AdvancementGenerator.java @@ -35,7 +35,7 @@ public class AdvancementGenerator extends AdvancementProvider { .display(new DisplayInfo(ActuallyItems.ITEM_BOOKLET.get().getDefaultInstance(), Component.translatable("achievement.actuallyadditions.openBooklet"), Component.translatable("achievement.actuallyadditions.openBooklet.desc"), - Optional.of(new ResourceLocation("textures/gui/advancements/backgrounds/stone.png")), AdvancementType.TASK, true, true, false)) + Optional.of(ResourceLocation.tryParse("textures/gui/advancements/backgrounds/stone.png")), AdvancementType.TASK, true, true, false)) .addCriterion("right_click", CriteriaTriggers.IMPOSSIBLE.createCriterion(new ImpossibleTrigger.TriggerInstance())) .save(consumer, "actuallyadditions:root"); @@ -46,7 +46,7 @@ public class AdvancementGenerator extends AdvancementProvider { .display(new DisplayInfo(ActuallyBlocks.PHANTOM_ITEMFACE.get().asItem().getDefaultInstance(), Component.translatable("achievement.actuallyadditions.craftPhantomface"), Component.translatable("achievement.actuallyadditions.craftPhantomface.desc"), - Optional.of(new ResourceLocation("textures/blocks/stone.png")), AdvancementType.TASK, true, true, false)) + Optional.of(ResourceLocation.tryParse("textures/blocks/stone.png")), AdvancementType.TASK, true, true, false)) .addCriterion("phantom_face", InventoryChangeTrigger.TriggerInstance.hasItems(ActuallyBlocks.PHANTOM_ITEMFACE.get())) .save(consumer, "actuallyadditions:craft_phantom_face"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BannerPatternTagsGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BannerPatternTagsGenerator.java index 1761eb2ee..9131f25f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/BannerPatternTagsGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BannerPatternTagsGenerator.java @@ -18,9 +18,9 @@ public class BannerPatternTagsGenerator extends BannerPatternTagsProvider { @Override protected void addTags(HolderLookup.Provider pProvider) { - this.tag(ActuallyTags.BannerPatterns.PATTERN_DRILL).add(BannerHelper.DRILL.getKey()); - this.tag(ActuallyTags.BannerPatterns.PATTERN_LEAF_BLO).add(BannerHelper.LEAF_BLO.getKey()); - this.tag(ActuallyTags.BannerPatterns.PATTERN_PHAN_CON).add(BannerHelper.PHAN_CON.getKey()); - this.tag(ActuallyTags.BannerPatterns.PATTERN_BOOK).add(BannerHelper.BOOK.getKey()); + this.tag(ActuallyTags.BannerPatterns.PATTERN_DRILL).add(BannerHelper.DRILL); + this.tag(ActuallyTags.BannerPatterns.PATTERN_LEAF_BLO).add(BannerHelper.LEAF_BLO); + this.tag(ActuallyTags.BannerPatterns.PATTERN_PHAN_CON).add(BannerHelper.PHAN_CON); + this.tag(ActuallyTags.BannerPatterns.PATTERN_BOOK).add(BannerHelper.BOOK); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java index cd530e959..932878096 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java @@ -4,6 +4,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -17,10 +18,11 @@ import net.neoforged.neoforge.common.Tags; import javax.annotation.Nonnull; import java.util.Arrays; +import java.util.concurrent.CompletableFuture; public class BlockRecipeGenerator extends RecipeProvider { - public BlockRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public BlockRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -57,7 +59,7 @@ public class BlockRecipeGenerator extends RecipeProvider { //Fireworks Box Recipe.shaped(ActuallyBlocks.FIREWORK_BOX.getItem()) .pattern("GFG", "SAS", "CCC") - .define('G', Tags.Items.GUNPOWDER) + .define('G', Tags.Items.GUNPOWDERS) .define('S', Tags.Items.RODS_WOODEN) .define('A', ActuallyBlocks.IRON_CASING.get()) .define('F', Items.FIREWORK_ROCKET) @@ -68,7 +70,7 @@ public class BlockRecipeGenerator extends RecipeProvider { Recipe.shaped(ActuallyBlocks.SHOCK_SUPPRESSOR.getItem()) .pattern("OAO", "ACA", "OAO") .define('A', ActuallyItems.EMPOWERED_VOID_CRYSTAL.get()) - .define('O', Tags.Items.OBSIDIAN) + .define('O', Tags.Items.OBSIDIANS) .define('C', ActuallyItems.ADVANCED_COIL.get()) .save(recipeOutput); @@ -173,7 +175,7 @@ public class BlockRecipeGenerator extends RecipeProvider { Recipe.shaped(ActuallyBlocks.LASER_RELAY.getItem(), 4) .pattern("OBO", "RCR", "OBO") .define('B', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('O', Tags.Items.OBSIDIAN) + .define('O', Tags.Items.OBSIDIANS) .define('R', ActuallyItems.RESTONIA_CRYSTAL.get()) .define('C', ActuallyItems.ADVANCED_COIL.get()) .save(recipeOutput); @@ -247,7 +249,7 @@ public class BlockRecipeGenerator extends RecipeProvider { //Canola Press Recipe.shaped(ActuallyBlocks.CANOLA_PRESS.getItem()) .pattern("CEC","CXC","CAC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('E', ActuallyItems.ENORI_CRYSTAL) .define('X', ActuallyItems.CANOLA) .define('A', ActuallyItems.ADVANCED_COIL) @@ -265,7 +267,7 @@ public class BlockRecipeGenerator extends RecipeProvider { //Oil Generator Recipe.shaped(ActuallyBlocks.OIL_GENERATOR.getItem()) .pattern("CIC","CAC","CIC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('A', ActuallyItems.CANOLA) .define('I', ActuallyBlocks.IRON_CASING.getItem()) .save(recipeOutput); @@ -273,7 +275,7 @@ public class BlockRecipeGenerator extends RecipeProvider { //Coal generator. Recipe.shaped(ActuallyBlocks.COAL_GENERATOR.getItem()) .pattern("CIC","CAC","CIC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('A', Items.COAL) .define('I', ActuallyBlocks.IRON_CASING.getItem()) .save(recipeOutput); @@ -281,7 +283,7 @@ public class BlockRecipeGenerator extends RecipeProvider { // Auto breaker. Recipe.shaped(ActuallyBlocks.BREAKER.getItem()) .pattern("CCC","CXV","CCC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('V', ActuallyItems.VOID_CRYSTAL) .define('X', ActuallyItems.BASIC_COIL) .save(recipeOutput); @@ -289,7 +291,7 @@ public class BlockRecipeGenerator extends RecipeProvider { // Auto placer. Recipe.shaped(ActuallyBlocks.PLACER.getItem()) .pattern("CCC", "CXP", "CCC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('P', ActuallyItems.PALIS_CRYSTAL) .define('X', ActuallyItems.BASIC_COIL) .save(recipeOutput); @@ -297,7 +299,7 @@ public class BlockRecipeGenerator extends RecipeProvider { // Dropper Recipe.shaped(ActuallyBlocks.DROPPER.getItem()) .pattern("CPC", "CDA", "CPC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('P', ActuallyItems.PALIS_CRYSTAL) .define('D', Items.DROPPER) .define('A', ActuallyItems.ADVANCED_COIL) @@ -332,7 +334,7 @@ public class BlockRecipeGenerator extends RecipeProvider { .pattern("EXC", "FIF", "CXE") .define('E', ActuallyItems.ENORI_CRYSTAL) .define('X', ActuallyItems.BASIC_COIL) - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('F', Items.FURNACE) .define('I', ActuallyBlocks.IRON_CASING.getItem()) .save(recipeOutput); @@ -340,7 +342,7 @@ public class BlockRecipeGenerator extends RecipeProvider { // Greenhouse glass Recipe.shaped(ActuallyBlocks.GREENHOUSE_GLASS.getItem(), 2) .pattern("GSG", "SES", "GSG") - .define('G', Tags.Items.GLASS) + .define('G', Tags.Items.GLASS_BLOCKS) .define('S', ItemTags.SAPLINGS) .define('E', ActuallyItems.EMPOWERED_PALIS_CRYSTAL) .save(recipeOutput); @@ -393,7 +395,7 @@ public class BlockRecipeGenerator extends RecipeProvider { .pattern("RFC", "BIB", "CFR") .define('R', ActuallyItems.RESTONIA_CRYSTAL.get()) .define('F', Items.FLINT) - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('I', ActuallyBlocks.IRON_CASING.get()) .define('B', ActuallyItems.BASIC_COIL.get()) .save(recipeOutput); @@ -401,7 +403,7 @@ public class BlockRecipeGenerator extends RecipeProvider { // Double Crusher Recipe.shaped(ActuallyBlocks.CRUSHER_DOUBLE.getItem()) .pattern("SAS", "CIC", "SAS") - .define('S', Tags.Items.COBBLESTONE) + .define('S', Tags.Items.COBBLESTONES) .define('A', ActuallyItems.ADVANCED_COIL.get()) .define('C', ActuallyBlocks.CRUSHER.get()) .define('I', ActuallyBlocks.IRON_CASING.get()) diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/CoffeeIngredientGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/CoffeeIngredientGenerator.java index 6c20b4dbe..360e94be5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/CoffeeIngredientGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/CoffeeIngredientGenerator.java @@ -2,6 +2,7 @@ package de.ellpeck.actuallyadditions.data; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; @@ -19,10 +20,11 @@ import net.neoforged.neoforge.common.conditions.NotCondition; import net.neoforged.neoforge.common.conditions.TagEmptyCondition; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class CoffeeIngredientGenerator extends RecipeProvider { - public CoffeeIngredientGenerator(PackOutput packOutput) { - super(packOutput); + public CoffeeIngredientGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -35,9 +37,9 @@ public class CoffeeIngredientGenerator extends RecipeProvider { buildIngredient(recipeOutput, Items.MILK_BUCKET, 0, "jei.actuallyadditions.coffee.extra.milk"); //Pam's puts milk in a tag, so we'll use that - TagKey milkTag = ItemTags.create(new ResourceLocation("forge", "milk")); + TagKey milkTag = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "milk")); RecipeOutput tagOutput = recipeOutput.withConditions(new NotCondition(new TagEmptyCondition(milkTag.location()))); - buildIngredient(tagOutput, new ResourceLocation(ActuallyAdditions.MODID, "coffee_ingredient/milk_tagged"), + buildIngredient(tagOutput, ActuallyAdditions.modLoc("coffee_ingredient/milk_tagged"), Ingredient.of(milkTag), 0, "jei.actuallyadditions.coffee.extra.milk"); buildIngredient(recipeOutput, Items.SUGAR, 4, new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 30, 0)); @@ -54,7 +56,7 @@ public class CoffeeIngredientGenerator extends RecipeProvider { } private void buildIngredient(RecipeOutput recipeOutput, ItemLike ingredient, int maxAmplifier, String extraText, MobEffectInstance... effects) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "coffee_ingredient/" + getItemName(ingredient)); + ResourceLocation id = ActuallyAdditions.modLoc("coffee_ingredient/" + getItemName(ingredient)); NonNullList instances = NonNullList.create(); for (MobEffectInstance effect : effects) { instances.add(new CoffeeIngredientRecipe.EffectInstance(effect)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ColorChangeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/ColorChangeGenerator.java index 8421fbe79..75b5a4712 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ColorChangeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ColorChangeGenerator.java @@ -4,21 +4,22 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.ColorChangeRecipe; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class ColorChangeGenerator extends RecipeProvider { - public ColorChangeGenerator(PackOutput packOutput) { - super(packOutput); + public ColorChangeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -195,15 +196,15 @@ public class ColorChangeGenerator extends RecipeProvider { private void changeColor(RecipeOutput consumer, ItemLike output, Ingredient input) { - consumer.accept(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), + consumer.accept(ActuallyAdditions.modLoc("colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), new ColorChangeRecipe(output.asItem().getDefaultInstance(), input), null); } private void changeColor(RecipeOutput consumer, ItemLike output, ItemLike input) { - consumer.accept(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), + consumer.accept(ActuallyAdditions.modLoc("colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), new ColorChangeRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input)), null); } private void changeColor(RecipeOutput consumer, ItemLike output, ItemStack input) { - consumer.accept(new ResourceLocation(ActuallyAdditions.MODID, "colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), + consumer.accept(ActuallyAdditions.modLoc("colorchange/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), new ColorChangeRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input)), null); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/CrushingRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/CrushingRecipeGenerator.java index 4b3492738..8f6840bc6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/CrushingRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/CrushingRecipeGenerator.java @@ -5,6 +5,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; @@ -15,10 +16,11 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class CrushingRecipeGenerator extends RecipeProvider { - public CrushingRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public CrushingRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -163,7 +165,7 @@ public class CrushingRecipeGenerator extends RecipeProvider { } public void save(RecipeOutput consumer, String name) { - ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "crushing/" + name); + ResourceLocation res = ActuallyAdditions.modLoc("crushing/" + name); if (results.size() != 2) throw new IllegalStateException("invalid result count: " + results.size() + ", recipe: " + name.toString()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java index 30fed90cb..7a5d940ea 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java @@ -6,6 +6,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.metalists.Crystals; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; @@ -21,9 +22,11 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.common.Tags; +import java.util.concurrent.CompletableFuture; + public class EmpoweringRecipeGenerator extends RecipeProvider { - public EmpoweringRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public EmpoweringRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -72,23 +75,23 @@ public class EmpoweringRecipeGenerator extends RecipeProvider { .addModifier(Tags.Items.DYES_GRAY) .addModifier(Items.SNOWBALL) .addModifier(Items.STONE_BUTTON) - .addModifier(Tags.Items.COBBLESTONE).save(recipeOutput, "enori"); + .addModifier(Tags.Items.COBBLESTONES).save(recipeOutput, "enori"); EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyBlocks.ENORI_CRYSTAL.get(), 50000, 500, Crystals.IRON.conversionColorParticles) .addModifier(Tags.Items.DYES_GRAY) .addModifier(Items.SNOWBALL) .addModifier(Items.STONE_BUTTON) - .addModifier(Tags.Items.COBBLESTONE).save(recipeOutput, "enori_block"); + .addModifier(Tags.Items.COBBLESTONES).save(recipeOutput, "enori_block"); EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_VOID_CRYSTAL.get(), ActuallyItems.VOID_CRYSTAL.get(), 5000, 50, Crystals.COAL.conversionColorParticles) .addModifier(Tags.Items.DYES_BLACK) .addModifier(ItemTags.COALS) .addModifier(Items.FLINT) - .addModifier(Tags.Items.STONE).save(recipeOutput, "void"); + .addModifier(Tags.Items.STONES).save(recipeOutput, "void"); EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_VOID_CRYSTAL.get(), ActuallyBlocks.VOID_CRYSTAL.get(), 50000, 500, Crystals.COAL.conversionColorParticles) .addModifier(Tags.Items.DYES_BLACK) .addModifier(ItemTags.COALS) .addModifier(Items.FLINT) - .addModifier(Tags.Items.STONE).save(recipeOutput, "void_block"); + .addModifier(Tags.Items.STONES).save(recipeOutput, "void_block"); EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyItems.EMERADIC_CRYSTAL.get(), 5000, 50, Crystals.EMERALD.conversionColorParticles) .addModifier(Tags.Items.DYES_LIME) @@ -159,7 +162,7 @@ public class EmpoweringRecipeGenerator extends RecipeProvider { } public void save(RecipeOutput consumer, String name) { - ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name); + ResourceLocation res = ActuallyAdditions.modLoc("empowering/" + name); if (modifiers.size() != 4) throw new IllegalStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java index dd1e26b95..906ae57e7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/FuelRecipeGenerator.java @@ -6,6 +6,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe; import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; @@ -17,10 +18,11 @@ import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.fluids.FluidStack; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class FuelRecipeGenerator extends RecipeProvider { - public FuelRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public FuelRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -39,29 +41,29 @@ public class FuelRecipeGenerator extends RecipeProvider { addSolid(recipeOutput, "coal-block", Items.COAL_BLOCK, 320000, 16000); addSolid(recipeOutput, "lava", Items.LAVA_BUCKET, 400000, 20000); - recipeOutput.accept(new ResourceLocation(ActuallyAdditions.MODID, "liquid_fuel/canola_oil"), new LiquidFuelRecipe( + recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/canola_oil"), new LiquidFuelRecipe( new FluidStack(InitFluids.CANOLA_OIL.get(), 50), 4000, 100), null); - recipeOutput.accept(new ResourceLocation(ActuallyAdditions.MODID, "liquid_fuel/refined_canola_oil"), new LiquidFuelRecipe( + recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/refined_canola_oil"), new LiquidFuelRecipe( new FluidStack(InitFluids.REFINED_CANOLA_OIL.get(), 50), 9600, 120), null); - recipeOutput.accept(new ResourceLocation(ActuallyAdditions.MODID, "liquid_fuel/crystallized_canola_oil"),new LiquidFuelRecipe( + recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/crystallized_canola_oil"),new LiquidFuelRecipe( new FluidStack(InitFluids.CRYSTALLIZED_OIL.get(), 50), 28000, 280), null); - recipeOutput.accept(new ResourceLocation(ActuallyAdditions.MODID, "liquid_fuel/empowered_canola_oil"), new LiquidFuelRecipe( + recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/empowered_canola_oil"), new LiquidFuelRecipe( new FluidStack(InitFluids.EMPOWERED_OIL.get(), 50), 48000, 400), null); } private void addSolid(RecipeOutput consumer, String name, Item item, int energy, int burnTime) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "solid_fuel/"+name); + ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); consumer.accept(id, new SolidFuelRecipe(Ingredient.of(item), energy, burnTime), null); } private void addSolid(RecipeOutput consumer, String name, Ingredient item, int energy, int burnTime) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "solid_fuel/"+name); + ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); consumer.accept(id, new SolidFuelRecipe(item, energy, burnTime), null); } private void addSolid(RecipeOutput consumer, String name, TagKey tag, int energy, int burnTime) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "solid_fuel/"+name); + ResourceLocation id = ActuallyAdditions.modLoc("solid_fuel/"+name); consumer.accept(id, new SolidFuelRecipe(Ingredient.of(tag), energy, burnTime), null); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/GlobalLootModifierGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/GlobalLootModifierGenerator.java index 2e8633d34..38a509490 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/GlobalLootModifierGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/GlobalLootModifierGenerator.java @@ -3,6 +3,7 @@ package de.ellpeck.actuallyadditions.data; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.lootmodifier.BatLootModifier; import de.ellpeck.actuallyadditions.mod.lootmodifier.DungeonLootModifier; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.storage.loot.BuiltInLootTables; @@ -12,9 +13,11 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemKilledByPlayerC import net.neoforged.neoforge.common.data.GlobalLootModifierProvider; import net.neoforged.neoforge.common.loot.LootTableIdCondition; +import java.util.concurrent.CompletableFuture; + public class GlobalLootModifierGenerator extends GlobalLootModifierProvider { - public GlobalLootModifierGenerator(PackOutput packOutput) { - super(packOutput, ActuallyAdditions.MODID); + public GlobalLootModifierGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider, ActuallyAdditions.MODID); } @Override @@ -22,20 +25,20 @@ public class GlobalLootModifierGenerator extends GlobalLootModifierProvider { this.add("bat_loot", new BatLootModifier( new LootItemCondition[]{ LootItemKilledByPlayerCondition.killedByPlayer().build(), - LootTableIdCondition.builder(EntityType.BAT.getDefaultLootTable()).build() + LootTableIdCondition.builder(EntityType.BAT.getDefaultLootTable().location()).build() })); this.add("dungeon_loot", new DungeonLootModifier( new LootItemCondition[]{ AnyOfCondition.anyOf( - LootTableIdCondition.builder(BuiltInLootTables.SIMPLE_DUNGEON), - LootTableIdCondition.builder(BuiltInLootTables.ABANDONED_MINESHAFT), - LootTableIdCondition.builder(BuiltInLootTables.VILLAGE_WEAPONSMITH), - LootTableIdCondition.builder(BuiltInLootTables.STRONGHOLD_LIBRARY), - LootTableIdCondition.builder(BuiltInLootTables.IGLOO_CHEST), - LootTableIdCondition.builder(BuiltInLootTables.DESERT_PYRAMID), - LootTableIdCondition.builder(BuiltInLootTables.NETHER_BRIDGE), - LootTableIdCondition.builder(BuiltInLootTables.END_CITY_TREASURE), - LootTableIdCondition.builder(BuiltInLootTables.WOODLAND_MANSION) + LootTableIdCondition.builder(BuiltInLootTables.SIMPLE_DUNGEON.location()), + LootTableIdCondition.builder(BuiltInLootTables.ABANDONED_MINESHAFT.location()), + LootTableIdCondition.builder(BuiltInLootTables.VILLAGE_WEAPONSMITH.location()), + LootTableIdCondition.builder(BuiltInLootTables.STRONGHOLD_LIBRARY.location()), + LootTableIdCondition.builder(BuiltInLootTables.IGLOO_CHEST.location()), + LootTableIdCondition.builder(BuiltInLootTables.DESERT_PYRAMID.location()), + LootTableIdCondition.builder(BuiltInLootTables.NETHER_BRIDGE.location()), + LootTableIdCondition.builder(BuiltInLootTables.END_CITY_TREASURE.location()), + LootTableIdCondition.builder(BuiltInLootTables.WOODLAND_MANSION.location()) ).build() })); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ItemModelGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/ItemModelGenerator.java index d566ea336..bdb744316 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ItemModelGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ItemModelGenerator.java @@ -66,11 +66,11 @@ public class ItemModelGenerator extends ItemModelProvider { String wormpath = ActuallyItems.WORM.getId().getPath(); singleTexture(wormpath, mcLoc("item/handheld"), "layer0", modLoc("item/" + wormpath)) - .override().predicate(new ResourceLocation(ActuallyAdditions.MODID, "snail"), 1F) + .override().predicate(ActuallyAdditions.modLoc("snail"), 1F) .model(singleTexture("snail", mcLoc("item/handheld"), "layer0", modLoc("item/snail"))).end(); /* withExistingParent(wormpath, mcLoc("item/handheld")) .texture("layer0", modLoc("item/" + wormpath)) - .override().predicate(new ResourceLocation(ActuallyAdditions.MODID, "snail"), 1F) + .override().predicate(ActuallyAdditions.modLoc("snail"), 1F) .model(getBuilder("snail").parent(getExistingFile(mcLoc("item/handheld"))).texture("layer0", "item/snail")).end();*/ String torchPath = BuiltInRegistries.ITEM.getKey(ActuallyBlocks.TINY_TORCH.getItem()).getPath(); @@ -87,7 +87,7 @@ public class ItemModelGenerator extends ItemModelProvider { if (block.get() instanceof WallBlock) { String name = path; path = "block/" + path.replace("_wall", "_block"); - withExistingParent(name, new ResourceLocation("block/wall_inventory")) + withExistingParent(name, ResourceLocation.tryParse("block/wall_inventory")) .texture("wall", modLoc(path)); return; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ItemRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/ItemRecipeGenerator.java index acdd7638a..8ae599546 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ItemRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ItemRecipeGenerator.java @@ -10,7 +10,9 @@ import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; import de.ellpeck.actuallyadditions.mod.util.RecipeInjector; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -29,16 +31,18 @@ import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapelessRecipe; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.ItemLike; +import net.neoforged.neoforge.common.CommonHooks; import net.neoforged.neoforge.common.Tags; -import net.neoforged.neoforge.common.crafting.NBTIngredient; +import net.neoforged.neoforge.common.crafting.DataComponentIngredient; import net.neoforged.neoforge.registries.DeferredItem; import javax.annotation.Nonnull; import java.util.Arrays; +import java.util.concurrent.CompletableFuture; public class ItemRecipeGenerator extends RecipeProvider { - public ItemRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public ItemRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -48,6 +52,7 @@ public class ItemRecipeGenerator extends RecipeProvider { @Override protected void buildRecipes(@Nonnull RecipeOutput output) { + var enchantmentLookup = CommonHooks.resolveLookup(Registries.ENCHANTMENT); var recipeOutput = new NoAdvRecipeOutput(output); generateAOIT(recipeOutput); @@ -58,7 +63,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("IGI") .define('R', ActuallyItems.RESTONIA_CRYSTAL.get()) .define('I', Items.IRON_BARS) - .define('G', Tags.Items.GLASS).save(recipeOutput); + .define('G', Tags.Items.GLASS_BLOCKS).save(recipeOutput); //Advanced Goggles Recipe.shaped(ActuallyItems.ENGINEERS_GOGGLES_ADVANCED.get()) @@ -74,7 +79,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("GGG") .pattern("RCR") .pattern("GGG") - .define('G', Tags.Items.GLASS_BLACK) + .define('G', Items.BLACK_STAINED_GLASS) .define('R', ActuallyItems.VOID_CRYSTAL.get()) .define('C', ActuallyItems.ADVANCED_COIL.get()).save(recipeOutput); @@ -103,8 +108,8 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("SLS") .pattern("SCS") .pattern("LVL") - .define('S', Tags.Items.STRING) - .define('L', Tags.Items.LEATHER) + .define('S', Tags.Items.STRINGS) + .define('L', Tags.Items.LEATHERS) .define('C', Tags.Items.CHESTS_WOODEN) .define('V', ActuallyBlocks.VOID_CRYSTAL.getItem()).save(recipeOutput); @@ -112,7 +117,7 @@ public class ItemRecipeGenerator extends RecipeProvider { Recipe.shapeless(ActuallyItems.VOID_SACK.get()) .requires(ActuallyItems.TRAVELERS_SACK.get()) .requires(Tags.Items.ENDER_PEARLS) - .requires(Tags.Items.OBSIDIAN) + .requires(Tags.Items.OBSIDIANS) .requires(ActuallyBlocks.VOID_CRYSTAL.getItem()) .save(recipeOutput); @@ -121,7 +126,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("GGG") .pattern("GBG") .pattern("GGG") - .define('G', Tags.Items.GLASS) + .define('G', Tags.Items.GLASS_BLOCKS) .define('B', ActuallyItems.BLACK_QUARTZ.get()).save(recipeOutput); //Booklet @@ -130,8 +135,8 @@ public class ItemRecipeGenerator extends RecipeProvider { //Clearing NBT Storage - Recipe.shapeless(ActuallyItems.LASER_WRENCH.get()).ingredients(ActuallyItems.LASER_WRENCH.get()).name(new ResourceLocation(ActuallyAdditions.MODID, "laser_wrench_nbt")).save(recipeOutput); - Recipe.shapeless(ActuallyItems.PHANTOM_CONNECTOR.get()).ingredients(ActuallyItems.PHANTOM_CONNECTOR.get()).name(new ResourceLocation(ActuallyAdditions.MODID, "phantom_clearing")).save(recipeOutput); + Recipe.shapeless(ActuallyItems.LASER_WRENCH.get()).ingredients(ActuallyItems.LASER_WRENCH.get()).name(ActuallyAdditions.modLoc("laser_wrench_nbt")).save(recipeOutput); + Recipe.shapeless(ActuallyItems.PHANTOM_CONNECTOR.get()).ingredients(ActuallyItems.PHANTOM_CONNECTOR.get()).name(ActuallyAdditions.modLoc("phantom_clearing")).save(recipeOutput); //Disenchanting Lens Recipe.shapeless(ActuallyItems.LENS_OF_DISENCHANTING.get()) @@ -156,12 +161,13 @@ public class ItemRecipeGenerator extends RecipeProvider { //Killer Lens ItemStack enchantedBook = new ItemStack(Items.ENCHANTED_BOOK); - enchantedBook.enchant(Enchantments.SHARPNESS, 5); + if (enchantmentLookup != null) { + enchantedBook.enchant(enchantmentLookup.getOrThrow(Enchantments.SHARPNESS), 5); + } Recipe.shapeless(ActuallyItems.LENS_OF_THE_KILLER.get()) - .requires(Items.DIAMOND_SWORD) - .requires(ActuallyItems.LENS_OF_CERTAIN_DEATH.get()) - .requires(NBTIngredient.of(true, enchantedBook)).save(recipeOutput); - + .requires(Items.DIAMOND_SWORD) + .requires(ActuallyItems.LENS_OF_CERTAIN_DEATH.get()) + .requires(DataComponentIngredient.of(true, enchantedBook)).save(recipeOutput); //Filter Recipe.shaped(ActuallyItems.FILTER.get()) @@ -194,7 +200,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("R ") .pattern(" R ") .pattern(" R") - .define('R', ActuallyItems.RICE).save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "rice_paper")); + .define('R', ActuallyItems.RICE).save(recipeOutput, ActuallyAdditions.modLoc("rice_paper")); Recipe.shaped(ActuallyItems.RICE_SLIMEBALL.get()) .requiresBook() @@ -203,7 +209,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern(" R ") .define('R', ActuallyItems.RICE_DOUGH.get()) .define('B', Items.WATER_BUCKET) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "rice_slime")); + .save(recipeOutput, ActuallyAdditions.modLoc("rice_slime")); Recipe.shaped(ActuallyItems.RICE_SLIMEBALL.get()) .requiresBook() @@ -212,7 +218,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern(" R ") .define('R', ActuallyItems.RICE_DOUGH.get()) .define('B', Items.POTION) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "rice_slime_potion")); + .save(recipeOutput, ActuallyAdditions.modLoc("rice_slime_potion")); //Leaf Blower Recipe.shaped(ActuallyItems.LEAF_BLOWER.get()) @@ -357,7 +363,7 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("CEC") .pattern("RAR") .pattern("CEC") - .define('C', Tags.Items.COBBLESTONE) + .define('C', Tags.Items.COBBLESTONES) .define('E', Items.PAPER) .define('A', ActuallyItems.BASIC_COIL.get()) .define('R', ActuallyItems.ENORI_CRYSTAL.get()).save(recipeOutput); @@ -460,15 +466,15 @@ public class ItemRecipeGenerator extends RecipeProvider { Recipe.shapeless(ActuallyItems.TINY_COAL.get(), 8) .requires(Items.COAL) - .save(boolConsumer, new ResourceLocation(ActuallyAdditions.MODID, "coal_to_tiny")); + .save(boolConsumer, ActuallyAdditions.modLoc("coal_to_tiny")); Recipe.shapeless(ActuallyItems.TINY_CHARCOAL.get(), 8) - .requires(Items.CHARCOAL).save(boolConsumer, new ResourceLocation(ActuallyAdditions.MODID, "charcoal_to_tiny")); + .requires(Items.CHARCOAL).save(boolConsumer, ActuallyAdditions.modLoc("charcoal_to_tiny")); Recipe.shaped(Items.COAL) .pattern("CCC", "C C", "CCC").define('C', ActuallyItems.TINY_COAL.get()) - .save(boolConsumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_to_coal")); + .save(boolConsumer, ActuallyAdditions.modLoc("tiny_to_coal")); Recipe.shaped(Items.CHARCOAL) .pattern("CCC", "C C", "CCC").define('C', ActuallyItems.TINY_CHARCOAL.get()) - .save(boolConsumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_to_charcoal")); + .save(boolConsumer, ActuallyAdditions.modLoc("tiny_to_charcoal")); //Canola Seeds Recipe.shapeless(ActuallyItems.CANOLA_SEEDS.get()) @@ -496,7 +502,7 @@ public class ItemRecipeGenerator extends RecipeProvider { //Cup Recipe.shaped(ActuallyItems.EMPTY_CUP.get()) .pattern("S S", "SCS", "SSS") - .define('S', Tags.Items.STONE) + .define('S', Tags.Items.STONES) .define('C', ActuallyItems.COFFEE_BEANS.get()) .save(recipeOutput); @@ -528,13 +534,13 @@ public class ItemRecipeGenerator extends RecipeProvider { .pattern("R", "P") .define('R', Tags.Items.SLIMEBALLS) .define('P', Items.PISTON) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "tagged_sticky_piston")); + .save(recipeOutput, ActuallyAdditions.modLoc("tagged_sticky_piston")); // Slime block from tagged balls Recipe.shaped(Items.SLIME_BLOCK) .pattern("RRR", "RRR", "RRR") .define('R', Tags.Items.SLIMEBALLS) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "tagged_slime_block")); + .save(recipeOutput, ActuallyAdditions.modLoc("tagged_slime_block")); //Shards addShard(recipeOutput, ActuallyItems.VOID_CRYSTAL_SHARD, ActuallyItems.VOID_CRYSTAL); @@ -576,15 +582,15 @@ public class ItemRecipeGenerator extends RecipeProvider { SimpleCookingRecipeBuilder.smelting(Ingredient.of(ActuallyItems.RICE_DOUGH), RecipeCategory.FOOD, Items.BREAD, 0.35F, 200) .unlockedBy("", has(Items.AIR)) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "rice_dough_smelting")); + .save(recipeOutput, ActuallyAdditions.modLoc("rice_dough_smelting")); // Black Quartz Ore SimpleCookingRecipeBuilder.smelting(Ingredient.of(ActuallyBlocks.BLACK_QUARTZ_ORE.getItem()), RecipeCategory.MISC, ActuallyItems.BLACK_QUARTZ.get(), 0.7F, 200) .unlockedBy("", has(Items.AIR)) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "black_quartz_ore_smelting")); + .save(recipeOutput, ActuallyAdditions.modLoc("black_quartz_ore_smelting")); SimpleCookingRecipeBuilder.blasting(Ingredient.of(ActuallyBlocks.BLACK_QUARTZ_ORE.getItem()), RecipeCategory.MISC, ActuallyItems.BLACK_QUARTZ.get(), 0.7F, 100) .unlockedBy("", has(Items.AIR)) - .save(recipeOutput, new ResourceLocation(ActuallyAdditions.MODID, "black_quartz_ore_blasting")); + .save(recipeOutput, ActuallyAdditions.modLoc("black_quartz_ore_blasting")); //Patterns Recipe.shapeless(ActuallyItems.DRILL_PATTERN.get()) @@ -616,9 +622,9 @@ public class ItemRecipeGenerator extends RecipeProvider { private static void dyeDrill(DeferredItem result, TagKey dyeItem, RecipeOutput recipeOutput) { Recipe.shapeless(result.get()) - .requires(TargetNBTIngredient.of(ActuallyTags.Items.DRILLS)) + .requires(Ingredient.of(ActuallyTags.Items.DRILLS)) //TargetNBTIngredient .requires(dyeItem) - .save(new RecipeInjector(recipeOutput, RecipeKeepDataShapeless::new), new ResourceLocation(ActuallyAdditions.MODID, "drill_coloring/dye_" + BuiltInRegistries.ITEM.getKey(result.get()).getPath())); + .save(new RecipeInjector(recipeOutput, RecipeKeepDataShapeless::new), ActuallyAdditions.modLoc("drill_coloring/dye_" + BuiltInRegistries.ITEM.getKey(result.get()).getPath())); } public static void addPaxel(RecipeOutput consumer, DeferredItem output, Item axe, Item pickaxe, Item sword, Item shovel, Item hoe) { @@ -643,11 +649,11 @@ public class ItemRecipeGenerator extends RecipeProvider { public static void decompress(RecipeOutput consumer, ItemLike output, ItemLike input) { ResourceLocation key = BuiltInRegistries.ITEM.getKey(output.asItem()); - Recipe.shapeless(output, 9).requires(input).save(consumer, new ResourceLocation(key.getNamespace(), "decompress/" + key.getPath())); + Recipe.shapeless(output, 9).requires(input).save(consumer, ResourceLocation.fromNamespaceAndPath(key.getNamespace(), "decompress/" + key.getPath())); } public static void compress(RecipeOutput consumer, ItemLike output, ItemLike input) { ResourceLocation key = BuiltInRegistries.ITEM.getKey(output.asItem()); - Recipe.shaped(output).pattern("xxx","xxx", "xxx").define('x', input).save(consumer, new ResourceLocation(key.getNamespace(), "compress/" + key.getPath())); + Recipe.shaped(output).pattern("xxx","xxx", "xxx").define('x', input).save(consumer, ResourceLocation.fromNamespaceAndPath(key.getNamespace(), "compress/" + key.getPath())); } public static void addShard(RecipeOutput consumer, DeferredItem shard, DeferredItem crystal) { compress(consumer, crystal, shard); diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/LaserRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/LaserRecipeGenerator.java index e7d6868e1..6b8d39ffe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/LaserRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/LaserRecipeGenerator.java @@ -5,6 +5,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; @@ -19,10 +20,11 @@ import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.common.Tags; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class LaserRecipeGenerator extends RecipeProvider { - public LaserRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public LaserRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -62,7 +64,7 @@ public class LaserRecipeGenerator extends RecipeProvider { laserRecipe(recipeOutput, ActuallyBlocks.LASER_RELAY.getItem(), ActuallyBlocks.LASER_RELAY_ITEM.getItem(), 2000); //Misc - laserRecipe(recipeOutput, Items.SOUL_SAND, Tags.Items.SAND, 20000); + laserRecipe(recipeOutput, Items.SOUL_SAND, Tags.Items.SANDS, 20000); laserRecipe(recipeOutput, Items.LEATHER, Items.ROTTEN_FLESH, 20000); laserRecipe(recipeOutput, Items.NETHER_WART, Items.RED_MUSHROOM, 150000); laserRecipe(recipeOutput, Items.PRISMARINE_SHARD, Items.QUARTZ, 30000); @@ -73,27 +75,27 @@ public class LaserRecipeGenerator extends RecipeProvider { } private void laserRecipe(RecipeOutput consumer, ItemLike output, Ingredient input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), input, energy), null); } private void laserRecipe(RecipeOutput consumer, ItemLike output, TagKey input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input), energy), null); } private void laserRecipe(RecipeOutput consumer, ItemLike output, ItemLike input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input), energy), null);; } private void laserCrystalizeRecipe(RecipeOutput consumer, ItemLike output, Ingredient input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), input, energy), null); } private void laserCrystalizeRecipe(RecipeOutput consumer, ItemLike output, TagKey input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input), energy), null); } private void laserCrystalizeRecipe(RecipeOutput consumer, ItemLike output, ItemLike input, int energy) { - ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + ResourceLocation id = ActuallyAdditions.modLoc("laser/crystalize_" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); consumer.accept(id, new LaserRecipe(output.asItem().getDefaultInstance(), Ingredient.of(input), energy), null); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java index 368797192..e9ad445c2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java @@ -4,15 +4,19 @@ package de.ellpeck.actuallyadditions.data; import com.google.common.collect.ImmutableSet; import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import net.minecraft.advancements.critereon.StatePropertiesPredicate; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.WritableRegistry; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; import net.minecraft.data.loot.LootTableSubProvider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.ProblemReporter; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -23,50 +27,50 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.TagEntry; -import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction; +import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction; import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; -import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import net.neoforged.neoforge.registries.DeferredHolder; -import javax.annotation.Nonnull; import java.util.List; -import java.util.Map; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; public class LootTableGenerator extends LootTableProvider { - public LootTableGenerator(PackOutput packOutput) { + public LootTableGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { super(packOutput, Set.of(), List.of( new SubProviderEntry(Blocks::new, LootContextParamSets.BLOCK), new SubProviderEntry(Dungeon::new, LootContextParamSets.CHEST) - )); + ), lookupProvider); } @Override - protected void validate(Map map, @Nonnull ValidationContext validationtracker) { - map.forEach((name, table) -> table.validate(validationtracker)); + protected void validate(WritableRegistry writableregistry, ValidationContext validationcontext, ProblemReporter.Collector problemreporter$collector) { + super.validate(writableregistry, validationcontext, problemreporter$collector); } public static class Blocks extends BlockLootSubProvider { - protected Blocks() { - super(Set.of(), FeatureFlags.REGISTRY.allFlags()); + protected Blocks(HolderLookup.Provider lookupProvider) { + super(Set.of(), FeatureFlags.REGISTRY.allFlags(), lookupProvider); } @Override protected void generate() { - CopyNbtFunction.Builder copyEnergy = CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("Energy", "BlockEntityTag.Energy"); - CopyNbtFunction.Builder copyPulseMode = CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("IsPulseMode", "BlockEntityTag.IsPulseMode"); + CopyComponentsFunction.Builder copyEnergy = CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY) + .include(ActuallyComponents.ENERGY_STORAGE.get()); + CopyComponentsFunction.Builder copyPulseMode = CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY) + .include(ActuallyComponents.PULSE_MODE.get()); //Special Drops - dropNBT(ActuallyBlocks.ATOMIC_RECONSTRUCTOR, $ -> $.apply(copyEnergy).apply(copyPulseMode)); + dropComponents(ActuallyBlocks.ATOMIC_RECONSTRUCTOR, $ -> $.apply(copyEnergy).apply(copyPulseMode)); dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND); dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR); dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR); @@ -214,7 +218,7 @@ public class LootTableGenerator extends LootTableProvider { } - private void dropNBT(Supplier blockSupplier, Consumer lootFunctionProvider) { + private void dropComponents(Supplier blockSupplier, Consumer lootFunctionProvider) { LootPool.Builder lootpool = LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(LootItem.lootTableItem(blockSupplier.get())); lootFunctionProvider.accept(lootpool); @@ -222,7 +226,8 @@ public class LootTableGenerator extends LootTableProvider { add(blockSupplier.get(), LootTable.lootTable().withPool(applyExplosionCondition(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get(), lootpool))); } private void dropKeepEnergy(Supplier blockSupplier) { - dropNBT(blockSupplier, $ -> $.apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("Energy", "BlockEntityTag.Energy"))); + dropComponents(blockSupplier, $ -> $.apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY) + .include(ActuallyComponents.ENERGY_STORAGE.get()))); } /* // This isn't quite right :cry: fortune doesn't change it @@ -251,8 +256,12 @@ public class LootTableGenerator extends LootTableProvider { } public static class Dungeon implements LootTableSubProvider { + public Dungeon(HolderLookup.Provider provider) { + + } + @Override - public void generate(BiConsumer pOutput) { + public void generate(BiConsumer, LootTable.Builder> pOutput) { // addCrystals = true; pOutput.accept( diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/MiningLensGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/MiningLensGenerator.java index 5b6ff69bc..33f3ad9ff 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/MiningLensGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/MiningLensGenerator.java @@ -4,6 +4,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; @@ -16,10 +17,11 @@ import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.common.Tags; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class MiningLensGenerator extends RecipeProvider { - public MiningLensGenerator(PackOutput packOutput) { - super(packOutput); + public MiningLensGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -37,14 +39,14 @@ public class MiningLensGenerator extends RecipeProvider { // } private ResourceLocation folderRecipe(String folder, String recipe) { - return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe); + return ActuallyAdditions.modLoc(folder + "/" + recipe); } private void buildStoneOre(RecipeOutput consumer, int weight, ItemLike output) { - buildTagOre(consumer, Tags.Items.STONE, "stone", weight, output); + buildTagOre(consumer, Tags.Items.STONES, "stone", weight, output); } private void buildNetherOre(RecipeOutput consumer, int weight, ItemLike output) { - buildTagOre(consumer, Tags.Items.NETHERRACK, "nether", weight, output); + buildTagOre(consumer, Tags.Items.NETHERRACKS, "nether", weight, output); } private void buildDeepSlateOre(RecipeOutput consumer, int weight, ItemLike output) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/MiscMachineRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/MiscMachineRecipeGenerator.java index 9be0cb1dd..79f6b41bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/MiscMachineRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/MiscMachineRecipeGenerator.java @@ -6,6 +6,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; @@ -14,10 +15,11 @@ import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.fluids.FluidStack; import javax.annotation.Nonnull; +import java.util.concurrent.CompletableFuture; public class MiscMachineRecipeGenerator extends RecipeProvider { - public MiscMachineRecipeGenerator(PackOutput packOutput) { - super(packOutput); + public MiscMachineRecipeGenerator(PackOutput packOutput, CompletableFuture lookupProvider) { + super(packOutput, lookupProvider); } @Override @@ -41,6 +43,6 @@ public class MiscMachineRecipeGenerator extends RecipeProvider { // } private ResourceLocation folderRecipe(String folder, String recipe) { - return new ResourceLocation(ActuallyAdditions.MODID, folder + "/" + recipe); + return ActuallyAdditions.modLoc(folder + "/" + recipe); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/SoundsGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/SoundsGenerator.java index 8edbc3fe9..59786c975 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/SoundsGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/SoundsGenerator.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.data; import de.ellpeck.actuallyadditions.mod.AASounds; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.common.data.ExistingFileHelper; import net.neoforged.neoforge.common.data.SoundDefinitionsProvider; @@ -15,10 +14,10 @@ public class SoundsGenerator extends SoundDefinitionsProvider { @Override public void registerSounds() { - add(AASounds.RECONSTRUCTOR, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "reconstructor")))); - add(AASounds.CRUSHER, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "crusher")))); - add(AASounds.COFFEE_MACHINE, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine")))); - add(AASounds.DUH_DUH_DUH_DUUUH, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh")))); - add(AASounds.VILLAGER_WORK_ENGINEER, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine")))); + add(AASounds.RECONSTRUCTOR, definition().with(sound(ActuallyAdditions.modLoc("reconstructor")))); + add(AASounds.CRUSHER, definition().with(sound(ActuallyAdditions.modLoc("crusher")))); + add(AASounds.COFFEE_MACHINE, definition().with(sound(ActuallyAdditions.modLoc("coffee_machine")))); + add(AASounds.DUH_DUH_DUH_DUUUH, definition().with(sound(ActuallyAdditions.modLoc("duh_duh_duh_duuuh")))); + add(AASounds.VILLAGER_WORK_ENGINEER, definition().with(sound(ActuallyAdditions.modLoc("coffee_machine")))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/patchouli/PachouliGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/patchouli/PachouliGenerator.java index 7b3d96a22..6dec5da19 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/patchouli/PachouliGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/patchouli/PachouliGenerator.java @@ -1,125 +1,125 @@ -package de.ellpeck.actuallyadditions.data.patchouli; - -import de.ellpeck.actuallyadditions.data.patchouli.builder.ReconstructorPageBuilder; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import xyz.brassgoggledcoders.patchouliprovider.BookBuilder; -import xyz.brassgoggledcoders.patchouliprovider.CategoryBuilder; -import xyz.brassgoggledcoders.patchouliprovider.EntryBuilder; -import xyz.brassgoggledcoders.patchouliprovider.PatchouliBookProvider; - -import java.util.function.Consumer; - -public class PachouliGenerator extends PatchouliBookProvider { - - public PachouliGenerator(PackOutput output) { - super(output, ActuallyAdditions.MODID, "en_us"); - } - - @Override - protected void addBooks(Consumer consumer) { - final ItemStack bookStack = ActuallyItems.ITEM_BOOKLET.get().getDefaultInstance(); - - BookBuilder bookBuilder = createBookBuilder("booklet", - prefix("item.actuallyadditions.booklet"), "To be perfectly honest, I never actually realized how much content Actually Additions has before. - Ellpeck") - .setVersion("153") - .setCreativeTab("actuallyadditions.tab") - .setCustomBookItem(bookStack) - .setBookTexture("actuallyadditions:textures/gui/booklet/booklet.png") - .setShowProgress(false) - .setUseBlockyFont(false) - .setI18n(true) - .setDontGenerateBook(true) - .addMacro("", "$(2)") - .addMacro("", "$(9)") - .addMacro("", "$()") - .addMacro("", "$(br)") - .addMacro("", "$(o)") - .addMacro("", "$(4)$(n)") - .setUseResourcePack(true); - - - //Getting Started - CategoryBuilder gettingStarted = bookBuilder.addCategory("getting_started", prefix("indexEntry.getting_started"), - "", bookStack); - - gettingStarted.addEntry("tutorial", prefix("chapter.book_tutorial"), bookStack) - .addTextPage(prefix("chapter.book_tutorial.text.1")).build() - .addTextPage(prefix("chapter.book_tutorial.text.2")).build() - .addTextPage(prefix("chapter.book_tutorial.text.3")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "booklet")) - .setTitle("").setText("booklet.actuallyadditions.shapeless_recipe").build(); - - gettingStarted.addEntry("guide", prefix("chapter.video_guide"), "actuallyadditions:textures/item/youtube.png") - .addLinkPage("https://www.youtube.com/watch?v=fhjz0Ew56pM", prefix("chapter.video_guide.booty.button")) - .setText(prefix("chapter.video_guide.booty.text.1")).build() - .addTextPage(prefix("chapter.video_guide.booty.text.2")).build() - .addLinkPage("https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF", prefix("chapter.video_guide.booty.button")) - .setText(prefix("chapter.video_guide.dire.text.1")).build() - .addTextPage(prefix("chapter.video_guide.dire.text.2")).build(); - - gettingStarted.addEntry("intro", prefix("chapter.intro"), bookStack) - .addTextPage(prefix("chapter.intro.text.1")).build() - .addTextPage(prefix("chapter.intro.text.2")).build() - .addTextPage(prefix("chapter.intro.text.3")).build() - .addTextPage(prefix("chapter.intro.text.4")).build(); - - gettingStarted.addEntry("engineer_house", prefix("chapter.engineer_house"), bookStack) - .addTextPage(prefix("chapter.engineer_house.text.1")).build() - .addImagePage(new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/booklet/page_engineer_house.png")) - .setText("booklet.actuallyadditions.chapter.engineer_house.text.2").build(); - - EntryBuilder crystalsBuilder = gettingStarted.addEntry("crystals", prefix("chapter.crystals"), bookStack) - .addTextPage(prefix("chapter.crystals.text.1")).build() - .addTextPage(prefix("chapter.crystals.text.2")).build() - .addTextPage(prefix("chapter.crystals.text.3")).build() - .addImagePage(new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/booklet/page_atomic_reconstructor.png")).setBorder(false).build() - .addTextPage(prefix("chapter.crystals.text.5")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "atomic_reconstructor")) - .setText(prefix("chapter.crystals.text.6")).build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_restonia_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_restonia_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_palis_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_palis_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_diamatine_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_diamatine_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_void_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_void_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_emeradic_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_emeradic_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addPage(new ReconstructorPageBuilder(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_enori_crystal_block"), crystalsBuilder)) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "laser/crystalize_enori_crystal")) - .setText("booklet.actuallyadditions.reconstructor_recipe").build(); - crystalsBuilder.addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/restonia_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/restonia_crystal_block")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/palis_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/palis_crystal_block")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/diamatine_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/diamatine_crystal_block")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/void_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/void_crystal_block")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/emeradic_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/emeradic_crystal_block")).build() - .addCraftingPage(new ResourceLocation(ActuallyAdditions.MODID, "decompress/enori_crystal")) - .setRecipe2(new ResourceLocation(ActuallyAdditions.MODID, "compress/enori_crystal_block")).build(); - crystalsBuilder.build(); - - //End of Getting Started - - - //Finish book - bookBuilder.build(consumer); - } - - private String prefix(String name) { - return "booklet.actuallyadditions." + name; - } -} +//package de.ellpeck.actuallyadditions.data.patchouli; +// +//import de.ellpeck.actuallyadditions.data.patchouli.builder.ReconstructorPageBuilder; +//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; +//import net.minecraft.data.PackOutput; +//import net.minecraft.resources.ResourceLocation; +//import net.minecraft.world.item.ItemStack; +//import xyz.brassgoggledcoders.patchouliprovider.BookBuilder; +//import xyz.brassgoggledcoders.patchouliprovider.CategoryBuilder; +//import xyz.brassgoggledcoders.patchouliprovider.EntryBuilder; +//import xyz.brassgoggledcoders.patchouliprovider.PatchouliBookProvider; +// +//import java.util.function.Consumer; +// +//public class PachouliGenerator extends PatchouliBookProvider { +// +// public PachouliGenerator(PackOutput output) { +// super(output, ActuallyAdditions.MODID, "en_us"); +// } +// +// @Override +// protected void addBooks(Consumer consumer) { +// final ItemStack bookStack = ActuallyItems.ITEM_BOOKLET.get().getDefaultInstance(); +// +// BookBuilder bookBuilder = createBookBuilder("booklet", +// prefix("item.actuallyadditions.booklet"), "To be perfectly honest, I never actually realized how much content Actually Additions has before. - Ellpeck") +// .setVersion("153") +// .setCreativeTab("actuallyadditions.tab") +// .setCustomBookItem(bookStack) +// .setBookTexture("actuallyadditions:textures/gui/booklet/booklet.png") +// .setShowProgress(false) +// .setUseBlockyFont(false) +// .setI18n(true) +// .setDontGenerateBook(true) +// .addMacro("", "$(2)") +// .addMacro("", "$(9)") +// .addMacro("", "$()") +// .addMacro("", "$(br)") +// .addMacro("", "$(o)") +// .addMacro("", "$(4)$(n)") +// .setUseResourcePack(true); +// +// +// //Getting Started +// CategoryBuilder gettingStarted = bookBuilder.addCategory("getting_started", prefix("indexEntry.getting_started"), +// "", bookStack); +// +// gettingStarted.addEntry("tutorial", prefix("chapter.book_tutorial"), bookStack) +// .addTextPage(prefix("chapter.book_tutorial.text.1")).build() +// .addTextPage(prefix("chapter.book_tutorial.text.2")).build() +// .addTextPage(prefix("chapter.book_tutorial.text.3")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("booklet")) +// .setTitle("").setText("booklet.actuallyadditions.shapeless_recipe").build(); +// +// gettingStarted.addEntry("guide", prefix("chapter.video_guide"), "actuallyadditions:textures/item/youtube.png") +// .addLinkPage("https://www.youtube.com/watch?v=fhjz0Ew56pM", prefix("chapter.video_guide.booty.button")) +// .setText(prefix("chapter.video_guide.booty.text.1")).build() +// .addTextPage(prefix("chapter.video_guide.booty.text.2")).build() +// .addLinkPage("https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF", prefix("chapter.video_guide.booty.button")) +// .setText(prefix("chapter.video_guide.dire.text.1")).build() +// .addTextPage(prefix("chapter.video_guide.dire.text.2")).build(); +// +// gettingStarted.addEntry("intro", prefix("chapter.intro"), bookStack) +// .addTextPage(prefix("chapter.intro.text.1")).build() +// .addTextPage(prefix("chapter.intro.text.2")).build() +// .addTextPage(prefix("chapter.intro.text.3")).build() +// .addTextPage(prefix("chapter.intro.text.4")).build(); +// +// gettingStarted.addEntry("engineer_house", prefix("chapter.engineer_house"), bookStack) +// .addTextPage(prefix("chapter.engineer_house.text.1")).build() +// .addImagePage(ActuallyAdditions.modLoc("textures/gui/booklet/page_engineer_house.png")) +// .setText("booklet.actuallyadditions.chapter.engineer_house.text.2").build(); +// +// EntryBuilder crystalsBuilder = gettingStarted.addEntry("crystals", prefix("chapter.crystals"), bookStack) +// .addTextPage(prefix("chapter.crystals.text.1")).build() +// .addTextPage(prefix("chapter.crystals.text.2")).build() +// .addTextPage(prefix("chapter.crystals.text.3")).build() +// .addImagePage(ActuallyAdditions.modLoc("textures/gui/booklet/page_atomic_reconstructor.png")).setBorder(false).build() +// .addTextPage(prefix("chapter.crystals.text.5")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("atomic_reconstructor")) +// .setText(prefix("chapter.crystals.text.6")).build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_restonia_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_restonia_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_palis_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_palis_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_diamatine_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_diamatine_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_void_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_void_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_emeradic_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_emeradic_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addPage(new ReconstructorPageBuilder(ActuallyAdditions.modLoc("laser/crystalize_enori_crystal_block"), crystalsBuilder)) +// .setRecipe2(ActuallyAdditions.modLoc("laser/crystalize_enori_crystal")) +// .setText("booklet.actuallyadditions.reconstructor_recipe").build(); +// crystalsBuilder.addCraftingPage(ActuallyAdditions.modLoc("decompress/restonia_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/restonia_crystal_block")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("decompress/palis_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/palis_crystal_block")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("decompress/diamatine_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/diamatine_crystal_block")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("decompress/void_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/void_crystal_block")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("decompress/emeradic_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/emeradic_crystal_block")).build() +// .addCraftingPage(ActuallyAdditions.modLoc("decompress/enori_crystal")) +// .setRecipe2(ActuallyAdditions.modLoc("compress/enori_crystal_block")).build(); +// crystalsBuilder.build(); +// +// //End of Getting Started +// +// +// //Finish book +// bookBuilder.build(consumer); +// } +// +// private String prefix(String name) { +// return "booklet.actuallyadditions." + name; +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/AASounds.java b/src/main/java/de/ellpeck/actuallyadditions/mod/AASounds.java index de78719e2..cc68835b5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/AASounds.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/AASounds.java @@ -1,7 +1,6 @@ package de.ellpeck.actuallyadditions.mod; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.registries.DeferredHolder; @@ -10,11 +9,11 @@ import net.neoforged.neoforge.registries.DeferredRegister; public class AASounds { public static final DeferredRegister SOUNDS = DeferredRegister.create(BuiltInRegistries.SOUND_EVENT, ActuallyAdditions.MODID); - public static DeferredHolder RECONSTRUCTOR = SOUNDS.register("reconstructor", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "reconstructor"))); - public static DeferredHolder CRUSHER = SOUNDS.register("crusher", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "crusher"))); - public static DeferredHolder COFFEE_MACHINE = SOUNDS.register("coffee_machine", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine"))); - public static DeferredHolder DUH_DUH_DUH_DUUUH = SOUNDS.register("duh_duh_duh_duuuh", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh"))); - public static DeferredHolder VILLAGER_WORK_ENGINEER = SOUNDS.register("villager.work_engineer", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "villager.work_engineer"))); + public static DeferredHolder RECONSTRUCTOR = SOUNDS.register("reconstructor", () -> SoundEvent.createVariableRangeEvent(ActuallyAdditions.modLoc("reconstructor"))); + public static DeferredHolder CRUSHER = SOUNDS.register("crusher", () -> SoundEvent.createVariableRangeEvent(ActuallyAdditions.modLoc("crusher"))); + public static DeferredHolder COFFEE_MACHINE = SOUNDS.register("coffee_machine", () -> SoundEvent.createVariableRangeEvent(ActuallyAdditions.modLoc("coffee_machine"))); + public static DeferredHolder DUH_DUH_DUH_DUUUH = SOUNDS.register("duh_duh_duh_duuuh", () -> SoundEvent.createVariableRangeEvent(ActuallyAdditions.modLoc("duh_duh_duh_duuuh"))); + public static DeferredHolder VILLAGER_WORK_ENGINEER = SOUNDS.register("villager.work_engineer", () -> SoundEvent.createVariableRangeEvent(ActuallyAdditions.modLoc("villager.work_engineer"))); public static void init(IEventBus bus) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 63f5deed9..57b9908c9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -11,12 +11,13 @@ package de.ellpeck.actuallyadditions.mod; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.conditions.BoolConfigCondition; import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes; @@ -35,7 +36,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.Worm; import de.ellpeck.actuallyadditions.mod.lootmodifier.ActuallyLootModifiers; -import de.ellpeck.actuallyadditions.mod.misc.BannerHelper; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; @@ -51,13 +51,13 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.event.config.ModConfigEvent; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; -import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.conditions.ICondition; import net.neoforged.neoforge.common.world.BiomeModifier; @@ -90,12 +90,12 @@ public class ActuallyAdditions { private static final DeferredRegister> ENTITIES = DeferredRegister.create(BuiltInRegistries.ENTITY_TYPE, MODID); public static final Supplier> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, MobCategory.MISC).build(MODID + ":worm")); - private static final DeferredRegister> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, MODID); - public static final DeferredHolder, Codec> BOOL_CONFIG_CONDITION = CONDITION_CODECS.register("bool_config_condition", () -> BoolConfigCondition.CODEC); + private static final DeferredRegister> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, MODID); + public static final DeferredHolder, MapCodec> BOOL_CONFIG_CONDITION = CONDITION_CODECS.register("bool_config_condition", () -> BoolConfigCondition.CODEC); - public static final DeferredRegister> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, MODID); - public static final Supplier> BOOL_CONFIG_MODIFIER = BIOME_MODIFIER_SERIALIZERS.register("bool_config_feature_modifier", () -> - RecordCodecBuilder.create(builder -> builder.group( + public static final DeferredRegister> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, MODID); + public static final Supplier> BOOL_CONFIG_MODIFIER = BIOME_MODIFIER_SERIALIZERS.register("bool_config_feature_modifier", () -> + RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(BoolConfigFeatureBiomeModifier::biomes), PlacedFeature.LIST_CODEC.fieldOf("features").forGetter(BoolConfigFeatureBiomeModifier::features), GenerationStep.Decoration.CODEC.fieldOf("step").forGetter(BoolConfigFeatureBiomeModifier::step), @@ -105,8 +105,8 @@ public class ActuallyAdditions { public static boolean commonCapsLoaded; - public ActuallyAdditions(IEventBus eventBus) { - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CommonConfig.COMMON_CONFIG); + public ActuallyAdditions(IEventBus eventBus, ModContainer container, Dist dist) { + container.registerConfig(ModConfig.Type.COMMON, CommonConfig.COMMON_CONFIG); ActuallyBlocks.init(eventBus); ActuallyItems.init(eventBus); @@ -115,9 +115,8 @@ public class ActuallyAdditions { AASounds.init(eventBus); ActuallyVillagers.init(eventBus); ActuallyPOITypes.init(eventBus); - ActuallyAttachments.init(eventBus); + ActuallyComponents.init(eventBus); ActuallyLootModifiers.init(eventBus); - BannerHelper.init(eventBus); ActuallyContainers.CONTAINERS.register(eventBus); ENTITIES.register(eventBus); CONDITION_CODECS.register(eventBus); @@ -139,7 +138,7 @@ public class ActuallyAdditions { eventBus.addListener(PacketHandler::register); eventBus.addListener(this::setup); - if (FMLEnvironment.dist.isClient()) { + if (dist.isClient()) { eventBus.addListener(ActuallyAdditionsClient::setup); eventBus.addListener(ActuallyAdditionsClient::setupMenus); eventBus.addListener(ActuallyAdditionsClient::setupSpecialRenders); @@ -167,8 +166,8 @@ public class ActuallyAdditions { } private void onConfigReload(ModConfigEvent event) { - Item item1 = BuiltInRegistries.ITEM.get(new ResourceLocation(CommonConfig.Other.REDSTONECONFIGURATOR.get())); - Item item2 = BuiltInRegistries.ITEM.get(new ResourceLocation(CommonConfig.Other.RELAYCONFIGURATOR.get())); + Item item1 = BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(CommonConfig.Other.REDSTONECONFIGURATOR.get())); + Item item2 = BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(CommonConfig.Other.RELAYCONFIGURATOR.get())); CommonConfig.Other.redstoneConfigureItem = item1 != null?item1: Items.AIR; CommonConfig.Other.relayConfigureItem = item2 != null?item2: Items.AIR; } @@ -188,4 +187,8 @@ public class ActuallyAdditions { // TODO: [port] check if this is needed WorldData.clear(); } + + public static ResourceLocation modLoc(String path) { + return ResourceLocation.fromNamespaceAndPath(MODID, path); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java index 28d61802e..05f7acbfa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java @@ -11,12 +11,42 @@ package de.ellpeck.actuallyadditions.mod; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.render.*; +import de.ellpeck.actuallyadditions.mod.blocks.render.ReconstructorRenderer; +import de.ellpeck.actuallyadditions.mod.blocks.render.RenderBatteryBox; +import de.ellpeck.actuallyadditions.mod.blocks.render.RenderDisplayStand; +import de.ellpeck.actuallyadditions.mod.blocks.render.RenderEmpowerer; +import de.ellpeck.actuallyadditions.mod.blocks.render.RenderLaserRelay; import de.ellpeck.actuallyadditions.mod.entity.RenderWorm; import de.ellpeck.actuallyadditions.mod.event.ClientEvents; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers; -import de.ellpeck.actuallyadditions.mod.inventory.gui.*; +import de.ellpeck.actuallyadditions.mod.inventory.gui.CrusherScreen; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiBioReactor; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiBreaker; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCanolaPress; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoalGenerator; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDirectionalBreaker; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDrill; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDropper; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiEnergizer; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiEnervator; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFarmer; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFeeder; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFermentingBarrel; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFilter; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFireworkBox; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFluidCollector; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiLaserRelayItemWhitelist; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiMiner; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiOilGenerator; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiPhantomPlacer; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiRangedCollector; +import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiXPSolidifier; +import de.ellpeck.actuallyadditions.mod.inventory.gui.ItemTagScreen; +import de.ellpeck.actuallyadditions.mod.inventory.gui.SackGui; +import de.ellpeck.actuallyadditions.mod.inventory.gui.VoidSackGui; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; import de.ellpeck.actuallyadditions.mod.particle.ActuallyParticles; @@ -30,7 +60,6 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.phys.BlockHitResult; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.neoforge.client.event.EntityRenderersEvent; @@ -75,7 +104,7 @@ public class ActuallyAdditionsClient { NeoForge.EVENT_BUS.register(new SpecialRenderInit()); event.enqueueWork(() -> - ItemProperties.register(ActuallyItems.WORM.get(), new ResourceLocation(ActuallyAdditions.MODID, "snail"), + ItemProperties.register(ActuallyItems.WORM.get(), ActuallyAdditions.modLoc("snail"), (stack, level, entity, tintIndex) -> "snail mail".equalsIgnoreCase(stack.getHoverName().getString()) ? 1F : 0F)); setupRenderLayers(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java index 949548aae..a367a2b7a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java @@ -1,9 +1,7 @@ package de.ellpeck.actuallyadditions.mod; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.world.item.CreativeModeTab; @@ -31,10 +29,10 @@ public class ActuallyTabs { .filter(stack -> stack.getItem() instanceof ItemEnergy).toList(); charged.forEach(stack -> { if(stack.getItem() instanceof ItemEnergy itemEnergy) { - CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer); - storage.setEnergyStored(itemEnergy.maxPower); - stack.setData(ActuallyAttachments.ENERGY_STORAGE.get(), storage); - stack.getOrCreateTag().putBoolean("Charged", true); +// CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer); +// storage.setEnergyStored(itemEnergy.maxPower); +// stack.setData(ActuallyComponents.ENERGY_STORAGE.get(), storage); +// stack.getOrCreateTag().putBoolean("Charged", true); TODO: IMPORTANT: ADD BACK THE CREATIVE ITEMS! } }); stacks.addAll(charged); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java index a045ca688..fd74a3b57 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java @@ -49,7 +49,7 @@ public class ClientRegistryHandler { @SubscribeEvent public void onModelBake(BakingCompleted e) { - // ModelResourceLocation mrl = new ModelResourceLocation(new ResourceLocation(ActuallyAdditions.MODID, "block_compost"), "normal"); + // ModelResourceLocation mrl = new ModelResourceLocation(ActuallyAdditions.modLoc("block_compost"), "normal"); // CompostModel.compostBase = e.getModelRegistry().getObject(mrl); // e.getModelRegistry().putObject(mrl, new ActualCompostModel()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ActuallyAttachments.java b/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ActuallyAttachments.java deleted file mode 100644 index 32b72eb9f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ActuallyAttachments.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.attachments; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; -import net.minecraft.world.item.ItemStack; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.neoforge.attachment.AttachmentType; -import net.neoforged.neoforge.registries.DeferredRegister; -import net.neoforged.neoforge.registries.NeoForgeRegistries; - -import java.util.function.Supplier; - -public class ActuallyAttachments { - private static final DeferredRegister> ATTACHMENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, ActuallyAdditions.MODID); - - public static final Supplier> ENERGY_STORAGE = ATTACHMENT_TYPES.register( - "energy", ActuallyAttachments.itemEnergyStorageAttachment()); - - public static final Supplier> ITEM_TAG = ATTACHMENT_TYPES.register( - "item_tag", () -> AttachmentType.serializable(ItemTagAttachment::new).build()); - - /* - * This is a supplier for an attachment type that can be used to attach an energy storage to an item. - * Implementation is based on EnderIO's https://github.com/Team-EnderIO/EnderIO/blob/e1f022df745131ed5fea718bd860880a5785d4c7/src/core/java/com/enderio/core/common/attachment/AttachmentUtil.java#L47-L60 - */ - public static Supplier> itemEnergyStorageAttachment() { - return () -> AttachmentType.serializable(holder -> { - if (holder instanceof ItemStack itemStack) { - int capacity = 1000; - int maxTransfer = 1000; - if (itemStack.getItem() instanceof ItemEnergy itemEnergy) { - capacity = itemEnergy.maxPower; - maxTransfer = itemEnergy.transfer; - } - - - return new CustomEnergyStorage(capacity, maxTransfer, maxTransfer); - } else { - throw new IllegalStateException("Cannot attach energy handler item to a non-item."); - } - }).build(); - } - - public static void init(IEventBus evt) { - ATTACHMENT_TYPES.register(evt); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ItemTagAttachment.java b/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ItemTagAttachment.java deleted file mode 100644 index 04fdd36b3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/attachments/ItemTagAttachment.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.attachments; - -import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.neoforged.neoforge.common.util.INBTSerializable; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Optional; - -public class ItemTagAttachment implements INBTSerializable { - private TagKey tag; - - - @Override - public CompoundTag serializeNBT() { - CompoundTag nbt = new CompoundTag(); - if (tag != null) { - nbt.putString("tag", tag.location().toString()); - } - return nbt; - } - - @Override - public void deserializeNBT(@Nonnull CompoundTag nbt) { - if (nbt.contains("tag")) { - tag = TagKey.create(Registries.ITEM, new ResourceLocation(nbt.getString("tag"))); - } - } - - public Optional> getTag() { - return Optional.ofNullable(tag); - } - - public void setTag(@Nullable TagKey tag) { - this.tag = tag; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/AABlockItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/AABlockItem.java index 654ba979a..3b46ccf8d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/AABlockItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/AABlockItem.java @@ -1,12 +1,12 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemNameBlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; +import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.block.Block; import javax.annotation.Nullable; @@ -35,14 +35,14 @@ public class AABlockItem extends BlockItem { } @Override - public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltip, TooltipFlag pFlag) { - super.appendHoverText(pStack, pLevel, pTooltip, pFlag); + public void appendHoverText(ItemStack pStack, @Nullable TooltipContext pContext, List pTooltip, TooltipFlag pFlag) { + super.appendHoverText(pStack, pContext, pTooltip, pFlag); - if (pStack.hasTag() && pStack.getTag().contains("BlockEntityTag")) { - CompoundTag BET = pStack.getTag().getCompound("BlockEntityTag"); + if (pStack.has(DataComponents.BLOCK_ENTITY_DATA)) { + CustomData customData = pStack.get(DataComponents.BLOCK_ENTITY_DATA); int energy = 0; - if (BET.contains("Energy")) { - energy = BET.getInt("Energy"); + if (customData.contains("Energy")) { + energy = customData.copyTag().getInt("Energy"); } NumberFormat format = NumberFormat.getInstance(); pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy))); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlock.java index a16653c84..e85f5e072 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlock.java @@ -6,8 +6,6 @@ import net.minecraft.world.level.block.SlabBlock; import net.minecraft.world.level.block.StairBlock; import net.minecraft.world.level.block.state.BlockState; -import java.util.function.Supplier; - /** * Using a custom class here to declare common rules between all of our blocks. * This also provides a simple instance of check for our blocks. @@ -30,7 +28,7 @@ public class ActuallyBlock extends Block implements IActuallyBlock { } public static class Stairs extends StairBlock implements IActuallyBlock { - public Stairs(Supplier state, Properties properties) { + public Stairs(BlockState state, Properties properties) { super(state, properties); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java index d6e50f38d..dac5687fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java @@ -14,7 +14,54 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.AACrops; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.metalists.Crystals; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.CrateBE; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCrusher; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCrusherDouble; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterfaceHopping; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPoweredFurnace; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; import de.ellpeck.actuallyadditions.registration.AABlockReg; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; @@ -252,13 +299,13 @@ public final class ActuallyBlocks { //Stairs - public static final AABlockReg ETHETIC_GREEN_STAIRS = new AABlockReg<>("ethetic_green_stairs", () -> new StairBlock(() -> ETHETIC_GREEN_BLOCK.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(ETHETIC_GREEN_BLOCK.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg ETHETIC_WHITE_STAIRS = new AABlockReg<>("ethetic_white_stairs", () -> new StairBlock(() -> ETHETIC_WHITE_BLOCK.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(ETHETIC_WHITE_BLOCK.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg BLACK_QUARTZ_STAIR = new AABlockReg<>("black_quartz_stair", () -> new StairBlock(() -> BLACK_QUARTZ.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg CHISELED_BLACK_QUARTZ_STAIR = new AABlockReg<>("chiseled_black_quartz_stair", () -> new StairBlock(() -> CHISELED_BLACK_QUARTZ.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(CHISELED_BLACK_QUARTZ.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg BLACK_QUARTZ_PILLAR_STAIR = new AABlockReg<>("black_quartz_pillar_stair", () -> new StairBlock(() -> BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg SMOOTH_BLACK_QUARTZ_STAIR = new AABlockReg<>("smooth_black_quartz_stair", () -> new StairBlock(() -> BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); - public static final AABlockReg BLACK_QUARTZ_BRICK_STAIR = new AABlockReg<>("black_quartz_brick_stair", () -> new StairBlock(() -> BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_GREEN_STAIRS = new AABlockReg<>("ethetic_green_stairs", () -> new StairBlock(ETHETIC_GREEN_BLOCK.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(ETHETIC_GREEN_BLOCK.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_WHITE_STAIRS = new AABlockReg<>("ethetic_white_stairs", () -> new StairBlock(ETHETIC_WHITE_BLOCK.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(ETHETIC_WHITE_BLOCK.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_STAIR = new AABlockReg<>("black_quartz_stair", () -> new StairBlock(BLACK_QUARTZ.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CHISELED_BLACK_QUARTZ_STAIR = new AABlockReg<>("chiseled_black_quartz_stair", () -> new StairBlock(CHISELED_BLACK_QUARTZ.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(CHISELED_BLACK_QUARTZ.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_PILLAR_STAIR = new AABlockReg<>("black_quartz_pillar_stair", () -> new StairBlock(BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg SMOOTH_BLACK_QUARTZ_STAIR = new AABlockReg<>("smooth_black_quartz_stair", () -> new StairBlock(BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_BRICK_STAIR = new AABlockReg<>("black_quartz_brick_stair", () -> new StairBlock(BLACK_QUARTZ_PILLAR.get().defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_QUARTZ_PILLAR.get())), (b) -> new AABlockItem(b, defaultBlockItemProperties)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java index cd142e3c6..3fdd39129 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java @@ -19,17 +19,17 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -40,10 +40,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -61,10 +57,10 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { ItemStack heldItem = player.getItemInHand(hand); if (this.tryToggleRedstone(world, pos, player)) { - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } if (!world.isClientSide) { TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getBlockEntity(pos); @@ -78,20 +74,20 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im if (!player.isCreative()) { heldItem.shrink(1); } - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } } else { ItemStack slot = reconstructor.inv.getStackInSlot(0); if (!slot.isEmpty() && hand == InteractionHand.MAIN_HAND) { player.setItemInHand(hand, slot.copy()); reconstructor.inv.setStackInSlot(0, ItemStack.EMPTY); - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } } } - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } /* @Override @@ -125,7 +121,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) { return; @@ -158,10 +154,10 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im block = blockIn; } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(@Nonnull ItemStack pStack, @Nullable Level pLevel, @Nonnull List pTooltip, @Nonnull TooltipFlag pFlag) { - super.appendHoverText(pStack, pLevel, pTooltip, pFlag); + public void appendHoverText(@Nonnull ItemStack pStack, @Nullable TooltipContext context, @Nonnull List pTooltip, @Nonnull TooltipFlag pFlag) { + super.appendHoverText(pStack, context, pTooltip, pFlag); long sysTime = System.currentTimeMillis(); @@ -177,18 +173,18 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im String base = block.getDescriptionId() + ".info."; pTooltip.add(Component.translatable(base + "1." + this.toPick1).append(" ").append(Component.translatable(base + "2." + this.toPick2)).withStyle(s -> s.withColor(ChatFormatting.GRAY))); - if (pStack.hasTag() && pStack.getTag().contains("BlockEntityTag")) { - CompoundTag BET = pStack.getTag().getCompound("BlockEntityTag"); + if (pStack.has(DataComponents.CUSTOM_DATA) ) { + CustomData customData = pStack.get(DataComponents.CUSTOM_DATA); int energy = 0; - if (BET.contains("Energy")) { - energy = BET.getInt("Energy"); + if (customData.contains("Energy")) { + energy = customData.copyTag().getInt("Energy"); } NumberFormat format = NumberFormat.getInstance(); pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy)).withStyle(ChatFormatting.GRAY)); - if (BET.contains("IsPulseMode")) { + if (customData.contains("IsPulseMode")) { pTooltip.add(Component.translatable("info.actuallyadditions.redstoneMode").append(": ") - .append(Component.translatable(BET.getBoolean("IsPulseMode")?"info.actuallyadditions.redstoneMode.pulse":"info.actuallyadditions.redstoneMode.deactivation").withStyle($ -> $.withColor(ChatFormatting.RED)))); + .append(Component.translatable(customData.copyTag().getBoolean("IsPulseMode")?"info.actuallyadditions.redstoneMode.pulse":"info.actuallyadditions.redstoneMode.deactivation").withStyle($ -> $.withColor(ChatFormatting.RED)))); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java index 60e0527e3..b236c5957 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java @@ -15,7 +15,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemBattery; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -58,7 +58,7 @@ public class BlockBatteryBox extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { BlockEntity tile = world.getBlockEntity(pos); if (tile instanceof TileEntityBatteryBox box) { ItemStack stack = player.getItemInHand(hand); @@ -67,17 +67,17 @@ public class BlockBatteryBox extends BlockContainerBase { if (stack.getItem() instanceof ItemBattery && box.inv.getStackInSlot(0).isEmpty()) { box.inv.setStackInSlot(0, stack.copy()); player.setItemInHand(hand, ItemStack.EMPTY); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } } else { ItemStack inSlot = box.inv.getStackInSlot(0); if (!inSlot.isEmpty()) { player.setItemInHand(hand, inSlot.copy()); box.inv.setStackInSlot(0, ItemStack.EMPTY); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } } } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java index 8d838ea25..f8dc6eb7a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java @@ -13,23 +13,17 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; -import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING; - public class BlockBioReactor extends DirectionalBlock.Container { public BlockBioReactor() { @@ -49,7 +43,7 @@ public class BlockBioReactor extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { return this.openGui(world, player, pos, TileEntityBioReactor.class); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java index c6bfc88de..f87fc7e10 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java @@ -14,18 +14,14 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -55,7 +51,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java index 3bd50b1ff..e43d1e9f8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java @@ -14,8 +14,9 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -53,18 +54,18 @@ public class BlockCanolaPress extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getBlockEntity(pos); if (tile == null) - return InteractionResult.PASS; //TODO this logic all needs to be rechecked... + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; //TODO this logic all needs to be rechecked... if (world.isClientSide) - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; if (!player.isShiftKeyDown()) { if (!FluidUtil.interactWithFluidHandler(player, hand, tile.tank)) player.openMenu(tile, pos); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java index 871c5cce7..98c6f9e5b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java @@ -16,7 +16,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.BlockGetter; @@ -61,7 +60,7 @@ public class BlockCoalGenerator extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { return this.openGui(world, player, pos, TileEntityCoalGenerator.class); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java index b344c5e0b..e821a16e5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java @@ -14,8 +14,9 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -34,9 +35,9 @@ public class BlockCoffeeMachine extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { if (world.isClientSide) { - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } else { TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine) world.getBlockEntity(pos); if (tile != null) { @@ -44,7 +45,7 @@ public class BlockCoffeeMachine extends DirectionalBlock.Container { player.openMenu(tile, pos); } } - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java index 7eae11c99..ff39ee681 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java @@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.DyeItem; @@ -66,18 +66,18 @@ public class BlockColoredLamp extends BlockBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { ItemStack stack = player.getItemInHand(hand); //Turning On if (hand == InteractionHand.MAIN_HAND && stack.isEmpty()) { world.setBlock(pos, this.defaultBlockState().setValue(LIT, !state.getValue(LIT)), Block.UPDATE_INVISIBLE); - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } if (StackUtil.isValid(stack) && stack.getItem() instanceof DyeItem) { DyeColor color = DyeColor.getColor(stack); if (color == null) { - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } Block newColor = COLOR_TO_LAMP.get(color).get(); @@ -88,7 +88,7 @@ public class BlockColoredLamp extends BlockBase { } } } - return super.use(state, world, pos, player, hand, hit); + return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrusher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrusher.java index 7dfe044b1..074dc8d86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrusher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrusher.java @@ -18,7 +18,6 @@ import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; @@ -32,8 +31,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -78,7 +75,7 @@ public class BlockCrusher extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.isDouble) { return this.openGui(world, player, pos, TileEntityCrusherDouble.class); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java index 4b0e3ed22..0396b793e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java @@ -18,7 +18,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -61,7 +61,7 @@ public class BlockDisplayStand extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { ItemStack heldItem = player.getItemInHand(hand); if (!world.isClientSide) { TileEntityInventoryBase stand = (TileEntityInventoryBase) world.getBlockEntity(pos); @@ -76,7 +76,7 @@ public class BlockDisplayStand extends BlockContainerBase { heldItem.shrink(1); else player.swing(hand, true); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } else if (ItemUtil.canBeStacked(heldItem, stackThere)) { int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount()); if (maxTransfer > 0) { @@ -87,21 +87,21 @@ public class BlockDisplayStand extends BlockContainerBase { ItemStack newStackThere = stackThere.copy(); newStackThere.shrink(maxTransfer); stand.inv.setStackInSlot(0, newStackThere); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } } } else { if (!stackThere.isEmpty() && hand == InteractionHand.MAIN_HAND) { player.setItemInHand(hand, stackThere.copy()); stand.inv.setStackInSlot(0, ItemStack.EMPTY); - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } } } - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java index e322de6e9..c8a669c34 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -47,7 +43,7 @@ public class BlockDropper extends FullyDirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java index 9451e0e31..298f541b4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java @@ -14,18 +14,14 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -54,7 +50,7 @@ public class BlockEnergizer extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.isEnergizer) { return this.openGui(world, player, pos, TileEntityEnergizer.class); } else { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java index 530fe67ce..73f0b502b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -47,8 +43,8 @@ public class BlockFarmer extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return this.openGui(worldIn, player, pos, TileEntityFarmer.class); + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { + return this.openGui(world, player, pos, TileEntityFarmer.class); } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java index a531ece53..e24b70619 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -47,8 +43,8 @@ public class BlockFeeder extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return this.openGui(worldIn, player, pos, TileEntityFeeder.class); + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { + return this.openGui(world, player, pos, TileEntityFeeder.class); } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java index 76bbef17c..ee4c051cb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java @@ -16,7 +16,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -55,21 +55,21 @@ public class BlockFermentingBarrel extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel) world.getBlockEntity(pos); if (tile == null) - return InteractionResult.PASS; //TODO this logic all needs to be rechecked... + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; //TODO this logic all needs to be rechecked... if (world.isClientSide) - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; if (!player.isShiftKeyDown()) { if (FluidUtil.interactWithFluidHandler(player, hand, tile.tanks)) { ItemStack stack = player.getItemInHand(hand); world.playSound(null, pos, stack.getItem() == Items.BUCKET ? SoundEvents.BUCKET_EMPTY:SoundEvents.BUCKET_FILL, SoundSource.BLOCKS, 1.0F, 1.0F); } else player.openMenu(tile, pos); - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java index 05db6022e..eadc498de 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.BlockGetter; @@ -34,7 +33,7 @@ public class BlockFireworkBox extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java index bd4472dcf..8e0b1e483 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java @@ -15,17 +15,15 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import net.neoforged.neoforge.fluids.FluidUtil; import javax.annotation.Nonnull; @@ -58,18 +56,18 @@ public class BlockFluidCollector extends FullyDirectionalBlock.Container { @Nonnull @Override - public InteractionResult use(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Player player, @Nonnull InteractionHand handIn, @Nonnull BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { if (world.isClientSide) - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; if (this.tryToggleRedstone(world, pos, player)) { - return InteractionResult.CONSUME; + return ItemInteractionResult.CONSUME; } - if (FluidUtil.interactWithFluidHandler(player, handIn, world, pos, hit.getDirection())) { - return InteractionResult.SUCCESS; + if (FluidUtil.interactWithFluidHandler(player, hand, world, pos, pHitResult.getDirection())) { + return ItemInteractionResult.SUCCESS; } - return this.openGui(world, player, pos, TileEntityFluidCollector.class); + return this.openGui2(world, player, pos, TileEntityFluidCollector.class); } /* @Nonnull diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemInterface.java index 94a3f88e8..b86662a53 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemInterface.java @@ -13,14 +13,11 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterface; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampController.java index 6faf9d53e..18b60eb40 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampController.java @@ -14,13 +14,10 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index 064ab534c..721b1e7d9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -14,7 +14,6 @@ import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles; @@ -35,7 +34,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; @@ -49,8 +48,6 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.ArrayList; @@ -99,14 +96,14 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { ItemStack stack = player.getItemInHand(hand); BlockEntity tile = world.getBlockEntity(pos); if (tile instanceof TileEntityLaserRelay relay) { if (!stack.isEmpty()) { if (stack.getItem() instanceof ItemLaserWrench) { - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } else if (stack.getItem() == CommonConfig.Other.relayConfigureItem) { if (!world.isClientSide) { relay.onCompassAction(player); @@ -120,7 +117,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements relay.sendUpdate(); } - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } else if (stack.getItem() instanceof ItemLaserRelayUpgrade) { ItemStack inRelay = relay.inv.getStackInSlot(0); if (inRelay.isEmpty()) { @@ -133,7 +130,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements set.setCount(1); relay.inv.setStackInSlot(0, set); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } } @@ -149,15 +146,15 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements player.spawnAtLocation(inRelay, 0); } } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } } if (relay instanceof TileEntityLaserRelayItemAdvanced) { - return this.openGui(world, player, pos, TileEntityLaserRelayItemAdvanced.class); + return this.openGui2(world, player, pos, TileEntityLaserRelayItemAdvanced.class); } } - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } @Nullable @@ -199,7 +196,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult)) { return; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java index 1a63f0bf3..938424ef2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; import com.mojang.blaze3d.platform.Window; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; import net.minecraft.client.Minecraft; @@ -20,7 +19,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -28,10 +26,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; @@ -55,7 +49,7 @@ public class BlockLavaFactoryController extends DirectionalBlock.Container imple } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult)) { return; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java index 90a3ed1e4..627b56475 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; @@ -21,8 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.MapColor; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLongRangeBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLongRangeBreaker.java index be24526b2..4039e23e5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLongRangeBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLongRangeBreaker.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -47,7 +43,7 @@ public class BlockLongRangeBreaker extends FullyDirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java index 0ea174702..f4e1163e0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java @@ -17,8 +17,9 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -63,7 +64,7 @@ public class BlockOilGenerator extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { if (!world.isClientSide) { TileEntityOilGenerator generator = (TileEntityOilGenerator) world.getBlockEntity(pos); if (generator != null) { @@ -73,7 +74,7 @@ public class BlockOilGenerator extends DirectionalBlock.Container { } } - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index a8ada296b..21910cff9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -12,9 +12,13 @@ package de.ellpeck.actuallyadditions.mod.blocks; import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -26,7 +30,7 @@ import net.minecraft.network.chat.FormattedText; import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -41,8 +45,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; @@ -125,9 +127,9 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } if (!world.isClientSide) { BlockEntity tile = world.getBlockEntity(pos); @@ -135,11 +137,11 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay { player.openMenu(menuProvider, pos); } } - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult)) { return; @@ -169,7 +171,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay { } } - @OnlyIn(Dist.CLIENT) + public static void drawWordWrap(GuiGraphics gg, Font font, FormattedText text, int x, int y, int width, int color, boolean shadow) { for (FormattedCharSequence line : font.split(text, width)) { gg.drawString(font, line, x, y, color, shadow); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java index 94e2bd063..c715f0f41 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java @@ -20,7 +20,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -28,10 +27,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; @@ -69,7 +64,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult)) { return; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPoweredFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPoweredFurnace.java index a3c7f34a7..d109d856c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPoweredFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPoweredFurnace.java @@ -19,13 +19,12 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -34,8 +33,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; import java.util.List; @@ -76,8 +73,8 @@ public class BlockPoweredFurnace extends DirectionalBlock.Container { @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return this.openGui(worldIn, player, pos, TileEntityPoweredFurnace.class); + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { + return this.openGui(world, player, pos, TileEntityPoweredFurnace.class); } @Override @@ -91,8 +88,8 @@ public class BlockPoweredFurnace extends DirectionalBlock.Container { } @Override - public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List tooltip, TooltipFlag advanced) { - super.appendHoverText(stack, level, tooltip, advanced); + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltip, TooltipFlag advanced) { + super.appendHoverText(stack, context, tooltip, advanced); tooltip.add(Component.translatable("tooltip.actuallyadditions.previouslyDoubleFurnace").withStyle(ChatFormatting.ITALIC)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java index 2db1ef2ce..25c770aba 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -47,7 +43,7 @@ public class BlockRangedCollector extends BlockContainerBase { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { if (this.tryToggleRedstone(world, pos, player)) { return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java index c25280622..cd166edd9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java @@ -72,7 +72,7 @@ public class BlockShockSuppressor extends Block implements EntityBlock { for (BlockPos pos : posesToRemove) { if (suppressor.storage.getEnergyStored() >= use) { - suppressor.storage.extractEnergyInternal(use, false); + suppressor.storage.extractEnergy(use, false); affectedBlocks.remove(pos); } else { break; @@ -80,7 +80,7 @@ public class BlockShockSuppressor extends Block implements EntityBlock { } for (Entity entity : entitiesToRemove) { if (suppressor.storage.getEnergyStored() >= use) { - suppressor.storage.extractEnergyInternal(use, false); + suppressor.storage.extractEnergy(use, false); affectedEntities.remove(entity); } else { break; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java index d7d8fcfe4..3f0e320e4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java @@ -145,7 +145,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, Direction side, PlayerEntity player, ItemStack stack) { // BlockState state = worldIn.getBlockState(pos); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java index 7f01130bc..26b74cdd0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java @@ -16,11 +16,9 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -28,10 +26,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; @@ -43,8 +37,8 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I } @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return this.openGui(worldIn, player, pos, TileEntityVerticalDigger.class); + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { + return this.openGui(world, player, pos, TileEntityVerticalDigger.class); } @Nullable @@ -60,7 +54,7 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { if (!(rayCast instanceof BlockHitResult)) { return; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java index ef0568250..2acb70eb0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java @@ -84,7 +84,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // @Deprecated // public boolean shouldSideBeRendered(BlockState blockState, IBlockAccess blockAccess, BlockPos pos, Direction side) { // return side != Direction.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); @@ -108,7 +108,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void getSubBlocks(CreativeTabs tab, NonNullList list) { // list.add(new ItemStack(this, 1, 0)); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java index f908413e4..efbdc8476 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java @@ -13,18 +13,14 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; @@ -46,8 +42,8 @@ public class BlockXPSolidifier extends DirectionalBlock.Container { } @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return this.openGui(worldIn, player, pos, TileEntityXPSolidifier.class); + protected InteractionResult useWithoutItem(BlockState pState, Level world, BlockPos pos, Player player, BlockHitResult pHitResult) { + return this.openGui(world, player, pos, TileEntityXPSolidifier.class); } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/CrystalClusterBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/CrystalClusterBlock.java index ec617317d..0805959ee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/CrystalClusterBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/CrystalClusterBlock.java @@ -21,13 +21,9 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; -import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import java.util.stream.Stream; - public class CrystalClusterBlock extends FullyDirectionalBlock { public static final DirectionProperty FACING = BlockStateProperties.FACING; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java index e09065dc5..14e8dfd3c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java @@ -16,12 +16,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.HitResult; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; public interface IHudDisplay { - @OnlyIn(Dist.CLIENT) + void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/VoxelShapes.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/VoxelShapes.java index 8949ba023..564138da1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/VoxelShapes.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/VoxelShapes.java @@ -5,7 +5,6 @@ import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import java.awt.*; import java.util.Optional; import java.util.stream.Stream; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index 798af8aeb..7ed0fdfea 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -10,19 +10,18 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; @@ -58,6 +57,18 @@ public abstract class BlockContainerBase extends Block implements EntityBlock { return InteractionResult.SUCCESS; } + public ItemInteractionResult openGui2(Level world, Player player, BlockPos pos, Class expectedInstance) { + if (!world.isClientSide) { + BlockEntity tile = world.getBlockEntity(pos); + if (expectedInstance.isInstance(tile)) { + player.openMenu((MenuProvider) tile, pos); + } + return ItemInteractionResult.SUCCESS; + } + + return ItemInteractionResult.SUCCESS; + } + private void dropInventory(Level world, BlockPos position) { if (!world.isClientSide) { BlockEntity aTile = world.getBlockEntity(position); @@ -172,13 +183,13 @@ public abstract class BlockContainerBase extends Block implements EntityBlock { @Override public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { - if (stack.hasTag()) { - BlockEntity tile = world.getBlockEntity(pos); - if (tile instanceof TileEntityBase base) { - CompoundTag compound = stack.getOrCreateTag().getCompound("Data"); - base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK); - } - } +// if (stack.hasTag()) { +// BlockEntity tile = world.getBlockEntity(pos); +// if (tile instanceof TileEntityBase base) { +// CompoundTag compound = stack.get(DataComponents.BLOCK_ENTITY_DATA).getCompound("Data"); +// base.readSyncableNBT(compound, world.registryAccess(), TileEntityBase.NBTType.SAVE_BLOCK); TODO: Check if this is still required +// } +// } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java index 8d23cc6dc..4c39b0965 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java @@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -66,9 +66,9 @@ public class BlockPlant extends CropBlock { @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { if (this.getAge(state) < 7) { - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } if (!world.isClientSide) { @@ -89,7 +89,7 @@ public class BlockPlant extends CropBlock { world.setBlockAndUpdate(pos, this.defaultBlockState().setValue(AGE, 0)); } - return super.use(state, world, pos, player, handIn, hit); + return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ReconstructorRenderer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ReconstructorRenderer.java index febd59636..c21ee41cd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ReconstructorRenderer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ReconstructorRenderer.java @@ -22,7 +22,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.phys.AABB; import javax.annotation.Nonnull; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java index 4a5469d6e..2ca4f7d2e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java @@ -27,14 +27,12 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.Capabilities; import org.joml.Matrix4f; import java.util.Optional; -@OnlyIn(Dist.CLIENT) + public class RenderBatteryBox implements BlockEntityRenderer { public RenderBatteryBox(BlockEntityRendererProvider.Context context) { } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java index 63ed3e281..edad3c8a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java @@ -129,7 +129,7 @@ public class RenderLaserRelay implements BlockEntityRenderer { // // @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java index 66d0f9153..5c9daff22 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java @@ -35,7 +35,7 @@ //import java.util.List; //import java.util.stream.Collectors; // -//@OnlyIn(Dist.CLIENT) +// //public class BookmarkButton extends Button { // // private final GuiBooklet booklet; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java index e184909dd..3a3754331 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java @@ -22,7 +22,7 @@ //import net.minecraftforge.api.distmarker.OnlyIn; // // -//@OnlyIn(Dist.CLIENT) +// //public class EntryButton extends Button { // // private final GuiBookletBase gui; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java index 4626eaec2..4e34d2629 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java @@ -57,13 +57,13 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedName() { // return StringUtil.localize("booklet.actuallyadditions.chapter." + this.getIdentifier() + ".name"); // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedNameWithFormatting() { // return this.color + this.getLocalizedName(); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java index 6c11a8e8e..b2eee6969 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java @@ -29,13 +29,13 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedName() { // return StringUtil.localize("booklet.actuallyadditions.trials." + this.getIdentifier() + ".name"); // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedNameWithFormatting() { // PlayerEntity player = Minecraft.getInstance().player; // PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java index 8f8f7b656..9168f5f37 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java @@ -48,7 +48,7 @@ // this.color = TextFormatting.RESET; // } // -// @OnlyIn(Dist.CLIENT) +// // private static boolean fitsFilter(IBookletPage page, String searchBarText) { // Minecraft mc = Minecraft.getInstance(); // @@ -96,13 +96,13 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedName() { // return StringUtil.localize("booklet.actuallyadditions.indexEntry." + this.getIdentifier() + ".name"); // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getLocalizedNameWithFormatting() { // return this.color + this.getLocalizedName(); // } @@ -113,7 +113,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public List getChaptersForDisplay(String searchBarText) { // if (searchBarText != null && !searchBarText.isEmpty()) { // String search = searchBarText.toLowerCase(Locale.ROOT); @@ -144,7 +144,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public boolean visibleOnFrontPage() { // return true; // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java index db44cdcc0..905f8c46d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java @@ -38,7 +38,7 @@ //import java.util.List; //import java.util.stream.Collectors; // -//@OnlyIn(Dist.CLIENT) +// //public abstract class GuiBooklet extends GuiBookletBase { // // public static final int BUTTONS_PER_PAGE = 12; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java index b267276da..f39957aa9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java @@ -27,7 +27,7 @@ //import java.io.IOException; //import java.util.List; // -//@OnlyIn(Dist.CLIENT) +// //public class GuiEntry extends GuiBooklet { // // //The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead. diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java index 5669b7694..366075f63 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java @@ -35,7 +35,7 @@ //import java.util.List; // ////TODO Fix achievement button -//@OnlyIn(Dist.CLIENT) +// //public class GuiMainPage extends GuiBooklet { // // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java index 024dc5643..89ec929a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java @@ -35,7 +35,7 @@ //import java.util.Collections; //import java.util.List; // -//@OnlyIn(Dist.CLIENT) +// //public class GuiPage extends GuiBooklet { // // public final IBookletPage[] pages = new IBookletPage[2]; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java index 33f978bf8..8786af9fc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java @@ -43,7 +43,7 @@ // return null; // } // -// @OnlyIn(Dist.CLIENT) +// // public static GuiPage createBookletGuiFromPage(Screen previousScreen, IBookletPage page) { // GuiMainPage mainPage = new GuiMainPage(previousScreen); // @@ -53,7 +53,7 @@ // return createPageGui(previousScreen, entry, page); // } // -// @OnlyIn(Dist.CLIENT) +// // public static GuiPage createPageGui(Screen previousScreen, GuiBookletBase parentPage, IBookletPage page) { // IBookletChapter chapter = page.getChapter(); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java index 051f346ae..381db4544 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java @@ -27,7 +27,7 @@ import java.io.IOException; /** * (Partially excerpted from Botania by Vazkii with permission, thanks!) * -@OnlyIn(Dist.CLIENT) + public class GuiAAAchievements extends GuiAchievements{ public GuiAAAchievements(GuiScreen screen, StatisticsManager statistics){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java index 82d52bf4e..91adace44 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java @@ -66,7 +66,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public String getInfoText() { // if (this.hasNoText) { // return null; @@ -86,55 +86,55 @@ // return base; // } // -// @OnlyIn(Dist.CLIENT) +// // protected String getLocalizationKey() { // return "booklet.actuallyadditions.chapter." + this.chapter.getIdentifier() + ".text." + this.localizationKey; // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void actionPerformed(GuiBookletBase gui, Button button) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java index 73388c25e..b5a6c3ee6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java @@ -48,12 +48,12 @@ // : null; // } // -// @OnlyIn(Dist.CLIENT) +// // public void drawPre() { // AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale); // } // -// @OnlyIn(Dist.CLIENT) +// // public void drawPost(int mouseX, int mouseY) { // if (this.isHovered(mouseX, mouseY)) { // Minecraft mc = this.gui.mc; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java index 22173bb6e..5b552ccc0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java @@ -40,7 +40,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -58,7 +58,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java index ac2ffb9ce..c47d9ebb8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java @@ -57,7 +57,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -72,7 +72,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) { // super.updateScreen(gui, startX, startY, pageTimer); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java index 2fb7a8375..943326610 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java @@ -37,7 +37,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -54,7 +54,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java index 9b698f988..2bfdef3ca 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java @@ -46,7 +46,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -62,7 +62,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java index 167a11e72..9c6c3da46 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java @@ -52,7 +52,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -65,7 +65,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java index 66edb4d04..df3709474 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java @@ -36,7 +36,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // @@ -44,14 +44,14 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5); // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void actionPerformed(GuiBookletBase gui, Button button) { // if (button.id == this.buttonId) { // if (Desktop.isDesktopSupported()) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java index 87156950b..1c1a6e4de 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java @@ -40,7 +40,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java index a62311a27..7e5e1a795 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java @@ -40,7 +40,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // @@ -58,7 +58,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java index 59b8d14ab..423805938 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java @@ -24,7 +24,7 @@ // super(localizationKey); // } // -// @OnlyIn(Dist.CLIENT) +// // public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y) { // String text = page.getInfoText(); // if (text != null && !text.isEmpty()) { @@ -33,7 +33,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // renderTextToPage(gui, this, startX + 6, startY + 5); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java index 241a5bc38..40b7f447a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java @@ -26,7 +26,7 @@ //public class PageTrials extends BookletPage { // // private final int buttonId; -// @OnlyIn(Dist.CLIENT) +// // private Button button; // // public PageTrials(int localizationKey, boolean button, boolean text) { @@ -45,7 +45,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void init(GuiBookletBase gui, int startX, int startY) { // super.init(gui, startX, startY); // @@ -57,20 +57,20 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { // super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); // PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5); // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // protected String getLocalizationKey() { // return "booklet.actuallyadditions.trials." + this.chapter.getIdentifier() + ".text." + this.localizationKey; // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void actionPerformed(GuiBookletBase gui, Button button) { // if (this.buttonId >= 0 && button.id == this.buttonId) { // PlayerEntity player = Minecraft.getInstance().player; @@ -91,7 +91,7 @@ // } // } // -// @OnlyIn(Dist.CLIENT) +// // private void updateButton() { // if (this.buttonId >= 0 && this.button != null) { // PlayerEntity player = Minecraft.getInstance().player; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/components/ActuallyComponents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/components/ActuallyComponents.java new file mode 100644 index 000000000..e0e2f6ee7 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/components/ActuallyComponents.java @@ -0,0 +1,138 @@ +package de.ellpeck.actuallyadditions.mod.components; + +import com.mojang.serialization.Codec; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.core.BlockPos; +import net.minecraft.core.UUIDUtil; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.component.ItemContainerContents; +import net.minecraft.world.level.Level; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.UUID; +import java.util.function.Supplier; + +public class ActuallyComponents { + private static final DeferredRegister> DATA_COMPONENT_TYPES = DeferredRegister.create(BuiltInRegistries.DATA_COMPONENT_TYPE, ActuallyAdditions.MODID); + + public static final Supplier> ENERGY_STORAGE = DATA_COMPONENT_TYPES.register("energy", () -> + DataComponentType.builder() + .persistent(Codec.INT) + .networkSynchronized(ByteBufCodecs.INT) + .build()); + + + public static final Supplier> ITEM_TAG = DATA_COMPONENT_TYPES.register("item_tag", () -> + DataComponentType.builder() + .persistent(ResourceLocation.CODEC) + .networkSynchronized(ResourceLocation.STREAM_CODEC) + .build()); + + public static final Supplier> AUTO_INSERT = DATA_COMPONENT_TYPES.register("auto_insert", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> PULSE_MODE = DATA_COMPONENT_TYPES.register("pulse_mode", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> WHITELIST = DATA_COMPONENT_TYPES.register("whitelist", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> MOD = DATA_COMPONENT_TYPES.register("mod", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> DAMAGE = DATA_COMPONENT_TYPES.register("damage", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> COMPONENTS = DATA_COMPONENT_TYPES.register("components", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> ENABLED = DATA_COMPONENT_TYPES.register("enabled", () -> + DataComponentType.builder() + .persistent(Codec.BOOL) + .networkSynchronized(ByteBufCodecs.BOOL) + .build()); + + public static final Supplier> CONTENTS = DATA_COMPONENT_TYPES.register("contents", () -> + DataComponentType.builder() + .persistent(ItemContainerContents.CODEC) + .networkSynchronized(ItemContainerContents.STREAM_CODEC) + .build()); + + public static final Supplier> UUID = DATA_COMPONENT_TYPES.register("uuid", () -> + DataComponentType.builder() + .persistent(UUIDUtil.CODEC) + .networkSynchronized(UUIDUtil.STREAM_CODEC) + .build()); + public static final Supplier> NAME = DATA_COMPONENT_TYPES.register("name", () -> + DataComponentType.builder() + .persistent(Codec.STRING) + .networkSynchronized(ByteBufCodecs.STRING_UTF8) + .build()); + + public static final Supplier>> LEVEL = DATA_COMPONENT_TYPES.register("level", () -> + DataComponentType.>builder() + .persistent(ResourceKey.codec(Registries.DIMENSION)) + .networkSynchronized(ResourceKey.streamCodec(Registries.DIMENSION)) + .build()); + public static final Supplier> POSITION = DATA_COMPONENT_TYPES.register("position", () -> + DataComponentType.builder() + .persistent(BlockPos.CODEC) + .networkSynchronized(BlockPos.STREAM_CODEC) + .build()); + public static final Supplier> LAST_XY = DATA_COMPONENT_TYPES.register("last_xy", () -> + DataComponentType.builder() + .persistent(LastXY.CODEC) + .networkSynchronized(LastXY.STREAM_CODEC) + .build()); + + + /* + * This is a supplier for an attachment type that can be used to attach an energy storage to an item. + * Implementation is based on EnderIO's https://github.com/Team-EnderIO/EnderIO/blob/e1f022df745131ed5fea718bd860880a5785d4c7/src/core/java/com/enderio/core/common/attachment/AttachmentUtil.java#L47-L60 + */ +// public static Supplier> itemEnergyStorageAttachment() { +// return () -> AttachmentType.serializable(holder -> { +// if (holder instanceof ItemStack itemStack) { +// int capacity = 1000; +// int maxTransfer = 1000; +// if (itemStack.getItem() instanceof ItemEnergy itemEnergy) { +// capacity = itemEnergy.maxPower; +// maxTransfer = itemEnergy.transfer; +// } +// +// +// return new CustomEnergyStorage(capacity, maxTransfer, maxTransfer); +// } else { +// throw new IllegalStateException("Cannot attach energy handler item to a non-item."); +// } +// }).build(); +// } + + public static void init(IEventBus evt) { + DATA_COMPONENT_TYPES.register(evt); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/components/LastXY.java b/src/main/java/de/ellpeck/actuallyadditions/mod/components/LastXY.java new file mode 100644 index 000000000..af4c61197 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/components/LastXY.java @@ -0,0 +1,19 @@ +package de.ellpeck.actuallyadditions.mod.components; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; + +public record LastXY(int x, int y) { + public static final Codec CODEC = RecordCodecBuilder.create(inst -> inst.group( + Codec.INT.fieldOf("x").forGetter(LastXY::x), + Codec.INT.fieldOf("y").forGetter(LastXY::y)) + .apply(inst, LastXY::new)); + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.INT, LastXY::x, + ByteBufCodecs.INT, LastXY::y, + LastXY::new + ); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java index d4c30ca2b..e3a1e8392 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java @@ -43,8 +43,8 @@ public final class ConfigValues { // // String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue(); // if (conf.length == 2) { -// itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0])); -// itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1])); +// itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(ResourceLocation.tryParse(conf[0])); +// itemCompassConfigurator = Item.REGISTRY.getObject(ResourceLocation.tryParse(conf[1])); // } // // if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/conditions/BoolConfigCondition.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/conditions/BoolConfigCondition.java index 2af945086..90a06acec 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/conditions/BoolConfigCondition.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/conditions/BoolConfigCondition.java @@ -1,19 +1,17 @@ package de.ellpeck.actuallyadditions.mod.config.conditions; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; -import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.common.conditions.ICondition; public record BoolConfigCondition(String boolConfig) implements ICondition { - public static Codec CODEC = RecordCodecBuilder.create( + public static MapCodec CODEC = RecordCodecBuilder.mapCodec( builder -> builder .group( Codec.STRING.fieldOf("boolConfig").forGetter(BoolConfigCondition::boolConfig)) .apply(builder, BoolConfigCondition::new)); - private static final ResourceLocation NAME = new ResourceLocation(ActuallyAdditions.MODID, "bool_config_condition"); @Override public boolean test(IContext condition) { @@ -26,7 +24,7 @@ public record BoolConfigCondition(String boolConfig) implements ICondition { } @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java index 5c8976c33..5cead8ea9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java @@ -282,10 +282,10 @@ public final class BlockCrafting { // RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGiantChest), "CWC", "WDW", "CWC", 'C', "chestWood", 'D', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), 'W', "plankWood"); // recipeCrate = RecipeUtil.lastIRecipe(); // - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_media"), new ItemStack(InitBlocks.blockGiantChestMedium), new ItemStack(InitBlocks.blockGiantChest), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChest), 'W', "plankWood"); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("giant_chest_media"), new ItemStack(InitBlocks.blockGiantChestMedium), new ItemStack(InitBlocks.blockGiantChest), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChest), 'W', "plankWood"); // recipeCrateMedium = RecipeUtil.lastIRecipe(); // - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_large"), new ItemStack(InitBlocks.blockGiantChestLarge), new ItemStack(InitBlocks.blockGiantChestMedium), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChestMedium), 'W', "plankWood"); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("giant_chest_large"), new ItemStack(InitBlocks.blockGiantChestLarge), new ItemStack(InitBlocks.blockGiantChestMedium), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChestMedium), 'W', "plankWood"); // recipeCrateLarge = RecipeUtil.lastIRecipe(); // // //Greenhouse Glass diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CoffeeIngredientRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CoffeeIngredientRecipe.java index 15ee73f18..255c78b16 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CoffeeIngredientRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CoffeeIngredientRecipe.java @@ -2,31 +2,34 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Optional; -public class CoffeeIngredientRecipe implements Recipe { +public class CoffeeIngredientRecipe implements Recipe { public static final String NAME = "coffee_ingredient"; protected final Ingredient ingredient; @@ -42,7 +45,7 @@ public class CoffeeIngredientRecipe implements Recipe { this.instances = effectInstances; List instances = new ArrayList<>(); for (EffectInstance instance : effectInstances) { - MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(instance.effect()); + Holder effect = BuiltInRegistries.MOB_EFFECT.getHolder(instance.effect()).orElse(null); if (effect == null) break; instances.add(new MobEffectInstance(effect, instance.duration, instance.amplifier)); } @@ -67,7 +70,7 @@ public class CoffeeIngredientRecipe implements Recipe { } @Override - public boolean matches(Container container, Level level) { + public boolean matches(RecipeInput container, Level level) { return false; } @@ -76,8 +79,8 @@ public class CoffeeIngredientRecipe implements Recipe { } @Override - public ItemStack assemble(Container container, RegistryAccess registryAccess) { - return getResultItem(registryAccess); + public ItemStack assemble(RecipeInput container, HolderLookup.Provider registries) { + return getResultItem(registries); } @Override @@ -86,7 +89,7 @@ public class CoffeeIngredientRecipe implements Recipe { } @Override - public ItemStack getResultItem(RegistryAccess registryAccess) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -114,7 +117,7 @@ public class CoffeeIngredientRecipe implements Recipe { } public record EffectInstance(ResourceLocation effect, int duration, int amplifier) { //Simplified record for the effect instance - public static final EffectInstance EMPTY = new EffectInstance(new ResourceLocation("darkness"), 0, 0); + public static final EffectInstance EMPTY = new EffectInstance(ResourceLocation.tryParse("darkness"), 0, 0); public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( ResourceLocation.CODEC.fieldOf("effect").forGetter(effect -> effect.effect), @@ -125,7 +128,7 @@ public class CoffeeIngredientRecipe implements Recipe { ); public EffectInstance(MobEffectInstance effect) { - this(BuiltInRegistries.MOB_EFFECT.getKey(effect.getEffect()), effect.getDuration(), effect.getAmplifier()); + this(BuiltInRegistries.MOB_EFFECT.getKey(effect.getEffect().value()), effect.getDuration(), effect.getAmplifier()); } public static EffectInstance fromNetwork(FriendlyByteBuf pBuffer) { @@ -143,7 +146,7 @@ public class CoffeeIngredientRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.ingredient), EffectInstance.CODEC @@ -166,16 +169,22 @@ public class CoffeeIngredientRecipe implements Recipe { ) .apply(instance, CoffeeIngredientRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + CoffeeIngredientRecipe.Serializer::toNetwork, CoffeeIngredientRecipe.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } - @Nullable @Override - public CoffeeIngredientRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + + public static CoffeeIngredientRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int i = pBuffer.readVarInt(); NonNullList list = NonNullList.withSize(i, EffectInstance.EMPTY); for (int j = 0; j < list.size(); ++j) { @@ -186,9 +195,8 @@ public class CoffeeIngredientRecipe implements Recipe { return new CoffeeIngredientRecipe(ingredient, list, maxAmplifier, extraText); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, CoffeeIngredientRecipe pRecipe) { - pRecipe.ingredient.toNetwork(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, CoffeeIngredientRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.ingredient); pBuffer.writeVarInt(pRecipe.instances.size()); for (EffectInstance effect : pRecipe.instances) { effect.toNetwork(pBuffer); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ColorChangeRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ColorChangeRecipe.java index dca1919b9..9c37ce332 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ColorChangeRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ColorChangeRecipe.java @@ -1,24 +1,25 @@ package de.ellpeck.actuallyadditions.mod.crafting; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Optional; -public class ColorChangeRecipe implements Recipe { +public class ColorChangeRecipe implements Recipe { public static final String NAME = "color_change"; private final Ingredient input; @@ -30,8 +31,8 @@ public class ColorChangeRecipe implements Recipe { } @Override - public boolean matches(@Nonnull Container pInv, @Nonnull Level pLevel) { - return input.test(pInv.getItem(0)); + public boolean matches(@Nonnull SingleRecipeInput input, @Nonnull Level pLevel) { + return this.input.test(input.getItem(0)); } public boolean matches(ItemStack stack) { @@ -45,7 +46,7 @@ public class ColorChangeRecipe implements Recipe { @Nonnull @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(SingleRecipeInput input, HolderLookup.Provider provider) { return output.copy(); } @@ -60,7 +61,7 @@ public class ColorChangeRecipe implements Recipe { @Nonnull @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return output.copy(); } @@ -76,40 +77,38 @@ public class ColorChangeRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output), Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.input) ) .apply(instance, ColorChangeRecipe::new) ); - -// @Override -// public ColorChangeRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { -// Ingredient ingredient = Ingredient.fromJson(GsonHelper.getAsJsonObject(pJson, "ingredient")); -// JsonObject resultObject = GsonHelper.getAsJsonObject(pJson, "result"); -// ItemStack result = new ItemStack(GsonHelper.getAsItem(resultObject, "item")); -// -// return new ColorChangeRecipe(pRecipeId, result, ingredient); -// } + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + ColorChangeRecipe.Serializer::toNetwork, ColorChangeRecipe.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } - @Nullable @Override - public ColorChangeRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); - ItemStack result = pBuffer.readItem(); + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + + @Nullable + public static ColorChangeRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); + + ItemStack result = ItemStack.STREAM_CODEC.decode(pBuffer); return new ColorChangeRecipe(result, ingredient); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, ColorChangeRecipe pRecipe) { - pRecipe.input.toNetwork(pBuffer); - pBuffer.writeItem(pRecipe.output); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, ColorChangeRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.input); + ItemStack.STREAM_CODEC.encode(pBuffer, pRecipe.output); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrushingRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrushingRecipe.java index 224b33d65..9e4236820 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrushingRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrushingRecipe.java @@ -2,21 +2,23 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; -public class CrushingRecipe implements Recipe { +public class CrushingRecipe implements Recipe { public static String NAME = "crushing"; protected Ingredient input; protected NonNullList outputs; @@ -39,7 +41,7 @@ public class CrushingRecipe implements Recipe { } @Override - public boolean matches(Container pInv, Level pLevel) { + public boolean matches(RecipeInput pInv, Level pLevel) { return input.test(pInv.getItem(0)); } @@ -54,7 +56,7 @@ public class CrushingRecipe implements Recipe { @Override @Nonnull - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -65,8 +67,8 @@ public class CrushingRecipe implements Recipe { @Override @Nonnull - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { - return this.outputs.get(0).stack.copy(); + public ItemStack getResultItem(HolderLookup.Provider provider) { + return this.outputs.getFirst().stack.copy(); } @Override @@ -82,7 +84,7 @@ public class CrushingRecipe implements Recipe { } public ItemStack getOutputOne() { - return this.outputs.get(0).stack; + return this.outputs.getFirst().stack; } public ItemStack getOutputTwo() { @@ -90,7 +92,7 @@ public class CrushingRecipe implements Recipe { } public float getFirstChance() { - return this.outputs.get(0).chance; + return this.outputs.getFirst().chance; } public float getSecondChance() { return this.outputs.get(1).chance; @@ -114,7 +116,7 @@ public class CrushingRecipe implements Recipe { .apply(instance, CrushingResult::new) ); - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.input), RESULT_CODEC @@ -141,12 +143,20 @@ public class CrushingRecipe implements Recipe { ) .apply(instance, CrushingRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + CrushingRecipe.Serializer::toNetwork, CrushingRecipe.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + // @Override // @Nonnull // public CrushingRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { @@ -173,26 +183,24 @@ public class CrushingRecipe implements Recipe { // return new CrushingRecipe(pRecipeId, ingredient, output1, chance1, output2, chance2); // } - @Override - public CrushingRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); + public static CrushingRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int i = pBuffer.readVarInt(); NonNullList nonnulllist = NonNullList.withSize(i, CrushingResult.EMPTY); for (int j = 0; j < nonnulllist.size(); ++j) { - nonnulllist.set(j, new CrushingResult(pBuffer.readItem(), pBuffer.readFloat())); + nonnulllist.set(j, new CrushingResult(ItemStack.STREAM_CODEC.decode(pBuffer), pBuffer.readFloat())); } return new CrushingRecipe(ingredient, nonnulllist); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, CrushingRecipe pRecipe) { - pRecipe.input.toNetwork(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, CrushingRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.input); pBuffer.writeVarInt(pRecipe.outputs.size()); for (CrushingResult result : pRecipe.outputs) { - pBuffer.writeItem(result.stack); + ItemStack.STREAM_CODEC.encode(pBuffer, result.stack); pBuffer.writeFloat(result.chance); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/EmpowererRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/EmpowererRecipe.java index eb6db8aef..89606cd8a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/EmpowererRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/EmpowererRecipe.java @@ -2,24 +2,25 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class EmpowererRecipe implements Recipe { +public class EmpowererRecipe implements Recipe { public static String NAME = "empowering"; protected final Ingredient input; protected final ItemStack output; @@ -47,7 +48,7 @@ public class EmpowererRecipe implements Recipe { boolean[] unused = {true, true, true, true}; for (ItemStack s : stacks) { if (unused[0] && this.modifiers.get(0).test(s)) { - matches.add(this.modifiers.get(0)); + matches.add(this.modifiers.getFirst()); unused[0] = false; } else if (unused[1] && this.modifiers.get(1).test(s)) { matches.add(this.modifiers.get(1)); @@ -65,7 +66,7 @@ public class EmpowererRecipe implements Recipe { } @Override - public boolean matches(@Nonnull Container pInv, @Nonnull Level pLevel) { + public boolean matches(@Nonnull RecipeInput pInv, @Nonnull Level pLevel) { return false; } @@ -76,7 +77,7 @@ public class EmpowererRecipe implements Recipe { @Override @Nonnull - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return output.copy(); } @@ -87,7 +88,7 @@ public class EmpowererRecipe implements Recipe { @Override @Nonnull - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return output; } @@ -112,7 +113,7 @@ public class EmpowererRecipe implements Recipe { } public Ingredient getStandOne() { - return this.modifiers.get(0); + return this.modifiers.getFirst(); } public Ingredient getStandTwo() { @@ -140,9 +141,9 @@ public class EmpowererRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output), Ingredient.CODEC_NONEMPTY.fieldOf("base").forGetter(recipe -> recipe.input), Ingredient.CODEC_NONEMPTY .listOf() @@ -168,13 +169,21 @@ public class EmpowererRecipe implements Recipe { ) .apply(instance, EmpowererRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + EmpowererRecipe.Serializer::toNetwork, EmpowererRecipe.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } - // @Override + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + +// @Override // @Nonnull // public EmpowererRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { // Ingredient base = Ingredient.fromJson(GsonHelper.getAsJsonObject(pJson, "base")); @@ -196,16 +205,14 @@ public class EmpowererRecipe implements Recipe { // return new EmpowererRecipe(pRecipeId, result, base, mod1, mod2, mod3, mod4, energy, color, time); // } - @Nullable - @Override - public EmpowererRecipe fromNetwork(FriendlyByteBuf pBuffer) { - ItemStack result = pBuffer.readItem(); - Ingredient input = Ingredient.fromNetwork(pBuffer); + public static EmpowererRecipe fromNetwork(RegistryFriendlyByteBuf pBuffer) { + ItemStack result = ItemStack.STREAM_CODEC.decode(pBuffer); + Ingredient input = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int i = pBuffer.readVarInt(); NonNullList nonnulllist = NonNullList.withSize(i, Ingredient.EMPTY); for (int j = 0; j < nonnulllist.size(); ++j) { - nonnulllist.set(j, Ingredient.fromNetwork(pBuffer)); + nonnulllist.set(j, Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer)); } int energy = pBuffer.readInt(); @@ -215,13 +222,12 @@ public class EmpowererRecipe implements Recipe { return new EmpowererRecipe(result, input, nonnulllist, energy, color, time); } - @Override - public void toNetwork(FriendlyByteBuf pBuffer, EmpowererRecipe pRecipe) { - pBuffer.writeItem(pRecipe.output); - pRecipe.input.toNetwork(pBuffer); + public static void toNetwork(RegistryFriendlyByteBuf pBuffer, EmpowererRecipe pRecipe) { + ItemStack.STREAM_CODEC.encode(pBuffer, pRecipe.output); + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.input); pBuffer.writeVarInt(pRecipe.modifiers.size()); for (Ingredient modifier : pRecipe.modifiers) { - modifier.toNetwork(pBuffer); + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, modifier); } pBuffer.writeInt(pRecipe.energyPerStand); pBuffer.writeInt(pRecipe.particleColor); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FermentingRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FermentingRecipe.java index 62db629ef..800aba359 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FermentingRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FermentingRecipe.java @@ -1,13 +1,15 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.mod.inventory.gui.FluidDisplay; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; @@ -17,7 +19,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Optional; -public class FermentingRecipe implements Recipe { +public class FermentingRecipe implements Recipe { public static final String NAME = "fermenting"; private final FluidStack input; private final FluidStack output; @@ -33,11 +35,12 @@ public class FermentingRecipe implements Recipe { } public boolean matches(FluidStack stack) { - return stack.isFluidEqual(this.input); + return FluidStack.isSameFluidSameComponents(stack, this.input); } public boolean matches(FluidStack input, FluidStack output) { - return input.isFluidEqual(this.input) && (output.isEmpty() || output.isFluidEqual(this.output) && input.getAmount() >= this.input.getAmount()); + return FluidStack.isSameFluidSameComponents(input, this.input) && (output.isEmpty() || + FluidStack.isSameFluidSameComponents(output, this.output) && input.getAmount() >= this.input.getAmount()); } public Optional getInputDisplay() { @@ -69,7 +72,7 @@ public class FermentingRecipe implements Recipe { } @Override - public boolean matches(Container pInv, Level pLevel) { + public boolean matches(RecipeInput pInv, Level pLevel) { return false; } @@ -80,7 +83,7 @@ public class FermentingRecipe implements Recipe { @Nonnull @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -91,7 +94,7 @@ public class FermentingRecipe implements Recipe { @Nonnull @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -108,7 +111,7 @@ public class FermentingRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( FluidStack.CODEC.fieldOf("ingredient").forGetter(recipe -> recipe.input), FluidStack.CODEC.fieldOf("result").forGetter(recipe -> recipe.output), @@ -116,52 +119,32 @@ public class FermentingRecipe implements Recipe { ) .apply(instance, FermentingRecipe::new) ); - -// @Nonnull -// @Override -// public FermentingRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { -// JsonObject ingredient = pJson.getAsJsonObject("ingredient"); -// -// ResourceLocation fluidRes = new ResourceLocation(GsonHelper.getAsString(ingredient, "fluid")); -// Fluid fluid = BuiltInRegistries.FLUIDS.getValue(fluidRes); -// if (fluid == null) -// throw new JsonParseException("Unknown fluid '" + fluidRes + "'"); -// int inputAmount = GsonHelper.getAsInt(ingredient, "amount", 80); -// FluidStack input = new FluidStack(fluid, inputAmount); -// -// JsonObject result = pJson.getAsJsonObject("result"); -// ResourceLocation fluidOutputRes = new ResourceLocation(GsonHelper.getAsString(result, "fluid")); -// int outputAmount = GsonHelper.getAsInt(result, "amount"); -// Fluid fluidOutput = BuiltInRegistries.FLUIDS.getValue(fluidOutputRes); -// if(fluidOutput == null) -// throw new JsonParseException("Unknown fluid '" + fluidRes + "'"); -// FluidStack output = new FluidStack(fluidOutput, outputAmount); -// -// int time = GsonHelper.getAsInt(pJson, "time", 100); -// -// return new FermentingRecipe(pRecipeId, input, output, time); -// } - + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + FermentingRecipe.Serializer::toNetwork, FermentingRecipe.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } - @Nullable @Override - public FermentingRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - FluidStack input = FluidStack.readFromPacket(pBuffer); - FluidStack output = FluidStack.readFromPacket(pBuffer); + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + + @Nullable + public static FermentingRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + FluidStack input = FluidStack.STREAM_CODEC.decode(pBuffer); + FluidStack output = FluidStack.STREAM_CODEC.decode(pBuffer); int time = pBuffer.readInt(); return new FermentingRecipe(input, output, time); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, @Nonnull FermentingRecipe pRecipe) { - pRecipe.input.writeToPacket(pBuffer); - pRecipe.output.writeToPacket(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, @Nonnull FermentingRecipe pRecipe) { + FluidStack.STREAM_CODEC.encode(pBuffer, pRecipe.input); + FluidStack.STREAM_CODEC.encode(pBuffer, pRecipe.output); pBuffer.writeInt(pRecipe.time); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java index 2b42b51e2..e4115eac6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java @@ -43,7 +43,7 @@ public final class InitCrafting { // ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior()); // ActuallyAdditionsAPI.addFarmerBehavior(new RedOrchidFarmerBehavior()); - //new RecipePotionRingCharging(new ResourceLocation(ActuallyAdditions.MODID, "potion_ring_charging")); - //new RecipeBioMash(new ResourceLocation(ActuallyAdditions.MODID, "bio_mash")); + //new RecipePotionRingCharging(ActuallyAdditions.modLoc("potion_ring_charging")); + //new RecipeBioMash(ActuallyAdditions.modLoc("bio_mash")); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java index 74040468d..e73726aa8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java @@ -119,7 +119,7 @@ public final class ItemCrafting { // // for (int i = 0; i < 16; i++) { // if (i != TheColoredLampColors.LIGHT_BLUE.ordinal()) { - // new RecipeKeepDataShapeless(new ResourceLocation(ActuallyAdditions.MODID, "dril_color_change" + i), new ItemStack(InitItems.itemDrill, 1, i), new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD), lightBlueDrill.copy(), "dye" + TheColoredLampColors.values()[i].oreName); + // new RecipeKeepDataShapeless(ActuallyAdditions.modLoc("dril_color_change" + i), new ItemStack(InitItems.itemDrill, 1, i), new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD), lightBlueDrill.copy(), "dye" + TheColoredLampColors.values()[i].oreName); // RECIPES_DRILL_COLORING.add(RecipeUtil.lastIRecipe()); // } // } @@ -169,7 +169,7 @@ public final class ItemCrafting { // recipeBattery = RecipeUtil.lastIRecipe(); // // //Double Battery - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "double_battery"), new ItemStack(InitItems.itemBatteryDouble), new ItemStack(InitItems.itemBattery), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBattery), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("double_battery"), new ItemStack(InitItems.itemBatteryDouble), new ItemStack(InitItems.itemBattery), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBattery), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); // recipeBatteryDouble = RecipeUtil.lastIRecipe(); // // //Magnet Ring @@ -185,15 +185,15 @@ public final class ItemCrafting { // recipeWaterRing = RecipeUtil.lastIRecipe(); // // //Triple Battery - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "triple_battery"), new ItemStack(InitItems.itemBatteryTriple), new ItemStack(InitItems.itemBatteryDouble), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryDouble), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("triple_battery"), new ItemStack(InitItems.itemBatteryTriple), new ItemStack(InitItems.itemBatteryDouble), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryDouble), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); // recipeBatteryTriple = RecipeUtil.lastIRecipe(); // // //Quadruple Battery - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quadruple_battery"), new ItemStack(InitItems.itemBatteryQuadruple), new ItemStack(InitItems.itemBatteryTriple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryTriple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("quadruple_battery"), new ItemStack(InitItems.itemBatteryQuadruple), new ItemStack(InitItems.itemBatteryTriple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryTriple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); // recipeBatteryQuadruple = RecipeUtil.lastIRecipe(); // // //Quintuple Battery - // new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quintuple_battery"), new ItemStack(InitItems.itemBatteryQuintuple), new ItemStack(InitItems.itemBatteryQuadruple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryQuadruple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + // new RecipeKeepDataShaped(ActuallyAdditions.modLoc("quintuple_battery"), new ItemStack(InitItems.itemBatteryQuintuple), new ItemStack(InitItems.itemBatteryQuadruple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryQuadruple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); // recipeBatteryQuintuple = RecipeUtil.lastIRecipe(); // // //Bat Wings diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LaserRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LaserRecipe.java index a46d1fafc..9fd02f0fc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LaserRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LaserRecipe.java @@ -1,26 +1,27 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.Optional; -public class LaserRecipe implements Recipe { +public class LaserRecipe implements Recipe { public static String NAME = "laser"; private ItemStack result; private Ingredient itemIngredient; @@ -55,7 +56,7 @@ public class LaserRecipe implements Recipe { //nah @Override - public boolean matches(Container pInv, Level pLevel) { + public boolean matches(RecipeInput pInv, Level pLevel) { return false; } @@ -65,7 +66,7 @@ public class LaserRecipe implements Recipe { } @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return result.copy(); } @@ -75,7 +76,7 @@ public class LaserRecipe implements Recipe { } @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return result; } @@ -98,14 +99,27 @@ public class LaserRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( - ItemStack.RESULT_CODEC.fieldOf("result").forGetter(recipe -> recipe.result), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(recipe -> recipe.result), Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.itemIngredient), Codec.INT.fieldOf("energy").forGetter(recipe -> recipe.energy) ) .apply(instance, LaserRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + LaserRecipe.Serializer::toNetwork, LaserRecipe.Serializer::fromNetwork + ); + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } // @Override // public LaserRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { @@ -117,26 +131,17 @@ public class LaserRecipe implements Recipe { // return new LaserRecipe(pRecipeId, result, ingredient, energy); // } - - @Override - public Codec codec() { - return CODEC; - } - - @Nullable - @Override - public LaserRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); + public static LaserRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int energy = pBuffer.readInt(); - ItemStack result = pBuffer.readItem(); + ItemStack result = ItemStack.STREAM_CODEC.decode(pBuffer); return new LaserRecipe(result, ingredient, energy); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, LaserRecipe pRecipe) { - pRecipe.itemIngredient.toNetwork(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, LaserRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.itemIngredient); pBuffer.writeInt(pRecipe.energy); - pBuffer.writeItem(pRecipe.result); + ItemStack.STREAM_CODEC.encode(pBuffer, pRecipe.result); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LiquidFuelRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LiquidFuelRecipe.java index daf35ce45..42f8d606a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LiquidFuelRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/LiquidFuelRecipe.java @@ -1,12 +1,14 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; @@ -14,7 +16,7 @@ import net.neoforged.neoforge.fluids.FluidStack; import javax.annotation.Nonnull; -public class LiquidFuelRecipe implements Recipe { +public class LiquidFuelRecipe implements Recipe { public static String NAME = "liquid_fuel"; private FluidStack fuel; private int burnTime; @@ -41,12 +43,12 @@ public class LiquidFuelRecipe implements Recipe { } @Override - public boolean matches(@Nonnull Container pInv,@Nonnull Level pLevel) { + public boolean matches(@Nonnull RecipeInput pInv,@Nonnull Level pLevel) { return false; } public boolean matches(FluidStack stack) { - return this.fuel.isFluidEqual(stack); + return FluidStack.isSameFluidSameComponents(this.fuel, stack); } @Override @@ -64,7 +66,7 @@ public class LiquidFuelRecipe implements Recipe { @Nonnull @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -75,7 +77,7 @@ public class LiquidFuelRecipe implements Recipe { @Nonnull @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -92,7 +94,7 @@ public class LiquidFuelRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( FluidStack.CODEC.fieldOf("fuel").forGetter(recipe -> recipe.fuel), Codec.INT.fieldOf("total_energy").forGetter(recipe -> recipe.totalEnergy), @@ -100,13 +102,26 @@ public class LiquidFuelRecipe implements Recipe { ) .apply(instance, LiquidFuelRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + LiquidFuelRecipe.Serializer::toNetwork, LiquidFuelRecipe.Serializer::fromNetwork + ); + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } // @Nonnull // @Override // public LiquidFuelRecipe fromJson(@Nonnull ResourceLocation pId, JsonObject pJson) { // JsonObject ingredient = pJson.getAsJsonObject("ingredient"); // -// ResourceLocation fluidRes = new ResourceLocation(GsonHelper.getAsString(ingredient, "fluid")); +// ResourceLocation fluidRes = ResourceLocation.tryParse(GsonHelper.getAsString(ingredient, "fluid")); // Fluid fluid = BuiltInRegistries.FLUIDS.getValue(fluidRes); // if (fluid == null) // throw new JsonParseException("Unknown fluid '" + fluidRes + "'"); @@ -119,22 +134,15 @@ public class LiquidFuelRecipe implements Recipe { // return new LiquidFuelRecipe(pId, input, totalEnergy, burnTime); // } - @Override - public Codec codec() { - return CODEC; - } - - @Override - public LiquidFuelRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - FluidStack input = FluidStack.readFromPacket(pBuffer); + public static LiquidFuelRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + FluidStack input = FluidStack.STREAM_CODEC.decode(pBuffer); int totalEnergy = pBuffer.readInt(); int burnTime = pBuffer.readInt(); return new LiquidFuelRecipe(input, totalEnergy, burnTime); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, LiquidFuelRecipe pRecipe) { - pRecipe.fuel.writeToPacket(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, LiquidFuelRecipe pRecipe) { + FluidStack.STREAM_CODEC.encode(pBuffer, pRecipe.fuel); pBuffer.writeInt(pRecipe.totalEnergy); pBuffer.writeInt(pRecipe.burnTime); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiningLensRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiningLensRecipe.java index 2146d47c2..fe6e41da5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiningLensRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiningLensRecipe.java @@ -1,23 +1,24 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.util.random.Weight; import net.minecraft.util.random.WeightedEntry; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; -import javax.annotation.Nullable; -public class MiningLensRecipe implements Recipe, WeightedEntry { +public class MiningLensRecipe implements Recipe, WeightedEntry { public static final String NAME = "mining_lens"; private final int weight; @@ -45,7 +46,7 @@ public class MiningLensRecipe implements Recipe, WeightedEntry { } @Override - public boolean matches(Container pInv, Level pLevel) { + public boolean matches(RecipeInput pInv, Level pLevel) { return false; } @@ -56,7 +57,7 @@ public class MiningLensRecipe implements Recipe, WeightedEntry { @Nonnull @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -66,7 +67,7 @@ public class MiningLensRecipe implements Recipe, WeightedEntry { } @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return output; } @@ -81,14 +82,27 @@ public class MiningLensRecipe implements Recipe, WeightedEntry { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.input), Codec.INT.fieldOf("weight").forGetter(recipe -> recipe.weight), - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output) + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(recipe -> recipe.output) ) .apply(instance, MiningLensRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + MiningLensRecipe.Serializer::toNetwork, MiningLensRecipe.Serializer::fromNetwork + ); + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } // @Override // public MiningLensRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { @@ -100,26 +114,17 @@ public class MiningLensRecipe implements Recipe, WeightedEntry { // return new MiningLensRecipe(pRecipeId, ingredient, weight, result); // } - - @Override - public Codec codec() { - return CODEC; - } - - @Nullable - @Override - public MiningLensRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); + public static MiningLensRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int weight = pBuffer.readInt(); - ItemStack result = pBuffer.readItem(); + ItemStack result = ItemStack.STREAM_CODEC.decode(pBuffer); return new MiningLensRecipe(ingredient, weight, result); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, MiningLensRecipe pRecipe) { - pRecipe.input.toNetwork(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, MiningLensRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.input); pBuffer.writeInt(pRecipe.weight); - pBuffer.writeItem(pRecipe.output); + ItemStack.STREAM_CODEC.encode(pBuffer, pRecipe.output); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/PressingRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/PressingRecipe.java index b040a3925..889ba2cdc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/PressingRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/PressingRecipe.java @@ -1,13 +1,14 @@ package de.ellpeck.actuallyadditions.mod.crafting; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.Container; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; @@ -16,7 +17,7 @@ import net.neoforged.neoforge.fluids.FluidStack; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class PressingRecipe implements Recipe { +public class PressingRecipe implements Recipe { public static final String NAME = "pressing"; private final Ingredient input; private final FluidStack output; @@ -27,7 +28,7 @@ public class PressingRecipe implements Recipe { } @Override - public boolean matches(@Nonnull Container pInv, @Nullable Level pLevel) { + public boolean matches(@Nonnull RecipeInput pInv, @Nullable Level pLevel) { return input.test(pInv.getItem(0)); } @@ -41,7 +42,7 @@ public class PressingRecipe implements Recipe { } @Override - public ItemStack assemble(Container pInv, RegistryAccess pRegistryAccess) { + public ItemStack assemble(RecipeInput pInv, HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -55,7 +56,7 @@ public class PressingRecipe implements Recipe { } @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -70,20 +71,33 @@ public class PressingRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.input), FluidStack.CODEC.fieldOf("fluid").forGetter(recipe -> recipe.output) ) .apply(instance, PressingRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + PressingRecipe.Serializer::toNetwork, PressingRecipe.Serializer::fromNetwork + ); + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } // @Nonnull // @Override // public PressingRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) { // Ingredient ingredient = Ingredient.fromJson(GsonHelper.getAsJsonObject(pJson, "ingredient")); // JsonObject result = pJson.getAsJsonObject("result"); -// ResourceLocation fluidRes = new ResourceLocation(GsonHelper.getAsString(result, "fluid")); +// ResourceLocation fluidRes = ResourceLocation.tryParse(GsonHelper.getAsString(result, "fluid")); // int fluidAmount = GsonHelper.getAsInt(result, "amount"); // Fluid fluid = BuiltInRegistries.FLUIDS.getValue(fluidRes); // if(fluid == null) @@ -93,24 +107,16 @@ public class PressingRecipe implements Recipe { // return new PressingRecipe(pRecipeId, ingredient, output); // } - @Override - public Codec codec() { - return CODEC; - } - - @Nullable - @Override - public PressingRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) { - Ingredient ingredient = Ingredient.fromNetwork(pBuffer); - FluidStack output = FluidStack.readFromPacket(pBuffer); + public static PressingRecipe fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); + FluidStack output = FluidStack.STREAM_CODEC.decode(pBuffer); return new PressingRecipe(ingredient, output); } - @Override - public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, @Nonnull PressingRecipe pRecipe) { - pRecipe.input.toNetwork(pBuffer); - pRecipe.output.writeToPacket(pBuffer); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, @Nonnull PressingRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.input); + FluidStack.STREAM_CODEC.encode(pBuffer, pRecipe.output); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java index 1ab9f67a3..53d6d39ee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java @@ -1,18 +1,16 @@ package de.ellpeck.actuallyadditions.mod.crafting; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingInput; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapedRecipe; -import net.neoforged.neoforge.attachment.AttachmentUtils; - -import javax.annotation.Nullable; public class RecipeKeepDataShaped extends ShapedRecipe { public static String NAME = "copy_nbt"; @@ -21,19 +19,19 @@ public class RecipeKeepDataShaped extends ShapedRecipe { } @Override - public ItemStack assemble(CraftingContainer inv, RegistryAccess registryAccess) { - final ItemStack craftingResult = super.assemble(inv, registryAccess); + public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registries) { + final ItemStack craftingResult = super.assemble(inv, registries); TargetNBTIngredient donorIngredient = null; ItemStack datasource = ItemStack.EMPTY; NonNullList ingredients = getIngredients(); for (Ingredient ingredient : ingredients) { - if (ingredient instanceof TargetNBTIngredient) { - donorIngredient = (TargetNBTIngredient) ingredient; + if (ingredient.getCustomIngredient() instanceof TargetNBTIngredient) { + donorIngredient = (TargetNBTIngredient)ingredient.getCustomIngredient(); break; } } if (donorIngredient != null && !inv.isEmpty()) { - for (int i = 0; i < inv.getContainerSize(); i++) { + for (int i = 0; i < inv.size(); i++) { final ItemStack item = inv.getItem(i); if (!item.isEmpty() && donorIngredient.test(item)) { datasource = item; @@ -42,11 +40,8 @@ public class RecipeKeepDataShaped extends ShapedRecipe { } } - if (!datasource.isEmpty() && datasource.hasTag()) - craftingResult.setTag(datasource.getTag().copy()); - - if (!datasource.isEmpty()) - AttachmentUtils.copyStackAttachments(datasource, craftingResult); + if (!datasource.isEmpty() && !datasource.getComponents().isEmpty()) + craftingResult.applyComponents(datasource.getComponents()); return craftingResult; } @@ -58,23 +53,28 @@ public class RecipeKeepDataShaped extends ShapedRecipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = ShapedRecipe.Serializer.CODEC.xmap(RecipeKeepDataShaped::new, $ -> $); + private static final MapCodec CODEC = ShapedRecipe.Serializer.CODEC.xmap(RecipeKeepDataShaped::new, $ -> $); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + RecipeKeepDataShaped.Serializer::toNetwork, RecipeKeepDataShaped.Serializer::fromNetwork + ); @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } - @Nullable @Override - public RecipeKeepDataShaped fromNetwork(FriendlyByteBuf buffer) { - return new RecipeKeepDataShaped(RecipeSerializer.SHAPED_RECIPE.fromNetwork(buffer)); + public StreamCodec streamCodec() { + return STREAM_CODEC; } - @Override - public void toNetwork(FriendlyByteBuf buffer, RecipeKeepDataShaped recipe) { + public static RecipeKeepDataShaped fromNetwork(RegistryFriendlyByteBuf buffer) { + return new RecipeKeepDataShaped(RecipeSerializer.SHAPED_RECIPE.streamCodec().decode(buffer)); + } + + public static void toNetwork(RegistryFriendlyByteBuf buffer, RecipeKeepDataShaped recipe) { try { - RecipeSerializer.SHAPED_RECIPE.toNetwork(buffer, recipe); + RecipeSerializer.SHAPED_RECIPE.streamCodec().encode(buffer, recipe); } catch (Exception exception) { ActuallyAdditions.LOGGER.info("Error writing "+ NAME +" Recipe to packet: ", exception); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java index 968256660..7f06ab3fb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java @@ -10,18 +10,19 @@ package de.ellpeck.actuallyadditions.mod.crafting; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingInput; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapelessRecipe; -import net.neoforged.neoforge.attachment.AttachmentUtils; public class RecipeKeepDataShapeless extends ShapelessRecipe { public static String NAME = "copy_nbt_shapeless"; @@ -38,21 +39,21 @@ public class RecipeKeepDataShapeless extends ShapelessRecipe { } @Override - public ItemStack assemble(CraftingContainer pContainer, RegistryAccess pRegistryAccess) { - ItemStack result = super.assemble(pContainer, pRegistryAccess); + public ItemStack assemble(CraftingInput pContainer, HolderLookup.Provider provider) { + ItemStack result = super.assemble(pContainer, provider); TargetNBTIngredient donorIngredient = null; ItemStack datasource = ItemStack.EMPTY; NonNullList ingredients = getIngredients(); for (Ingredient ingredient : ingredients) { - if (ingredient instanceof TargetNBTIngredient) { - donorIngredient = (TargetNBTIngredient) ingredient; + if (ingredient.getCustomIngredient() instanceof TargetNBTIngredient) { + donorIngredient = (TargetNBTIngredient)ingredient.getCustomIngredient(); break; } } if (donorIngredient != null && !pContainer.isEmpty()) { - for (int i = 0; i < pContainer.getContainerSize(); i++) { + for (int i = 0; i < pContainer.size(); i++) { final ItemStack item = pContainer.getItem(i); if (!item.isEmpty() && donorIngredient.test(item)) { datasource = item; @@ -61,35 +62,39 @@ public class RecipeKeepDataShapeless extends ShapelessRecipe { } } - if (!datasource.isEmpty() && datasource.hasTag()) - result.setTag(datasource.getTag().copy()); + if (!datasource.isEmpty() && !datasource.getComponents().isEmpty()) + result.applyComponents(datasource.getComponents()); else { ActuallyAdditions.LOGGER.info("AA.KeepDataShapeless missing TargetNBTIngredient"); return ItemStack.EMPTY; } - if (!datasource.isEmpty()) - AttachmentUtils.copyStackAttachments(datasource, result); - return result; } public static class Serializer implements RecipeSerializer { - public static final Codec CODEC = ShapelessRecipe.Serializer.CODEC.xmap(RecipeKeepDataShapeless::new, $ -> $); + public static final MapCodec CODEC = ShapelessRecipe.Serializer.CODEC.xmap(RecipeKeepDataShapeless::new, $ -> $); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + RecipeKeepDataShapeless.Serializer::toNetwork, RecipeKeepDataShapeless.Serializer::fromNetwork + ); + @Override - public Codec codec() { + public MapCodec codec() { return CODEC; } @Override - public RecipeKeepDataShapeless fromNetwork(FriendlyByteBuf pBuffer) { - return new RecipeKeepDataShapeless(RecipeSerializer.SHAPELESS_RECIPE.fromNetwork(pBuffer)); + public StreamCodec streamCodec() { + return STREAM_CODEC; } - @Override - public void toNetwork(net.minecraft.network.FriendlyByteBuf pBuffer, RecipeKeepDataShapeless pRecipe) { + public static RecipeKeepDataShapeless fromNetwork(RegistryFriendlyByteBuf pBuffer) { + return new RecipeKeepDataShapeless(RecipeSerializer.SHAPELESS_RECIPE.streamCodec().decode((pBuffer))); + } + + public static void toNetwork(RegistryFriendlyByteBuf pBuffer, RecipeKeepDataShapeless pRecipe) { try { - RecipeSerializer.SHAPELESS_RECIPE.toNetwork(pBuffer, pRecipe); + RecipeSerializer.SHAPELESS_RECIPE.streamCodec().encode(pBuffer, pRecipe); } catch (Exception e) { ActuallyAdditions.LOGGER.info("Failed to serialize " + NAME + " Recipe to packet: " + e.getMessage()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SingleItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SingleItem.java deleted file mode 100644 index 14430dec4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SingleItem.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.crafting; - -import net.minecraft.world.Container; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; - -public class SingleItem implements Container { - private final ItemStack itemStack; - - public SingleItem(ItemStack itemStack) { - this.itemStack = itemStack.copy(); - this.itemStack.setCount(1); - } - - @Override - public int getContainerSize() { - return 1; - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public ItemStack getItem(int pIndex) { - return itemStack; - } - - public ItemStack getItem() { - return itemStack; - } - - @Override - public ItemStack removeItem(int pIndex, int pCount) { - return ItemStack.EMPTY; - } - - @Override - public ItemStack removeItemNoUpdate(int pIndex) { - return ItemStack.EMPTY; - } - - @Override - public void setItem(int pIndex, ItemStack pStack) { - - } - - @Override - public void setChanged() { - - } - - @Override - public boolean stillValid(Player pPlayer) { - return false; - } - - @Override - public void clearContent() { - - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java index b3389be30..6dd6e5282 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/SolidFuelRecipe.java @@ -1,17 +1,20 @@ package de.ellpeck.actuallyadditions.mod.crafting; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.Level; -public class SolidFuelRecipe implements Recipe { +public class SolidFuelRecipe implements Recipe { public static String NAME = "solid_fuel"; private Ingredient itemIngredient; private int burnTime; @@ -32,8 +35,8 @@ public class SolidFuelRecipe implements Recipe { } @Override - public boolean matches(SingleItem pInv, Level pLevel) { - return itemIngredient.test(pInv.getItem()); + public boolean matches(SingleRecipeInput pInv, Level pLevel) { + return itemIngredient.test(pInv.getItem(0)); } public boolean matches(ItemStack stack) { @@ -46,7 +49,7 @@ public class SolidFuelRecipe implements Recipe { } @Override - public ItemStack assemble(SingleItem pInv, RegistryAccess registryAccess) { + public ItemStack assemble(SingleRecipeInput pInv, HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -56,7 +59,7 @@ public class SolidFuelRecipe implements Recipe { } @Override - public ItemStack getResultItem(RegistryAccess pRegistryAccess) { + public ItemStack getResultItem(HolderLookup.Provider provider) { return ItemStack.EMPTY; } @@ -71,7 +74,7 @@ public class SolidFuelRecipe implements Recipe { } public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( Ingredient.CODEC_NONEMPTY.fieldOf("item").forGetter(recipe -> recipe.itemIngredient), Codec.INT.fieldOf("total_energy").forGetter(recipe -> recipe.totalEnergy), @@ -79,6 +82,19 @@ public class SolidFuelRecipe implements Recipe { ) .apply(instance, SolidFuelRecipe::new) ); + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + SolidFuelRecipe.Serializer::toNetwork, SolidFuelRecipe.Serializer::fromNetwork + ); + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } // @Override // public SolidFuelRecipe fromJson(ResourceLocation pId, JsonObject pJson) { @@ -88,23 +104,15 @@ public class SolidFuelRecipe implements Recipe { // return new SolidFuelRecipe(pId, itemIngredient, totalEnergy, burnTime); // } - - @Override - public Codec codec() { - return CODEC; - } - - @Override - public SolidFuelRecipe fromNetwork(FriendlyByteBuf pBuffer) { - Ingredient itemIngredient = Ingredient.fromNetwork(pBuffer); + public static SolidFuelRecipe fromNetwork(RegistryFriendlyByteBuf pBuffer) { + Ingredient itemIngredient = Ingredient.CONTENTS_STREAM_CODEC.decode(pBuffer); int totalEnergy = pBuffer.readInt(); int burnTime = pBuffer.readInt(); return new SolidFuelRecipe(itemIngredient, totalEnergy, burnTime); } - @Override - public void toNetwork(FriendlyByteBuf pBuffer, SolidFuelRecipe pRecipe) { - pRecipe.itemIngredient.toNetwork(pBuffer); + public static void toNetwork(RegistryFriendlyByteBuf pBuffer, SolidFuelRecipe pRecipe) { + Ingredient.CONTENTS_STREAM_CODEC.encode(pBuffer, pRecipe.itemIngredient); pBuffer.writeInt(pRecipe.totalEnergy); pBuffer.writeInt(pRecipe.burnTime); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java index 2dadc131a..1ff07c2dc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java @@ -1,42 +1,59 @@ package de.ellpeck.actuallyadditions.mod.crafting; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; -import org.jetbrains.annotations.Nullable; +import net.neoforged.neoforge.common.crafting.ICustomIngredient; +import net.neoforged.neoforge.common.crafting.IngredientType; import javax.annotation.Nonnull; -import java.util.Arrays; import java.util.stream.Stream; -public class TargetNBTIngredient extends Ingredient { - public static final Codec CODEC = Ingredient.VANILLA_CODEC.xmap(TargetNBTIngredient::new, TargetNBTIngredient::new); //Wrapped in value sub-object +public record TargetNBTIngredient(Ingredient ingredient) implements ICustomIngredient { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + builder -> builder + .group( + Ingredient.CODEC.fieldOf("base").forGetter(TargetNBTIngredient::ingredient) + ) + .apply(builder, TargetNBTIngredient::new)); + + /* public static final Codec CODEC = RecordCodecBuilder.create(builder -> builder.group( BuiltInRegistries.ITEM.byNameCodec().fieldOf( "item").forGetter(TargetNBTIngredient::getItem) ).apply(builder, TargetNBTIngredient::new));*/ - public TargetNBTIngredient(Stream itemLists) { - super(itemLists, ActuallyRecipes.Ingredients.TARGET_NBT); - } - public TargetNBTIngredient(Ingredient ingredient) { - super(Arrays.stream(ingredient.values), ActuallyRecipes.Ingredients.TARGET_NBT); - } - @Override - public boolean test(@Nullable ItemStack pStack) { - return super.test(pStack); - } + @Override + public Stream getItems() { + return Stream.of(ingredient.getItems()); + } - public static TargetNBTIngredient of(ItemLike itemProvider) { - return new TargetNBTIngredient(Stream.of(new ItemValue(new ItemStack(itemProvider)))); + @Override + public boolean test(ItemStack stack) { + return ingredient.test(stack); + } + + @Override + public boolean isSimple() { + return ingredient.isSimple(); + } + + @Override + public IngredientType getType() { + return ActuallyRecipes.Ingredients.TARGET_NBT.get(); + } + + public static Ingredient of(ItemLike itemProvider) { + return new TargetNBTIngredient(Ingredient.of(itemProvider)).toVanilla(); } - public static TargetNBTIngredient of(ItemStack itemStack) { - return new TargetNBTIngredient(Stream.of(new ItemValue(itemStack))); + public static Ingredient of(ItemStack itemStack) { + return new TargetNBTIngredient(Ingredient.of(itemStack)).toVanilla(); } - public static TargetNBTIngredient of(@Nonnull TagKey tag) { - return new TargetNBTIngredient(Stream.of(new TagValue(tag))); + public static Ingredient of(@Nonnull TagKey tag) { + return new TargetNBTIngredient(Ingredient.of(tag)).toVanilla(); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java index 7e29460d8..d8dcd5b30 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java @@ -62,7 +62,7 @@ public final class PlayerData { public IBookletPage[] bookmarks = new IBookletPage[12]; public List completedTrials = new ArrayList<>(); -// @OnlyIn(Dist.CLIENT) +// // public GuiBooklet lastOpenBooklet; public PlayerSave(UUID id) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java index 8543c97fd..b43730485 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; import io.netty.util.internal.ConcurrentSet; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.server.level.ServerLevel; @@ -49,7 +50,7 @@ public class WorldData extends SavedData { } } - public static WorldData load(CompoundTag compound) { + public static WorldData load(CompoundTag compound, HolderLookup.Provider provider) { WorldData worldData = new WorldData(); worldData.laserRelayNetworks.clear(); ListTag networkList = compound.getList("Networks", 10); @@ -74,7 +75,7 @@ public class WorldData extends SavedData { } @Override - public CompoundTag save(CompoundTag compound) { + public CompoundTag save(CompoundTag compound, HolderLookup.Provider provider) { //Laser World Data ListTag networkList = new ListTag(); for (Network network : this.laserRelayNetworks) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java index 76684fc4c..d2c9516b3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java @@ -10,11 +10,11 @@ package de.ellpeck.actuallyadditions.mod.entity; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -28,7 +28,7 @@ import net.minecraft.world.level.block.GrassBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.common.FarmlandWaterManager; -import net.neoforged.neoforge.common.IPlantable; +import net.neoforged.neoforge.common.SpecialPlantable; import net.neoforged.neoforge.common.ticket.AABBTicket; public class EntityWorm extends Entity { @@ -48,7 +48,7 @@ public class EntityWorm extends Entity { BlockPos posUp = pos.above(); BlockState stateUp = world.getBlockState(posUp); Block blockUp = stateUp.getBlock(); - return blockUp instanceof IPlantable || blockUp instanceof BushBlock || stateUp.canBeReplaced(); + return blockUp instanceof SpecialPlantable || blockUp instanceof BushBlock || stateUp.canBeReplaced(); } else { return false; } @@ -85,11 +85,6 @@ public class EntityWorm extends Entity { waterTicket = FarmlandWaterManager.addAABBTicket(this.level(), aabb); } - @Override - public boolean canUpdate() { - return true; - } - @Override public void tick() { if (!this.level().isClientSide) { @@ -117,8 +112,8 @@ public class EntityWorm extends Entity { BlockState plantState = this.level().getBlockState(plant); Block plantBlock = plantState.getBlock(); - if ((plantBlock instanceof BonemealableBlock || plantBlock instanceof IPlantable) && !(plantBlock instanceof GrassBlock)) { - plantBlock.randomTick(plantState, (ServerLevel) this.level(), plant, this.level().random); + if ((plantBlock instanceof BonemealableBlock /*|| plantBlock instanceof IPlantable*/) && !(plantBlock instanceof GrassBlock)) { + plantState.randomTick((ServerLevel) this.level(), plant, this.level().random); BlockState newState = this.level().getBlockState(plant); if (newState != plantState) { @@ -142,7 +137,7 @@ public class EntityWorm extends Entity { } @Override - protected void defineSynchedData() { + protected void defineSynchedData(SynchedEntityData.Builder builder) { } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java index 4af063657..42bff110d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java @@ -11,8 +11,6 @@ package de.ellpeck.actuallyadditions.mod.entity; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; public final class InitEntities { @@ -20,10 +18,10 @@ public final class InitEntities { public static void init() { ActuallyAdditions.LOGGER.info("Initializing Entities..."); - //EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); + //EntityRegistry.registerModEntity(ActuallyAdditions.modLoc("worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); } - @OnlyIn(Dist.CLIENT) + public static void initClient() { //RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java index be5d147a1..b206ee201 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java @@ -19,16 +19,15 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) + public class RenderWorm extends EntityRenderer { private ItemStack stack; @@ -39,7 +38,7 @@ public class RenderWorm extends EntityRenderer { stack = new ItemStack(ActuallyItems.WORM.get()); snailStack = new ItemStack(ActuallyItems.WORM.get()); - snailStack.setHoverName(Component.literal("Snail Mail")); + snailStack.set(DataComponents.CUSTOM_NAME, Component.literal("Snail Mail")); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java index d75df4897..f1aafb8c8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.event; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.data.WorldData; @@ -31,7 +30,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -41,18 +39,16 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.RenderGuiLayerEvent; import net.neoforged.neoforge.client.event.RenderHighlightEvent; -import net.neoforged.neoforge.client.gui.overlay.GuiOverlayManager; -import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.neoforge.client.gui.VanillaGuiLayers; import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; import java.util.List; -@OnlyIn(Dist.CLIENT) + public class ClientEvents { private static final Component ADVANCED_INFO_TEXT_PRE = Component.literal(" -").withStyle(ChatFormatting.DARK_GRAY); @@ -62,13 +58,11 @@ public class ClientEvents { // TODO: [port] the fuck? @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - if (event.phase == TickEvent.Phase.END) { - Minecraft mc = Minecraft.getInstance(); + public void onClientTick(ClientTickEvent.Post event) { + Minecraft mc = Minecraft.getInstance(); - if (mc.level == null) { - WorldData.clear(); - } + if (mc.level == null) { + WorldData.clear(); } } @@ -174,9 +168,9 @@ public class ClientEvents { } @SubscribeEvent - public void onGameOverlay(RenderGuiOverlayEvent.Post event) { + public void onGameOverlay(RenderGuiLayerEvent.Post event) { Minecraft minecraft = Minecraft.getInstance(); - if (event.getOverlay() == GuiOverlayManager.findOverlay(new ResourceLocation("portal")) && minecraft.screen == null) { //ALL + if (event.getName() == VanillaGuiLayers.CAMERA_OVERLAYS && minecraft.screen == null) { //ALL GuiGraphics guiGraphics = event.getGuiGraphics(); Player player = minecraft.player; if (player == null) { @@ -189,7 +183,7 @@ public class ClientEvents { if (StackUtil.isValid(stack)) { if (stack.getItem() instanceof IHudDisplay) { - ((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, event.getWindow()); + ((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); } } @@ -199,7 +193,7 @@ public class ClientEvents { BlockEntity tileHit = minecraft.level.getBlockEntity(rayCast.getBlockPos()); if (blockHit instanceof IHudDisplay) { - ((IHudDisplay) blockHit).displayHud(guiGraphics, minecraft, player, stack, posHit, event.getWindow()); + ((IHudDisplay) blockHit).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); } if (tileHit instanceof TileEntityBase base) { @@ -208,7 +202,7 @@ public class ClientEvents { .append(Component.translatable("info.actuallyadditions.redstoneMode." + (base.isPulseMode ? "pulse" : "deactivation")).withStyle(ChatFormatting.DARK_RED)); - guiGraphics.drawString(font, component, (int) (event.getWindow().getGuiScaledWidth() / 2f + 5), (int) (event.getWindow().getGuiScaledHeight() / 2f + 5), 0xFFFFFF); + guiGraphics.drawString(font, component, (int) (minecraft.getWindow().getGuiScaledWidth() / 2f + 5), (int) (minecraft.getWindow().getGuiScaledHeight() / 2f + 5), 0xFFFFFF); Component expl; if (!stack.isEmpty() && stack.getItem() == CommonConfig.Other.redstoneConfigureItem) { @@ -216,7 +210,7 @@ public class ClientEvents { } else { expl = Component.translatable("info.actuallyadditions.redstoneMode.invalidItem", Component.translatable(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); } - guiGraphics.drawString(font, expl, (int) (event.getWindow().getGuiScaledWidth() / 2f + 5), (int) (event.getWindow().getGuiScaledHeight() / 2f + 15), 0xFFFFFF); + guiGraphics.drawString(font, expl, (int) (minecraft.getWindow().getGuiScaledWidth() / 2f + 5), (int) (minecraft.getWindow().getGuiScaledHeight() / 2f + 15), 0xFFFFFF); } } @@ -225,7 +219,7 @@ public class ClientEvents { if (energyDisplay == null) { energyDisplay = new EnergyDisplay(0, 0, null); } - energyDisplay.setData(2, event.getWindow().getGuiScaledHeight() - 96, display.getEnergyStorage(), true, true); + energyDisplay.setData(2, minecraft.getWindow().getGuiScaledHeight() - 96, display.getEnergyStorage(), true, true); PoseStack matrices = guiGraphics.pose(); matrices.pushPose(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java index deb59c95c..aff812775 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java @@ -11,8 +11,8 @@ package de.ellpeck.actuallyadditions.mod.event; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.data.PlayerData; @@ -28,6 +28,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.TagKey; @@ -36,17 +37,14 @@ import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.bus.api.Event; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.neoforge.common.util.TriState; import net.neoforged.neoforge.event.AnvilUpdateEvent; import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; -import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent; +import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; -import net.neoforged.neoforge.event.level.BlockEvent; import java.util.Locale; @@ -56,19 +54,17 @@ public class CommonEvents { if (event.getLevel().isClientSide) return; if( (event.getLevel().getBlockState(event.getHitVec().getBlockPos()).getBlock() instanceof BlockLaserRelay) && (event.getItemStack().is(CommonConfig.Other.relayConfigureItem))) { - event.setUseItem(Event.Result.DENY); - event.setUseBlock(Event.Result.ALLOW); + event.setUseItem(TriState.FALSE); + event.setUseBlock(TriState.TRUE); +// event.setUseItem(Event.Result.DENY); +// event.setUseBlock(Event.Result.ALLOW); } } @SubscribeEvent - public void onItemPickup(EntityItemPickupEvent event) { - if (event.isCanceled() || event.getResult() == Event.Result.ALLOW) { - return; - } - - Player player = event.getEntity(); - ItemEntity item = event.getItem(); + public void onItemPickup(ItemEntityPickupEvent.Pre event) { + Player player = event.getPlayer(); + ItemEntity item = event.getItemEntity(); if (item != null && item.isAlive()) { ItemStack stack = item.getItem(); if (StackUtil.isValid(stack)) { @@ -76,59 +72,57 @@ public class CommonEvents { if (i != player.getInventory().selected) { ItemStack invStack = player.getInventory().getItem(i); - if (StackUtil.isValid(invStack) && (invStack.getItem() instanceof Sack) && invStack.hasTag()) { - if (invStack.getOrCreateTag().getBoolean("AutoInsert")) { - boolean changed = false; - boolean isVoid = ((Sack) invStack.getItem()).isVoid; + if (StackUtil.isValid(invStack) && (invStack.getItem() instanceof Sack)) { + boolean changed = false; + boolean isVoid = ((Sack) invStack.getItem()).isVoid; - FilterSettings filter = new FilterSettings(4, false, false, false, false); - filter.readFromNBT(invStack.getOrCreateTag(), "Filter"); + FilterSettings filter = new FilterSettings(4, false, false, false, false); + filter.readFromNBT(player.registryAccess(), new CompoundTag(), "Filter"); //TODO: IMPORTANT, FIX FILTER READ! - if (isVoid) { - if (filter.check(stack)) { - stack.setCount(0); - changed = true; - } + if (isVoid) { + if (filter.check(stack)) { + stack.setCount(0); + changed = true; } - else { - var optHandler = SackManager.get().getHandler(invStack); + } + else { + var optHandler = SackManager.get().getHandler(invStack); - if (optHandler.isEmpty()) - continue; + if (optHandler.isEmpty()) + continue; - ItemStackHandlerAA inv = optHandler.get(); + ItemStackHandlerAA inv = optHandler.get(); - if (filter.check(stack)) { - for (int j = 0; j < inv.getSlots(); j++) { - ItemStack bagStack = inv.getStackInSlot(j); - if (StackUtil.isValid(bagStack)) { - if (ItemUtil.canBeStacked(bagStack, stack)) { - int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount()); - if (maxTransfer > 0) { - inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer)); - stack.shrink(maxTransfer); - changed = true; - } - } - } else { - inv.setStackInSlot(j, stack.copy()); - stack.setCount(0); + if (filter.check(stack)) { + for (int j = 0; j < inv.getSlots(); j++) { + ItemStack bagStack = inv.getStackInSlot(j); + if (StackUtil.isValid(bagStack)) { + if (ItemUtil.canBeStacked(bagStack, stack)) { + int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount()); + if (maxTransfer > 0) { + inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer)); + stack.shrink(maxTransfer); changed = true; } - - if (stack.isEmpty()) { - break; - } } + } else { + inv.setStackInSlot(j, stack.copy()); + stack.setCount(0); + changed = true; + } + + if (stack.isEmpty()) { + break; + } } } + } - if (changed) { + if (changed) { /* if (!isVoid) { DrillItem.writeSlotsToNBT(inv, invStack); }*/ - event.setResult(Event.Result.ALLOW); - } + event.setCanPickup(TriState.FALSE); } } } @@ -162,8 +156,8 @@ public class CommonEvents { if (event.getEntity().level() != null && !event.getEntity().level().isClientSide && event.getSource().getEntity() instanceof Player) { //Drop Cobwebs from Spiders if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntity() instanceof Spider) { - if (event.getEntity().level().random.nextInt(20) <= event.getLootingLevel() * 2) { - event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), new ItemStack(Blocks.COBWEB, event.getEntity().level().random.nextInt(2 + event.getLootingLevel()) + 1))); + if (event.getEntity().level().random.nextInt(20) <= /*event.getLootingLevel() * 2*/ 1) {//TODO: Looting Level is gone from LivingDropsEvent + event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), new ItemStack(Blocks.COBWEB, event.getEntity().level().random.nextInt(2 + 1/*event.getLootingLevel()*/) + 1))); } } } @@ -209,19 +203,20 @@ public class CommonEvents { //TODO im pretty sure this can be done with normal advancements... @SubscribeEvent - public void onPickupEvent(EntityItemPickupEvent event) { + public void onPickupEvent(ItemEntityPickupEvent.Pre event) { //checkAchievements(event.getItem().getItem(), event.getEntityPlayer(), InitAchievements.Type.PICK_UP); } @SubscribeEvent public void onAnvilEvent(AnvilUpdateEvent event) { if (!event.getLeft().isEmpty() && event.getLeft().getItem() instanceof ItemTag && event.getName() != null && !event.getName().isEmpty()) { event.setCost(0); - if (ResourceLocation.isValidResourceLocation(event.getName())) { - TagKey tagKey = TagKey.create(Registries.ITEM, new ResourceLocation(event.getName())); + ResourceLocation tagLocation = ResourceLocation.tryParse(event.getName()); + if (tagLocation != null) { + TagKey tagKey = TagKey.create(Registries.ITEM, tagLocation); var tag = BuiltInRegistries.ITEM.getTag(tagKey); if (tag.isPresent()) { ItemStack stack = event.getLeft().copy(); - stack.getData(ActuallyAttachments.ITEM_TAG).setTag(tagKey); + stack.set(ActuallyComponents.ITEM_TAG, tagLocation); event.setOutput(stack); } else { event.setCanceled(true); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java index 130619433..b833eeb9a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java @@ -24,7 +24,7 @@ import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathType; import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions; import net.neoforged.neoforge.common.SoundActions; import net.neoforged.neoforge.fluids.BaseFlowingFluid; @@ -56,8 +56,8 @@ public class FluidAA implements Supplier { public FluidAA(String fluidName, String textureName) { this.name = fluidName; - this.stillTexture = new ResourceLocation(ActuallyAdditions.MODID, "block/" + textureName + "_still"); - this.flowingTexture = new ResourceLocation(ActuallyAdditions.MODID, "block/" + textureName + "_flowing"); + this.stillTexture = ActuallyAdditions.modLoc("block/" + textureName + "_still"); + this.flowingTexture = ActuallyAdditions.modLoc("block/" + textureName + "_flowing"); this.fluidType = InitFluids.FLUID_TYPES.register(name, () -> new FluidType(createTypeProperties()) { @Override public void initializeClient(Consumer consumer) { @@ -78,8 +78,8 @@ public class FluidAA implements Supplier { source = InitFluids.FLUIDS.register(name, () -> new BaseFlowingFluid.Source(createProperties(fluidType, source, flowing, bucket, fluidBlock))); flowing = InitFluids.FLUIDS.register(name + "_flowing", () -> new BaseFlowingFluid.Flowing(createProperties(fluidType, source, flowing, bucket, fluidBlock))); - fluidBlock = ActuallyBlocks.BLOCKS.register(name, () -> new LiquidBlock(source, BlockBehaviour.Properties.ofFullCopy(Blocks.WATER))); - bucket = ActuallyItems.ITEMS.register(name + "_bucket", () -> new BucketItem(source, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))); + fluidBlock = ActuallyBlocks.BLOCKS.register(name, () -> new LiquidBlock(source.get(), BlockBehaviour.Properties.ofFullCopy(Blocks.WATER))); + bucket = ActuallyItems.ITEMS.register(name + "_bucket", () -> new BucketItem(source.get(), new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))); } public FluidType getFluidType() { @@ -107,7 +107,7 @@ public class FluidAA implements Supplier { return FluidType.Properties.create() .canSwim(true) .canDrown(true) - .pathType(BlockPathTypes.LAVA) + .pathType(PathType.LAVA) .sound(SoundActions.BUCKET_FILL, SoundEvents.BUCKET_FILL) .sound(SoundActions.BUCKET_EMPTY, SoundEvents.BUCKET_EMPTY); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java index 8d2dd3c50..a848823fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyBiomeModifiers.java @@ -5,9 +5,8 @@ import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModif import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderSet; import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BiomeTags; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.GenerationStep; @@ -17,9 +16,9 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries; public class ActuallyBiomeModifiers { protected static final ResourceKey ADD_BLACK_QUARTZ_ORE_MODIFIER = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, - new ResourceLocation(ActuallyAdditions.MODID, "add_black_quartz")); + ActuallyAdditions.modLoc("add_black_quartz")); - public static void bootstrap(BootstapContext context) { + public static void bootstrap(BootstrapContext context) { HolderGetter biomeGetter = context.lookup(Registries.BIOME); HolderGetter placedGetter = context.lookup(Registries.PLACED_FEATURE); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java index a203f809c..77a019934 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyConfiguredFeatures.java @@ -1,7 +1,7 @@ package de.ellpeck.actuallyadditions.mod.gen; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.data.worldgen.features.FeatureUtils; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.BlockTags; @@ -16,7 +16,7 @@ import java.util.List; public class ActuallyConfiguredFeatures { public static final ResourceKey> ORE_BLACK_QUARTZ = FeatureUtils.createKey("actuallyadditions:ore_black_quartz"); - public static void bootstrap(BootstapContext> context) { + public static void bootstrap(BootstrapContext> context) { RuleTest stoneRuleTest = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); RuleTest deepslateRuleTest = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES); List list = List.of( diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java index 3dc4394f7..77df044b3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyPlacedFeatures.java @@ -2,7 +2,7 @@ package de.ellpeck.actuallyadditions.mod.gen; import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.levelgen.VerticalAnchor; @@ -19,7 +19,7 @@ import java.util.List; public class ActuallyPlacedFeatures { public static final ResourceKey PLACED_ORE_BLACK_QUARTZ = PlacementUtils.createKey("actuallyadditions:ore_black_quartz"); - public static void bootstrap(BootstapContext context) { + public static void bootstrap(BootstrapContext context) { HolderGetter> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE); PlacementUtils.register(context, PLACED_ORE_BLACK_QUARTZ, holdergetter.getOrThrow(ActuallyConfiguredFeatures.ORE_BLACK_QUARTZ), diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyProcessorLists.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyProcessorLists.java index 6353c96dd..9930efa98 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyProcessorLists.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyProcessorLists.java @@ -4,9 +4,8 @@ import com.google.common.collect.ImmutableList; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.levelgen.structure.templatesystem.AlwaysTrueTest; import net.minecraft.world.level.levelgen.structure.templatesystem.ProcessorRule; @@ -19,9 +18,9 @@ import java.util.List; public class ActuallyProcessorLists { public static final ResourceKey ENGINEER_HOUSE_PROCESSOR_LIST_KEY = ResourceKey.create( - Registries.PROCESSOR_LIST, new ResourceLocation(ActuallyAdditions.MODID, "engineer_house")); + Registries.PROCESSOR_LIST, ActuallyAdditions.modLoc("engineer_house")); - public static void bootstrap(BootstapContext context) { + public static void bootstrap(BootstrapContext context) { register(context, ENGINEER_HOUSE_PROCESSOR_LIST_KEY, ImmutableList.of(new RuleProcessor(ImmutableList.of( new ProcessorRule(new RandomBlockMatchTest(ActuallyBlocks.LAMP_WHITE.get(), 0.0625F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.LAMP_ORANGE.get().defaultBlockState().setValue(BlockStateProperties.LIT, true)), new ProcessorRule(new RandomBlockMatchTest(ActuallyBlocks.LAMP_WHITE.get(), 0.0625F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.LAMP_MAGENTA.get().defaultBlockState().setValue(BlockStateProperties.LIT, true)), @@ -41,7 +40,7 @@ public class ActuallyProcessorLists { )))); } - private static void register(BootstapContext bootstapContext, + private static void register(BootstrapContext bootstapContext, ResourceKey processorListResourceKey, List structureProcessorList) { bootstapContext.register(processorListResourceKey, new StructureProcessorList(structureProcessorList)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyVillages.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyVillages.java index a9bf57fd3..da3bd7c95 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyVillages.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/ActuallyVillages.java @@ -67,23 +67,23 @@ public class ActuallyVillages { //Add Engineer house to villages addBuildingToPool(templatePoolRegistry, processorListRegistry, - new ResourceLocation("minecraft:village/plains/houses"), + ResourceLocation.tryParse("minecraft:village/plains/houses"), ActuallyAdditions.MODID + ":andrew_period_house", 10); addBuildingToPool(templatePoolRegistry, processorListRegistry, - new ResourceLocation("minecraft:village/snowy/houses"), + ResourceLocation.tryParse("minecraft:village/snowy/houses"), ActuallyAdditions.MODID + ":andrew_period_house", 10); addBuildingToPool(templatePoolRegistry, processorListRegistry, - new ResourceLocation("minecraft:village/savanna/houses"), + ResourceLocation.tryParse("minecraft:village/savanna/houses"), ActuallyAdditions.MODID + ":andrew_period_house", 10); addBuildingToPool(templatePoolRegistry, processorListRegistry, - new ResourceLocation("minecraft:village/taiga/houses"), + ResourceLocation.tryParse("minecraft:village/taiga/houses"), ActuallyAdditions.MODID + ":andrew_period_house", 10); addBuildingToPool(templatePoolRegistry, processorListRegistry, - new ResourceLocation("minecraft:village/desert/houses"), + ResourceLocation.tryParse("minecraft:village/desert/houses"), ActuallyAdditions.MODID + ":andrew_period_house", 50); //Add Actually Additions crops to village farms @@ -94,21 +94,21 @@ public class ActuallyVillages { new ProcessorRule(new RandomBlockMatchTest(Blocks.WHEAT, 0.05F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.FLAX.get().defaultBlockState()) )); - addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_plains"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_savanna"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_snowy"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_taiga"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_desert"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("minecraft:farm_plains"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("minecraft:farm_savanna"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("minecraft:farm_snowy"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("minecraft:farm_taiga"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("minecraft:farm_desert"), cropProcessor, processorListRegistry); // Can target other mod's processor lists - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/badlands/crop_replacement"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/birch/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/dark_forest/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/giant_taiga/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/jungle/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/mountains/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/oak/crop_randomizer"), cropProcessor, processorListRegistry); - addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/swamp/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/badlands/crop_replacement"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/birch/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/dark_forest/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/giant_taiga/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/jungle/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/mountains/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/oak/crop_randomizer"), cropProcessor, processorListRegistry); + addNewRuleToProcessorList(ResourceLocation.tryParse("repurposed_structures:villages/swamp/crop_randomizer"), cropProcessor, processorListRegistry); } private static void addNewRuleToProcessorList(ResourceLocation targetProcessorList, StructureProcessor processorToAdd, Registry processorListRegistry) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java index f58b38caf..b8025da2e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/modifier/BoolConfigFeatureBiomeModifier.java @@ -1,6 +1,6 @@ package de.ellpeck.actuallyadditions.mod.gen.modifier; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import net.minecraft.core.Holder; @@ -33,7 +33,7 @@ public record BoolConfigFeatureBiomeModifier(HolderSet biomes, HolderSet< } @Override - public Codec codec() { + public MapCodec codec() { return ActuallyAdditions.BOOL_CONFIG_MODIFIER.get(); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java index a9f57b294..9bf730b19 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java @@ -17,6 +17,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.ItemCost; import net.minecraft.world.item.trading.MerchantOffer; import org.jetbrains.annotations.Nullable; @@ -67,7 +68,7 @@ public class BasicTradeList implements VillagerTrades.ItemListing { in.setCount(this.inputAmount.getPrice(random)); ItemStack out = this.stack.copy(); out.setCount(this.outputAmount.getPrice(random)); - return new MerchantOffer(in, out, this.maxUses, this.villagerXp, this.priceMultiplier); + return new MerchantOffer(new ItemCost(in.getItem(), in.getCount()), out, this.maxUses, this.villagerXp, this.priceMultiplier); } public static class PriceRange extends Tuple { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java index 78c6b79c3..cbc23029f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java @@ -46,7 +46,7 @@ // //public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 { // -// private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ActuallyAdditions.MODID, "andrew_period_house"); +// private static final ResourceLocation STRUCTURE_RES_LOC = ActuallyAdditions.modLoc("andrew_period_house"); // // private static final int X_SIZE = 13; // private static final int Y_SIZE = 11; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java index 121ba4c7a..e0191e8da 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java @@ -19,7 +19,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.common.CommonHooks; import java.util.Objects; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java index 3efb636b0..4c34990e4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java @@ -25,6 +25,7 @@ import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.neoforged.neoforge.capabilities.Capabilities; import org.jetbrains.annotations.Nullable; @@ -77,13 +78,13 @@ public class ContainerEnergizer extends AbstractContainerMenu { @Override public boolean mayPickup(Player player) { ItemStack itemstack = this.getItem(); - return (itemstack.isEmpty() || player.isCreative() || !EnchantmentHelper.hasBindingCurse(itemstack)) && super.mayPickup(player); + return (itemstack.isEmpty() || player.isCreative() || !EnchantmentHelper.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) && super.mayPickup(player); } @Nullable @Override public Pair getNoItemIcon() { - return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[slot.getIndex()]); + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS.get(slot.getIndex())); } }); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java index 1f53aa638..96c20e317 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java @@ -71,7 +71,7 @@ public class ContainerEnervator extends AbstractContainerMenu { @Nullable @Override public Pair getNoItemIcon() { - return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[slot.getIndex()]); + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS.get(slot.getIndex())); } }); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java index 0b4460114..b9f7983a3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.inventory; -import de.ellpeck.actuallyadditions.mod.crafting.SingleItem; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPoweredFurnace; @@ -23,6 +22,7 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.item.crafting.SmeltingRecipe; import javax.annotation.Nonnull; @@ -79,7 +79,7 @@ public class ContainerFurnaceDouble extends AbstractContainerMenu { //Other Slots in Inventory excluded else if (slot >= inventoryStart) { // TODO: VALIDATE - RecipeHolder recipeHolder = this.furnace.getLevel().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(newStack), this.furnace.getLevel()).orElse(null); + RecipeHolder recipeHolder = this.furnace.getLevel().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(newStack), this.furnace.getLevel()).orElse(null); if (recipeHolder == null) { return ItemStack.EMPTY; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ItemTagContainer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ItemTagContainer.java index 8a2b634ef..944696206 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ItemTagContainer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ItemTagContainer.java @@ -1,6 +1,6 @@ package de.ellpeck.actuallyadditions.mod.inventory; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.ItemTag; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import net.minecraft.network.FriendlyByteBuf; @@ -34,9 +34,6 @@ public class ItemTagContainer extends AbstractContainerMenu implements IButtonRe @Override public void onButtonPressed(int buttonID, Player player) { ItemStack stack = player.getInventory().getSelected(); - stack.getExistingData(ActuallyAttachments.ITEM_TAG).ifPresent(data -> { - data.setTag(null); - stack.setData(ActuallyAttachments.ITEM_TAG, data); - }); + stack.remove(ActuallyComponents.ITEM_TAG); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java index f29f79923..464f08a16 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/SackContainer.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -84,11 +83,11 @@ public class SackContainer extends AbstractContainerMenu implements IButtonReact ItemStack stack = playerInventory.getSelected(); if (!stack.isEmpty() && stack.getItem() instanceof Sack) { - if (stack.hasTag()) { - CompoundTag compound = stack.getOrCreateTag(); - this.filter.readFromNBT(compound, "Filter"); - this.autoInsert = compound.getBoolean("AutoInsert"); - } +// if (stack.hasTag()) { TODO: IMPORTANT! RE_ENABLE FILTER READ +// CompoundTag compound = stack.getOrCreateTag(); +// this.filter.readFromNBT(playerInventory.player.registryAccess(), compound, "Filter"); +// this.autoInsert = compound.getBoolean("AutoInsert"); +// } } } @@ -154,9 +153,9 @@ public class SackContainer extends AbstractContainerMenu implements IButtonReact public void removed(@Nonnull Player player) { ItemStack stack = this.inventory.getSelected(); if (!stack.isEmpty() && stack.getItem() instanceof Sack) { - CompoundTag compound = stack.getOrCreateTag(); - this.filter.writeToNBT(compound, "Filter"); - compound.putBoolean("AutoInsert", this.autoInsert); +// CompoundTag compound = stack.getOrCreateTag();TODO: IMPORTANT! RE_ENABLE FILTER WRITE +// this.filter.writeToNBT(compound, "Filter"); +// compound.putBoolean("AutoInsert", this.autoInsert); } super.removed(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/VoidSackContainer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/VoidSackContainer.java index f18838fee..768f7f71c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/VoidSackContainer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/VoidSackContainer.java @@ -7,7 +7,6 @@ import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -65,11 +64,11 @@ public class VoidSackContainer extends AbstractContainerMenu implements IButtonR ItemStack stack = inventory.getSelected(); if (!stack.isEmpty() && stack.getItem() instanceof Sack) { - if (stack.hasTag()) { - CompoundTag compound = stack.getOrCreateTag(); - this.filter.readFromNBT(compound, "Filter"); - this.autoInsert = compound.getBoolean("AutoInsert"); - } +// if (stack.hasTag()) { TODO: IMPORTANT! RE_ENABLE FILTER READ +// CompoundTag compound = stack.getOrCreateTag(); +// this.filter.readFromNBT(compound, "Filter"); +// this.autoInsert = compound.getBoolean("AutoInsert"); +// } } } @@ -87,11 +86,11 @@ public class VoidSackContainer extends AbstractContainerMenu implements IButtonR @Override public void removed(@Nonnull Player player) { ItemStack stack = this.inventory.getSelected(); - if (!stack.isEmpty() && stack.getItem() instanceof Sack) { - CompoundTag compound = stack.getOrCreateTag(); - this.filter.writeToNBT(compound, "Filter"); - compound.putBoolean("AutoInsert", this.autoInsert); - } +// if (!stack.isEmpty() && stack.getItem() instanceof Sack) { +// CompoundTag compound = stack.getOrCreateTag(); +// this.filter.writeToNBT(compound, "Filter"); TODO: IMPORTANT! RE_ENABLE FILTER READ +// compound.putBoolean("AutoInsert", this.autoInsert); +// } super.removed(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/Buttons.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/Buttons.java index 2909bd4b5..62ed9a90b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/Buttons.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/Buttons.java @@ -8,13 +8,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; public class Buttons { - @OnlyIn(Dist.CLIENT) + @Deprecated(forRemoval = true) //Vanilla's Button class can render small just fine and even allows text scrolling public static class SmallerButton extends Button { @@ -60,7 +58,7 @@ public class Buttons { } } - @OnlyIn(Dist.CLIENT) + public static class TinyButton extends Button { public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/CrusherScreen.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/CrusherScreen.java index 0ef8c1f2d..4ea96618b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/CrusherScreen.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/CrusherScreen.java @@ -20,12 +20,10 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class CrusherScreen extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_grinder"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java index 9a1f563e6..6a0f0e54b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java @@ -16,14 +16,12 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; -@OnlyIn(Dist.CLIENT) + public class EnergyDisplay { private CustomEnergyStorage rfReference; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java index f2eb71260..fca358019 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -18,14 +17,12 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -@OnlyIn(Dist.CLIENT) + public class FilterSettingsGui { private final FilterSettings theSettings; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java index 2c476de67..74e052a2d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; @@ -26,8 +27,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FastColor; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.material.Fluid; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.IFluidTank; @@ -37,7 +36,7 @@ import javax.annotation.Nonnull; import java.text.NumberFormat; import java.util.Collections; -@OnlyIn(Dist.CLIENT) + public class FluidDisplay { private IFluidTank fluidReference; @@ -134,7 +133,7 @@ public class FluidDisplay { for (int i = 0; i < count; i++) { double subHeight = Math.min(16.0, tankLevel - (16.0 * i)); double offsetY = 84 - 16.0 * i - subHeight; - drawQuad(barX + 1, barY + offsetY, 16, subHeight, minU, (float) (maxV - deltaV * (subHeight / 16.0)), maxU, maxV); + drawQuad((float) (barX + 1), (float) (barY + offsetY), 16F, (float) subHeight, minU, (float) (maxV - deltaV * (subHeight / 16.0)), maxU, maxV); } RenderSystem.disableBlend(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); @@ -146,15 +145,14 @@ public class FluidDisplay { } } - private void drawQuad(double x, double y, double width, double height, float minU, float minV, float maxU, float maxV) { + private void drawQuad(float x, float y, float width, float height, float minU, float minV, float maxU, float maxV) { Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - buffer.vertex(x, y + height, 0).uv(minU, maxV).endVertex(); - buffer.vertex(x + width, y + height, 0).uv(maxU, maxV).endVertex(); - buffer.vertex(x + width, y, 0).uv(maxU, minV).endVertex(); - buffer.vertex(x, y, 0).uv(minU, minV).endVertex(); - tesselator.end(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + buffer.addVertex(x, y + height, 0).setUv(minU, maxV); + buffer.addVertex(x + width, y + height, 0).setUv(maxU, maxV); + buffer.addVertex(x + width, y, 0).setUv(maxU, minV); + buffer.addVertex(x, y, 0).setUv(minU, minV); + BufferUploader.drawWithShader(buffer.buildOrThrow()); } public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) { @@ -174,7 +172,7 @@ public class FluidDisplay { String cap = format.format(this.fluidReference.getCapacity()); return stack.isEmpty() ? Component.literal("0/" + cap + " mB") - : Component.literal(format.format(this.fluidReference.getFluidAmount()) + (drawCapacityInTooltip?"/" + cap + " mB ":" mB ")).append(stack.getDisplayName()); + : Component.literal(format.format(this.fluidReference.getFluidAmount()) + (drawCapacityInTooltip?"/" + cap + " mB ":" mB ")).append(stack.getHoverName()); } public static class DummyTank implements IFluidTank { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java index 3dc28bc51..6e1843b08 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java @@ -18,12 +18,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiBreaker extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java index 5d2a5e171..b6ced1672 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java @@ -18,12 +18,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiCanolaPress extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_canola_press"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java index c30307e04..d623bd8b8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java @@ -18,12 +18,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiCoalGenerator extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_coal_generator"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java index 3ab28200c..76e7092cf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java @@ -21,13 +21,11 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import java.util.Collections; -@OnlyIn(Dist.CLIENT) + public class GuiCoffeeMachine extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_coffee_machine"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java index 061dcf5bf..c09ab016f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java @@ -18,12 +18,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiDirectionalBreaker extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_directional_breaker"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java index e9b580c37..5a741b935 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java @@ -17,13 +17,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiDrill extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_drill"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java index 6b0a9a45e..2ab6e5244 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java @@ -18,11 +18,9 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) + public class GuiDropper extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java index 283823578..c7af08032 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java @@ -18,12 +18,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiEnergizer extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_energizer"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java index 6f8998c44..bdc62641a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java @@ -18,13 +18,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiEnervator extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_energizer"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java index 2be96ba81..ba3132097 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java @@ -18,13 +18,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiFarmer extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_farmer"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java index 9bdea973a..baed37ba0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; import com.mojang.blaze3d.systems.RenderSystem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFeeder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; @@ -19,13 +18,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import java.util.List; -@OnlyIn(Dist.CLIENT) + public class GuiFeeder extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_feeder"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java index c3eb7fe8b..3cd87a869 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java @@ -18,13 +18,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiFermentingBarrel extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_fermenting_barrel"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java index 2732631af..c27619db4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java @@ -17,12 +17,10 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiFilter extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_filter"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFireworkBox.java index 6243471e4..089c138a5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFireworkBox.java @@ -21,13 +21,11 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.text.DecimalFormat; import java.text.NumberFormat; -@OnlyIn(Dist.CLIENT) + public class GuiFireworkBox extends AbstractContainerScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_firework_box"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java index 7504a8d4b..5952e427b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java @@ -18,13 +18,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiFluidCollector extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_fluid_collector"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java index 9e5c19fd3..a8d6538c2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java @@ -21,12 +21,10 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiFurnaceDouble extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_furnace_double"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java index d7587d4fd..4ee3bc556 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java @@ -26,7 +26,7 @@ // //import java.io.IOException; // -//@OnlyIn(Dist.CLIENT) +// //public class GuiGiantChest extends GuiWtfMojang { // // private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_giant_chest"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java index 7100373ad..72ffcad39 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; import com.mojang.blaze3d.systems.RenderSystem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; @@ -27,15 +26,13 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.network.PacketDistributor; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; -@OnlyIn(Dist.CLIENT) + public class GuiLaserRelayItemWhitelist extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_laser_relay_item_whitelist"); @@ -91,7 +88,7 @@ public class GuiLaserRelayItemWhitelist extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java index f0a57aa6d..b505f64af 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java @@ -19,13 +19,11 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiOilGenerator extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_oil_generator"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java index 8861da114..8ae412812 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java @@ -21,14 +21,12 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; -@OnlyIn(Dist.CLIENT) + public class GuiPhantomPlacer extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java index b4e6616dd..51a6ed2f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java @@ -22,14 +22,12 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.network.PacketDistributor; import javax.annotation.Nonnull; -@OnlyIn(Dist.CLIENT) + public class GuiRangedCollector extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_ranged_collector"); @@ -82,7 +80,7 @@ public class GuiRangedCollector extends AAScreen { data.putInt("X", this.collector.getBlockPos().getX()); data.putInt("Y", this.collector.getBlockPos().getY()); data.putInt("Z", this.collector.getBlockPos().getZ()); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java index 9232b1cb2..d6cf4d2a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java @@ -21,7 +21,7 @@ //import net.minecraftforge.api.distmarker.OnlyIn; // // -//@OnlyIn(Dist.CLIENT) +// //public class GuiRepairer extends GuiWtfMojang { // // private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_repairer"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java index 7ec9d1852..4ac85d3d2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java @@ -31,7 +31,7 @@ // //import java.io.IOException; // -//@OnlyIn(Dist.CLIENT) +// //public class GuiSmileyCloud extends GuiWtfMojang { // // private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_smiley_cloud"); @@ -122,6 +122,6 @@ // compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId()); // compound.putInt("TextID", textID); // compound.setString("Text", text); -// PacketDistributor.SERVER.noArg().send(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER)); +// PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER)); // } //} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java index 32ae8b829..e025bee0d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java @@ -20,11 +20,8 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) public class GuiXPSolidifier extends AAScreen { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_xp_solidifier"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/ItemTagScreen.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/ItemTagScreen.java index 973dcd97f..024c8838f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/ItemTagScreen.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/ItemTagScreen.java @@ -57,7 +57,7 @@ public class ItemTagScreen extends AAScreen { if (valid) { this.tagBox.setTextColor(0x00FF00); - TagKey tagKey = TagKey.create(Registries.ITEM, new ResourceLocation(text)); + TagKey tagKey = TagKey.create(Registries.ITEM, ResourceLocation.tryParse(text)); Optional> optionalNamed = BuiltInRegistries.ITEM.getTag(tagKey); if (optionalNamed.isPresent()) { @@ -86,14 +86,14 @@ public class ItemTagScreen extends AAScreen { data.putInt("PlayerID", Minecraft.getInstance().player.getId()); data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString()); data.putString("Tag", tagBox.getValue()); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); this.minecraft.player.closeContainer(); } return tagBox.keyPressed(pKeyCode, pScanCode, pModifiers) || tagBox.canConsumeInput() || super.keyPressed(pKeyCode, pScanCode, pModifiers); } private boolean validateTag(String tag) { - return ResourceLocation.isValidResourceLocation(tag); + return ResourceLocation.tryParse(tag) != null; //return !tag.matches("^[a-z0-9_\\-]+:[a-z0-9_\\-]+(/[a-z0-9_\\-]+)*$"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java index e489b89bf..87d66b36f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/SackGui.java @@ -69,7 +69,7 @@ public class SackGui extends AAScreen { data.putInt("ButtonID", id); data.putInt("PlayerID", Minecraft.getInstance().player.getId()); data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString()); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java index f88dfba9e..c872434a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java @@ -17,14 +17,12 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -@OnlyIn(Dist.CLIENT) + public class TexturedButton extends Button { public final List textList = new ArrayList<>(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/VoidSackGui.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/VoidSackGui.java index 0b657f92d..70192a74e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/VoidSackGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/VoidSackGui.java @@ -69,7 +69,7 @@ public class VoidSackGui extends AAScreen { data.putInt("ButtonID", id); data.putInt("PlayerID", Minecraft.getInstance().player.getId()); data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString()); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java index 8cc109f52..249102d24 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.AABlockItem; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.lens.ItemLens; @@ -27,6 +28,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; +import net.neoforged.neoforge.energy.ComponentEnergyStorage; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; @@ -241,7 +243,9 @@ public final class ActuallyItems { public static void registerCapabilities(RegisterCapabilitiesEvent event) { for (DeferredHolder holder : ITEMS.getEntries()) { if (holder.get() instanceof ItemEnergy energyItem) { - event.registerItem(Capabilities.EnergyStorage.ITEM, (stack, context) -> energyItem.getEnergyStorage(stack), holder.get()); + event.registerItem(Capabilities.EnergyStorage.ITEM, (stack, context) -> + new ComponentEnergyStorage(stack, ActuallyComponents.ENERGY_STORAGE.get(), energyItem.maxPower) + ); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/AllInOneTool.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/AllInOneTool.java index dfc17b433..b155f08e8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/AllInOneTool.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/AllInOneTool.java @@ -1,7 +1,6 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyTags; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.DiggerItem; import net.minecraft.world.item.ItemStack; @@ -9,9 +8,8 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; import java.util.List; @@ -19,13 +17,13 @@ public class AllInOneTool extends DiggerItem { private final Tier tier; private static List ACTIONS = List.of( - ToolActions.AXE_DIG, - ToolActions.HOE_DIG, - ToolActions.PICKAXE_DIG, - ToolActions.SHOVEL_DIG, - ToolActions.HOE_TILL, - ToolActions.SHOVEL_FLATTEN, - ToolActions.AXE_STRIP + ItemAbilities.AXE_DIG, + ItemAbilities.HOE_DIG, + ItemAbilities.PICKAXE_DIG, + ItemAbilities.SHOVEL_DIG, + ItemAbilities.HOE_TILL, + ItemAbilities.SHOVEL_FLATTEN, + ItemAbilities.AXE_STRIP ); public AllInOneTool(Tier tier) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/CanolaSeed.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/CanolaSeed.java index 6a6856123..7a5294933 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/CanolaSeed.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/CanolaSeed.java @@ -29,8 +29,8 @@ public class CanolaSeed extends ItemBase { BlockState state = entity.level().getBlockState(pos); Block block = state.getBlock(); - if (block instanceof LiquidBlock && state.getFluidState().isSource()) { - Fluid fluid = ((LiquidBlock) block).getFluid(); + if (block instanceof LiquidBlock liquidBlock && state.getFluidState().isSource()) { + Fluid fluid = liquidBlock.fluid; if (fluid != null && fluid == (empowered ? InitFluids.CRYSTALLIZED_OIL.get() : InitFluids.REFINED_CANOLA_OIL.get())) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java index ed1e2a0ac..298410be5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/DrillItem.java @@ -24,6 +24,7 @@ import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -49,7 +50,9 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.neoforged.neoforge.common.*; +import net.neoforged.neoforge.common.CommonHooks; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.items.IItemHandler; import net.neoforged.neoforge.items.IItemHandlerModifiable; @@ -60,24 +63,24 @@ import java.util.List; public class DrillItem extends ItemEnergy { public static final int HARVEST_LEVEL = 4; private static final int ENERGY_USE = 100; - private static final List ACTIONS = List.of(ToolActions.SHOVEL_DIG, ToolActions.PICKAXE_DIG); + private static final List ACTIONS = List.of(ItemAbilities.SHOVEL_DIG, ItemAbilities.PICKAXE_DIG); - private final Multimap attributes_unpowered = ArrayListMultimap.create(); - private final Multimap attributes_powered = ArrayListMultimap.create(); + private final Multimap, AttributeModifier> attributes_unpowered = ArrayListMultimap.create(); + private final Multimap, AttributeModifier> attributes_powered = ArrayListMultimap.create(); public DrillItem() { - super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1), 250000, 1000); - attributes_powered.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Drill Modifier", 8.0F, AttributeModifier.Operation.ADDITION)); - attributes_powered.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID,"Tool Modifier", 1.5F, AttributeModifier.Operation.ADDITION)); - attributes_unpowered.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Drill Modifier", 0.1F, AttributeModifier.Operation.ADDITION)); - attributes_unpowered.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID,"Tool Modifier", 1.5F, AttributeModifier.Operation.ADDITION)); + super(ActuallyItems.defaultProps().durability(0).stacksTo(1), 250000, 1000); + attributes_powered.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ActuallyAdditions.modLoc("drill_speed_powered"), 8.0F, AttributeModifier.Operation.ADD_VALUE)); + attributes_powered.put(Attributes.ATTACK_SPEED, new AttributeModifier(ActuallyAdditions.modLoc("drill_speed_powered"), 1.5F, AttributeModifier.Operation.ADD_VALUE)); + attributes_unpowered.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ActuallyAdditions.modLoc("drill_attack"), 0.1F, AttributeModifier.Operation.ADD_VALUE)); + attributes_unpowered.put(Attributes.ATTACK_SPEED, new AttributeModifier(ActuallyAdditions.modLoc("drill_speed"), 1.5F, AttributeModifier.Operation.ADD_VALUE)); } @Override - public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ToolAction toolAction) { + public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ItemAbility toolAction) { return ACTIONS.contains(toolAction); } - @Override + public boolean isCorrectToolForDrops(@Nonnull BlockState pBlock) { Tier tier = Tiers.NETHERITE; //Use Nettherite as the tier as it has the same harvest level as the drill if (TierSortingRegistry.isTierSorted(tier)) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Filler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Filler.java index 27dfc53c5..19a43ae38 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Filler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Filler.java @@ -13,13 +13,8 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtUtils; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; @@ -29,12 +24,9 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.List; @@ -68,13 +60,13 @@ public class Filler extends ItemEnergy { } private static void saveData(BlockState state, ItemStack wand) { - wand.getOrCreateTag().put("state", NbtUtils.writeBlockState(state)); +// wand.getOrCreateTag().put("state", NbtUtils.writeBlockState(state)); TODO: IMPORTANT: Fix Filler Item! } private static Optional loadData(ItemStack stack) { - if (stack.getOrCreateTag().contains("state")) { - return Optional.of(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), stack.getOrCreateTag().getCompound("state"))); - } +// if (stack.getOrCreateTag().contains("state")) { +// return Optional.of(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), stack.getOrCreateTag().getCompound("state"))); +// } return Optional.empty(); } @@ -92,16 +84,16 @@ public class Filler extends ItemEnergy { saveData(state, stack); return InteractionResult.SUCCESS; } else if (loadData(stack).isPresent()) { - CompoundTag compound = stack.getOrCreateTag(); - - if (compound.getInt("CurrX") == 0 && compound.getInt("CurrY") == 0 && compound.getInt("CurrZ") == 0) { - compound.putInt("FirstX", context.getClickedPos().getX()); - compound.putInt("FirstY", context.getClickedPos().getY()); - compound.putInt("FirstZ", context.getClickedPos().getZ()); - - context.getPlayer().startUsingItem(context.getHand()); - return InteractionResult.SUCCESS; - } +// CompoundTag compound = stack.getOrCreateTag(); +// +// if (compound.getInt("CurrX") == 0 && compound.getInt("CurrY") == 0 && compound.getInt("CurrZ") == 0) { +// compound.putInt("FirstX", context.getClickedPos().getX()); +// compound.putInt("FirstY", context.getClickedPos().getY()); +// compound.putInt("FirstZ", context.getClickedPos().getZ()); +// +// context.getPlayer().startUsingItem(context.getHand()); +// return InteractionResult.SUCCESS; +// } } } return super.useOn(context); @@ -114,20 +106,20 @@ public class Filler extends ItemEnergy { if (entity instanceof Player player) { HitResult result = player.pick(Util.getReachDistance(player), 1f, false); if (result instanceof BlockHitResult) { - CompoundTag compound = stack.getOrCreateTag(); - - BlockPos pos = ((BlockHitResult) result).getBlockPos(); - compound.putInt("SecondX", pos.getX()); - compound.putInt("SecondY", pos.getY()); - compound.putInt("SecondZ", pos.getZ()); - - clear = false; +// CompoundTag compound = stack.getOrCreateTag(); +// +// BlockPos pos = ((BlockHitResult) result).getBlockPos(); +// compound.putInt("SecondX", pos.getX()); +// compound.putInt("SecondY", pos.getY()); +// compound.putInt("SecondZ", pos.getZ()); +// +// clear = false; } } if (clear) { - ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ"); - } +// ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ"); + } //TODO: HOOK BACK UP!!!!!!!!!!!!!!!!!!!!!!! } super.releaseUsing(stack, world, entity, timeLeft); @@ -141,88 +133,88 @@ public class Filler extends ItemEnergy { if (!world.isClientSide) { boolean shouldClear = false; - if (isSelected) { - if (entity instanceof Player player && stack.hasTag()) { - boolean creative = player.isCreative(); +// if (isSelected) { +// if (entity instanceof Player player && stack.hasTag()) { +// boolean creative = player.isCreative(); +// +// CompoundTag compound = stack.getOrCreateTag(); +// +// BlockPos firstPos = new BlockPos(compound.getInt("FirstX"), compound.getInt("FirstY"), compound.getInt("FirstZ")); +// BlockPos secondPos = new BlockPos(compound.getInt("SecondX"), compound.getInt("SecondY"), compound.getInt("SecondZ")); +// +// if (!BlockPos.ZERO.equals(firstPos) && !BlockPos.ZERO.equals(secondPos)) { +// int energyUse = 1500; +// +// Optional data = loadData(stack); +// if (data.isPresent() && (creative || this.getEnergyStored(stack) >= energyUse)) { +// BlockState replaceState = data.get(); // not the best way to do this. +// int lowestX = Math.min(firstPos.getX(), secondPos.getX()); +// int lowestY = Math.min(firstPos.getY(), secondPos.getY()); +// int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ()); +// +// int currX = compound.getInt("CurrX"); +// int currY = compound.getInt("CurrY"); +// int currZ = compound.getInt("CurrZ"); +// +// BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ); +// BlockState state = world.getBlockState(pos); +// +// if (state.canBeReplaced() && replaceState.canSurvive(world, pos)) { +// if (creative || removeFittingItem(replaceState, player)) { +// world.setBlock(pos, replaceState, 2); +// +// SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player); +// world.playSound(null, pos, sound.getPlaceSound(), SoundSource.BLOCKS, sound.getVolume() / 2F + .5F, sound.getPitch() * 0.8F); +// +// if (!creative) { +// this.extractEnergy(stack, energyUse, false); +// } +// } else { +// shouldClear = true; +// } +// } +// +// int distX = Math.abs(secondPos.getX() - firstPos.getX()); +// int distY = Math.abs(secondPos.getY() - firstPos.getY()); +// int distZ = Math.abs(secondPos.getZ() - firstPos.getZ()); +// +// currX++; +// if (currX > distX) { +// currX = 0; +// currY++; +// if (currY > distY) { +// currY = 0; +// currZ++; +// if (currZ > distZ) { +// shouldClear = true; +// } +// } +// } +// +// if (!shouldClear) { +// compound.putInt("CurrX", currX); +// compound.putInt("CurrY", currY); +// compound.putInt("CurrZ", currZ); +// } +// } else { +// shouldClear = true; +// } +// } +// } +// } else { +// shouldClear = true; +// } - CompoundTag compound = stack.getOrCreateTag(); - - BlockPos firstPos = new BlockPos(compound.getInt("FirstX"), compound.getInt("FirstY"), compound.getInt("FirstZ")); - BlockPos secondPos = new BlockPos(compound.getInt("SecondX"), compound.getInt("SecondY"), compound.getInt("SecondZ")); - - if (!BlockPos.ZERO.equals(firstPos) && !BlockPos.ZERO.equals(secondPos)) { - int energyUse = 1500; - - Optional data = loadData(stack); - if (data.isPresent() && (creative || this.getEnergyStored(stack) >= energyUse)) { - BlockState replaceState = data.get(); // not the best way to do this. - int lowestX = Math.min(firstPos.getX(), secondPos.getX()); - int lowestY = Math.min(firstPos.getY(), secondPos.getY()); - int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ()); - - int currX = compound.getInt("CurrX"); - int currY = compound.getInt("CurrY"); - int currZ = compound.getInt("CurrZ"); - - BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ); - BlockState state = world.getBlockState(pos); - - if (state.canBeReplaced() && replaceState.canSurvive(world, pos)) { - if (creative || removeFittingItem(replaceState, player)) { - world.setBlock(pos, replaceState, 2); - - SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player); - world.playSound(null, pos, sound.getPlaceSound(), SoundSource.BLOCKS, sound.getVolume() / 2F + .5F, sound.getPitch() * 0.8F); - - if (!creative) { - this.extractEnergyInternal(stack, energyUse, false); - } - } else { - shouldClear = true; - } - } - - int distX = Math.abs(secondPos.getX() - firstPos.getX()); - int distY = Math.abs(secondPos.getY() - firstPos.getY()); - int distZ = Math.abs(secondPos.getZ() - firstPos.getZ()); - - currX++; - if (currX > distX) { - currX = 0; - currY++; - if (currY > distY) { - currY = 0; - currZ++; - if (currZ > distZ) { - shouldClear = true; - } - } - } - - if (!shouldClear) { - compound.putInt("CurrX", currX); - compound.putInt("CurrY", currY); - compound.putInt("CurrZ", currZ); - } - } else { - shouldClear = true; - } - } - } - } else { - shouldClear = true; - } - - if (shouldClear) { - ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ"); + if (shouldClear) { //TODO: HOOK BACK UP!!!!!!!!!!!!!!!!!!!!!!! +// ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ"); } } } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, worldIn, tooltip, flagIn); + public void appendHoverText(ItemStack stack, @Nullable TooltipContext context, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); MutableComponent display = loadData(stack) .map(state -> state.getBlock().getName()) @@ -232,7 +224,7 @@ public class Filler extends ItemEnergy { } @Override - public int getUseDuration(ItemStack stack) { + public int getUseDuration(ItemStack stack, LivingEntity livingEntity) { return Integer.MAX_VALUE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java index c03d3f805..1a0aaa515 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java @@ -20,8 +20,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.energy.IEnergyStorage; @@ -71,9 +69,9 @@ public class ItemBattery extends ItemEnergy { return super.use(worldIn, player, hand); } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List list, TooltipFlag advanced) { + public void appendHoverText(ItemStack stack, @Nullable TooltipContext playerIn, List list, TooltipFlag advanced) { super.appendHoverText(stack, playerIn, list, advanced); list.add(Component.translatable("tooltip.actuallyadditions.battery." + (ItemUtil.isEnabled(stack) ? "discharge" diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index e44552a79..730b9c7ca 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -20,7 +20,6 @@ import net.minecraft.advancements.AdvancementHolder; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.ServerAdvancementManager; import net.minecraft.server.level.ServerPlayer; @@ -33,15 +32,12 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.HitResult; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import javax.annotation.Nullable; import java.util.List; public class ItemBooklet extends ItemBase implements IHudDisplay { - @OnlyIn(Dist.CLIENT) + public static IBookletPage forcedPage; public ItemBooklet() { @@ -72,12 +68,12 @@ public class ItemBooklet extends ItemBase implements IHudDisplay { ServerPlayer serverPlayer = (ServerPlayer) player; PlayerAdvancements advancements = serverPlayer.getAdvancements(); ServerAdvancementManager manager = player.getServer().getAdvancements(); - AdvancementHolder advancement = manager.get(new ResourceLocation(ActuallyAdditions.MODID, "root")); + AdvancementHolder advancement = manager.get(ActuallyAdditions.modLoc("root")); if (advancement != null && !advancements.getOrStartProgress(advancement).isDone()) { advancements.award(advancement, "right_click"); } } else { - vazkii.patchouli.api.PatchouliAPI.get().openBookGUI(new ResourceLocation(ActuallyAdditions.MODID, "booklet")); + vazkii.patchouli.api.PatchouliAPI.get().openBookGUI(ActuallyAdditions.modLoc("booklet")); } // player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); // @@ -88,9 +84,9 @@ public class ItemBooklet extends ItemBase implements IHudDisplay { return InteractionResultHolder.success(player.getItemInHand(hand)); } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List tooltip, TooltipFlag advanced) { + public void appendHoverText(ItemStack stack, TooltipContext pContext, List tooltip, TooltipFlag advanced) { tooltip.add(Component.translatable("tooltip.actuallyadditions.item_booklet.desc").withStyle(ChatFormatting.GRAY)); // TODO: this is bad @@ -104,7 +100,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay { } @Override - @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { // if (rayCast != null && rayCast.getBlockPos() != null) { // BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java index 32e4ff491..af9063954 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.ChatFormatting; @@ -27,16 +26,13 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.UseAnim; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.List; public class ItemCoffee extends ItemBase { //TODO: Do we want to change the saturation? Currently it's 5.0F which becomes 40 in game. That's a lot of saturation. - private static final FoodProperties FOOD = new FoodProperties.Builder().nutrition(8).saturationMod(5.0F).alwaysEat().build(); + private static final FoodProperties FOOD = new FoodProperties.Builder().nutrition(8).saturationModifier(5.0F).alwaysEdible().build(); public ItemCoffee() { super(ActuallyItems.defaultProps().food(FOOD).durability(3)); @@ -79,9 +75,8 @@ public class ItemCoffee extends ItemBase { //TODO: Do we want to change the satu return UseAnim.DRINK; } - @OnlyIn(Dist.CLIENT) @Override - public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List tooltip, TooltipFlag advanced) { + public void appendHoverText(ItemStack stack, TooltipContext pContext, List tooltip, TooltipFlag advanced) { MobEffectInstance[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); if (effects != null) { for (MobEffectInstance effect : effects) { @@ -99,10 +94,10 @@ public class ItemCoffee extends ItemBase { //TODO: Do we want to change the satu return false; } - @Override - public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { - return false; - } +// @Override +// public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { +// return false; +// } public static class MilkIngredient extends CoffeeIngredient { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java index a8d4983c8..9e4101eea 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java @@ -51,7 +51,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public void getSubItems(CreativeTabs tab, NonNullList list) { // if (this.isInCreativeTab(tab)) { // for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) { @@ -68,7 +68,7 @@ // } // // @Override -// @OnlyIn(Dist.CLIENT) +// // public IItemColor getItemColor() { // return (stack, tintIndex) -> { // int damage = stack.getItemDamage(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java index 30ee2227f..6da6e190d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java @@ -20,12 +20,10 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.AABB; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.client.event.ClientTickEvent; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.TickEvent; import java.util.List; import java.util.Set; @@ -51,9 +49,9 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles { return StackUtil.isValid(face) && face.getItem() instanceof IGoggles; } - @OnlyIn(Dist.CLIENT) + @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { + public void onClientTick(ClientTickEvent.Post event) { Player player = Minecraft.getInstance().player; if (player != null && isWearing(player)) { ItemStack face = player.getInventory().armor.get(3); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java index 035d69d3b..96c0d5e81 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -23,8 +22,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import javax.annotation.Nullable; import java.util.List; @@ -44,10 +41,10 @@ public class ItemFilter extends ItemBase { return InteractionResultHolder.pass(player.getItemInHand(hand)); } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, worldIn, tooltip, flagIn); + public void appendHoverText(ItemStack stack, @Nullable TooltipContext pContext, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, pContext, tooltip, flagIn); ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT); DrillItem.loadSlotsFromNBT(inv, stack); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java index 5681b52e2..f5a3294ad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; @@ -23,7 +22,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.GrassBlock; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.common.IPlantable; import java.util.ArrayList; import java.util.List; @@ -57,7 +55,7 @@ public class ItemGrowthRing extends ItemEnergy { int theZ = Mth.floor(player.getZ() + z); BlockPos posInQuestion = new BlockPos(theX, theY, theZ); Block theBlock = world.getBlockState(posInQuestion).getBlock(); - if ((theBlock instanceof BonemealableBlock || theBlock instanceof IPlantable) && !(theBlock instanceof GrassBlock)) { + if ((theBlock instanceof BonemealableBlock /*|| theBlock instanceof IPlantable*/) && !(theBlock instanceof GrassBlock)) { blocks.add(posInQuestion); } } @@ -80,7 +78,7 @@ public class ItemGrowthRing extends ItemEnergy { } if (!player.isCreative()) { - this.extractEnergyInternal(stack, energyUse, false); + this.extractEnergy(stack, energyUse, false); } } else { break; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java index 69520b537..39c2b680e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java @@ -11,7 +11,7 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; import net.minecraft.ChatFormatting; @@ -24,8 +24,6 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.util.List; @@ -58,7 +56,7 @@ public class ItemLaserWrench extends ItemBase { int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange()); int range = lowestRange * lowestRange; if (ItemPhantomConnector.getStoredWorld(stack) == world.dimension() && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)) { - ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); + ItemPhantomConnector.clearStorage(stack, ActuallyComponents.POSITION.get(), ActuallyComponents.LEVEL.get()); ((TileEntityLaserRelay) savedTile).sendUpdate(); relay.sendUpdate(); @@ -70,7 +68,7 @@ public class ItemLaserWrench extends ItemBase { } player.displayClientMessage(Component.translatable("tooltip.actuallyadditions.laser.cantConnect.desc"), false); - ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); + ItemPhantomConnector.clearStorage(stack, ActuallyComponents.POSITION.get(), ActuallyComponents.LEVEL.get()); } } } @@ -86,9 +84,8 @@ public class ItemLaserWrench extends ItemBase { // return new CompoundNBT(); // } - @OnlyIn(Dist.CLIENT) @Override - public void appendHoverText(ItemStack stack, Level playerIn, List list, TooltipFlag advanced) { + public void appendHoverText(ItemStack stack, TooltipContext playerIn, List list, TooltipFlag advanced) { BlockPos coords = ItemPhantomConnector.getStoredPosition(stack); if (coords != null) { list.add(Component.translatable("tooltip.actuallyadditions.boundTo.desc").append(":")); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java index 8b477e4fb..a90a80f55 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java @@ -58,7 +58,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { } @Override - public int getUseDuration(@Nonnull ItemStack stack) { + public int getUseDuration(ItemStack stack, LivingEntity livingEntity) { return Integer.MAX_VALUE; } @@ -69,7 +69,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { private boolean doUpdate(Level world, int x, int y, int z, int time, ItemStack stack) { if (!world.isClientSide) { - if (time <= this.getUseDuration(stack) && (this.isAdvanced || time % 3 == 0)) { + if (time <= this.getUseDuration(stack, null) && (this.isAdvanced || time % 3 == 0)) { //Breaks the Blocks boolean broke = this.breakStuff(world, x, y, z); //Plays a Minecart sounds (It really sounds like a Leaf Blower!) @@ -114,7 +114,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); - BlockPos pos = breakPositions.get(0); + BlockPos pos = breakPositions.getFirst(); BlockState theState = world.getBlockState(pos); world.destroyBlock(pos, true); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java index 510d251f2..ea3b43fcb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java @@ -60,7 +60,7 @@ public class ItemMagnetRing extends ItemEnergy { if (!player.isCreative()) { if (!item.isAlive() || !ItemStack.matches(item.getItem(), oldItem)) { - this.extractEnergyInternal(stack, energyForItem, false); + this.extractEnergy(stack, energyForItem, false); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java index 446ec9898..62124bc15 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java @@ -11,26 +11,21 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.component.DataComponentType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import javax.annotation.Nullable; import java.util.List; public class ItemPhantomConnector extends ItemBase { @@ -40,40 +35,22 @@ public class ItemPhantomConnector extends ItemBase { } public static ResourceKey getStoredWorld(ItemStack stack) { - CompoundTag tag = stack.getOrCreateTag(); - if (!tag.contains("WorldOfTileStored")) { - return null; - } - - return ResourceKey.create(Registries.DIMENSION, new ResourceLocation(tag.getString("WorldOfTileStored"))); + return stack.get(ActuallyComponents.LEVEL); } public static BlockPos getStoredPosition(ItemStack stack) { - CompoundTag tag = stack.getOrCreateTag(); - int x = tag.getInt("XCoordOfTileStored"); - int y = tag.getInt("YCoordOfTileStored"); - int z = tag.getInt("ZCoordOfTileStored"); - if (!(x == 0 && y == 0 && z == 0)) { - return new BlockPos(x, y, z); - } - - return null; + return stack.get(ActuallyComponents.POSITION); } - public static void clearStorage(ItemStack stack, String... keys) { - CompoundTag compound = stack.getOrCreateTag(); - for (String key : keys) { - compound.remove(key); + public static void clearStorage(ItemStack stack, DataComponentType... componentTypes) { + for (DataComponentType key : componentTypes) { + stack.remove(key); } } public static void storeConnection(ItemStack stack, int x, int y, int z, Level world) { - CompoundTag tag = stack.getOrCreateTag(); - - tag.putInt("XCoordOfTileStored", x); - tag.putInt("YCoordOfTileStored", y); - tag.putInt("ZCoordOfTileStored", z); - tag.putString("WorldOfTileStored", world.dimension().location().toString()); + stack.set(ActuallyComponents.POSITION, new BlockPos(x, y, z)); + stack.set(ActuallyComponents.LEVEL, world.dimension()); } @Override @@ -92,7 +69,7 @@ public class ItemPhantomConnector extends ItemBase { if (tile instanceof TileEntityBase) { ((TileEntityBase) tile).sendUpdate(); } - clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); + clearStorage(stack, ActuallyComponents.POSITION.get(), ActuallyComponents.LEVEL.get()); context.getPlayer().displayClientMessage(Component.translatable("tooltip.actuallyadditions.phantom.connected.desc"), true); return InteractionResult.SUCCESS; } @@ -112,9 +89,8 @@ public class ItemPhantomConnector extends ItemBase { // return new CompoundTag(); // } - @OnlyIn(Dist.CLIENT) - @Override - public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List list, TooltipFlag advanced) { + @Override + public void appendHoverText(ItemStack stack, TooltipContext pContext, List list, TooltipFlag advanced) { BlockPos coords = getStoredPosition(stack); if (coords != null) { list.add(Component.translatable("tooltip.actuallyadditions.boundTo.desc").append(":")); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java index d09b130cd..e5196e65e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java @@ -10,11 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -26,10 +25,7 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import javax.annotation.Nullable; import java.util.List; import java.util.UUID; @@ -43,19 +39,18 @@ public class ItemPlayerProbe extends ItemBase { @Override public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) { if (!world.isClientSide) { - CompoundTag compound = stack.getOrCreateTag(); - if (compound.contains("UUID")) { - UUID id = compound.getUUID("UUID"); - Player player = world.getPlayerByUUID(id); + UUID uuid = stack.get(ActuallyComponents.UUID); + if (uuid != null) { + Player player = world.getPlayerByUUID(uuid); if (player != null) { if (player.isShiftKeyDown()) { - ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); + ItemPhantomConnector.clearStorage(stack, ActuallyComponents.UUID.get(), ActuallyComponents.NAME.get()); ((Player) entity).displayClientMessage(Component.translatable("tooltip.actuallyadditions.playerProbe.disconnect.1"), false); player.displayClientMessage(Component.translatable("tooltip.actuallyadditions.playerProbe.notice"), false); //TheAchievements.GET_UNPROBED.get(player); } } else { - ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); + ItemPhantomConnector.clearStorage(stack, ActuallyComponents.UUID.get(), ActuallyComponents.NAME.get()); ((Player) entity).displayClientMessage(Component.translatable("tooltip.actuallyadditions.playerProbe.disconnect.2"), false); } } @@ -72,15 +67,16 @@ public class ItemPlayerProbe extends ItemBase { ItemStack stack = player.getItemInHand(context.getHand()); BlockEntity tile = context.getLevel().getBlockEntity(context.getClickedPos()); if (tile instanceof TileEntityPlayerInterface face) { - CompoundTag compound = stack.getOrCreateTag(); - if (compound.contains("UUID")) { + UUID uuid = stack.get(ActuallyComponents.UUID); + String name = stack.get(ActuallyComponents.NAME); + if (uuid != null) { if (!context.getLevel().isClientSide) { - face.connectedPlayer = compound.getUUID("UUID"); - face.playerName = compound.getString("Name"); + face.connectedPlayer = uuid; + face.playerName = name; face.setChanged(); face.sendUpdate(); - ItemPhantomConnector.clearStorage(stack, "UUID", "Name"); + ItemPhantomConnector.clearStorage(stack, ActuallyComponents.UUID.get(), ActuallyComponents.NAME.get()); } return InteractionResult.SUCCESS; } @@ -96,9 +92,8 @@ public class ItemPlayerProbe extends ItemBase { if (entity instanceof Player playerHit) { if (!playerHit.isShiftKeyDown()) { - CompoundTag compound = stack.getOrCreateTag(); - compound.putString("Name", playerHit.getName().getString()); - compound.putUUID("UUID", playerHit.getUUID()); + stack.set(ActuallyComponents.UUID, playerHit.getUUID()); + stack.set(ActuallyComponents.NAME, playerHit.getName().getString()); return InteractionResult.SUCCESS; } } @@ -107,11 +102,11 @@ public class ItemPlayerProbe extends ItemBase { return InteractionResult.FAIL; } - @OnlyIn(Dist.CLIENT) + @Override - public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List tooltip, TooltipFlag advanced) { - if (stack.getOrCreateTag().contains("Name")) { - String name = stack.getOrCreateTag().getString("Name"); + public void appendHoverText(ItemStack stack, TooltipContext pContext, List tooltip, TooltipFlag advanced) { + String name = stack.get(ActuallyComponents.NAME); + if (name != null) { tooltip.add(Component.translatable("tooltip.actuallyadditions.playerProbe.probing").append(": " + name)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java index 610a830d1..28e10cc68 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java @@ -62,7 +62,7 @@ // compound.removeTag("SpawnData"); // logic.readFromNBT(compound); // -// logic.setEntityId(new ResourceLocation(entity)); +// logic.setEntityId(ResourceLocation.tryParse(entity)); // // tile.markDirty(); // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTag.java index ca5be5200..fafadf133 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTag.java @@ -1,21 +1,19 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; -import de.ellpeck.actuallyadditions.mod.attachments.ItemTagAttachment; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import javax.annotation.Nullable; import java.util.List; public class ItemTag extends ItemBase { @Override - public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, TooltipFlag pIsAdvanced) { - var data = pStack.getExistingData(ActuallyAttachments.ITEM_TAG); + public void appendHoverText(ItemStack pStack, @Nullable TooltipContext pLevel, List pTooltipComponents, TooltipFlag pIsAdvanced) { + var data = pStack.get(ActuallyComponents.ITEM_TAG); /* data.flatMap(ItemTagAttachment::getTag).ifPresent(itemTag -> { BuiltInRegistries.ITEM.getTag(itemTag).ifPresent(itemTagCollection -> { pTooltipComponents.add(Component.literal("Valid Tag").withStyle(ChatFormatting.GREEN)); @@ -23,10 +21,11 @@ public class ItemTag extends ItemBase { pTooltipComponents.add(Component.literal("Contains: " + itemTagCollection.stream().count() + " items").withStyle(ChatFormatting.GRAY)); }); });*/ - data.flatMap(ItemTagAttachment::getTag).ifPresentOrElse( - itemTag -> pTooltipComponents.add(Component.literal("Tag: " + itemTag.location()).withStyle(ChatFormatting.GRAY)), - () -> pTooltipComponents.add(Component.translatable("tooltip.actuallyadditions.item_tag.no_tag").withStyle(ChatFormatting.RED) - )); + if(data != null) { + pTooltipComponents.add(Component.literal("Tag: " + data.toString()).withStyle(ChatFormatting.GRAY)); + } else { + pTooltipComponents.add(Component.translatable("tooltip.actuallyadditions.item_tag.no_tag").withStyle(ChatFormatting.RED)); + } super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java index f809a24a0..accd27c5f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleportStaff.java @@ -49,7 +49,7 @@ public class ItemTeleportStaff extends ItemEnergy { player.removeVehicle(); world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1.0F, 1.0F); if (!player.isCreative()) { - this.extractEnergyInternal(stack, use, false); + this.extractEnergy(stack, use, false); player.getCooldowns().addCooldown(this, 50); } return InteractionResultHolder.success(stack); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java index b106aa28c..6119eb5b0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java @@ -10,13 +10,14 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; +import de.ellpeck.actuallyadditions.mod.components.LastXY; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; @@ -36,7 +37,6 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; public class ItemWaterBowl extends ItemBase { @@ -57,26 +57,23 @@ public class ItemWaterBowl extends ItemBase { return; } - InteractionResultHolder result = EventHooks.onBucketUse(event.getEntity(), event.getLevel(), event.getItemStack(), trace); - if (result == null) { - if (event.getEntity().mayUseItemAt(trace.getBlockPos().relative(trace.getDirection()), trace.getDirection(), event.getItemStack())) { - BlockState state = event.getLevel().getBlockState(trace.getBlockPos()); + if (event.getEntity().mayUseItemAt(trace.getBlockPos().relative(trace.getDirection()), trace.getDirection(), event.getItemStack())) { + BlockState state = event.getLevel().getBlockState(trace.getBlockPos()); - if (state.getFluidState().is(Fluids.WATER) && state.getValue(BlockStateProperties.LEVEL) == 0) { - event.getEntity().playSound(SoundEvents.BUCKET_FILL, 1.0F, 1.0F); + if (state.getFluidState().is(Fluids.WATER) && state.getValue(BlockStateProperties.LEVEL) == 0) { + event.getEntity().playSound(SoundEvents.BUCKET_FILL, 1.0F, 1.0F); - if (!event.getLevel().isClientSide) { - event.getLevel().setBlock(trace.getBlockPos(), Blocks.AIR.defaultBlockState(), 11); - ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1); + if (!event.getLevel().isClientSide) { + event.getLevel().setBlock(trace.getBlockPos(), Blocks.AIR.defaultBlockState(), 11); + ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1); - ItemStack bowl = new ItemStack(ActuallyItems.WATER_BOWL.get()); - if (!StackUtil.isValid(reduced)) { - event.getEntity().setItemInHand(event.getHand(), bowl); - } else if (!event.getEntity().getInventory().add(bowl.copy())) { - ItemEntity entityItem = new ItemEntity(event.getLevel(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), bowl.copy()); - entityItem.setPickUpDelay(0); - event.getLevel().addFreshEntity(entityItem); - } + ItemStack bowl = new ItemStack(ActuallyItems.WATER_BOWL.get()); + if (!StackUtil.isValid(reduced)) { + event.getEntity().setItemInHand(event.getHand(), bowl); + } else if (!event.getEntity().getInventory().add(bowl.copy())) { + ItemEntity entityItem = new ItemEntity(event.getLevel(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), bowl.copy()); + entityItem.setPickUpDelay(0); + event.getLevel().addFreshEntity(entityItem); } } } @@ -90,10 +87,6 @@ public class ItemWaterBowl extends ItemBase { ItemStack stack = player.getItemInHand(hand); HitResult trace = player.pick(8.0D, 1.0F, false); - InteractionResultHolder result = EventHooks.onBucketUse(player, world, stack, trace); - if (result != null) { - return result; - } if (trace == null) { return InteractionResultHolder.pass(stack); @@ -131,10 +124,10 @@ public class ItemWaterBowl extends ItemBase { int lastX = 0; int lastY = 0; - if (stack.hasTag()) { - CompoundTag compound = stack.getOrCreateTag(); - lastX = compound.getInt("lastX"); - lastY = compound.getInt("lastY"); + if (stack.has(ActuallyComponents.LAST_XY)) { + LastXY lastXY = stack.get(ActuallyComponents.LAST_XY); + lastX = lastXY.x(); + lastY = lastXY.y(); } boolean change = false; @@ -150,9 +143,7 @@ public class ItemWaterBowl extends ItemBase { } if (change || lastX == 0 || lastY == 0) { - CompoundTag compound = stack.getOrCreateTag(); - compound.putInt("lastX", (int) entity.getX()); - compound.putInt("lastY", (int) entity.getY()); + stack.set(ActuallyComponents.LAST_XY, new LastXY((int) entity.getX(), (int) entity.getY())); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java index 6ebd5309f..12ca4e18a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java @@ -55,7 +55,7 @@ public class ItemWaterRemovalRing extends ItemEnergy { world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); if (!((Player) player).isCreative()) { - this.extractEnergyInternal(stack, energyUse, false); + this.extractEnergy(stack, energyUse, false); } } //Remove Lava @@ -64,7 +64,7 @@ public class ItemWaterRemovalRing extends ItemEnergy { world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); if (!((Player) player).isCreative()) { - this.extractEnergyInternal(stack, energyUse * 2, false); + this.extractEnergy(stack, energyUse * 2, false); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java index f1db3bca6..47dcd99cf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java @@ -27,7 +27,7 @@ import net.minecraft.world.item.SwordItem; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; -import net.neoforged.neoforge.event.entity.living.LivingEvent; +import net.neoforged.neoforge.event.tick.PlayerTickEvent; public class ItemWingsOfTheBats extends ItemBase { @@ -88,12 +88,12 @@ public class ItemWingsOfTheBats extends ItemBase { public void onEntityDropEvent(LivingDropsEvent event) { Entity source = event.getSource().getEntity(); - if (event.getEntity().level() != null && !event.getEntity().level().isClientSide && source instanceof Player) { + if (event.getEntity().level() != null && !event.getEntity().level().isClientSide && source instanceof Player player) { //Drop Wings from Bats if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntity() instanceof Bat) { //TODO: Change to CommonConfig - int looting = event.getLootingLevel(); + int looting = 1; //event.getLootingLevel(); TODO: Looting is gone from LivingDropsEvent - Iterable equip = source.getHandSlots(); + Iterable equip = player.getHandSlots(); for (ItemStack stack : equip) { // Todo: [port] this might not work anymore due to the way things are checked if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getHoverName().getString()) && stack.getItem() instanceof SwordItem) { @@ -111,7 +111,7 @@ public class ItemWingsOfTheBats extends ItemBase { } @SubscribeEvent - public void livingUpdateEvent(LivingEvent.LivingTickEvent event) { + public void livingUpdateEvent(PlayerTickEvent.Post event) { if (event.getEntity() instanceof Player player) { if (false &&!player.isCreative() && !player.isSpectator()) { //TODO disabled for now. diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java index 7d3d70988..e98d2768f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Sack.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.inventory.SackContainer; import de.ellpeck.actuallyadditions.mod.inventory.VoidSackContainer; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; @@ -17,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.sack.SackData; import de.ellpeck.actuallyadditions.mod.sack.SackManager; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -116,13 +116,8 @@ public class Sack extends ItemBase { public static SackData getData(ItemStack stack) { if (!(stack.getItem() instanceof Sack)) return null; - UUID uuid; - CompoundTag tag = stack.getOrCreateTag(); - if (!tag.contains("UUID")) { - uuid = UUID.randomUUID(); - tag.putUUID("UUID", uuid); - } else - uuid = tag.getUUID("UUID"); + UUID uuid = stack.getOrDefault(ActuallyComponents.UUID.get(), UUID.randomUUID()); + stack.set(ActuallyComponents.UUID.get(), uuid); return SackManager.get().getOrCreateSack(uuid); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java index d4cbfe8ed..169855a28 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/Worm.java @@ -23,8 +23,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; -import net.neoforged.bus.api.Event; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.event.level.BlockEvent; import java.util.List; @@ -60,10 +59,10 @@ public class Worm extends ItemBase { } public static void onHoe(BlockEvent.BlockToolModificationEvent event) { - if (event.getToolAction() == ToolActions.HOE_TILL) { + if (event.getItemAbility() == ItemAbilities.HOE_TILL) { Level level = event.getPlayer().level(); - if (level.isClientSide || !CommonConfig.Other.WORMS.get() || event.getResult() == Event.Result.DENY) + if (level.isClientSide || !CommonConfig.Other.WORMS.get()) return; BlockPos pos = event.getContext().getClickedPos(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java index bcd8dba7e..940708c5f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java @@ -12,17 +12,18 @@ package de.ellpeck.actuallyadditions.mod.items.base; import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; +import net.minecraft.core.Holder; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; public class ItemArmorAA extends ArmorItem implements IDisableableItem { private final boolean disabled; - public ItemArmorAA(ArmorMaterial material, Type type) { + public ItemArmorAA(Holder material, Type type) { this(material, type, ActuallyItems.defaultProps()); } - public ItemArmorAA(ArmorMaterial material, Type type, Properties properties) { + public ItemArmorAA(Holder material, Type type, Properties properties) { super(material, type, properties); this.disabled = false; // this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(this.name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(this.name) + ". It will not be registered."); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java index 00e889e9c..6c0f802b4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items.base; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; @@ -20,15 +20,11 @@ import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.energy.EnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage; -import javax.annotation.Nullable; import java.text.NumberFormat; import java.util.List; import java.util.Optional; @@ -49,10 +45,9 @@ public abstract class ItemEnergy extends ItemBase { this.transfer = transfer; } - @OnlyIn(Dist.CLIENT) @Override - public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { - super.appendHoverText(stack, worldIn, tooltip, flagIn); + public void appendHoverText(ItemStack stack, TooltipContext context, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM); if(storage != null) { int energy = storage.getEnergyStored(); @@ -104,14 +99,14 @@ public abstract class ItemEnergy extends ItemBase { @Deprecated public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate) { return Optional.ofNullable(stack.getCapability(Capabilities.EnergyStorage.ITEM)) - .map(cap -> ((CustomEnergyStorage) cap).receiveEnergyInternal(maxReceive, simulate)) + .map(cap -> cap.receiveEnergy(maxReceive, simulate)) .orElse(0); } public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate) { return Optional.ofNullable(stack.getCapability(Capabilities.EnergyStorage.ITEM)) .map(cap -> cap instanceof EnergyStorage - ? ((CustomEnergyStorage) cap).extractEnergyInternal(maxExtract, simulate) + ? cap.extractEnergy(maxExtract, simulate) : 0) .orElse(0); } @@ -141,8 +136,8 @@ public abstract class ItemEnergy extends ItemBase { .orElse(0); } - public IEnergyStorage getEnergyStorage(ItemStack stack) { - return stack.getData(ActuallyAttachments.ENERGY_STORAGE); + public int getEnergyStorage(ItemStack stack) { + return stack.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0); } // @Override TODO: Register Energy cap/attachment diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java index 429c32146..e43d021c1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java @@ -16,7 +16,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.ColorChangeRecipe; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; @@ -81,8 +81,8 @@ public class LensColor extends Lens { return false; } - private ItemStack tryConvert(ItemStack stack, RegistryAccess registryAccess) { - return ColorChangeRecipe.getRecipeForStack(stack).map(recipe -> recipe.value().getResultItem(registryAccess)).orElse(ItemStack.EMPTY); + private ItemStack tryConvert(ItemStack stack, HolderLookup.Provider registries) { + return ColorChangeRecipe.getRecipeForStack(stack).map(recipe -> recipe.value().getResultItem(registries)).orElse(ItemStack.EMPTY); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java index a20cb421b..24d5ae68d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java @@ -16,19 +16,20 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.EnchantedBookItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentInstance; +import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import java.util.List; -import java.util.Map; public class LensDisenchanting extends Lens { @@ -53,7 +54,7 @@ public class LensDisenchanting extends Lens { return false; } } else { - Map enchants = EnchantmentHelper.getEnchantments(stack); + ItemEnchantments enchants = stack.getAllEnchantments(tile.getWorldObject().registryAccess().lookupOrThrow(Registries.ENCHANTMENT)); if (enchants != null && !enchants.isEmpty()) { if (toDisenchant == null) { toDisenchant = item; @@ -70,21 +71,20 @@ public class LensDisenchanting extends Lens { ItemStack disenchantStack = toDisenchant.getItem(); ItemStack bookStack = book.getItem(); - Map enchants = EnchantmentHelper.getEnchantments(disenchantStack); + ItemEnchantments enchants = disenchantStack.getAllEnchantments(tile.getWorldObject().registryAccess().lookupOrThrow(Registries.ENCHANTMENT)); if (!enchants.isEmpty()) { - Enchantment enchant = enchants.keySet().iterator().next(); - int level = enchants.get(enchant); + Holder enchant = enchants.keySet().iterator().next(); + int level = enchants.getLevel(enchant); ItemStack newDisenchantStack = disenchantStack.copy(); ItemStack newBookStack; if (bookStack.getItem() == Items.BOOK) { - newBookStack = new ItemStack(Items.ENCHANTED_BOOK); + newBookStack = EnchantedBookItem.createForEnchantment(new EnchantmentInstance(enchant, level)); } else { newBookStack = bookStack.copy(); } - ItemUtil.removeEnchantment(newDisenchantStack, enchant); - EnchantedBookItem.addEnchantment(newBookStack, new EnchantmentInstance(enchant, level)); + ItemUtil.removeEnchantment(newDisenchantStack, enchant, tile.getWorldObject().registryAccess()); ItemEntity disenchanted = new ItemEntity(toDisenchant.getCommandSenderWorld(), toDisenchant.getX(), toDisenchant.getY(), toDisenchant.getZ(), newDisenchantStack); ItemEntity newBook = new ItemEntity(book.getCommandSenderWorld(), book.getX(), book.getY(), book.getZ(), newBookStack); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java index e44d51bf8..14010a83c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items.metalists; +import net.minecraft.core.Holder; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.item.ItemStack; @@ -124,15 +125,15 @@ public enum ThePotionRings { public final String name; public final int color; public final Rarity rarity; - public final MobEffect effect; + public final Holder effect; public final int normalAmplifier; public final int advancedAmplifier; public final int activeTime; public final boolean needsWaitBeforeActivating; public final ItemStack craftingItem; - ThePotionRings(int color, MobEffect effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, Rarity rarity, ItemStack craftingItem) { - this.name = effect.getDisplayName().getString(); + ThePotionRings(int color, Holder effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, Rarity rarity, ItemStack craftingItem) { + this.name = effect.value().getDisplayName().getString(); this.color = color; this.rarity = rarity; this.effect = effect; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 1415452bd..55bb451d3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -12,12 +12,18 @@ package de.ellpeck.actuallyadditions.mod.jei; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import de.ellpeck.actuallyadditions.mod.crafting.*; +import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes; +import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe; import de.ellpeck.actuallyadditions.mod.inventory.gui.CrusherScreen; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineCategory; import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherCategory; import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory; @@ -30,18 +36,19 @@ import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.RecipeType; -import mezz.jei.api.registration.*; +import mezz.jei.api.registration.IGuiHandlerRegistration; +import mezz.jei.api.registration.IRecipeCatalystRegistration; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; -import javax.annotation.Nonnull; - @JeiPlugin public class JEIActuallyAdditionsPlugin implements IModPlugin { - public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "jei_plugin"); + public static final ResourceLocation ID = ActuallyAdditions.modLoc("jei_plugin"); @Override public ResourceLocation getPluginUid() { return ID; @@ -55,13 +62,13 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin { public static final RecipeType CRUSHING = RecipeType.create(ActuallyAdditions.MODID, "crushing", CrushingRecipe.class); public static final RecipeType MINING_LENS = RecipeType.create(ActuallyAdditions.MODID, "mining_lens", MiningLensRecipe.class); - @Override - public void registerItemSubtypes(@Nonnull ISubtypeRegistration reg) { - ActuallyItems.ITEMS.getEntries().forEach(entry -> { - if (entry.get() instanceof ItemEnergy) - reg.useNbtForSubtypes(entry.get()); - }); - } +// @Override TODO: See if this is still needed +// public void registerItemSubtypes(@Nonnull ISubtypeRegistration reg) { +// ActuallyItems.ITEMS.getEntries().forEach(entry -> { +// if (entry.get() instanceof ItemEnergy) +// reg.useNbtForSubtypes(entry.get()); +// }); +// } @Override public void registerCategories(IRecipeCategoryRegistration registry) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineCategory.java index c6cc19ba4..46f5b0657 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineCategory.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.mod.jei.coffee; import com.google.common.base.Strings; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyTags; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.jei.JEIActuallyAdditionsPlugin; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java index e3f3ab53a..c873587e1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java @@ -24,13 +24,13 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; public class EmpowererRecipeCategory implements IRecipeCategory { - public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "empowerer_jei"); + public static final ResourceLocation ID = ActuallyAdditions.modLoc("empowerer_jei"); private final IDrawableStatic background; @@ -65,7 +65,7 @@ public class EmpowererRecipeCategory implements IRecipeCategory if (level == null) { throw new NullPointerException("level must not be null."); } - RegistryAccess registryAccess = level.registryAccess(); + HolderLookup.Provider registries = level.registryAccess(); builder.addSlot(RecipeIngredientRole.INPUT, 32, 32).addIngredients(recipe.getInput()); builder.addSlot(RecipeIngredientRole.INPUT, 2, 32).addIngredients(recipe.getStandOne()); @@ -73,6 +73,6 @@ public class EmpowererRecipeCategory implements IRecipeCategory builder.addSlot(RecipeIngredientRole.INPUT, 62, 32).addIngredients(recipe.getStandThree()); builder.addSlot(RecipeIngredientRole.INPUT, 32, 62).addIngredients(recipe.getStandFour()); - builder.addSlot(RecipeIngredientRole.OUTPUT, 113, 32).addItemStack(recipe.getResultItem(registryAccess)); + builder.addSlot(RecipeIngredientRole.OUTPUT, 113, 32).addItemStack(recipe.getResultItem(registries)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/laser/LaserRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/laser/LaserRecipeCategory.java index b3f314277..ba9b0dac9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/laser/LaserRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/laser/LaserRecipeCategory.java @@ -24,7 +24,7 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -63,11 +63,11 @@ public class LaserRecipeCategory implements IRecipeCategory { if (level == null) { throw new NullPointerException("level must not be null."); } - RegistryAccess registryAccess = level.registryAccess(); + HolderLookup.Provider registries = level.registryAccess(); builder.addSlot(RecipeIngredientRole.INPUT, 5, 19).addIngredients(recipe.getInput()); builder.addSlot(RecipeIngredientRole.INPUT, 35, 20).addItemStack(RECONSTRUCTOR); - builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 19).addItemStack(recipe.getResultItem(registryAccess)); + builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 19).addItemStack(recipe.getResultItem(registries)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/lens/MiningLensRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/lens/MiningLensRecipeCategory.java index 6cc3900f6..0a52f796b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/lens/MiningLensRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/lens/MiningLensRecipeCategory.java @@ -27,7 +27,7 @@ import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -66,13 +66,13 @@ public class MiningLensRecipeCategory implements IRecipeCategory { private final IDrawableStatic fluidBackground; public PressingCategory(IGuiHelper guiHelper) { - background = guiHelper.drawableBuilder(new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/gui_canola_press.png"), 41, 4, 93, 85).setTextureSize(256,256).build(); + background = guiHelper.drawableBuilder(ActuallyAdditions.modLoc("textures/gui/gui_canola_press.png"), 41, 4, 93, 85).setTextureSize(256,256).build(); fluidBackground = guiHelper.drawableBuilder(AssetUtil.GUI_INVENTORY_LOCATION, 0, 171, 18, 85).build(); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/ActuallyLootModifiers.java b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/ActuallyLootModifiers.java index 452a47b4d..8f0ac280f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/ActuallyLootModifiers.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/ActuallyLootModifiers.java @@ -1,6 +1,6 @@ package de.ellpeck.actuallyadditions.mod.lootmodifier; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.common.loot.IGlobalLootModifier; @@ -10,10 +10,10 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries; import java.util.function.Supplier; public class ActuallyLootModifiers { - private static final DeferredRegister> GLM = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, ActuallyAdditions.MODID); + private static final DeferredRegister> GLM = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, ActuallyAdditions.MODID); - public static final Supplier> BAT_LOOT = GLM.register("bat_loot", BatLootModifier.CODEC); - public static final Supplier> DUNGEON_LOOT = GLM.register("dungeon_loot", DungeonLootModifier.CODEC); + public static final Supplier> BAT_LOOT = GLM.register("bat_loot", BatLootModifier.CODEC); + public static final Supplier> DUNGEON_LOOT = GLM.register("dungeon_loot", DungeonLootModifier.CODEC); public static void init(IEventBus evt) { GLM.register(evt); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/BatLootModifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/BatLootModifier.java index c95fe0ca7..503ef032c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/BatLootModifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/BatLootModifier.java @@ -2,14 +2,18 @@ package de.ellpeck.actuallyadditions.mod.lootmodifier; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ambient.Bat; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; @@ -17,8 +21,8 @@ import net.neoforged.neoforge.common.loot.IGlobalLootModifier; import net.neoforged.neoforge.common.loot.LootModifier; public class BatLootModifier extends LootModifier { - public static final Supplier> CODEC = Suppliers.memoize(() -> - RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, BatLootModifier::new))); + public static final Supplier> CODEC = Suppliers.memoize(() -> + RecordCodecBuilder.mapCodec(inst -> codecStart(inst).apply(inst, BatLootModifier::new))); public BatLootModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); @@ -28,11 +32,15 @@ public class BatLootModifier extends LootModifier { protected ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { RandomSource random = context.getRandom(); if (CommonConfig.Other.DO_BAT_DROPS.get() && - context.hasParam(LootContextParams.KILLER_ENTITY) && + context.hasParam(LootContextParams.ATTACKING_ENTITY) && context.hasParam(LootContextParams.DAMAGE_SOURCE) && context.hasParam(LootContextParams.THIS_ENTITY) && context.getParam(LootContextParams.THIS_ENTITY) instanceof Bat) { - int looting = context.getLootingModifier(); + Entity entity = context.getParamOrNull(LootContextParams.ATTACKING_ENTITY); + int looting = 1; + if (entity instanceof LivingEntity livingentity) { + looting = EnchantmentHelper.getEnchantmentLevel(livingentity.level().holderOrThrow(Enchantments.LOOTING), livingentity); + } if (random.nextInt(15) <= looting * 2) { generatedLoot.add(new ItemStack(ActuallyItems.BATS_WING.get(), random.nextInt(2 + looting) + 1)); } @@ -41,7 +49,7 @@ public class BatLootModifier extends LootModifier { } @Override - public Codec codec() { - return CODEC.get(); + public MapCodec codec() { + return ActuallyLootModifiers.BAT_LOOT.get(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/DungeonLootModifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/DungeonLootModifier.java index 9f7f771a7..5617364e0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/DungeonLootModifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/lootmodifier/DungeonLootModifier.java @@ -2,10 +2,9 @@ package de.ellpeck.actuallyadditions.mod.lootmodifier; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.actuallyadditions.api.ActuallyTags; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; @@ -18,7 +17,6 @@ import net.minecraft.tags.TagKey; import net.minecraft.util.RandomSource; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; @@ -26,8 +24,8 @@ import net.neoforged.neoforge.common.loot.IGlobalLootModifier; import net.neoforged.neoforge.common.loot.LootModifier; public class DungeonLootModifier extends LootModifier { - public static final Supplier> CODEC = Suppliers.memoize(() -> - RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, DungeonLootModifier::new))); + public static final Supplier> CODEC = Suppliers.memoize(() -> + RecordCodecBuilder.mapCodec(inst -> codecStart(inst).apply(inst, DungeonLootModifier::new))); public DungeonLootModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); @@ -135,7 +133,7 @@ public class DungeonLootModifier extends LootModifier { } @Override - public Codec codec() { - return CODEC.get(); + public MapCodec codec() { + return ActuallyLootModifiers.DUNGEON_LOOT.get(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/material/ArmorMaterials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/material/ArmorMaterials.java index b25c3830e..54241ff65 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/ArmorMaterials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/material/ArmorMaterials.java @@ -1,18 +1,19 @@ package de.ellpeck.actuallyadditions.mod.material; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import net.minecraft.Util; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.LazyLoadedValue; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.util.EnumMap; +import java.util.List; import java.util.function.Supplier; /** @@ -20,94 +21,59 @@ import java.util.function.Supplier; *

* todo validate all values refect correctly */ -public enum ArmorMaterials implements ArmorMaterial { +public class ArmorMaterials { // EMERALD("emerald_armor_material", 30, createProtectionMap( 5, 8, 9, 4 ), 15, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 2, 0f, () -> Ingredient.fromItems(Items.EMERALD)), // OBSIDIAN("obsidian_armor_material", 28, createProtectionMap( 1, 3, 4, 3 ), 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 1, 0f, () -> Ingredient.fromItems(Items.OBSIDIAN)), - QUARTZ("quartz_armor_material", 15, createProtectionMap(3, 5, 6, 3), 8, SoundEvents.ARMOR_EQUIP_GENERIC, 1, 0f, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())), - RESTONIA("restonia_armor_material", 18, createProtectionMap(3, 6, 7, 3), 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.RESTONIA_CRYSTAL.get())), - PALIS("palis_armor_material", 10, createProtectionMap(3, 6, 7, 3), 10, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.PALIS_CRYSTAL.get())), - DIAMATINE("diamatine_armor_material", 36, createProtectionMap(4, 7, 8, 4), 12, SoundEvents.ARMOR_EQUIP_GENERIC, 3, 0f, () -> Ingredient.of(ActuallyItems.DIAMATINE_CRYSTAL.get())), - VOID("void_armor_material", 23, createProtectionMap(1, 3, 4, 1), 13, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.VOID_CRYSTAL.get())), - EMERADIC("emeradic_armor_material", 32, createProtectionMap(6, 9, 9, 4), 18, SoundEvents.ARMOR_EQUIP_GENERIC, 3, 0f, () -> Ingredient.of(ActuallyItems.EMERADIC_CRYSTAL.get())), - ENORI("enori_armor_material", 24, createProtectionMap(3, 6, 6, 3), 11, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.ENORI_CRYSTAL.get())), - GOGGLES("goggles_armor_material", 0, createProtectionMap(0, 0, 0, 0), 0, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.EMPTY); +// QUARTZ("quartz_armor_material", 15, createProtectionMap(3, 5, 6, 3), 8, SoundEvents.ARMOR_EQUIP_GENERIC, 1, 0f, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())), +// RESTONIA("restonia_armor_material", 18, createProtectionMap(3, 6, 7, 3), 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.RESTONIA_CRYSTAL.get())), +// PALIS("palis_armor_material", 10, createProtectionMap(3, 6, 7, 3), 10, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.PALIS_CRYSTAL.get())), +// DIAMATINE("diamatine_armor_material", 36, createProtectionMap(4, 7, 8, 4), 12, SoundEvents.ARMOR_EQUIP_GENERIC, 3, 0f, () -> Ingredient.of(ActuallyItems.DIAMATINE_CRYSTAL.get())), +// VOID("void_armor_material", 23, createProtectionMap(1, 3, 4, 1), 13, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.VOID_CRYSTAL.get())), +// EMERADIC("emeradic_armor_material", 32, createProtectionMap(6, 9, 9, 4), 18, SoundEvents.ARMOR_EQUIP_GENERIC, 3, 0f, () -> Ingredient.of(ActuallyItems.EMERADIC_CRYSTAL.get())), +// ENORI("enori_armor_material", 24, createProtectionMap(3, 6, 6, 3), 11, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.of(ActuallyItems.ENORI_CRYSTAL.get())), +// GOGGLES("goggles_armor_material", 0, createProtectionMap(0, 0, 0, 0), 0, SoundEvents.ARMOR_EQUIP_GENERIC, 0, 0f, () -> Ingredient.EMPTY); - private static EnumMap createProtectionMap(int boots, int leggings, int chest, int helmet) { - return Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { - map.put(ArmorItem.Type.BOOTS, boots); - map.put(ArmorItem.Type.LEGGINGS, leggings); - map.put(ArmorItem.Type.CHESTPLATE, chest); - map.put(ArmorItem.Type.HELMET, helmet); - }); - } + public static final Holder GOGGLES = register( + "goggles_armor_material", + Util.make(new EnumMap<>(ArmorItem.Type.class), p323384 -> { + p323384.put(ArmorItem.Type.BOOTS, 0); + p323384.put(ArmorItem.Type.LEGGINGS, 0); + p323384.put(ArmorItem.Type.CHESTPLATE, 0); + p323384.put(ArmorItem.Type.HELMET, 0); + p323384.put(ArmorItem.Type.BODY, 0); + }), + 0, + SoundEvents.ARMOR_EQUIP_GENERIC, + 0.0F, + 0.0F, + () -> Ingredient.EMPTY, + List.of( + new ArmorMaterial.Layer(ActuallyAdditions.modLoc("goggles"), "", true), + new ArmorMaterial.Layer(ActuallyAdditions.modLoc("goggles"), "_overlay", false) + ) + ); - // HMMM Tasty stolen code from MC, how lovely. - private static final EnumMap HEALTH_FUNCTION_FOR_TYPE = Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { - map.put(ArmorItem.Type.BOOTS, 13); - map.put(ArmorItem.Type.LEGGINGS, 15); - map.put(ArmorItem.Type.CHESTPLATE, 16); - map.put(ArmorItem.Type.HELMET, 11); - }); - private final String name; - private final int durabilityMultiplier; - private final EnumMap protectionFunctionForType; - private final int enchantability; - private final SoundEvent soundEvent; - private final float toughness; - private final float knockbackResistance; - private final LazyLoadedValue repairMaterial; + private static Holder register( + String pName, + EnumMap pDefense, + int pEnchantmentValue, + Holder pEquipSound, + float pToughness, + float pKnockbackResistance, + Supplier pRepairIngridient, + List pLayers + ) { + EnumMap enummap = new EnumMap<>(ArmorItem.Type.class); - ArmorMaterials(String name, int durabilityMultiplier, EnumMap protectionFunctionForType, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier repairMaterial) { - this.name = String.format("%s:%s", ActuallyAdditions.MODID, name); - this.durabilityMultiplier = durabilityMultiplier; - this.protectionFunctionForType = protectionFunctionForType; - this.enchantability = enchantability; - this.soundEvent = soundEvent; - this.toughness = toughness; - this.knockbackResistance = knockbackResistance; - this.repairMaterial = new LazyLoadedValue<>(repairMaterial); - } + for (ArmorItem.Type armoritem$type : ArmorItem.Type.values()) { + enummap.put(armoritem$type, pDefense.get(armoritem$type)); + } - public int getDurabilityForType(ArmorItem.Type type) { - return HEALTH_FUNCTION_FOR_TYPE.get(type) * this.durabilityMultiplier; - } - - public int getDefenseForType(ArmorItem.Type type) { - return this.protectionFunctionForType.get(type); - } - - @Override - public int getEnchantmentValue() { - return this.enchantability; - } - - @Override - public SoundEvent getEquipSound() { - return this.soundEvent; - } - - @Override - public Ingredient getRepairIngredient() { - return this.repairMaterial.get(); - } - - @Override - @OnlyIn(Dist.CLIENT) - public String getName() { - return this.name; - } - - @Override - public float getToughness() { - return this.toughness; - } - - /** - * Gets the percentage of knockback resistance provided by armor of the material. - */ - @Override - public float getKnockbackResistance() { - return this.knockbackResistance; + return Registry.registerForHolder( + BuiltInRegistries.ARMOR_MATERIAL, + ResourceLocation.withDefaultNamespace(pName), + new ArmorMaterial(enummap, pEnchantmentValue, pEquipSound, pRepairIngridient, pLayers, pToughness, pKnockbackResistance) + ); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/material/ToolMaterials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/material/ToolMaterials.java index 80853fdb2..e2618fe80 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/ToolMaterials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/material/ToolMaterials.java @@ -1,26 +1,14 @@ package de.ellpeck.actuallyadditions.mod.material; -import de.ellpeck.actuallyadditions.api.ActuallyTags; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.Tiers; -import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.neoforge.common.SimpleTier; -import net.neoforged.neoforge.common.TierSortingRegistry; - -import java.util.List; - /** * todo: review to ensure all values act as intended */ public class ToolMaterials { - public static final Tier BLACK_QUARTZ = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.5f, 2.0f, 10, ActuallyTags.Blocks.NEEDS_BLACK_QUARTZ_TOOL, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())), new ResourceLocation(ActuallyAdditions.MODID, "black_quartz"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); - public static final Tier RESTONIA = TierSortingRegistry.registerTier(new SimpleTier(2, 300, 7.0f, 2.25f, 12, ActuallyTags.Blocks.NEEDS_RESTONIA_TOOL, () -> Ingredient.of(ActuallyItems.RESTONIA_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "restonia"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); - public static final Tier PALIS = TierSortingRegistry.registerTier(new SimpleTier(2, 300, 7.0f, 2.25f, 12, ActuallyTags.Blocks.NEEDS_PALIS_TOOL, () -> Ingredient.of(ActuallyItems.PALIS_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "palis"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); - public static final Tier DIAMATINE = TierSortingRegistry.registerTier(new SimpleTier(3, 1600, 9.0f, 4.0f, 14, ActuallyTags.Blocks.NEEDS_DIAMATINE_TOOL, () -> Ingredient.of(ActuallyItems.DIAMATINE_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "diamatine"), List.of(Tiers.DIAMOND), List.of(Tiers.NETHERITE)); - public static final Tier VOID = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.0f, 2.0f, 8, ActuallyTags.Blocks.NEEDS_VOID_TOOL, () -> Ingredient.of(ActuallyItems.VOID_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "void"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); - public static final Tier EMERADIC = TierSortingRegistry.registerTier(new SimpleTier(4, 2200, 9.5f, 5.55f, 18, ActuallyTags.Blocks.NEEDS_EMERADIC_TOOL, () -> Ingredient.of(ActuallyItems.EMERADIC_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "emeradic"), List.of(Tiers.NETHERITE), List.of()); - public static final Tier ENORI = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.25f, 6.25f, 15, ActuallyTags.Blocks.NEEDS_ENORI_TOOL, () -> Ingredient.of(ActuallyItems.ENORI_CRYSTAL.get())), new ResourceLocation(ActuallyAdditions.MODID, "enori"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); +// public static final Tier BLACK_QUARTZ = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.5f, 2.0f, 10, ActuallyTags.Blocks.NEEDS_BLACK_QUARTZ_TOOL, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())), ActuallyAdditions.modLoc("black_quartz"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); +// public static final Tier RESTONIA = TierSortingRegistry.registerTier(new SimpleTier(2, 300, 7.0f, 2.25f, 12, ActuallyTags.Blocks.NEEDS_RESTONIA_TOOL, () -> Ingredient.of(ActuallyItems.RESTONIA_CRYSTAL.get())), ActuallyAdditions.modLoc("restonia"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); +// public static final Tier PALIS = TierSortingRegistry.registerTier(new SimpleTier(2, 300, 7.0f, 2.25f, 12, ActuallyTags.Blocks.NEEDS_PALIS_TOOL, () -> Ingredient.of(ActuallyItems.PALIS_CRYSTAL.get())), ActuallyAdditions.modLoc("palis"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); +// public static final Tier DIAMATINE = TierSortingRegistry.registerTier(new SimpleTier(3, 1600, 9.0f, 4.0f, 14, ActuallyTags.Blocks.NEEDS_DIAMATINE_TOOL, () -> Ingredient.of(ActuallyItems.DIAMATINE_CRYSTAL.get())), ActuallyAdditions.modLoc("diamatine"), List.of(Tiers.DIAMOND), List.of(Tiers.NETHERITE)); +// public static final Tier VOID = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.0f, 2.0f, 8, ActuallyTags.Blocks.NEEDS_VOID_TOOL, () -> Ingredient.of(ActuallyItems.VOID_CRYSTAL.get())), ActuallyAdditions.modLoc("void"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); +// public static final Tier EMERADIC = TierSortingRegistry.registerTier(new SimpleTier(4, 2200, 9.5f, 5.55f, 18, ActuallyTags.Blocks.NEEDS_EMERADIC_TOOL, () -> Ingredient.of(ActuallyItems.EMERADIC_CRYSTAL.get())), ActuallyAdditions.modLoc("emeradic"), List.of(Tiers.NETHERITE), List.of()); +// public static final Tier ENORI = TierSortingRegistry.registerTier(new SimpleTier(2, 280, 6.25f, 6.25f, 15, ActuallyTags.Blocks.NEEDS_ENORI_TOOL, () -> Ingredient.of(ActuallyItems.ENORI_CRYSTAL.get())), ActuallyAdditions.modLoc("enori"), List.of(Tiers.IRON), List.of(Tiers.DIAMOND)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/ActuallyDamageTypes.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/ActuallyDamageTypes.java index 30167aff5..ea162fee2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/ActuallyDamageTypes.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/ActuallyDamageTypes.java @@ -3,13 +3,12 @@ package de.ellpeck.actuallyadditions.mod.misc; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.damagesource.DamageType; public class ActuallyDamageTypes { public static final ResourceKey ATOMIC_RECONSTRUCTOR = register("atomicreconstructor"); private static ResourceKey register(String name) { - return ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ActuallyAdditions.MODID, name)); + return ResourceKey.create(Registries.DAMAGE_TYPE, ActuallyAdditions.modLoc(name)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java index d44857500..d06f07a0f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java @@ -11,21 +11,30 @@ package de.ellpeck.actuallyadditions.mod.misc; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.block.entity.BannerPattern; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.neoforge.registries.DeferredHolder; -import net.neoforged.neoforge.registries.DeferredRegister; public final class BannerHelper { - public static final DeferredRegister BANNER_PATTERNS = DeferredRegister.create(BuiltInRegistries.BANNER_PATTERN, ActuallyAdditions.MODID); - public static DeferredHolder DRILL = BANNER_PATTERNS.register("drill", () -> new BannerPattern(ActuallyAdditions.MODID + ":drill")); - public static DeferredHolder LEAF_BLO = BANNER_PATTERNS.register("leaf_blo", () -> new BannerPattern(ActuallyAdditions.MODID + ":leaf_blo")); - public static DeferredHolder PHAN_CON = BANNER_PATTERNS.register("phan_con", () -> new BannerPattern(ActuallyAdditions.MODID + ":phan_con")); - public static DeferredHolder BOOK = BANNER_PATTERNS.register("book", () -> new BannerPattern(ActuallyAdditions.MODID + ":book")); + public static ResourceKey DRILL = create("drill"); + public static ResourceKey LEAF_BLO = create("leaf_blo"); + public static ResourceKey PHAN_CON = create("phan_con"); + public static ResourceKey BOOK = create("book"); - public static void init(IEventBus eventBus) { - BANNER_PATTERNS.register(eventBus); + private static ResourceKey create(String pName) { + return ResourceKey.create(Registries.BANNER_PATTERN, ActuallyAdditions.modLoc(pName)); + } + + public static void bootstrap(BootstrapContext pContext) { + register(pContext, DRILL); + register(pContext, LEAF_BLO); + register(pContext, PHAN_CON); + register(pContext, BOOK); + } + + public static void register(BootstrapContext pContext, ResourceKey pResourceKey) { + pContext.register(pResourceKey, new BannerPattern(pResourceKey.location(), "block.minecraft.banner." + pResourceKey.location().toShortLanguageKey())); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java index 8e9d7a70f..647896016 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java @@ -11,15 +11,21 @@ package de.ellpeck.actuallyadditions.mod.misc; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.storage.loot.LootTable; // TODO: [port] MOVE OVER TO DATA GENS @Deprecated public class DungeonLoot { // - // public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "jam_house"); - // public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ActuallyAdditions.MODID, "lush_caves"); - public static final ResourceLocation ENGINEER_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "engineer_house"); + // public static final ResourceLocation JAM_HOUSE = ActuallyAdditions.modLoc("jam_house"); + // public static final ResourceLocation LUSH_CAVES = ActuallyAdditions.modLoc("lush_caves"); + public static final ResourceKey ENGINEER_HOUSE = register("engineer_house"); + + private static ResourceKey register(String path) { + return ResourceKey.create(Registries.LOOT_TABLE, ActuallyAdditions.modLoc(path)); + } // // public DungeonLoot() { // LootTableList.register(JAM_HOUSE); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java index 13c889433..7163dc59b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java @@ -146,7 +146,7 @@ public class MethodHandler implements IMethodHandler { while (counter > 0) { CompoundTag compound = tag.getCompound(counter + ""); String id = compound.getString("ID"); - ResourceLocation effectID = id.isEmpty() ? new ResourceLocation("speed") : ResourceLocation.tryParse(id); + ResourceLocation effectID = id.isEmpty() ? ResourceLocation.tryParse("speed") : ResourceLocation.tryParse(id); MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(effectID); if (effect == null) { ActuallyAdditions.LOGGER.error("Unable to find effect with ID: {}, defaulting to speed", effectID); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java index c90b404d6..6d2df8f59 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java @@ -151,7 +151,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { if (StackUtil.isValid(stack)) { IPlantable plantable = this.getPlantableFromStack(stack); if (plantable != null) { - BlockState state = plantable.getPlant(world, pos); + BlockState state = plantable.g(world, pos); if (state != null && state.getBlock() instanceof BonemealableBlock) { return state; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java index 643188f6a..d3fa7eb11 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java @@ -47,7 +47,7 @@ public class SpecialRenderInit { } // TODO: remove tolowercase hack - ResourceLocation resLoc = new ResourceLocation(itemName.toLowerCase()); + ResourceLocation resLoc = ResourceLocation.tryParse(itemName.toLowerCase()); ItemStack stack = findItem(resLoc); //TODO Remove this block once the transition to 1.11 is done and the special people stuff file has been converted to snake_case @@ -61,7 +61,7 @@ public class SpecialRenderInit { convertedItemName += c; } } - stack = findItem(new ResourceLocation(convertedItemName)); + stack = findItem(ResourceLocation.tryParse(convertedItemName)); } if (StackUtil.isValid(stack)) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java index 41a04ec9a..1530d5c74 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java @@ -11,10 +11,10 @@ package de.ellpeck.actuallyadditions.mod.network; import net.minecraft.nbt.CompoundTag; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; +import net.neoforged.neoforge.network.handling.IPayloadContext; public interface IDataHandler { - void handleData(CompoundTag compound, PlayPayloadContext context); + void handleData(CompoundTag compound, IPayloadContext context); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java index 7b7eaf541..e9c391391 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java @@ -13,13 +13,16 @@ package de.ellpeck.actuallyadditions.mod.network; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; +import net.neoforged.neoforge.network.handling.IPayloadContext; import org.apache.commons.lang3.tuple.Pair; public record PacketClientToServer(CompoundTag data, IDataHandler handler) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "client_to_server"); + public static final StreamCodec CODEC = CustomPacketPayload.codec( + PacketClientToServer::write, + PacketClientToServer::new); + public static final Type ID = new Type<>(ActuallyAdditions.modLoc("client_to_server")); public PacketClientToServer(Pair data) { this(data.getLeft(), data.getRight()); @@ -48,8 +51,8 @@ public record PacketClientToServer(CompoundTag data, IDataHandler handler) imple buf.writeInt(PacketHandler.DATA_HANDLERS.indexOf(handler)); } - public static void handle(final PacketClientToServer message, final PlayPayloadContext context) { - context.workHandler().submitAsync( + public static void handle(final PacketClientToServer message, final IPayloadContext context) { + context.enqueueWork( () -> { if (message.data != null && message.handler != null) { message.handler.handleData(message.data, context); @@ -59,7 +62,7 @@ public record PacketClientToServer(CompoundTag data, IDataHandler handler) imple } @Override - public ResourceLocation id() { + public Type type() { return ID; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index db4405301..e44ee3522 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -23,7 +23,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -32,12 +31,9 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.network.PacketDistributor; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; -import net.neoforged.neoforge.network.registration.IPayloadRegistrar; +import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; +import net.neoforged.neoforge.network.handling.IPayloadContext; +import net.neoforged.neoforge.network.registration.PayloadRegistrar; import java.util.ArrayList; import java.util.List; @@ -47,30 +43,30 @@ public final class PacketHandler { public static final List DATA_HANDLERS = new ArrayList<>(); public static final IDataHandler LASER_HANDLER = new IDataHandler() { @Override - @OnlyIn(Dist.CLIENT) - public void handleData(CompoundTag compound, PlayPayloadContext context) { + + public void handleData(CompoundTag compound, IPayloadContext context) { AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInt("Color"), compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); } }; public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() { @Override - @OnlyIn(Dist.CLIENT) - public void handleData(CompoundTag compound, PlayPayloadContext context) { + + public void handleData(CompoundTag compound, IPayloadContext context) { Level world = Minecraft.getInstance().level; if (world != null) { BlockEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof TileEntityBase) { - ((TileEntityBase) tile).readSyncableNBT(compound.getCompound("Data"), TileEntityBase.NBTType.SYNC); + ((TileEntityBase) tile).readSyncableNBT(compound.getCompound("Data"), world.registryAccess(), TileEntityBase.NBTType.SYNC); } } } }; public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler() { @Override - @OnlyIn(Dist.CLIENT) - public void handleData(CompoundTag compound, PlayPayloadContext context) { + + public void handleData(CompoundTag compound, IPayloadContext context) { Minecraft mc = Minecraft.getInstance(); - ItemStack stack = ItemStack.of(compound); + ItemStack stack = ItemStack.parseOptional(context.player().registryAccess(), compound); double inX = compound.getDouble("InX") + 0.5; double inY = compound.getDouble("InY") + 0.78; @@ -88,9 +84,9 @@ public final class PacketHandler { } }; public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> { - if (context.player().isPresent()) { - Player player = context.player().get(); - Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(compound.getString("WorldID")))); + if (context.player() != null) { + Player player = context.player(); + Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(compound.getString("WorldID")))); BlockEntity tile = level.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof IButtonReactor reactor) { @@ -102,9 +98,9 @@ public final class PacketHandler { } }; public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = (compound, context) -> { - if (context.player().isPresent()) { - Player player = context.player().get(); - Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(compound.getString("WorldID")))); + if (context.player() != null) { + Player player = context.player(); + Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(compound.getString("WorldID")))); Entity entity = level.getEntity(compound.getInt("PlayerID")); if (entity instanceof Player p) { AbstractContainerMenu container = p.containerMenu; @@ -115,9 +111,9 @@ public final class PacketHandler { } }; public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = (compound, context) -> { - if (context.player().isPresent()) { - Player player = context.player().get(); - Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(compound.getString("WorldID")))); + if (context.player() != null) { + Player player = context.player(); + Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(compound.getString("WorldID")))); BlockEntity tile = level.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof INumberReactor reactor) { @@ -126,9 +122,9 @@ public final class PacketHandler { } }; public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = (compound, context) -> { - if (context.player().isPresent()) { - Player player = context.player().get(); - Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(compound.getString("WorldID")))); + if (context.player() != null) { + Player player = context.player(); + Level level = player.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(compound.getString("WorldID")))); BlockEntity tile = level.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof IStringReactor reactor) { @@ -138,10 +134,10 @@ public final class PacketHandler { }; public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() { @Override - @OnlyIn(Dist.CLIENT) - public void handleData(CompoundTag compound, PlayPayloadContext context) { + + public void handleData(CompoundTag compound, IPayloadContext context) { CompoundTag dataTag = compound.getCompound("Data"); - Player player = context.player().orElse(null); //ActuallyAdditions.PROXY.getCurrentPlayer(); + Player player = context.player(); //ActuallyAdditions.PROXY.getCurrentPlayer(); if (player != null) { PlayerData.getDataFromPlayer(player).readFromNBT(dataTag, false); @@ -155,8 +151,8 @@ public final class PacketHandler { } }; public static final IDataHandler PLAYER_DATA_TO_SERVER = (compound, context) -> { - if (context.player().isPresent()) { - Level level = context.player().get().getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(compound.getString("World")))); + if (context.player() != null) { + Level level = context.player().getServer().getLevel(ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(compound.getString("World")))); Player player = level.getServer().getPlayerList().getPlayer(compound.getUUID("UUID")); if (player != null) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); @@ -184,13 +180,11 @@ public final class PacketHandler { } }; - public static void register(final RegisterPayloadHandlerEvent event) { - final IPayloadRegistrar registrar = event.registrar(ActuallyAdditions.MODID); + public static void register(final RegisterPayloadHandlersEvent event) { + final PayloadRegistrar registrar = event.registrar(ActuallyAdditions.MODID); - registrar.play(PacketServerToClient.ID, PacketServerToClient::new, handler -> handler - .client(PacketServerToClient::handle)); - registrar.play(PacketClientToServer.ID, PacketClientToServer::new, handler -> handler - .server(PacketClientToServer::handle)); + registrar.playToClient(PacketServerToClient.ID, PacketServerToClient.CODEC, PacketServerToClient::handle); + registrar.playToServer(PacketClientToServer.ID, PacketClientToServer.CODEC, PacketClientToServer::handle); DATA_HANDLERS.add(LASER_HANDLER); DATA_HANDLERS.add(TILE_ENTITY_HANDLER); @@ -202,8 +196,4 @@ public final class PacketHandler { DATA_HANDLERS.add(LASER_PARTICLE_HANDLER); DATA_HANDLERS.add(PLAYER_DATA_TO_SERVER); } - - public static void send(CustomPacketPayload msg, PacketDistributor.PacketTarget target) { - target.send(msg); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java index 62cabea6a..9d0e3e5bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java @@ -20,13 +20,11 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.network.PacketDistributor; public final class PacketHandlerHelper { - @OnlyIn(Dist.CLIENT) + public static void sendButtonPacket(BlockEntity tile, int buttonId) { CompoundTag compound = new CompoundTag(); BlockPos pos = tile.getBlockPos(); @@ -36,7 +34,7 @@ public final class PacketHandlerHelper { compound.putString("WorldID", tile.getLevel().dimension().location().toString()); compound.putInt("PlayerID", Minecraft.getInstance().player.getId()); compound.putInt("ButtonID", buttonId); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); } public static void syncPlayerData(Player player, boolean log) { @@ -52,7 +50,7 @@ public final class PacketHandlerHelper { } } - @OnlyIn(Dist.CLIENT) + public static void sendPlayerDataToServer(boolean log, int type) { CompoundTag compound = new CompoundTag(); compound.putBoolean("Log", log); @@ -84,11 +82,11 @@ public final class PacketHandlerHelper { } } - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(compound, PacketHandler.PLAYER_DATA_TO_SERVER)); + PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.PLAYER_DATA_TO_SERVER)); } } - @OnlyIn(Dist.CLIENT) + public static void sendNumberPacket(BlockEntity tile, double number, int id) { CompoundTag compound = new CompoundTag(); compound.putInt("X", tile.getBlockPos().getX()); @@ -98,6 +96,6 @@ public final class PacketHandlerHelper { compound.putInt("PlayerID", Minecraft.getInstance().player.getId()); compound.putInt("NumberID", id); compound.putDouble("Number", number); - PacketDistributor.SERVER.noArg().send(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER)); + PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java index eaf41f360..b5b78496a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java @@ -13,14 +13,17 @@ package de.ellpeck.actuallyadditions.mod.network; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; -import net.neoforged.neoforge.network.handling.PlayPayloadContext; +import net.neoforged.neoforge.network.handling.IPayloadContext; import org.apache.commons.lang3.tuple.Pair; public record PacketServerToClient(CompoundTag data, IDataHandler handler) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "server_to_client"); + public static final StreamCodec CODEC = CustomPacketPayload.codec( + PacketServerToClient::write, + PacketServerToClient::new); + public static final Type ID = new Type<>(ActuallyAdditions.modLoc("server_to_client")); public PacketServerToClient(Pair data) { this(data.getLeft(), data.getRight()); @@ -48,14 +51,13 @@ public record PacketServerToClient(CompoundTag data, IDataHandler handler) imple buf.writeNbt(data); buf.writeInt(PacketHandler.DATA_HANDLERS.indexOf(handler)); } - @Override - public ResourceLocation id() { + public Type type() { return ID; } - public static void handle(final PacketServerToClient message, final PlayPayloadContext context) { - context.workHandler().submitAsync( + public static void handle(final PacketServerToClient message, final IPayloadContext context) { + context.enqueueWork( () -> { if (message.data != null && message.handler != null) { message.handler.handleData(message.data, context); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleData.java index 49651ab63..57fc9b807 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleData.java @@ -1,136 +1,53 @@ package de.ellpeck.actuallyadditions.mod.particle; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; -import java.util.Locale; +import javax.annotation.Nonnull; -public class BeamParticleData extends ParticleType implements ParticleOptions { - private ParticleType type; - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( +public record BeamParticleData(double endX, double endY, double endZ, float red, float green, float blue, float alpha, + int maxAge, double rotationTime, float size) implements ParticleOptions { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( Codec.DOUBLE.fieldOf("endX").forGetter(d -> d.endX), Codec.DOUBLE.fieldOf("endY").forGetter(d -> d.endY), Codec.DOUBLE.fieldOf("endZ").forGetter(d -> d.endZ), - Codec.FLOAT.fieldOf("r").forGetter(d -> d.color[0]), - Codec.FLOAT.fieldOf("g").forGetter(d -> d.color[1]), - Codec.FLOAT.fieldOf("b").forGetter(d -> d.color[2]), + Codec.FLOAT.fieldOf("r").forGetter(d -> d.red), + Codec.FLOAT.fieldOf("g").forGetter(d -> d.green), + Codec.FLOAT.fieldOf("b").forGetter(d -> d.blue), Codec.FLOAT.fieldOf("alpha").forGetter(d -> d.alpha), Codec.INT.fieldOf("maxAge").forGetter(d -> d.maxAge), Codec.DOUBLE.fieldOf("rotationTime").forGetter(d -> d.rotationTime), Codec.FLOAT.fieldOf("size").forGetter(d -> d.size) ) .apply(instance, BeamParticleData::new)); - protected final double endX, endY, endZ; - protected final float[] color = new float[3]; - protected final float alpha; - protected final int maxAge; - protected final double rotationTime; - protected final float size; - @SuppressWarnings("deprecation") - static final Deserializer DESERIALIZER = new Deserializer() { + public static final StreamCodec STREAM_CODEC = StreamCodec.of( + BeamParticleData::toNetwork, BeamParticleData::fromNetwork + ); - @Override - public BeamParticleData fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - double endX = reader.readDouble(); - reader.expect(' '); - double endY = reader.readDouble(); - reader.expect(' '); - double endZ = reader.readDouble(); - reader.expect(' '); - float red = (float) reader.readDouble(); - reader.expect(' '); - float green = (float) reader.readDouble(); - reader.expect(' '); - float blue = (float) reader.readDouble(); - reader.expect(' '); - float alpha = (float) reader.readDouble(); - reader.expect(' '); - int maxAge = reader.readInt(); - reader.expect(' '); - double rotationTime = reader.readDouble(); - reader.expect(' '); - float size = (float) reader.readDouble(); - return new BeamParticleData(type, endX, endY, endZ, red, green, blue, alpha, maxAge, rotationTime, size); - } - - @Override - public BeamParticleData fromNetwork(ParticleType type, FriendlyByteBuf buffer) { - double endX = buffer.readDouble(); - double endY = buffer.readDouble(); - double endZ = buffer.readDouble(); - float red = buffer.readFloat(); - float green = buffer.readFloat(); - float blue = buffer.readFloat(); - float alpha = buffer.readFloat(); - int maxAge = buffer.readInt(); - double rotationTime = buffer.readDouble(); - float size = buffer.readFloat(); - - return new BeamParticleData(type, endX, endY, endZ, red, green, blue, alpha, maxAge, rotationTime, size); - } - }; - - public BeamParticleData(ParticleType particleTypeData, - double endX, double endY, double endZ, float red, float green, float blue, float alpha, - int maxAge, double rotationTime, float size) { - super(false, DESERIALIZER); - this.type = particleTypeData; - this.endX = endX; - this.endY = endY; - this.endZ = endZ; - this.color[0] = red; - this.color[1] = green; - this.color[2] = blue; - this.alpha = alpha; - this.maxAge = maxAge; - this.rotationTime = rotationTime; - this.size = size; + public static BeamParticleData fromNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer) { + return new BeamParticleData(pBuffer.readDouble(), pBuffer.readDouble(), pBuffer.readDouble(), pBuffer.readFloat(), pBuffer.readFloat(), pBuffer.readFloat(), pBuffer.readFloat(), pBuffer.readInt(), pBuffer.readDouble(), pBuffer.readFloat()); } - public BeamParticleData(double endX, double endY, double endZ, float red, float green, float blue, float alpha, - int maxAge, double rotationTime, float size) { - this(ActuallyParticles.BEAM.get(), endX, endY, endZ, red, green, blue, alpha, maxAge, rotationTime, size); - } - - public BeamParticleData(double endX, double endY, double endZ, float[] color, float alpha, - int maxAge, double rotationTime, float size) { - this(ActuallyParticles.BEAM.get(), endX, endY, endZ, color[0], color[1], color[2], alpha, maxAge, rotationTime, size); + public static void toNetwork(@Nonnull RegistryFriendlyByteBuf pBuffer, BeamParticleData pRecipe) { + pBuffer.writeDouble(pRecipe.endX()); + pBuffer.writeDouble(pRecipe.endY()); + pBuffer.writeDouble(pRecipe.endZ()); + pBuffer.writeFloat(pRecipe.red()); + pBuffer.writeFloat(pRecipe.green()); + pBuffer.writeFloat(pRecipe.blue()); + pBuffer.writeFloat(pRecipe.alpha()); + pBuffer.writeInt(pRecipe.maxAge()); + pBuffer.writeDouble(pRecipe.rotationTime()); + pBuffer.writeFloat(pRecipe.size()); } @Override public ParticleType getType() { - return type; - } - - @Override - public void writeToNetwork(FriendlyByteBuf buffer) { - buffer.writeDouble(this.endX); - buffer.writeDouble(this.endY); - buffer.writeDouble(this.endZ); - buffer.writeFloat(this.color[0]); - buffer.writeFloat(this.color[1]); - buffer.writeFloat(this.color[2]); - buffer.writeFloat(this.alpha); - buffer.writeInt(this.maxAge); - buffer.writeDouble(this.rotationTime); - buffer.writeFloat(this.size); - } - - @Override - public String writeToString() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f, %.2f %.2f %.2f %.2f %d %.2f %.2f", - this.endX, this.endY, this.endZ, this.color[0], this.color[1], this.color[2], this.alpha, - this.maxAge, this.rotationTime, this.size); - } - - @Override - public Codec codec() { - return BeamParticleData.CODEC; + return ActuallyParticles.BEAM.get(); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleType.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleType.java index 050934fb6..9de9e828a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleType.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/BeamParticleType.java @@ -1,15 +1,26 @@ package de.ellpeck.actuallyadditions.mod.particle; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.core.particles.ParticleType; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import org.jetbrains.annotations.NotNull; public class BeamParticleType extends ParticleType { + public BeamParticleType() { - super(false, BeamParticleData.DESERIALIZER); + super(false); } + @NotNull @Override - public Codec codec() { + public MapCodec codec() { return BeamParticleData.CODEC; } + + @NotNull + @Override + public StreamCodec streamCodec() { + return BeamParticleData.STREAM_CODEC; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleData.java index 1dc23cac6..b8cdc4c51 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleData.java @@ -1,95 +1,48 @@ package de.ellpeck.actuallyadditions.mod.particle; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; -import java.util.Locale; - -public class LaserItemParticleData extends ParticleType implements ParticleOptions { - private ParticleType type; - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( +public record LaserItemParticleData(ItemStack stack, double outputX, double outputY, double outputZ) implements ParticleOptions { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( ItemStack.CODEC.fieldOf("stack").forGetter(d -> d.stack), Codec.DOUBLE.fieldOf("outputX").forGetter(d -> d.outputX), Codec.DOUBLE.fieldOf("outputY").forGetter(d -> d.outputY), Codec.DOUBLE.fieldOf("outputZ").forGetter(d -> d.outputZ) ) .apply(instance, LaserItemParticleData::new)); - protected final ItemStack stack; - protected final double outputX, outputY, outputZ; - @SuppressWarnings("deprecation") - static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer() { - - @Override - public LaserItemParticleData fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - String itemString = reader.readString(); - ResourceLocation itemLocation = ResourceLocation.tryParse(itemString); - Item item = itemLocation == null ? null : BuiltInRegistries.ITEM.get(itemLocation); - ItemStack stack = item == null ? ItemStack.EMPTY : new ItemStack(item); - reader.expect(' '); - double outputX = reader.readDouble(); - reader.expect(' '); - double outputY = reader.readDouble(); - reader.expect(' '); - double outputZ = reader.readDouble(); - return new LaserItemParticleData(type, stack, outputX, outputY, outputZ); - } - - @Override - public LaserItemParticleData fromNetwork(ParticleType type, FriendlyByteBuf buffer) { - ItemStack stack = buffer.readItem(); - double outputX = buffer.readDouble(); - double outputY = buffer.readDouble(); - double outputZ = buffer.readDouble(); - return new LaserItemParticleData(type, stack, outputX, outputY, outputZ); - } - }; - - public LaserItemParticleData(ParticleType particleTypeData, ItemStack stack, - double outputX, double outputY, double outputZ) { - super(false, DESERIALIZER); - this.type = particleTypeData; - this.stack = stack; - this.outputX = outputX; - this.outputY = outputY; - this.outputZ = outputZ; - } - - public LaserItemParticleData(ItemStack stack, double outputX, double outputY, double outputZ) { - this(ActuallyParticles.LASER_ITEM.get(), stack, outputX, outputY, outputZ); - } + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ItemStack.STREAM_CODEC, LaserItemParticleData::stack, + ByteBufCodecs.DOUBLE, LaserItemParticleData::outputX, + ByteBufCodecs.DOUBLE, LaserItemParticleData::outputY, + ByteBufCodecs.DOUBLE, LaserItemParticleData::outputZ, + LaserItemParticleData::new + ); @Override public ParticleType getType() { - return type; + return ActuallyParticles.LASER_ITEM.get(); } - @Override - public void writeToNetwork(FriendlyByteBuf buffer) { - buffer.writeItem(this.stack); - buffer.writeDouble(this.outputX); - buffer.writeDouble(this.outputY); - buffer.writeDouble(this.outputZ); - } - - @Override - public String writeToString() { - return String.format(Locale.ROOT, "%s %s %.2f %.2f %.2f", BuiltInRegistries.PARTICLE_TYPE.getKey(this.getType()), - BuiltInRegistries.ITEM.getKey(this.stack.getItem()), - this.outputX, this.outputY, this.outputZ); - } - - @Override - public Codec codec() { - return LaserItemParticleData.CODEC; - } +// @Override +// public void writeToNetwork(FriendlyByteBuf buffer) { +// buffer.writeItem(this.stack); +// buffer.writeDouble(this.outputX); +// buffer.writeDouble(this.outputY); +// buffer.writeDouble(this.outputZ); +// } +// +// @Override +// public String writeToString() { +// return String.format(Locale.ROOT, "%s %s %.2f %.2f %.2f", BuiltInRegistries.PARTICLE_TYPE.getKey(this.getType()), +// BuiltInRegistries.ITEM.getKey(this.stack.getItem()), +// this.outputX, this.outputY, this.outputZ); +// } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleType.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleType.java index 612ce9c9c..2b7a16734 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleType.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/LaserItemParticleType.java @@ -1,15 +1,25 @@ package de.ellpeck.actuallyadditions.mod.particle; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.core.particles.ParticleType; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import org.jetbrains.annotations.NotNull; public class LaserItemParticleType extends ParticleType { - public LaserItemParticleType() { - super(false, LaserItemParticleData.DESERIALIZER); - } + public LaserItemParticleType() { + super(false); + } - @Override - public Codec codec() { - return LaserItemParticleData.CODEC; - } + @NotNull + @Override + public MapCodec codec() { + return LaserItemParticleData.CODEC; + } + + @NotNull + @Override + public StreamCodec streamCodec() { + return LaserItemParticleData.STREAM_CODEC; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/patchouli/PatchouliPages.java b/src/main/java/de/ellpeck/actuallyadditions/mod/patchouli/PatchouliPages.java index d1c23b0b3..c58f6fecd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/patchouli/PatchouliPages.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/patchouli/PatchouliPages.java @@ -1,11 +1,10 @@ package de.ellpeck.actuallyadditions.mod.patchouli; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.resources.ResourceLocation; import vazkii.patchouli.client.book.ClientBookRegistry; public class PatchouliPages { public static void init() { - ClientBookRegistry.INSTANCE.pageTypes.put(new ResourceLocation(ActuallyAdditions.MODID, "reconstructor"), PageReconstructor.class); + ClientBookRegistry.INSTANCE.pageTypes.put(ActuallyAdditions.modLoc("reconstructor"), PageReconstructor.class); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java index f8c264c9d..3f3090016 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java @@ -32,26 +32,6 @@ public class CustomEnergyStorage extends EnergyStorage { return super.extractEnergy(maxExtract, simulate); } - public int extractEnergyInternal(int maxExtract, boolean simulate) { - int before = this.maxExtract; - this.maxExtract = Integer.MAX_VALUE; - - int toReturn = this.extractEnergy(maxExtract, simulate); - - this.maxExtract = before; - return toReturn; - } - - public int receiveEnergyInternal(int maxReceive, boolean simulate) { - int before = this.maxReceive; - this.maxReceive = Integer.MAX_VALUE; - - int toReturn = this.receiveEnergy(maxReceive, simulate); - - this.maxReceive = before; - return toReturn; - } - public boolean isDirty() { return dirty; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java index 9a352fbb0..62f32c808 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java @@ -10,18 +10,21 @@ package de.ellpeck.actuallyadditions.mod.tile; -import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; import de.ellpeck.actuallyadditions.mod.items.DrillItem; import de.ellpeck.actuallyadditions.mod.items.ItemTag; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.Item; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; public class FilterSettings { + public final ItemStackHandlerAA filterInventory; public boolean isWhitelist; public boolean respectMod; @@ -73,13 +76,11 @@ public class FilterSettings { } } else if (slot.getItem() instanceof ItemTag) { - var data = slot.getExistingData(ActuallyAttachments.ITEM_TAG); - if (data.isPresent()) { - var tag = data.get().getTag(); - if (tag.isPresent()) { - if (stack.is(tag.get())) { - return whitelist; - } + var tagLocation = slot.get(ActuallyComponents.ITEM_TAG); + if (tagLocation != null) { + var tag = TagKey.create(Registries.ITEM,tagLocation); + if (stack.is(tag)) { + return whitelist; } } } @@ -104,30 +105,30 @@ public class FilterSettings { } public static boolean checkItem(ItemStack first, ItemStack second, boolean nbt) { - return nbt? ItemStack.isSameItemSameTags(first, second) : ItemStack.isSameItem(first, second); + return nbt? ItemStack.isSameItemSameComponents(first, second) : ItemStack.isSameItem(first, second); } public static boolean checkMod(ItemStack first, ItemStack second) { return BuiltInRegistries.ITEM.getKey(first.getItem()).getNamespace().equals(BuiltInRegistries.ITEM.getKey(second.getItem()).getNamespace()); } - public void writeToNBT(CompoundTag tag, String name) { - CompoundTag compound = new CompoundTag(); - compound.putBoolean("Whitelist", this.isWhitelist); - compound.putBoolean("Mod", this.respectMod); - compound.putBoolean("Damage", this.matchDamage); - compound.putBoolean("NBT", this.matchNBT); - compound.put("Items", filterInventory.serializeNBT()); - tag.put(name, compound); + public void writeToNBT(HolderLookup.Provider provider, CompoundTag tag, String name) { +// CompoundTag compound = new CompoundTag(); TODO: IMPORTANT! FIX THE FILTER SETTINGS!!! +// compound.putBoolean("Whitelist", this.isWhitelist); +// compound.putBoolean("Mod", this.respectMod); +// compound.putBoolean("Damage", this.matchDamage); +// compound.putBoolean("NBT", this.matchNBT); +// compound.put("Items", filterInventory.serializeNBT()); +// tag.put(name, compound); } - public void readFromNBT(CompoundTag tag, String name) { - CompoundTag compound = tag.getCompound(name); - this.isWhitelist = compound.getBoolean("Whitelist"); - this.respectMod = compound.getBoolean("Mod"); - this.matchDamage = compound.getBoolean("Damage"); - this.matchNBT = compound.getBoolean("NBT"); - this.filterInventory.deserializeNBT(compound.getCompound("Items")); + public void readFromNBT(HolderLookup.Provider provider, CompoundTag tag, String name) { +// CompoundTag compound = tag.getCompound(name); +// this.isWhitelist = compound.getBoolean("Whitelist"); +// this.respectMod = compound.getBoolean("Mod"); +// this.matchDamage = compound.getBoolean("Damage"); +// this.matchNBT = compound.getBoolean("NBT"); +// this.filterInventory.deserializeNBT(compound.getCompound("Items")); } public boolean needsUpdateSend() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java index 8637e7498..76d5b3b1f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java @@ -10,14 +10,11 @@ package de.ellpeck.actuallyadditions.mod.tile; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; - public interface IEnergyDisplay { - @OnlyIn(Dist.CLIENT) + CustomEnergyStorage getEnergyStorage(); - @OnlyIn(Dist.CLIENT) + boolean needsHoldShift(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java index 2a4cc1f1f..210910b29 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java @@ -22,6 +22,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; @@ -88,8 +89,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CurrentTime", this.currentTime); compound.putInt("Counter", this.counter); @@ -103,8 +104,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInt("CurrentTime"); this.counter = compound.getInt("Counter"); @@ -183,7 +184,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple @Override public void extractEnergy(int amount) { - this.storage.extractEnergyInternal(amount, false); + this.storage.extractEnergy(amount, false); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index 7bf012218..e0dcadd6d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -14,6 +14,9 @@ import de.ellpeck.actuallyadditions.mod.util.VanillaPacketDispatcher; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; @@ -41,9 +44,9 @@ public abstract class TileEntityBase extends BlockEntity { } @Override - protected void saveAdditional(CompoundTag compound) { - super.saveAdditional(compound); - this.writeSyncableNBT(compound, NBTType.SAVE_TILE); + protected void saveAdditional(CompoundTag compound, HolderLookup.Provider lookupProvider) { + super.saveAdditional(compound, lookupProvider); + this.writeSyncableNBT(compound, lookupProvider, NBTType.SAVE_TILE); } // TODO: [port] remove if the above is correct @@ -54,8 +57,8 @@ public abstract class TileEntityBase extends BlockEntity { // } @Override - public void load(CompoundTag compound) { - this.readSyncableNBT(compound, NBTType.SAVE_TILE); + public void loadAdditional(CompoundTag compound, HolderLookup.Provider lookupProvider) { + this.readSyncableNBT(compound, lookupProvider, NBTType.SAVE_TILE); } @@ -69,26 +72,28 @@ public abstract class TileEntityBase extends BlockEntity { @Override public ClientboundBlockEntityDataPacket getUpdatePacket() { CompoundTag compound = new CompoundTag(); - this.writeSyncableNBT(compound, NBTType.SYNC); + this.writeSyncableNBT(compound, + this.level != null ? this.level.registryAccess() : RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY), + NBTType.SYNC); return ClientboundBlockEntityDataPacket.create(this); } @Override - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookupProvider) { if (pkt.getTag() != null) //TODO: pkt.getTag() is nullable. Hopping Item Interface will throw in the log when placed because of this - this.readSyncableNBT(pkt.getTag(), NBTType.SYNC); + this.readSyncableNBT(pkt.getTag(), lookupProvider, NBTType.SYNC); } @Override - public final CompoundTag getUpdateTag() { + public final CompoundTag getUpdateTag(HolderLookup.Provider lookupProvider) { CompoundTag compound = new CompoundTag(); - this.writeSyncableNBT(compound, NBTType.SYNC); + this.writeSyncableNBT(compound, lookupProvider, NBTType.SYNC); return compound; } @Override - public void handleUpdateTag(CompoundTag tag) { - this.readSyncableNBT(tag, NBTType.SYNC); + public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider lookupProvider) { + this.readSyncableNBT(tag, lookupProvider, NBTType.SYNC); } public final void sendUpdate() { @@ -109,9 +114,9 @@ public abstract class TileEntityBase extends BlockEntity { }*/ } - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - super.saveAdditional(compound); + super.saveAdditional(compound, lookupProvider); } if (type == NBTType.SAVE_TILE) { @@ -127,9 +132,9 @@ public abstract class TileEntityBase extends BlockEntity { } } - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - super.load(compound); // FIXME: [port] flag as possible crash source + super.loadAdditional(compound, lookupProvider); // FIXME: [port] flag as possible crash source } if (type == NBTType.SAVE_TILE) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java index 11c427235..c4fb616f8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java @@ -17,6 +17,8 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -31,7 +33,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.common.IPlantable; +import net.neoforged.neoforge.common.SpecialPlantable; import net.neoforged.neoforge.energy.IEnergyStorage; import javax.annotation.Nullable; @@ -56,7 +58,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements Men public static boolean isValidItem(ItemStack stack) { if (!stack.isEmpty()) { Item item = stack.getItem(); - if (item.isEdible()) { + if (stack.has(DataComponents.FOOD)) { return true; } else if (item instanceof BlockItem) { return isValid(Block.byItem(item)); @@ -66,7 +68,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements Men } private static boolean isValid(Object o) { - return o instanceof IPlantable || o instanceof BonemealableBlock; + return o instanceof SpecialPlantable || o instanceof BonemealableBlock; } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -114,7 +116,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements Men } } else { tile.burnTime--; - tile.storage.receiveEnergyInternal(tile.producePerTick, false); + tile.storage.receiveEnergy(tile.producePerTick, false); } if ((tile.lastBurnTime != tile.burnTime || tile.lastProducePerTick != tile.producePerTick) && tile.sendUpdateWithInterval()) { @@ -125,8 +127,8 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements Men } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); compound.putInt("BurnTime", this.burnTime); @@ -135,8 +137,8 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements Men } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); this.burnTime = compound.getInt("BurnTime"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java index b8018c0a2..7f69b22fb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; @@ -33,7 +34,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.neoforge.common.util.FakePlayer; import net.neoforged.neoforge.common.util.FakePlayerFactory; -import net.neoforged.neoforge.fluids.IFluidBlock; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -54,16 +54,16 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements MenuPr } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CurrentTime", this.currentTime); } } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInt("CurrentTime"); } @@ -103,7 +103,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements MenuPr BlockState stateToBreak = this.level.getBlockState(breakCoords); Block blockToBreak = stateToBreak.getBlock(); - if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) { + if (!this.isPlacer && blockToBreak != Blocks.AIR && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) { List drops = Block.getDrops(stateToBreak, (ServerLevel) this.level, breakCoords, this.level.getBlockEntity(breakCoords)); FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level); if (stateToBreak.canHarvestBlock(this.level, breakCoords, fake)) { //TODO might double check this is right mikey diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java index 84371cd24..491be2045 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.SingleItem; import de.ellpeck.actuallyadditions.mod.fluids.OutputOnlyFluidTank; import de.ellpeck.actuallyadditions.mod.inventory.ContainerCanolaPress; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -21,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -29,11 +29,10 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; @@ -58,39 +57,39 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements Me super(ActuallyBlocks.CANOLA_PRESS.getTileEntityType(), pos, state, 1); } - @OnlyIn(Dist.CLIENT) + public int getTankScaled(int i) { return this.tank.getFluidAmount() * i / this.tank.getCapacity(); } - @OnlyIn(Dist.CLIENT) + public int getProcessScaled(int i) { return this.currentProcessTime * i / TIME; } - @OnlyIn(Dist.CLIENT) + public int getEnergyScaled(int i) { return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { compound.putInt("ProcessTime", this.currentProcessTime); } this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + this.tank.writeToNBT(lookupProvider, compound); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { this.currentProcessTime = compound.getInt("ProcessTime"); } this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, type); + this.tank.readFromNBT(lookupProvider, compound); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -106,10 +105,10 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements Me Optional> recipe = getRecipeForInput(tile.inv.getStackInSlot(0)); recipe.ifPresent(h -> { PressingRecipe r = h.value(); - if ((r.getOutput().isFluidEqual(tile.tank.getFluid()) || tile.tank.isEmpty()) && r.getOutput().getAmount() <= tile.tank.getCapacity() - tile.tank.getFluidAmount()) { + if ((FluidStack.isSameFluid(r.getOutput(), tile.tank.getFluid()) || tile.tank.isEmpty()) && r.getOutput().getAmount() <= tile.tank.getCapacity() - tile.tank.getFluidAmount()) { if (tile.storage.getEnergyStored() >= ENERGY_USE) { tile.currentProcessTime++; - tile.storage.extractEnergyInternal(ENERGY_USE, false); + tile.storage.extractEnergy(ENERGY_USE, false); if (tile.currentProcessTime >= TIME) { tile.currentProcessTime = 0; @@ -137,7 +136,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements Me } public static Optional> getRecipeForInput(ItemStack stack) { - return ActuallyAdditionsAPI.PRESSING_RECIPES.stream().filter(recipe -> recipe.value().matches(new SingleItem(stack), null)).findFirst(); + return ActuallyAdditionsAPI.PRESSING_RECIPES.stream().filter(recipe -> recipe.value().matches(new SingleRecipeInput(stack), null)).findFirst(); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java index d48196eb0..a1cd3a3f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java @@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -31,9 +32,6 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.common.CommonHooks; import net.neoforged.neoforge.energy.IEnergyStorage; import javax.annotation.Nullable; @@ -53,18 +51,18 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements super(ActuallyBlocks.COAL_GENERATOR.getTileEntityType(), pos, state, 1); } - @OnlyIn(Dist.CLIENT) + public int getEnergyScaled(int i) { return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); } - @OnlyIn(Dist.CLIENT) + public int getBurningScaled(int i) { return this.currentBurnTime * i / this.maxBurnTime; } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { compound.putInt("BurnTime", this.currentBurnTime); compound.putInt("MaxBurnTime", this.maxBurnTime); @@ -72,16 +70,16 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements compound.putString("currentRecipe", currentRecipe.id().toString()); } this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { this.currentBurnTime = compound.getInt("BurnTime"); this.maxBurnTime = compound.getInt("MaxBurnTime"); if (compound.contains("currentRecipe")) { - ResourceLocation id = new ResourceLocation(compound.getString("currentRecipe")); + ResourceLocation id = ResourceLocation.tryParse(compound.getString("currentRecipe")); for (RecipeHolder fuelRecipe : ActuallyAdditionsAPI.SOLID_FUEL_RECIPES) { if (fuelRecipe.id().equals(id)) { this.currentRecipe = fuelRecipe; @@ -91,7 +89,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements } } this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -110,7 +108,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements tile.currentBurnTime--; int produce = tile.currentRecipe.value().getTotalEnergy() / tile.currentRecipe.value().getBurnTime(); if (produce > 0) { - tile.storage.receiveEnergyInternal(produce, false); + tile.storage.receiveEnergy(produce, false); } } @@ -162,7 +160,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements if (!automation) { return true; } - return CommonHooks.getBurnTime(this.inv.getStackInSlot(0), null) <= 0; + return this.inv.getStackInSlot(0).getBurnTime(null) <= 0; }; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java index aaadebbaa..a7da4e3e3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java @@ -23,6 +23,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundSource; @@ -36,8 +37,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; @@ -90,31 +89,31 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements super(ActuallyBlocks.COFFEE_MACHINE.getTileEntityType(), pos, state, 11); } - @OnlyIn(Dist.CLIENT) + public int getCoffeeScaled(int i) { return this.coffeeCacheAmount * i / COFFEE_CACHE_MAX_AMOUNT; } - @OnlyIn(Dist.CLIENT) + public int getWaterScaled(int i) { return this.tank.getFluidAmount() * i / this.tank.getCapacity(); } - @OnlyIn(Dist.CLIENT) + public int getEnergyScaled(int i) { return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); } - @OnlyIn(Dist.CLIENT) + public int getBrewScaled(int i) { return this.brewTime * i / TIME_USED; } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); + this.tank.writeToNBT(lookupProvider, compound); compound.putInt("Cache", this.coffeeCacheAmount); if (type != NBTType.SAVE_BLOCK) { compound.putInt("Time", this.brewTime); @@ -122,10 +121,10 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); + this.tank.readFromNBT(lookupProvider, compound); this.coffeeCacheAmount = compound.getInt("Cache"); if (type != NBTType.SAVE_BLOCK) { this.brewTime = compound.getInt("Time"); @@ -190,7 +189,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } this.brewTime++; - this.storage.extractEnergyInternal(ENERGY_USED, false); + this.storage.extractEnergy(ENERGY_USED, false); if (this.brewTime >= TIME_USED) { this.brewTime = 0; ItemStack output = new ItemStack(ActuallyItems.COFFEE_CUP.get()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java index 5b7bcadc8..26504a5e5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java @@ -46,7 +46,7 @@ // // @Override // public void writeSyncableNBT(CompoundNBT compound, NBTType type) { -// super.writeSyncableNBT(compound, type); +// super.writeSyncableNBT(compound, lookupProvider, type); // if (type != NBTType.SAVE_BLOCK) { // compound.putInt("ConversionTime", this.conversionTime); // } @@ -59,7 +59,7 @@ // // @Override // public void readSyncableNBT(CompoundNBT compound, NBTType type) { -// super.readSyncableNBT(compound, type); +// super.readSyncableNBT(compound, lookupProvider, type); // if (type != NBTType.SAVE_BLOCK) { // this.conversionTime = compound.getInt("ConversionTime"); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCrusher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCrusher.java index 23cef8392..9aad60b18 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCrusher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCrusher.java @@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundSource; @@ -70,25 +71,25 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { compound.putInt("FirstCrushTime", this.firstCrushTime); compound.putInt("SecondCrushTime", this.secondCrushTime); compound.putBoolean("IsAutoSplit", this.isAutoSplit); } this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { this.firstCrushTime = compound.getInt("FirstCrushTime"); this.secondCrushTime = compound.getInt("SecondCrushTime"); this.isAutoSplit = compound.getBoolean("IsAutoSplit"); } this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -130,7 +131,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); firstCrushTime = 0; } - storage.extractEnergyInternal(ENERGY_USE, false); + storage.extractEnergy(ENERGY_USE, false); } crushed = storage.getEnergyStored() >= ENERGY_USE; } else { @@ -148,7 +149,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); secondCrushTime = 0; } - storage.extractEnergyInternal(ENERGY_USE, false); + storage.extractEnergy(ENERGY_USE, false); } crushed = storage.getEnergyStored() >= ENERGY_USE; } else { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java index ef4c19a29..a205941b3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; @@ -50,7 +51,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I int energy = item.getUsePerTick(tile.inv.getStackInSlot(0), tile, tile.ticksElapsed); if (tile.storage.getEnergyStored() >= energy) { if (item.update(tile.inv.getStackInSlot(0), tile, tile.ticksElapsed)) { - tile.storage.extractEnergyInternal(energy, false); + tile.storage.extractEnergy(energy, false); } } } @@ -68,14 +69,14 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java index 0dbbfe4d0..3cbf46ec7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerDropper; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -37,16 +38,16 @@ public class TileEntityDropper extends TileEntityInventoryBase implements MenuPr } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CurrentTime", this.currentTime); } } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInt("CurrentTime"); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java index e645a5f9c..001194122 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java @@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -95,7 +96,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { boolean done = tile.processTime >= recipe.getTime(); for (TileEntityDisplayStand stand : stands) { - stand.storage.extractEnergyInternal(recipe.getEnergyPerStand() / recipe.getTime(), false); + stand.storage.extractEnergy(recipe.getEnergyPerStand() / recipe.getTime(), false); if (done) { stand.inv.getStackInSlot(0).shrink(1); @@ -148,8 +149,8 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SAVE_TILE) { compound.putInt("ProcessTime", this.processTime); } @@ -162,14 +163,14 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SAVE_TILE) { this.processTime = compound.getInt("ProcessTime"); } if (type == NBTType.SYNC && compound.contains("CurrentRecipe")) { if (!compound.getString("CurrentRecipe").isEmpty()) { - ResourceLocation id = new ResourceLocation(compound.getString("CurrentRecipe")); + ResourceLocation id = ResourceLocation.tryParse(compound.getString("CurrentRecipe")); for (RecipeHolder empowererRecipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { if (empowererRecipe.id().equals(id)) { this.currentRecipe = empowererRecipe; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java index 3eb15431d..f100573df 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java @@ -17,12 +17,14 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -43,15 +45,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements Menu } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -72,7 +74,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements Menu boolean canTakeUp = capability.map(cap -> cap.getEnergyStored() >= cap.getMaxEnergyStored()).orElse(false); if (received > 0) { - tile.storage.extractEnergyInternal(received, false); + tile.storage.extractEnergy(received, false); } if (canTakeUp) { @@ -95,7 +97,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements Menu @Override public IRemover getRemover() { - return (slot, automation) -> !EnchantmentHelper.hasBindingCurse(this.inv.getStackInSlot(slot)) && !automation || slot == 1; + return (slot, automation) -> !(EnchantmentHelper.has(this.inv.getStackInSlot(slot), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) && !automation || slot == 1; } public int getEnergyScaled(int i) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java index fc02b07db..49007be5f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -41,15 +42,15 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -71,7 +72,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha boolean canTakeUp = capability.map(cap -> cap.getEnergyStored() <= 0).orElse(false); if (extracted > 0) { - tile.storage.receiveEnergyInternal(extracted, false); + tile.storage.receiveEnergy(extracted, false); } if (canTakeUp) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java index c4d7711bc..59e4b2f70 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java @@ -23,6 +23,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; @@ -57,7 +58,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { compound.putInt("WaitTime", this.waitTime); } @@ -66,11 +67,11 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer compound.putInt("CheckY", this.checkY); } this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { this.waitTime = compound.getInt("WaitTime"); } @@ -79,7 +80,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer this.checkY = compound.getInt("CheckY"); } this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -212,7 +213,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer @Override public void extractEnergy(int amount) { - this.storage.extractEnergyInternal(amount, false); + this.storage.extractEnergy(amount, false); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java index 0a0a8a0bf..705c98431 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFeeder; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -54,8 +55,8 @@ public class TileEntityFeeder extends TileEntityInventoryBase implements MenuPro } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); compound.putInt("Timer", this.currentTimer); if (type == NBTType.SYNC) { compound.putInt("Animals", this.currentAnimalAmount); @@ -63,8 +64,8 @@ public class TileEntityFeeder extends TileEntityInventoryBase implements MenuPro } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.currentTimer = compound.getInt("Timer"); if (type == NBTType.SYNC) { this.currentAnimalAmount = compound.getInt("Animals"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index 3b7eb02ff..6b2322e3f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFermentingBarrel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -26,8 +27,6 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.fluids.capability.IFluidHandler; @@ -52,24 +51,24 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { compound.putInt("ProcessTime", this.currentProcessTime); - compound.put("tanks", tanks.writeNBT()); + compound.put("tanks", tanks.writeNBT(lookupProvider)); if (currentRecipe != null) compound.putString("currentRecipe", currentRecipe.id().toString()); - super.writeSyncableNBT(compound, type); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { this.currentProcessTime = compound.getInt("ProcessTime"); if (compound.contains("tanks")) { - tanks.readNBT(compound.getCompound("tanks")); + tanks.readNBT(lookupProvider, compound.getCompound("tanks")); } if (compound.contains("currentRecipe")) { this.currentRecipe = ActuallyAdditionsAPI.FERMENTING_RECIPES.stream().filter(recipe -> recipe.id().toString().equals(compound.getString("currentRecipe"))).findFirst().orElse(null); } - super.readSyncableNBT(compound, type); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -126,7 +125,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari return (int) calc; } - @OnlyIn(Dist.CLIENT) + public int getProcessScaled(int i) { if (currentRecipe != null) return this.currentProcessTime * i / currentRecipe.value().getTime(); @@ -134,12 +133,12 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari return this.currentProcessTime * i / 100; } - @OnlyIn(Dist.CLIENT) + public int getOilTankScaled(int i) { return this.tanks.getFluidInTank(1).getAmount() * i / this.tanks.getTankCapacity(1); } - @OnlyIn(Dist.CLIENT) + public int getCanolaTankScaled(int i) { return this.tanks.getFluidInTank(0).getAmount() * i / this.tanks.getTankCapacity(0); } @@ -226,7 +225,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } else { if (inputTank.isEmpty()) { - inputTank.fill(new FluidStack(resource, Math.min(capacity, resource.getAmount())), FluidAction.EXECUTE); + inputTank.fill(new FluidStack(resource.getFluidHolder(), Math.min(capacity, resource.getAmount())), FluidAction.EXECUTE); //TODO need to set the BE dirty. return inputTank.getFluid().getAmount(); } @@ -247,11 +246,11 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } } - public CompoundTag writeNBT() { + public CompoundTag writeNBT(HolderLookup.Provider lookupProvider) { CompoundTag inputNBT = new CompoundTag(); - inputTank.writeToNBT(inputNBT); + inputTank.writeToNBT(lookupProvider, inputNBT); CompoundTag outputNBT = new CompoundTag(); - outputTank.writeToNBT(outputNBT); + outputTank.writeToNBT(lookupProvider, outputNBT); CompoundTag nbt = new CompoundTag(); nbt.put("inputTank", inputNBT); @@ -259,9 +258,9 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari return nbt; } - public void readNBT(CompoundTag nbt) { - inputTank.readFromNBT(nbt.getCompound("inputTank")); - outputTank.readFromNBT(nbt.getCompound("outputTank")); + public void readNBT(HolderLookup.Provider lookupProvider, CompoundTag nbt) { + inputTank.readFromNBT(lookupProvider, nbt.getCompound("inputTank")); + outputTank.readFromNBT(lookupProvider, nbt.getCompound("outputTank")); } @Nonnull @@ -281,7 +280,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari { drained = outputTank.getFluid().getAmount(); } - FluidStack stack = new FluidStack(outputTank.getFluid(), drained); + FluidStack stack = new FluidStack(outputTank.getFluid().getFluidHolder(), drained); if (action.execute() && drained > 0) { outputTank.getFluid().shrink(drained); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index c1301c1f0..f4bdefb4a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -13,10 +13,12 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFireworkBox; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; +import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.util.random.Weight; @@ -30,6 +32,8 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.FireworkExplosion; +import net.minecraft.world.item.component.Fireworks; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -63,8 +67,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { @@ -84,8 +88,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { @@ -170,32 +174,27 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } private ItemStack makeFirework() { - ListTag list = new ListTag(); + List explosions = new ArrayList<>(); for (int i = 0; i < this.getRandomWithPlay(this.chargeAmount); i++) { - list.add(this.makeFireworkCharge()); + explosions.add(this.makeFireworkCharge()); } - CompoundTag compound1 = new CompoundTag(); - compound1.put("Explosions", list); - compound1.putByte("Flight", (byte) this.getRandomWithPlay(this.flightTime)); - - CompoundTag compound = new CompoundTag(); - compound.put("Fireworks", compound1); - ItemStack firework = new ItemStack(Items.FIREWORK_ROCKET); - firework.setTag(compound); + Fireworks fireworks = new Fireworks(1, explosions); + firework.set(DataComponents.FIREWORKS, fireworks); return firework; } - private CompoundTag makeFireworkCharge() { - CompoundTag compound = new CompoundTag(); + private FireworkExplosion makeFireworkCharge() { + boolean flicker = false; + boolean trail = false; if (this.level.random.nextFloat() <= this.trailOrFlickerChance) { if (this.level.random.nextFloat() <= this.flickerChance) { - compound.putBoolean("Flicker", true); + flicker = true; } else { - compound.putBoolean("Trail", true); + trail = true; } } @@ -204,11 +203,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp for (int i = 0; i < colors.length; i++) { colors[i] = DyeColor.values()[this.level.random.nextInt(DyeColor.values().length)].getFireworkColor(); } - compound.putIntArray("Colors", colors); - compound.putByte("Type", (byte) this.getRandomType()); - - return compound; + return new FireworkExplosion(FireworkExplosion.Shape.byId((byte) this.getRandomType()), IntList.of(colors), IntList.of(), trail, flicker); } private int getRandomWithPlay(int value) { @@ -263,7 +259,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp if (this.storage.getEnergyStored() >= USE_PER_SHOT) { this.spawnFireworks(this.level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); - this.storage.extractEnergyInternal(USE_PER_SHOT, false); + this.storage.extractEnergy(USE_PER_SHOT, false); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 83835f576..7bbbc5667 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerFluidCollector; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -103,9 +104,9 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing BlockState stateToBreak = this.level.getBlockState(coordsBlock); Block blockToBreak = stateToBreak.getBlock(); if (!this.isPlacer && FluidType.BUCKET_VOLUME <= this.tank.getCapacity() - this.tank.getFluidAmount()) { - if (blockToBreak instanceof LiquidBlock && stateToBreak.getFluidState().isSource() && ((LiquidBlock) blockToBreak).getFluid() != null) { - if (this.tank.fillInternal(new FluidStack(((LiquidBlock) blockToBreak).getFluid(), FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE) >= FluidType.BUCKET_VOLUME) { - this.tank.fillInternal(new FluidStack(((LiquidBlock) blockToBreak).getFluid(), FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE); + if (blockToBreak instanceof LiquidBlock liquidBlock && liquidBlock.fluid != null && stateToBreak.getFluidState().isSource() ) { + if (this.tank.fillInternal(new FluidStack(liquidBlock.fluid, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE) >= FluidType.BUCKET_VOLUME) { + this.tank.fillInternal(new FluidStack(liquidBlock.fluid, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE); this.level.setBlockAndUpdate(coordsBlock, Blocks.AIR.defaultBlockState()); } } @@ -148,21 +149,21 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CurrentTime", this.currentTime); } - this.tank.writeToNBT(compound); + this.tank.writeToNBT(lookupProvider, compound); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInt("CurrentTime"); } - this.tank.readFromNBT(compound); + this.tank.readFromNBT(lookupProvider, compound); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java index f13c40124..310b728d7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java @@ -34,13 +34,13 @@ // // @Override // public void writeSyncableNBT(CompoundNBT compound, NBTType type) { -// super.writeSyncableNBT(compound, type); +// super.writeSyncableNBT(compound, lookupProvider, type); // this.storage.writeToNBT(compound); // } // // @Override // public void readSyncableNBT(CompoundNBT compound, NBTType type) { -// super.readSyncableNBT(compound, type); +// super.readSyncableNBT(compound, lookupProvider, type); // this.storage.readFromNBT(compound); // } // @@ -51,7 +51,7 @@ // int power = this.getPowerToGenerate(PRODUCE); // if (this.level.isDay() && power > 0) { // if (power <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) { -// this.storage.receiveEnergyInternal(power, false); +// this.storage.receiveEnergy(power, false); // this.setChanged(); // } // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java index 658309a59..f9610622f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java @@ -37,7 +37,7 @@ // // @Override // public void writeSyncableNBT(CompoundNBT compound, NBTType type) { -// super.writeSyncableNBT(compound, type); +// super.writeSyncableNBT(compound, lookupProvider, type); // // if (this.lootTable != null) { // compound.setString("LootTable", this.lootTable.toString()); @@ -46,10 +46,10 @@ // // @Override // public void readSyncableNBT(CompoundNBT compound, NBTType type) { -// super.readSyncableNBT(compound, type); +// super.readSyncableNBT(compound, lookupProvider, type); // // if (compound.hasKey("LootTable")) { -// this.lootTable = new ResourceLocation(compound.getString("LootTable")); +// this.lootTable = ResourceLocation.tryParse(compound.getString("LootTable")); // } // } // diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java index 46d539a05..7b5bad33d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.FluidTags; import net.minecraft.world.level.Level; @@ -39,8 +40,8 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (type == NBTType.SAVE_TILE) { @@ -49,8 +50,8 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (type == NBTType.SAVE_TILE) { @@ -80,7 +81,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE } if (blocksAround.size() >= BLOCKS_NEEDED) { - tile.storage.receiveEnergyInternal(ENERGY_PRODUCE, false); + tile.storage.receiveEnergy(ENERGY_PRODUCE, false); tile.setChanged(); tile.disappearTime++; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 32af3508d..f93ec72a5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.world.item.ItemStack; @@ -34,14 +35,14 @@ public abstract class TileEntityInventoryBase extends TileEntityBase { this.inv = new TileStackHandler(slots); } - public static void saveSlots(IItemHandler slots, CompoundTag compound) { + public static void saveSlots(IItemHandler slots, CompoundTag compound, HolderLookup.Provider provider) { if (slots != null && slots.getSlots() > 0) { ListTag tagList = new ListTag(); for (int i = 0; i < slots.getSlots(); i++) { ItemStack slot = slots.getStackInSlot(i); CompoundTag tagCompound = new CompoundTag(); if (StackUtil.isValid(slot)) { - slot.save(tagCompound); + slot.save(provider, tagCompound); } tagList.add(tagCompound); } @@ -49,23 +50,23 @@ public abstract class TileEntityInventoryBase extends TileEntityBase { } } - public static void loadSlots(IItemHandlerModifiable slots, CompoundTag compound) { + public static void loadSlots(IItemHandlerModifiable slots, CompoundTag compound, HolderLookup.Provider provider) { if (slots != null && slots.getSlots() > 0) { ListTag tagList = compound.getList("Items", 10); for (int i = 0; i < slots.getSlots(); i++) { CompoundTag tagCompound = tagList.getCompound(i); slots.setStackInSlot(i, tagCompound.contains("id") - ? ItemStack.of(tagCompound) + ? ItemStack.parseOptional(provider, tagCompound) : ItemStack.EMPTY); } } } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SAVE_TILE || type == NBTType.SYNC && this.shouldSyncSlots()) { - saveSlots(this.inv, compound); + saveSlots(this.inv, compound, lookupProvider); } } @@ -105,10 +106,10 @@ public abstract class TileEntityInventoryBase extends TileEntityBase { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SAVE_TILE || type == NBTType.SYNC && this.shouldSyncSlots()) { - loadSlots(this.inv, compound); + loadSlots(this.inv, compound, lookupProvider); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java index 6936c4c8a..b98862eaa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java @@ -35,7 +35,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; public class TileEntityItemInterface extends TileEntityBase { @@ -164,7 +163,7 @@ public class TileEntityItemInterface extends TileEntityBase { public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) { if (!this.level.isClientSide) { CompoundTag compound = new CompoundTag(); - stack.save(compound); + stack.save(this.level.registryAccess(), compound); compound.putDouble("InX", input.getX()); compound.putDouble("InY", input.getY()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java index 799247186..8bc671094 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.core.BlockPos; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index b9bc5b6e2..a08ca5461 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import io.netty.util.internal.ConcurrentSet; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.chat.Component; @@ -27,8 +28,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.items.IItemHandler; public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { @@ -50,8 +49,8 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SYNC) { ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(this.worldPosition, this.level); @@ -70,8 +69,8 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type == NBTType.SYNC) { ListTag list = new ListTag(); @@ -137,7 +136,7 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } } - @OnlyIn(Dist.CLIENT) + public void renderParticles(){ if(this.world.rand.nextInt(8) == 0){ PlayerEntity player = Minecraft.getInstance().player; @@ -176,7 +175,7 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } // @Override TODO: Fix the renderBoundingBox -// @OnlyIn(Dist.CLIENT) +// // public AABB getRenderBoundingBox() { // return INFINITE_EXTENT_AABB; // } @@ -200,10 +199,10 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } } - @OnlyIn(Dist.CLIENT) + public abstract Component getExtraDisplayString(); - @OnlyIn(Dist.CLIENT) + public abstract Component getCompassDisplayString(); public abstract void onCompassAction(Player player); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index fa8a96040..5169a6d64 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -13,13 +13,13 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -28,8 +28,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.energy.IEnergyStorage; @@ -258,13 +256,13 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { } @Override - @OnlyIn(Dist.CLIENT) + public Component getExtraDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.energy.extra").append(": ").append(Component.translatable(this.mode.name).withStyle(ChatFormatting.DARK_RED)); } @Override - @OnlyIn(Dist.CLIENT) + public Component getCompassDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.energy.display").withStyle(ChatFormatting.GREEN); } @@ -275,8 +273,8 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putString("Mode", this.mode.toString()); @@ -284,8 +282,8 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { String modeStrg = compound.getString("Mode"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java index b1b78fc66..9718bc39d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -13,21 +13,19 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy.Mode; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; @@ -250,13 +248,13 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { } @Override - @OnlyIn(Dist.CLIENT) + public Component getExtraDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.fluid.extra").append(": ").append(Component.translatable(this.mode.name).withStyle(ChatFormatting.DARK_RED)); } @Override - @OnlyIn(Dist.CLIENT) + public Component getCompassDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.energy.display").withStyle(ChatFormatting.GREEN); } @@ -267,8 +265,8 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putString("Mode", this.mode.toString()); @@ -276,8 +274,8 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { String modeStrg = compound.getString("Mode"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index b7e459c38..622ac3a16 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterface.GenericItemHandlerInfo; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; @@ -21,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapp import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; @@ -29,8 +29,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.items.IItemHandler; @@ -149,21 +147,21 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("Priority", this.priority); } } @Override - @OnlyIn(Dist.CLIENT) + public Component getExtraDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.item.extra").append(": ").append(Component.literal(String.valueOf(this.getPriority())).withStyle(ChatFormatting.DARK_RED)); } @Override - @OnlyIn(Dist.CLIENT) + public Component getCompassDisplayString() { return Component.translatable("info.actuallyadditions.laserRelay.item.display.1").append(" - ").append(Component.translatable("info.actuallyadditions.laserRelay.item.display.2")).withStyle(ChatFormatting.GREEN); } @@ -178,8 +176,8 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.priority = compound.getInt("Priority"); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemAdvanced.java index 09057671c..a5fc26842 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemAdvanced.java @@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -72,19 +73,19 @@ public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem i } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); - this.leftFilter.writeToNBT(compound, "LeftFilter"); - this.rightFilter.writeToNBT(compound, "RightFilter"); + this.leftFilter.writeToNBT(lookupProvider, compound, "LeftFilter"); + this.rightFilter.writeToNBT(lookupProvider, compound, "RightFilter"); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); - this.leftFilter.readFromNBT(compound, "LeftFilter"); - this.rightFilter.readFromNBT(compound, "RightFilter"); + this.leftFilter.readFromNBT(lookupProvider, compound, "LeftFilter"); + this.rightFilter.readFromNBT(lookupProvider, compound, "RightFilter"); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java index 787f4737f..83dcf1d4e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -38,8 +39,8 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { compound.putInt("WorkTime", this.currentWorkTime); @@ -47,8 +48,8 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { this.currentWorkTime = compound.getInt("WorkTime"); @@ -70,7 +71,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I if (tile.currentWorkTime >= 200) { tile.currentWorkTime = 0; level.setBlock(tile.worldPosition.above(), Blocks.LAVA.defaultBlockState(), 2); - tile.storage.extractEnergyInternal(ENERGY_USE, false); + tile.storage.extractEnergy(ENERGY_USE, false); } } else { tile.currentWorkTime = 0; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index 57c1ba836..7b40b34b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.BlockTags; import net.minecraft.world.level.Level; @@ -40,14 +41,14 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); } @@ -79,13 +80,13 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); - BlockPos theCoord = breakPositions.get(0); + BlockPos theCoord = breakPositions.getFirst(); level.levelEvent(2001, theCoord, Block.getId(level.getBlockState(theCoord))); level.setBlockAndUpdate(theCoord, Blocks.AIR.defaultBlockState()); - tile.storage.receiveEnergyInternal(energyProduced, false); + tile.storage.receiveEnergy(energyProduced, false); AssetUtil.spawnLaserWithTimeServer(level, pos.getX(), pos.getY(), pos.getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), 0x3EA34A, 25, 0, 0.075F, 0.8F); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLongRangeBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLongRangeBreaker.java index 7848d2dfc..16ddd678c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLongRangeBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLongRangeBreaker.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; @@ -48,8 +49,8 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CurrentTime", this.currentTime); @@ -57,8 +58,8 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInt("CurrentTime"); @@ -110,7 +111,7 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen this.level.levelEvent(2001, coordsBlock, Block.getId(this.level.getBlockState(coordsBlock))); this.level.setBlockAndUpdate(coordsBlock, Blocks.AIR.defaultBlockState()); StackUtil.addAll(this.inv, drops, false); - this.storage.extractEnergyInternal(ENERGY_USE, false); + this.storage.extractEnergy(ENERGY_USE, false); this.setChanged(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index 4afd3f977..c840a1cde 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe; import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -27,8 +28,6 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; @@ -79,7 +78,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn return null; } - @OnlyIn(Dist.CLIENT) + public int getBurningScaled(int i) { return this.currentBurnTime * i / this.maxBurnTime; } @@ -93,7 +92,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { compound.putInt("BurnTime", this.currentBurnTime); compound.putInt("CurrentEnergy", this.currentEnergyProduce); @@ -101,12 +100,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn compound.putInt("FuelUsage", this.fuelUsage); } this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, type); + this.tank.writeToNBT(lookupProvider, compound); + super.writeSyncableNBT(compound, lookupProvider, type); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { if (type != NBTType.SAVE_BLOCK) { this.currentBurnTime = compound.getInt("BurnTime"); this.currentEnergyProduce = compound.getInt("CurrentEnergy"); @@ -114,8 +113,8 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn this.fuelUsage = compound.getInt("FuelUsage"); } this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, type); + this.tank.readFromNBT(lookupProvider, compound); + super.readSyncableNBT(compound, lookupProvider, type); } public static void clientTick(Level level, BlockPos pos, BlockState state, T t) { @@ -133,7 +132,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn if (tile.currentBurnTime > 0 && tile.currentEnergyProduce > 0) { tile.currentBurnTime--; - tile.storage.receiveEnergyInternal(tile.currentEnergyProduce, false); + tile.storage.receiveEnergy(tile.currentEnergyProduce, false); } else if (!tile.isRedstonePowered) { RecipeHolder recipeHolder = tile.getRecipeForCurrentFluid(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java index b5cbf6674..72c3f43c2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java @@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -61,8 +62,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("Range", this.range); if (this.boundPosition != null) { @@ -77,8 +78,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { int x = compound.getInt("xOfTileStored"); int y = compound.getInt("yOfTileStored"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 52cada79a..f733da425 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -21,8 +22,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.capabilities.ICapabilityInvalidationListener; public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile { @@ -56,8 +55,8 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("Range", this.range); if (this.boundPosition != null) { @@ -69,8 +68,8 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { int x = compound.getInt("xOfTileStored"); int y = compound.getInt("yOfTileStored"); @@ -150,7 +149,7 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl return false; } - @OnlyIn(Dist.CLIENT) + public void renderParticles() { if (this.level.random.nextInt(2) == 0) { double d1 = this.boundPosition.getY() + this.level.random.nextFloat(); @@ -203,7 +202,7 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl return 0; } - public class CapListener implements ICapabilityInvalidationListener { + public static class CapListener implements ICapabilityInvalidationListener { private boolean valid = true; private final TileEntityPhantomface tile; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java index 32e5d0f2d..c3bbc879e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -95,7 +96,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy int received = Optional.ofNullable(slot.getCapability(Capabilities.EnergyStorage.ITEM)) .map(cap -> cap.receiveEnergy(tile.storage.getEnergyStored(), false)).orElse(0); if (received > 0) { - tile.storage.extractEnergyInternal(received, false); + tile.storage.extractEnergy(received, false); } } } else { @@ -116,8 +117,8 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (this.connectedPlayer != null && type != NBTType.SAVE_BLOCK) { @@ -127,8 +128,8 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (compound.contains("Player") && type != NBTType.SAVE_BLOCK) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java index 40a54a399..ef871fefa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import de.ellpeck.actuallyadditions.mod.crafting.SingleItem; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -20,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -29,6 +29,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.item.crafting.SmeltingRecipe; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -92,8 +93,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { compound.putInt("FirstSmeltTime", this.firstSmeltTime); compound.putInt("SecondSmeltTime", this.secondSmeltTime); @@ -103,8 +104,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); if (type != NBTType.SAVE_BLOCK) { this.firstSmeltTime = compound.getInt("FirstSmeltTime"); this.secondSmeltTime = compound.getInt("SecondSmeltTime"); @@ -140,7 +141,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements tile.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1); tile.firstSmeltTime = 0; } - tile.storage.extractEnergyInternal(ENERGY_USE, false); + tile.storage.extractEnergy(ENERGY_USE, false); } smelted = true; } else { @@ -154,7 +155,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements tile.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2); tile.secondSmeltTime = 0; } - tile.storage.extractEnergyInternal(ENERGY_USE, false); + tile.storage.extractEnergy(ENERGY_USE, false); } smelted = true; } else { @@ -193,11 +194,11 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements } public Optional getOutputForInput(ItemStack stack) { - return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level).map(recipe -> recipe.value().getResultItem(this.level.registryAccess())); + return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(stack), level).map(recipe -> recipe.value().getResultItem(this.level.registryAccess())); } public Optional> getRecipeForInput(ItemStack stack) { - return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level); + return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(stack), level); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index eb3f6eda5..05984975f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -46,17 +47,17 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); - this.filter.writeToNBT(compound, "Filter"); + this.filter.writeToNBT(lookupProvider, compound, "Filter"); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); - this.filter.readFromNBT(compound, "Filter"); + this.filter.readFromNBT(lookupProvider, compound, "Filter"); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java index 87c9bd8f6..0caa43565 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -75,14 +76,14 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java index 97b08750e..610f02260 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java @@ -26,7 +26,7 @@ // // @Override // public void writeSyncableNBT(CompoundNBT compound, NBTType type) { -// super.writeSyncableNBT(compound, type); +// super.writeSyncableNBT(compound, lookupProvider, type); // if (this.name != null && type != NBTType.SAVE_BLOCK) { // compound.setString("Name", this.name); // } @@ -34,7 +34,7 @@ // // @Override // public void readSyncableNBT(CompoundNBT compound, NBTType type) { -// super.readSyncableNBT(compound, type); +// super.readSyncableNBT(compound, lookupProvider, type); // if (type != NBTType.SAVE_BLOCK) { // this.name = compound.getString("Name"); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java index 95ddcd9c6..7f3ec4ddf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityVerticalDigger.java @@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -29,7 +30,6 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Tiers; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -38,10 +38,8 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.common.Tags; -import net.neoforged.neoforge.common.TierSortingRegistry; import net.neoforged.neoforge.common.util.FakePlayerFactory; import net.neoforged.neoforge.energy.IEnergyStorage; -import net.neoforged.neoforge.fluids.IFluidBlock; import javax.annotation.Nullable; import java.util.List; @@ -65,8 +63,8 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { compound.putInt("CheckX", this.checkX); @@ -79,8 +77,8 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { this.checkX = compound.getInt("CheckX"); @@ -146,7 +144,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements ItemStack stack = block.getCloneItemStack(state, new BlockHitResult(new Vec3(0, 0, 0), Direction.DOWN, pos, false), this.level, pos, FakePlayerFactory.getMinecraft((ServerLevel) this.level)); if (!state.isAir()) { //block.getHarvestLevel(state) <= DrillItem.HARVEST_LEVEL - if (TierSortingRegistry.isCorrectTierForDrops(Tiers.NETHERITE, state) && state.getDestroySpeed(this.level, pos) >= 0F && !(block instanceof IFluidBlock) && this.isMinable(state, stack)) { + if (stack.isCorrectToolForDrops(state) && state.getDestroySpeed(this.level, pos) >= 0F && this.isMinable(state, stack)) { List drops = Block.getDrops(state, (ServerLevel) this.level, pos, this.level.getBlockEntity(pos)); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, pos); @@ -158,7 +156,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements StackUtil.addAll(this.inv, drops, false); this.setChanged(); - this.storage.extractEnergyInternal(actualUse, false); + this.storage.extractEnergy(actualUse, false); this.shootParticles(pos.getX(), pos.getY(), pos.getZ()); } else { return false; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index 548758b58..1e7dea6a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -115,15 +116,15 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } @Override - public void writeSyncableNBT(CompoundTag compound, NBTType type) { - super.writeSyncableNBT(compound, type); + public void writeSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.writeSyncableNBT(compound, lookupProvider, type); compound.putInt("Amount", this.amount); compound.putInt("SinglePointAmount", this.singlePointAmount); } @Override - public void readSyncableNBT(CompoundTag compound, NBTType type) { - super.readSyncableNBT(compound, type); + public void readSyncableNBT(CompoundTag compound, HolderLookup.Provider lookupProvider, NBTType type) { + super.readSyncableNBT(compound, lookupProvider, type); this.amount = compound.getInt("Amount"); this.singlePointAmount = compound.getInt("SinglePointAmount"); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java index cbdbe0b07..df8c1e42a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java @@ -14,11 +14,9 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.neoforge.client.event.ClientTickEvent; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.TickEvent; public class UpdateChecker { @@ -38,9 +36,9 @@ public class UpdateChecker { // } } - @OnlyIn(Dist.CLIENT) + @SubscribeEvent(receiveCanceled = true) - public void onTick(TickEvent.ClientTickEvent event) { + public void onTick(ClientTickEvent.Pre event) { if (Minecraft.getInstance().player != null) { Player player = Minecraft.getInstance().player; if (UpdateChecker.checkFailed) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index 8aee13317..4a0327e34 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -49,8 +49,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.client.ClientHooks; import net.neoforged.neoforge.network.PacketDistributor; import org.joml.Matrix4f; @@ -61,22 +59,22 @@ public final class AssetUtil { public static final int MAX_LIGHT_Y = 0xF000F0; public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory"); - private static final ResourceLocation FORGE_WHITE = new ResourceLocation("forge", "white"); + private static final ResourceLocation FORGE_WHITE = ResourceLocation.tryParse("forge", "white"); public static ResourceLocation getGuiLocation(String file) { - return new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/" + file + ".png"); + return ActuallyAdditions.modLoc("textures/gui/" + file + ".png"); } public static ResourceLocation getBookletGuiLocation(String file) { return getGuiLocation("booklet/" + file); } - @OnlyIn(Dist.CLIENT) + public static void displayNameString(GuiGraphics guiGraphics, Font font, int xSize, int yPositionOfMachineText, String text) { guiGraphics.drawString(font, text, xSize / 2f - font.width(text) / 2f, yPositionOfMachineText, 0xFFFFFF, false); } - @OnlyIn(Dist.CLIENT) + public static void displayNameString(GuiGraphics guiGraphics, Font font, int xSize, int yPositionOfMachineText, TileEntityBase tile) { displayNameString(guiGraphics, font, xSize, yPositionOfMachineText, I18n.get(tile.getNameForTranslation())); } @@ -85,7 +83,7 @@ public final class AssetUtil { // renderItemInWorld(new ItemStack(block, 1, meta), combinedLightIn, combinedOverlayIn, matrices, buffer); // } - @OnlyIn(Dist.CLIENT) + public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, PoseStack matrices, MultiBufferSource buffer) { if (!stack.isEmpty()) { Minecraft.getInstance().getItemRenderer().renderStatic( @@ -94,7 +92,7 @@ public final class AssetUtil { } } - // @OnlyIn(Dist.CLIENT) + // // public static void renderStateInWorld(BlockState state, IWorldReader world, BlockPos pos, float brightness) { // Minecraft.getInstance().getTextureManager().bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE); // IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state); @@ -108,7 +106,7 @@ public final class AssetUtil { // Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b); // } - @OnlyIn(Dist.CLIENT) + public static void renderItemWithoutScrewingWithColors(ItemStack stack, PoseStack matrices, int combinedOverlay, int combinedLight) { if (StackUtil.isValid(stack)) { Minecraft mc = Minecraft.getInstance(); @@ -136,7 +134,7 @@ public final class AssetUtil { } } - @OnlyIn(Dist.CLIENT) + public static void renderStackToGui(ItemStack stack, int x, int y, float scale) { /* GlStateManager._pushMatrix(); GlStateManager._enableBlend(); @@ -159,7 +157,7 @@ public final class AssetUtil { } //Copied from Gui.class and changed - @OnlyIn(Dist.CLIENT) + public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel) { /* float f = (startColor >> 24 & 255) / 255.0F; float f1 = (startColor >> 16 & 255) / 255.0F; @@ -188,7 +186,7 @@ public final class AssetUtil { GlStateManager.enableTexture2D();*/ } -// @OnlyIn(Dist.CLIENT) +// // public static void renderNameTag(String tag, double x, double y, double z) { // FontRenderer fontrenderer = Minecraft.getInstance().font; // float f = 1.6F; @@ -244,20 +242,20 @@ public final class AssetUtil { } } - @OnlyIn(Dist.CLIENT) + public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, int color, int maxAge, double rotationTime, float size, float alpha) { Minecraft mc = Minecraft.getInstance(); if (mc.player != null && mc.player.distanceToSqr(startX, startY, startZ) <= 64 || mc.player.distanceToSqr(endX, endY, endZ) <= 64) { mc.level.addParticle(ParticleBeam.Factory.createData(endX, endY, endZ, color, alpha, maxAge, rotationTime, size), startX, startY, startZ, 0, 0, 0); } } -/* @OnlyIn(Dist.CLIENT) +/* public static void renderLaser(MatrixStack matrixStack, IRenderTypeBuffer buffer, float x, float y, float z, float tx, float ty, float tz, float rotation, int color, float beamWidth) { }*/ - @OnlyIn(Dist.CLIENT) + public static void renderLaser(PoseStack matrixStack, MultiBufferSource buffer, float offX, float offY, float offZ, float yaw, float pitch, float length, float rotationTime, int color, float alpha, float beamWidth) { Level world = Minecraft.getInstance().level; /* int r = (color >> 16) & 0xFF; @@ -331,7 +329,7 @@ public final class AssetUtil { //Thanks to feldim2425 for this. //I can't do rendering code. Ever. - @OnlyIn(Dist.CLIENT) + public static void renderLaserParticle(VertexConsumer builder, Camera camera, double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, float rotationTime, float a, float beamWidth, float[] color) { Level world = Minecraft.getInstance().level; @@ -400,7 +398,7 @@ public final class AssetUtil { Tesselator.getInstance().end(); } - @OnlyIn(Dist.CLIENT) + public static void renderTextInWorld(GuiGraphics guiGraphics, double offsetX, double offsetY, double offsetZ, NonNullList text, int color) { PoseStack matrices = guiGraphics.pose(); matrices.pushPose(); @@ -430,7 +428,7 @@ public final class AssetUtil { return new float[]{0.0f, (pos -= 170.0f) * 3.0f, 255.0f - pos * 3.0f}; } - @OnlyIn(Dist.CLIENT) + public static void renderHitOutline(PoseStack poseStack, VertexConsumer consumer, Entity entity, double camX, double camY, double camZ, Level level, BlockPos pos, BlockState state) { renderShape(poseStack, consumer, state.getShape(level, pos, CollisionContext.of(entity)), @@ -444,7 +442,7 @@ public final class AssetUtil { ); } - @OnlyIn(Dist.CLIENT) + private static void renderShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha) { PoseStack.Pose posestack$pose = poseStack.last(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/EnchantmentUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/EnchantmentUtil.java new file mode 100644 index 000000000..389e844ef --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/EnchantmentUtil.java @@ -0,0 +1,23 @@ +package de.ellpeck.actuallyadditions.mod.util; + +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.Level; + +public class EnchantmentUtil { + public static Holder getEnchantmentHolder(RegistryAccess registryAccess, ResourceKey resourceKey) { + return registryAccess.registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(resourceKey); + } + + public static Holder getEnchantmentHolder(Entity entity, ResourceKey resourceKey) { + return getEnchantmentHolder(entity.registryAccess(), resourceKey); + } + + public static Holder getEnchantmentHolder(Level level, ResourceKey resourceKey) { + return getEnchantmentHolder(level.registryAccess(), resourceKey); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java index 05a517d92..0d2f8f71d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java @@ -10,7 +10,11 @@ package de.ellpeck.actuallyadditions.mod.util; +import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; @@ -18,13 +22,12 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; - -import java.util.Map; +import net.minecraft.world.item.enchantment.ItemEnchantments; public final class ItemUtil { public static Item getItemFromName(String name) { - return BuiltInRegistries.ITEM.get(new ResourceLocation(name)); + return BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(name)); } // public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) { @@ -60,26 +63,28 @@ public final class ItemUtil { // } @Deprecated - public static void addEnchantment(ItemStack stack, Enchantment e, int level) { - if (!EnchantmentHelper.getEnchantments(stack).containsKey(e)) { + public static void addEnchantment(ItemStack stack, Holder e, int level, RegistryAccess lookup) { + if (!(stack.getAllEnchantments(lookup.lookupOrThrow(Registries.ENCHANTMENT)).getLevel(e) > 0)) { stack.enchant(e, level); } } // TODO: [port] ensure this still works :D - public static void removeEnchantment(ItemStack stack, Enchantment e) { - Map enchantments = EnchantmentHelper.getEnchantments(stack); - enchantments.remove(e); + public static void removeEnchantment(ItemStack stack, Holder e, RegistryAccess registryAccess) { + ItemEnchantments enchantments = stack.getAllEnchantments(registryAccess.lookupOrThrow(Registries.ENCHANTMENT)); + ItemEnchantments.Mutable itemenchantments$mutable = new ItemEnchantments.Mutable(enchantments); - EnchantmentHelper.setEnchantments(enchantments, stack); + itemenchantments$mutable.removeIf((enchantment) -> enchantment == e); + + EnchantmentHelper.setEnchantments(stack, itemenchantments$mutable.toImmutable()); } public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) { - return ItemStack.isSameItemSameTags(stack1, stack2); + return ItemStack.isSameItemSameComponents(stack1, stack2); } public static boolean isEnabled(ItemStack stack) { - return stack.getOrCreateTag().getBoolean("IsEnabled"); + return stack.getOrDefault(ActuallyComponents.ENABLED, false); } public static void changeEnabled(Player player, InteractionHand hand) { @@ -88,6 +93,6 @@ public final class ItemUtil { public static void changeEnabled(ItemStack stack) { boolean isEnabled = isEnabled(stack); - stack.getOrCreateTag().putBoolean("IsEnabled", !isEnabled); + stack.set(ActuallyComponents.ENABLED, !isEnabled); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java index 433721f35..119597a17 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java @@ -14,8 +14,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.resources.language.I18n; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; @Deprecated public final class StringUtil { @@ -23,14 +21,14 @@ public final class StringUtil { /** * Localizes a given formatted String with the given Replacements */ - @OnlyIn(Dist.CLIENT) + public static String localizeFormatted(String text, Object... replace) { return I18n.get(text, replace); } // TODO: Move to official @Deprecated - @OnlyIn(Dist.CLIENT) + public static void drawSplitString(Font renderer, String strg, int x, int y, int width, int color, boolean shadow) { // ResourcePackList <- holds the correct way // List list = renderer.listFormattedStringToWidth(strg, width); @@ -40,7 +38,7 @@ public final class StringUtil { // } } -// @OnlyIn(Dist.CLIENT) +// // public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) { // List lines = font.listFormattedStringToWidth(text, (int) (length / scale)); // for (int i = 0; i < lines.size(); i++) { @@ -48,7 +46,7 @@ public final class StringUtil { // } // } - @OnlyIn(Dist.CLIENT) + public static void renderScaledString(GuiGraphics guiGraphics, Font font, String text, float x, float y, int color, boolean shadow, float scale) { PoseStack matrices = guiGraphics.pose(); matrices.pushPose(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java index 566a6d1af..a238196f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java @@ -19,7 +19,7 @@ // }; // } // -// @OnlyIn(Dist.CLIENT) +// // public static Gui getFastBenchGui(PlayerEntity p, World world) { // return new GuiFastBench(p.inventory, world, BlockPos.ORIGIN); // } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java index fb9e14a7b..8f7cf977a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java @@ -24,7 +24,7 @@ // // static boolean fb = Loader.isModLoaded("fastbench"); // -// @OnlyIn(Dist.CLIENT) +// // public static Object getCrafterGuiElement(PlayerEntity player, World world, int x, int y, int z) { // if (fb) { // return CompatFastBench.getFastBenchGui(player, world); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java index 8ef6fe584..37d4a1b90 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java @@ -41,7 +41,7 @@ // Item i = rec.getRecipeOutput().getItem(); // if (i instanceof IDisableableItem && ((IDisableableItem) i).isDisabled()) rec = new BlankRecipe(); // if (rec.getRegistryName() == null) { -// RECIPE_LIST.add(rec.setRegistryName(new ResourceLocation(MODID, name))); +// RECIPE_LIST.add(rec.setRegistryName(ResourceLocation.tryParse(MODID, name))); // } else { // RECIPE_LIST.add(rec); // } @@ -53,7 +53,7 @@ // */ // public static void addOldShaped(ItemStack stack, Object... input) { // ShapedPrimer primer = CraftingHelper.parseShaped(input); -// addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), primer.width, primer.height, primer.input, stack)); +// addRecipe(j++, new ShapedRecipes(ResourceLocation.tryParse(MODID, "recipes" + j).toString(), primer.width, primer.height, primer.input, stack)); // } // // /* @@ -61,7 +61,7 @@ // */ // public static void addOldShaped(String group, ItemStack stack, Object... input) { // ShapedPrimer primer = CraftingHelper.parseShaped(input); -// addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, primer.input, stack)); +// addRecipe(j++, new ShapedRecipes(ResourceLocation.tryParse(MODID, group).toString(), primer.width, primer.height, primer.input, stack)); // } // // /* @@ -69,25 +69,25 @@ // */ // public static void addOldShaped(String name, String group, ItemStack stack, Object... input) { // ShapedPrimer primer = CraftingHelper.parseShaped(input); -// addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, primer.input, stack).setRegistryName(MODID, name)); +// addRecipe(j++, new ShapedRecipes(ResourceLocation.tryParse(MODID, group).toString(), primer.width, primer.height, primer.input, stack).setRegistryName(MODID, name)); // } // // /* // * This adds a shapeless recipe to the list of crafting recipes, using the forge format. // */ // public static void addOldShapeless(ItemStack stack, Object... input) { -// addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), stack, createInput(input))); +// addRecipe(j++, new ShapelessRecipes(ResourceLocation.tryParse(MODID, "recipes" + j).toString(), stack, createInput(input))); // } // // /* // * This adds a shapeless recipe to the list of crafting recipes, using the forge format, with a custom group. // */ // public static void addOldShapeless(String group, ItemStack stack, Object... input) { -// addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), stack, createInput(input))); +// addRecipe(j++, new ShapelessRecipes(ResourceLocation.tryParse(MODID, group).toString(), stack, createInput(input))); // } // // public static void addOldShapeless(String name, String group, ItemStack stack, Object... input) { -// addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), stack, createInput(input)).setRegistryName(MODID, name)); +// addRecipe(j++, new ShapelessRecipes(ResourceLocation.tryParse(MODID, group).toString(), stack, createInput(input)).setRegistryName(MODID, name)); // } // // /* diff --git a/src/main/resources/actuallyadditions.mixins.json b/src/main/resources/actuallyadditions.mixins.json index 8e513d17f..dd4c1eae8 100644 --- a/src/main/resources/actuallyadditions.mixins.json +++ b/src/main/resources/actuallyadditions.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8.5", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "package": "de.ellpeck.actuallyadditions.mixin", "target": "@env(DEFAULT)", "mixins": [ diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementalcraft/inert_crystal_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementalcraft/inert_crystal_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementalcraft/inert_crystal_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementalcraft/inert_crystal_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/agate_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/agate_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/agate_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/agate_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/citrine_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/citrine_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/citrine_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/citrine_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/onyx_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/onyx_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/onyx_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/onyx_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/rubellite_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/rubellite_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/rubellite_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/rubellite_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/ruby_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/ruby_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/ruby_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/ruby_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/sapphire_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/sapphire_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/elementsofpower/sapphire_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/elementsofpower/sapphire_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/immersiveengineering/silver_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/immersiveengineering/silver_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/immersiveengineering/silver_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/immersiveengineering/silver_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/fluorite_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/fluorite_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/fluorite_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/fluorite_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/lead_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/lead_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/lead_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/lead_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/osmium_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/osmium_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/osmium_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/osmium_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/tin_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/tin_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/tin_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/tin_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/uranium_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/uranium_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/mekanism/uranium_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/mekanism/uranium_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/antimony_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/antimony_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/antimony_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/antimony_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/lignite_coal_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/lignite_coal_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/lignite_coal_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/lignite_coal_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/monazite_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/monazite_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/monazite_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/monazite_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/nickel_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/nickel_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/nickel_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/nickel_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/salt_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/salt_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/modern_industrialization/salt_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/modern_industrialization/salt_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/powah/uraninite_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/powah/uraninite_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/powah/uraninite_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/powah/uraninite_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/aluminum_ore.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/aluminum_ore.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/aluminum_ore.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/aluminum_ore.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_blue.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_blue.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_blue.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_blue.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_dark.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_dark.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_dark.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_dark.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_green.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_green.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_green.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_green.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_light.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_light.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_light.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_light.json diff --git a/src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_red.json b/src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_red.json similarity index 100% rename from src/main/resources/data/actuallyadditions/recipes/mininglens/xycraft/xychorium_ore_red.json rename to src/main/resources/data/actuallyadditions/recipe/mininglens/xycraft/xychorium_ore_red.json diff --git a/src/main/resources/data/actuallyadditions/structures/andrew_period_house.nbt b/src/main/resources/data/actuallyadditions/structure/andrew_period_house.nbt similarity index 100% rename from src/main/resources/data/actuallyadditions/structures/andrew_period_house.nbt rename to src/main/resources/data/actuallyadditions/structure/andrew_period_house.nbt diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 374ca6d66..7e75c4ee2 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -3,6 +3,6 @@ "description": { "text": "actuallyadditions resources" }, - "pack_format": 26 + "pack_format": 34 } }