diff --git a/build.gradle b/build.gradle index c0b2fc438..76a3c4373 100644 --- a/build.gradle +++ b/build.gradle @@ -121,9 +121,10 @@ dependencies { minecraft "net.minecraftforge:forge:${forge_version}" //Jei - compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}") - compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}") - runtimeOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}") + //TODO: renable once updated +// compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}") +// compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}") +// runtimeOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}") compileOnly fg.deobf("com.klikli_dev:modonomicon:${modonomicon_mc_version}-${modonomicon_version}") //we build against full jar because we NEED IT ALL runtimeOnly fg.deobf("com.klikli_dev:modonomicon:${modonomicon_mc_version}-${modonomicon_version}") diff --git a/gradle.properties b/gradle.properties index c9509b98b..ddd104ff7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,15 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false mod_version=0.0.1 -mc_version=1.19.2 - -forge_version=1.19.2-43.1.57 +mc_version=1.19.3 +forge_version=1.19.3-44.0.7 mapping_channel=parchment #postfix is target mc version, optional prefix is source parchment mc version -mapping_version=2022.08.10-1.19.2 +mapping_version=1.19.2-2022.11.27-1.19.3 jei_mc_version=1.19.2 jei_version=11.4.0.286 -modonomicon_mc_version=1.19.2 -modonomicon_version=1.15.0 \ No newline at end of file +modonomicon_mc_version=1.19.3 +modonomicon_version=1.18.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c684f..574724f44 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,9 @@ +# SPDX-FileCopyrightText: 2022 klikli-dev +# +# SPDX-License-Identifier: MIT + distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/main/java/com/klikli_dev/theurgy/Theurgy.java b/src/main/java/com/klikli_dev/theurgy/Theurgy.java index 6d3da0dbb..6b213dd53 100644 --- a/src/main/java/com/klikli_dev/theurgy/Theurgy.java +++ b/src/main/java/com/klikli_dev/theurgy/Theurgy.java @@ -11,13 +11,11 @@ import com.klikli_dev.theurgy.config.CommonConfig; import com.klikli_dev.theurgy.config.ServerConfig; import com.klikli_dev.theurgy.datagen.DataGenerators; -import com.klikli_dev.theurgy.item.TheurgyCreativeModeTab; import com.klikli_dev.theurgy.network.Networking; import com.klikli_dev.theurgy.registry.*; import com.klikli_dev.theurgy.tooltips.TooltipHandler; import com.mojang.logging.LogUtils; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; @@ -35,8 +33,6 @@ public class Theurgy { public static final String MODID = "theurgy"; public static final Logger LOGGER = LogUtils.getLogger(); - public static final CreativeModeTab CREATIVE_MODE_TAB = new TheurgyCreativeModeTab(); - public static Theurgy INSTANCE; public Theurgy() { @@ -59,6 +55,7 @@ public Theurgy() { modEventBus.addListener(this::onServerSetup); modEventBus.addListener(DataGenerators::gatherData); + modEventBus.addListener(ItemRegistry::onRegisterCreativeModeTabs); MinecraftForge.EVENT_BUS.addListener(TooltipHandler::onItemTooltipEvent); diff --git a/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java b/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java index cb5408ca6..21efcbfee 100644 --- a/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java +++ b/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java @@ -56,6 +56,8 @@ public static class ItemProperty { public static class I18n { + public static final String ITEM_GROUP = "itemGroup." + Theurgy.MODID; + public static class Tooltip { private static final String PREFIX = "tooltip." + Theurgy.MODID + "."; diff --git a/src/main/java/com/klikli_dev/theurgy/client/ClientSetupEventHandler.java b/src/main/java/com/klikli_dev/theurgy/client/ClientSetupEventHandler.java index 46c54eb1f..80aae7a88 100644 --- a/src/main/java/com/klikli_dev/theurgy/client/ClientSetupEventHandler.java +++ b/src/main/java/com/klikli_dev/theurgy/client/ClientSetupEventHandler.java @@ -42,9 +42,9 @@ public static void registerItemProperties(FMLClientSetupEvent event) { //Not safe to call during parallel load, so register to run threadsafe event.enqueueWork(() -> { ItemProperties.register(ItemRegistry.DIVINATION_ROD_T1.get(), - TheurgyConstants.ItemProperty.DIVINATION_DISTANCE, DivinationRodItem.PropertyFunctions.DIVINATION_DISTANCE); + TheurgyConstants.ItemProperty.DIVINATION_DISTANCE, DivinationRodItem.DistHelper.DIVINATION_DISTANCE); ItemProperties.register(ItemRegistry.DIVINATION_ROD_T4.get(), - TheurgyConstants.ItemProperty.DIVINATION_DISTANCE, DivinationRodItem.PropertyFunctions.DIVINATION_DISTANCE); + TheurgyConstants.ItemProperty.DIVINATION_DISTANCE, DivinationRodItem.DistHelper.DIVINATION_DISTANCE); Theurgy.LOGGER.debug("Registered Item Properties"); }); diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/DataGenerators.java b/src/main/java/com/klikli_dev/theurgy/datagen/DataGenerators.java index bbe1c48eb..41f08bbdd 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/DataGenerators.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/DataGenerators.java @@ -17,6 +17,6 @@ public static void gatherData(GatherDataEvent event) { generator.addProvider(event.includeClient(), new ENUSProvider(generator)); generator.addProvider(event.includeClient(), new ItemModelsProvider(generator, event.getExistingFileHelper())); - generator.addProvider(event.includeClient(), new RecipeProvider(generator)); + generator.addProvider(event.includeClient(), new RecipeProvider(generator.getPackOutput())); } } \ No newline at end of file diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/ItemModelsProvider.java b/src/main/java/com/klikli_dev/theurgy/datagen/ItemModelsProvider.java index e661c3fd1..5c704ae2f 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/ItemModelsProvider.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/ItemModelsProvider.java @@ -16,6 +16,7 @@ import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.ForgeRegistries; public class ItemModelsProvider extends ItemModelProvider { public ItemModelsProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { @@ -23,7 +24,7 @@ public ItemModelsProvider(DataGenerator generator, ExistingFileHelper existingFi } protected String name(Item item) { - return Registry.ITEM.getKey(item).getPath(); + return ForgeRegistries.ITEMS.getKey(item).getPath(); } private void registerItemGenerated(String name) { diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/RecipeProvider.java b/src/main/java/com/klikli_dev/theurgy/datagen/RecipeProvider.java index ed265cdc8..3a6d4a245 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/RecipeProvider.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/RecipeProvider.java @@ -7,19 +7,20 @@ package com.klikli_dev.theurgy.datagen; import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; import java.util.function.Consumer; public class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider { - public RecipeProvider(DataGenerator pGenerator) { - super(pGenerator); + public RecipeProvider(PackOutput packOutput) { + super(packOutput); } @Override - protected void buildCraftingRecipes(Consumer pFinishedRecipeConsumer) { + protected void buildRecipes(Consumer pFinishedRecipeConsumer) { //we need nbt output, so we use a manual json recipe -// ShapedRecipeBuilder.shaped(ItemRegistry.DIVINATION_ROD_T1.get()) + // ShapedRecipeBuilder.shaped(ItemRegistry.DIVINATION_ROD_T1.get()) // .define('R', Tags.Items.RODS_WOODEN) // .define('G', Tags.Items.GLASS) // .pattern("RGR") diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java b/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java index 3c6afd341..6397e053f 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java @@ -44,7 +44,7 @@ private void addMessages() { } private void addItems() { - this.add(((TranslatableContents)Theurgy.CREATIVE_MODE_TAB.getDisplayName().getContents()).getKey(), "Theurgy"); + this.add(TheurgyConstants.I18n.ITEM_GROUP, "Theurgy"); this.addItem(ItemRegistry.EMPTY_JAR, "Empty Jar"); diff --git a/src/main/java/com/klikli_dev/theurgy/entity/FollowProjectile.java b/src/main/java/com/klikli_dev/theurgy/entity/FollowProjectile.java index c77f24774..1615e2cea 100644 --- a/src/main/java/com/klikli_dev/theurgy/entity/FollowProjectile.java +++ b/src/main/java/com/klikli_dev/theurgy/entity/FollowProjectile.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -185,8 +186,8 @@ public void addAdditionalSaveData(CompoundTag compound) { } @Override - public Packet getAddEntityPacket() { - return NetworkHooks.getEntitySpawningPacket(this); + public Packet getAddEntityPacket() { + throw new UnsupportedOperationException(); } @Override diff --git a/src/main/java/com/klikli_dev/theurgy/integration/jei/DivinationRodSubtypeInterpreter.java b/src/main/java/com/klikli_dev/theurgy/integration/jei/DivinationRodSubtypeInterpreter.java index 2b39c0032..68ba3a074 100644 --- a/src/main/java/com/klikli_dev/theurgy/integration/jei/DivinationRodSubtypeInterpreter.java +++ b/src/main/java/com/klikli_dev/theurgy/integration/jei/DivinationRodSubtypeInterpreter.java @@ -7,35 +7,36 @@ package com.klikli_dev.theurgy.integration.jei; import com.klikli_dev.theurgy.TheurgyConstants; -import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; -import mezz.jei.api.ingredients.subtypes.UidContext; +//import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; +//import mezz.jei.api.ingredients.subtypes.UidContext; import net.minecraft.world.item.ItemStack; -public class DivinationRodSubtypeInterpreter implements IIngredientSubtypeInterpreter { - - private static final DivinationRodSubtypeInterpreter instance = new DivinationRodSubtypeInterpreter(); - - - public static DivinationRodSubtypeInterpreter get() { - return instance; - } - - @Override - public String apply(ItemStack ingredient, UidContext context) { - var tag = ingredient.getTag(); - - if(tag != null){ - var settingTier = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_TIER); - var settingAllowedBlocksTag = tag.getString(TheurgyConstants.Nbt.Divination.SETTING_ALLOWED_BLOCKS_TAG); - var settingDisallowedBlocksTag = tag.getString(TheurgyConstants.Nbt.Divination.SETTING_DISALLOWED_BLOCKS_TAG); - var settingRange = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_RANGE); - var settingDuration = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_DURATION); - var settingDurability = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_DURABILITY); - var settingAllowAttuning = tag.getBoolean(TheurgyConstants.Nbt.Divination.SETTING_ALLOW_ATTUNING); - - return String.format("%s_%s_%s_%s_%s_%s_%s", settingTier, settingAllowedBlocksTag, settingDisallowedBlocksTag, settingRange, settingDuration, settingDurability, settingAllowAttuning); - } - - return IIngredientSubtypeInterpreter.NONE; - } -} +//TODO: reenable once jei updates +//public class DivinationRodSubtypeInterpreter implements IIngredientSubtypeInterpreter { +// +// private static final DivinationRodSubtypeInterpreter instance = new DivinationRodSubtypeInterpreter(); +// +// +// public static DivinationRodSubtypeInterpreter get() { +// return instance; +// } +// +// @Override +// public String apply(ItemStack ingredient, UidContext context) { +// var tag = ingredient.getTag(); +// +// if(tag != null){ +// var settingTier = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_TIER); +// var settingAllowedBlocksTag = tag.getString(TheurgyConstants.Nbt.Divination.SETTING_ALLOWED_BLOCKS_TAG); +// var settingDisallowedBlocksTag = tag.getString(TheurgyConstants.Nbt.Divination.SETTING_DISALLOWED_BLOCKS_TAG); +// var settingRange = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_RANGE); +// var settingDuration = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_DURATION); +// var settingDurability = tag.getInt(TheurgyConstants.Nbt.Divination.SETTING_DURABILITY); +// var settingAllowAttuning = tag.getBoolean(TheurgyConstants.Nbt.Divination.SETTING_ALLOW_ATTUNING); +// +// return String.format("%s_%s_%s_%s_%s_%s_%s", settingTier, settingAllowedBlocksTag, settingDisallowedBlocksTag, settingRange, settingDuration, settingDurability, settingAllowAttuning); +// } +// +// return IIngredientSubtypeInterpreter.NONE; +// } +//} diff --git a/src/main/java/com/klikli_dev/theurgy/integration/jei/JeiPlugin.java b/src/main/java/com/klikli_dev/theurgy/integration/jei/JeiPlugin.java index 0a27372c9..4b663065e 100644 --- a/src/main/java/com/klikli_dev/theurgy/integration/jei/JeiPlugin.java +++ b/src/main/java/com/klikli_dev/theurgy/integration/jei/JeiPlugin.java @@ -8,20 +8,21 @@ import com.klikli_dev.theurgy.Theurgy; import com.klikli_dev.theurgy.registry.ItemRegistry; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.registration.ISubtypeRegistration; +//import mezz.jei.api.IModPlugin; +//import mezz.jei.api.registration.ISubtypeRegistration; import net.minecraft.resources.ResourceLocation; -@mezz.jei.api.JeiPlugin -public class JeiPlugin implements IModPlugin { - @Override - public ResourceLocation getPluginUid() { - return Theurgy.loc("jei_plugin"); - } - - @Override - public void registerItemSubtypes(ISubtypeRegistration registration) { - registration.registerSubtypeInterpreter(ItemRegistry.DIVINATION_ROD_T1.get(), DivinationRodSubtypeInterpreter.get()); - registration.registerSubtypeInterpreter(ItemRegistry.DIVINATION_ROD_T4.get(), DivinationRodSubtypeInterpreter.get()); - } -} +//TODO: reenable once jei updates +//@mezz.jei.api.JeiPlugin +//public class JeiPlugin implements IModPlugin { +// @Override +// public ResourceLocation getPluginUid() { +// return Theurgy.loc("jei_plugin"); +// } +// +// @Override +// public void registerItemSubtypes(ISubtypeRegistration registration) { +// registration.registerSubtypeInterpreter(ItemRegistry.DIVINATION_ROD_T1.get(), DivinationRodSubtypeInterpreter.get()); +// registration.registerSubtypeInterpreter(ItemRegistry.DIVINATION_ROD_T4.get(), DivinationRodSubtypeInterpreter.get()); +// } +//} diff --git a/src/main/java/com/klikli_dev/theurgy/item/AlchemicalSulfurItem.java b/src/main/java/com/klikli_dev/theurgy/item/AlchemicalSulfurItem.java index 61c5fe7c3..676a86527 100644 --- a/src/main/java/com/klikli_dev/theurgy/item/AlchemicalSulfurItem.java +++ b/src/main/java/com/klikli_dev/theurgy/item/AlchemicalSulfurItem.java @@ -12,7 +12,6 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; -import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.chat.MutableComponent; @@ -21,9 +20,7 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.extensions.common.IClientItemExtensions; -import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.registries.ForgeRegistries; import java.util.List; @@ -83,24 +80,18 @@ public Component getName(ItemStack pStack) { return super.getName(pStack); } - @Override - public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - if (FMLEnvironment.dist == Dist.CLIENT) { - DistHelper.fillItemCategory(this, tab, items); - } - } - /** * Inner class to avoid classloading issues on the server */ public static class DistHelper { - public static void fillItemCategory(AlchemicalSulfurItem item, CreativeModeTab tab, NonNullList items) { + + public static void registerCreativeModeTabs(AlchemicalSulfurItem item, CreativeModeTab.Output output) { var level = Minecraft.getInstance().level; if (level != null) { var recipeManager = level.getRecipeManager(); recipeManager.getRecipes().forEach((recipe) -> { if (recipe.getResultItem().getItem() == item) { - items.add(recipe.getResultItem().copy()); + output.accept(recipe.getResultItem().copy()); } }); } diff --git a/src/main/java/com/klikli_dev/theurgy/item/DivinationRodItem.java b/src/main/java/com/klikli_dev/theurgy/item/DivinationRodItem.java index fbc97184f..dec17ef2e 100644 --- a/src/main/java/com/klikli_dev/theurgy/item/DivinationRodItem.java +++ b/src/main/java/com/klikli_dev/theurgy/item/DivinationRodItem.java @@ -18,7 +18,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.item.ItemPropertyFunction; import net.minecraft.core.BlockPos; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.*; import net.minecraft.resources.ResourceLocation; @@ -27,6 +26,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; @@ -35,10 +35,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.TierSortingRegistry; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; @@ -218,7 +216,7 @@ public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity enti if (result != null) { stack.getTag().putLong(TheurgyConstants.Nbt.Divination.POS, result.asLong()); - this.spawnResultParticle(result, (ClientLevel) level, player); + this.spawnResultParticle(result, level, player); } } else { stack.hurtAndBreak(1, player, (entity) -> { @@ -253,7 +251,7 @@ public void releaseUsing(ItemStack stack, Level level, LivingEntity pLivingEntit //re-use old result if (stack.getTag().contains(TheurgyConstants.Nbt.Divination.POS)) { BlockPos result = BlockPos.of(stack.getTag().getLong(TheurgyConstants.Nbt.Divination.POS)); - this.spawnResultParticle(result, (ClientLevel) level, pLivingEntity); + this.spawnResultParticle(result, level, pLivingEntity); } } super.releaseUsing(stack, level, pLivingEntity, pTimeCharged); @@ -380,7 +378,7 @@ protected MutableComponent getBlockDisplayComponent(Block block) { .withStyle((style) -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(new ItemStack(block))))); } - protected void spawnResultParticle(BlockPos result, ClientLevel level, LivingEntity entity) { + protected void spawnResultParticle(BlockPos result, Level level, LivingEntity entity) { final var visualizationRange = 10.0f; var from = new Vec3(entity.getX(), entity.getEyeY() - (double) 0.1F, entity.getZ()); var resultVec = Vec3.atCenterOf(result); @@ -388,9 +386,9 @@ protected void spawnResultParticle(BlockPos result, ClientLevel level, LivingEnt var dir = dist.normalize(); var to = dist.length() <= visualizationRange ? resultVec : from.add(dir.scale(visualizationRange)); - if (level.isLoaded(new BlockPos(to)) && level.isLoaded(new BlockPos(from))) { + if (level.isLoaded(new BlockPos(to)) && level.isLoaded(new BlockPos(from)) && level.isClientSide) { FollowProjectile aoeProjectile = new FollowProjectile(level, from, to); - level.putNonPlayerEntity(aoeProjectile.getId(), aoeProjectile); //client only spawn of entity + DistHelper.spawnEntityClientSide(level, aoeProjectile); } } @@ -409,20 +407,12 @@ public TagKey getDisallowedBlocksTag(ItemStack stack) { return TagRegistry.makeBlockTag(new ResourceLocation(disallowedBlocksTag)); } + /** * Inner class to avoid classloading issues on the server */ - @Override - public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - if (FMLEnvironment.dist == Dist.CLIENT) { - DistHelper.fillItemCategory(this, tab, items); - } - } + public static class DistHelper { - /** - * Inner class to avoid classloading of client only property functions on server - */ - public static class PropertyFunctions { @SuppressWarnings("deprecation") public static ItemPropertyFunction DIVINATION_DISTANCE = (stack, world, entity, i) -> { if (!stack.getOrCreateTag().contains(TheurgyConstants.Nbt.Divination.DISTANCE) || @@ -430,16 +420,20 @@ public static class PropertyFunctions { return NOT_FOUND; return stack.getTag().getFloat(TheurgyConstants.Nbt.Divination.DISTANCE); }; - } - public static class DistHelper { - public static void fillItemCategory(DivinationRodItem item, CreativeModeTab tab, NonNullList items) { + public static void spawnEntityClientSide(Level level, Entity entity) { + if (level instanceof ClientLevel clientLevel) { + clientLevel.putNonPlayerEntity(entity.getId(), entity); //client only spawn of entity + } + } + + public static void registerCreativeModeTabs(DivinationRodItem item, CreativeModeTab.Output output) { var level = Minecraft.getInstance().level; if (level != null) { var recipeManager = level.getRecipeManager(); recipeManager.getRecipes().forEach((recipe) -> { if (recipe.getResultItem().getItem() == item) { - items.add(recipe.getResultItem().copy()); + output.accept(recipe.getResultItem().copy()); } }); } diff --git a/src/main/java/com/klikli_dev/theurgy/item/TheurgyCreativeModeTab.java b/src/main/java/com/klikli_dev/theurgy/item/TheurgyCreativeModeTab.java deleted file mode 100644 index 7c44afa27..000000000 --- a/src/main/java/com/klikli_dev/theurgy/item/TheurgyCreativeModeTab.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 klikli-dev - * - * SPDX-License-Identifier: MIT - */ - -package com.klikli_dev.theurgy.item; - -import com.klikli_dev.theurgy.Theurgy; -import com.klikli_dev.theurgy.registry.ItemRegistry; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; - -public class TheurgyCreativeModeTab extends CreativeModeTab { - public TheurgyCreativeModeTab() { - super(Theurgy.MODID); - } - - @Override - public ItemStack makeIcon() { - return new ItemStack(ItemRegistry.EMPTY_JAR.get()); - } - //TODO: return theurgy book icon -} diff --git a/src/main/java/com/klikli_dev/theurgy/recipe/DivinationRodRecipe.java b/src/main/java/com/klikli_dev/theurgy/recipe/DivinationRodRecipe.java index 3ede6ed77..131ea8c95 100644 --- a/src/main/java/com/klikli_dev/theurgy/recipe/DivinationRodRecipe.java +++ b/src/main/java/com/klikli_dev/theurgy/recipe/DivinationRodRecipe.java @@ -16,6 +16,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapedRecipe; @@ -25,7 +26,7 @@ public class DivinationRodRecipe extends ShapedRecipe { public DivinationRodRecipe(ResourceLocation pId, String pGroup, int pWidth, int pHeight, NonNullList pRecipeItems, ItemStack pResult) { - super(pId, pGroup, pWidth, pHeight, pRecipeItems, pResult); + super(pId, pGroup, CraftingBookCategory.MISC, pWidth, pHeight, pRecipeItems, pResult); } public RecipeSerializer getSerializer() { diff --git a/src/main/java/com/klikli_dev/theurgy/registry/ItemRegistry.java b/src/main/java/com/klikli_dev/theurgy/registry/ItemRegistry.java index 165b83322..d37e2ad4e 100644 --- a/src/main/java/com/klikli_dev/theurgy/registry/ItemRegistry.java +++ b/src/main/java/com/klikli_dev/theurgy/registry/ItemRegistry.java @@ -7,12 +7,15 @@ package com.klikli_dev.theurgy.registry; import com.klikli_dev.theurgy.Theurgy; -import com.klikli_dev.theurgy.config.ServerConfig; +import com.klikli_dev.theurgy.TheurgyConstants; import com.klikli_dev.theurgy.item.AlchemicalSulfurItem; import com.klikli_dev.theurgy.item.DivinationRodItem; -import net.minecraft.tags.TagKey; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tiers; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; @@ -20,7 +23,7 @@ public class ItemRegistry { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Theurgy.MODID); public static final RegistryObject EMPTY_JAR = - ITEMS.register("empty_jar", () -> new Item(defaultProperties())); + ITEMS.register("empty_jar", () -> new Item(new Item.Properties())); //helper item for sulfur rendering public static final RegistryObject EMPTY_JAR_LABELED = @@ -29,25 +32,38 @@ public class ItemRegistry { //helper item for sulfur rendering public static final RegistryObject JAR_LABEL = ITEMS.register("jar_label", () -> new Item(new Item.Properties())); - public static final RegistryObject ALCHEMICAL_SULFUR = - ITEMS.register("alchemical_sulfur", () -> new AlchemicalSulfurItem(defaultProperties())); + public static final RegistryObject ALCHEMICAL_SULFUR = + ITEMS.register("alchemical_sulfur", () -> new AlchemicalSulfurItem(new Item.Properties())); // public static final RegistryObject SULFUR_INGOT = -// ITEMS.register("sulfur_ingot", () -> new Item(defaultProperties())); +// ITEMS.register("sulfur_ingot", () -> new Item(new Item.Properties())); - public static final RegistryObject DIVINATION_ROD_T1 = + public static final RegistryObject DIVINATION_ROD_T1 = ITEMS.register("divination_rod_t1", () -> new DivinationRodItem( - defaultProperties().stacksTo(1).defaultDurability(1), + new Item.Properties().stacksTo(1).defaultDurability(1), Tiers.STONE, TagRegistry.DIVINATION_ROD_T1_ALLOWED_BLOCKS, TagRegistry.DIVINATION_ROD_T1_DISALLOWED_BLOCKS, 96, 40, 10, true)); - public static final RegistryObject DIVINATION_ROD_T4 = + public static final RegistryObject DIVINATION_ROD_T4 = ITEMS.register("divination_rod_t4", () -> new DivinationRodItem( - defaultProperties().stacksTo(1).defaultDurability(1), - Tiers.STONE, TagRegistry.DIVINATION_ROD_T4_ALLOWED_BLOCKS, TagRegistry.DIVINATION_ROD_T4_DISALLOWED_BLOCKS, + new Item.Properties().stacksTo(1).defaultDurability(1), + Tiers.STONE, TagRegistry.DIVINATION_ROD_T4_ALLOWED_BLOCKS, TagRegistry.DIVINATION_ROD_T4_DISALLOWED_BLOCKS, 96, 40, 10, false)); - public static Item.Properties defaultProperties() { - return new Item.Properties().tab(Theurgy.CREATIVE_MODE_TAB); + public static void onRegisterCreativeModeTabs(CreativeModeTabEvent.Register event) { + event.registerCreativeModeTab(new ResourceLocation("occultism:occultism"), + (builder) -> { + builder.icon(() -> new ItemStack(EMPTY_JAR.get())) + .title(Component.translatable(TheurgyConstants.I18n.ITEM_GROUP)).build(); + builder.displayItems((featureFlagSet, output, hasPermission) -> { + output.accept(EMPTY_JAR.get()); + + AlchemicalSulfurItem.DistHelper.registerCreativeModeTabs(ALCHEMICAL_SULFUR.get(), output); + DivinationRodItem.DistHelper.registerCreativeModeTabs(DIVINATION_ROD_T1.get(), output); + DivinationRodItem.DistHelper.registerCreativeModeTabs(DIVINATION_ROD_T4.get(), output); + }); + + } + ); } } diff --git a/src/main/java/com/klikli_dev/theurgy/registry/SoundRegistry.java b/src/main/java/com/klikli_dev/theurgy/registry/SoundRegistry.java index add7af01e..807775100 100644 --- a/src/main/java/com/klikli_dev/theurgy/registry/SoundRegistry.java +++ b/src/main/java/com/klikli_dev/theurgy/registry/SoundRegistry.java @@ -29,6 +29,6 @@ public class SoundRegistry { */ private static SoundEvent loadSoundEvent(String name) { ResourceLocation location = new ResourceLocation(Theurgy.MODID, name); - return new SoundEvent(location); + return SoundEvent.createVariableRangeEvent(location); } } diff --git a/src/main/java/com/klikli_dev/theurgy/registry/TagRegistry.java b/src/main/java/com/klikli_dev/theurgy/registry/TagRegistry.java index 6eebd47c1..b701557e0 100644 --- a/src/main/java/com/klikli_dev/theurgy/registry/TagRegistry.java +++ b/src/main/java/com/klikli_dev/theurgy/registry/TagRegistry.java @@ -8,6 +8,7 @@ import com.klikli_dev.theurgy.Theurgy; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; @@ -26,6 +27,6 @@ public static TagKey makeBlockTag(String id) { } public static TagKey makeBlockTag(ResourceLocation id) { - return TagKey.create(Registry.BLOCK_REGISTRY, id); + return TagKey.create(Registries.BLOCK, id); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 19cc7ddf5..93c89ebd9 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[44,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="MIT and CC-BY-4.0" @@ -29,9 +29,9 @@ displayName="Theurgy" #mandatory # A file name (in the root of the mod JAR) containing a logo for display logoFile="theurgy.png" #optional # A text field displayed in the mod UI -credits="Thanks for this example mod goes to Java" #optional +credits="""See https://github.com/klikli-dev/theurgy#licensing""" #optional # A text field displayed in the mod UI -authors="Love, Cheese and small house plants" #optional +authors="Kli Kli" #optional # Display Test controls the display for your mod in the server connection screen # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. @@ -43,4 +43,10 @@ authors="Love, Cheese and small house plants" #optional # The description text for the mod (multi line!) (#mandatory) description=''' An open-source magic mod built around classical alchemy to replicate and transmute matter, and create magical artifacts. -''' \ No newline at end of file +''' + +[[dependencies.theurgy]] +modId = "forge" +mandatory = true +versionRange = "[1.19.3-44.0.5,)" +side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index b27eb0cdc..f21c188f6 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { "description": "Theurgy resources", - "pack_format": 9, - "forge:resource_pack_format": 9, + "pack_format": 12, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } }