Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

HeyImAmethyst

Members
  • Posts

    13
  • Joined

  • Last visited

Recent Profile Visitors

536 profile views

HeyImAmethyst's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I made a crafting table block that behaves like a crafting table but only my custom recipes work on it. I made a container, recipe, recipe type, and serializer for it but my custom recipe doesnt work properly. When I put enough items to make only one craft result it works fine but if I put more than enough, like enough to make multiple at once, the items that I put in for the recipe either multiplies within the crafting grid or it doesnt get used up at all. I've tried moving code around, changing values ect. but I can't find out what is causing the issue. Here is my container class: https://pastebin.com/dvN01bEt Here is my recipe class: https://pastebin.com/GKZFENZT Here is my recipe type class: https://pastebin.com/SywS2Av1 And here is the serializer for my recipe: https://pastebin.com/6J4ZUZGp
  2. I have these witch hat armor items with a custom model that already renders fine when I put them on my player's head. But instead of making a 2d pixel image that I made in an art program I want to have the inventory icon be 3d like the custom model as well as have the custom model be rendered in my hand when I have the items selected. I tried looking on google and on the discord and someone said I could use a ISTER or custom model loader but I have no idea how to set them up. I already tried looking on google but it's either the information is outdated or the method isn't for what I want. I'm not using any obj models. The model is in Java made with blockbench. Does anyone know how I can do this?
  3. Thanks! I was able to get it to work. The render is funky but I'll figure it out. At least something is on my player's back XD. But if I wanted other players to see the wings if I am on a server, would I need to do something similar in a server event similar to FMLClientSetupEvent or is this a whole different process completely?
  4. The code is in here: package com.HeyImAmethyst.MagiWitchHats; import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.PlayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.data.DataGenerator; import net.minecraft.entity.EntityPredicate; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.loot.LootContext.EntityTarget; import net.minecraft.loot.conditions.EntityHasProperty; import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.loot.conditions.MatchTool; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.GlobalLootModifierProvider; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import java.util.Map; import javax.annotation.Nonnull; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.HeyImAmethyst.MagiWitchHats.proxy.IProxy; import com.HeyImAmethyst.MagiWitchHats.util.RegistryHandler; import com.google.common.collect.Maps; import com.HeyImAmethyst.MagiWitchHats.VanillaMobDropsModifier.VanillaMobDropsModifier; import com.HeyImAmethyst.MagiWitchHats.proxy.ClientProxy; import com.HeyImAmethyst.MagiWitchHats.proxy.ServerProxy; import com.HeyImAmethyst.MagiWitchHats.render.LayerWings; import com.HeyImAmethyst.MagiWitchHats.render.WingsRenderer; @Mod("mwh") public class MagiWitchHats { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "mwh"; public static final boolean ENABLE = true; public MagiWitchHats() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); RegistryHandler.Init(); Minecraft mc = Minecraft.getInstance(); EntityRendererManager manager = mc.getRenderManager(); manager.getSkinMap().get("default").addLayer(new LayerWings<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(WingsRenderer.instance)); manager.getSkinMap().get("slim").addLayer(new LayerWings<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(WingsRenderer.instance)); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { } public static final ItemGroup MOD_CREATIVE_TAB = new ItemGroup("magiWitchHatsTab") { @Override public ItemStack createIcon() { return new ItemStack(RegistryHandler.ARCANE_WITCH_HAT.get()); } }; }
  5. I tried putting this in my main mod class just to see if I can get it to work: Minecraft mc = Minecraft.getInstance(); EntityRendererManager manager = mc.getRenderManager(); manager.getSkinMap().get("default").addLayer(new LayerWings<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(WingsRenderer.instance)); manager.getSkinMap().get("slim").addLayer(new LayerWings<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(WingsRenderer.instance)); But I'm getting this error: Failure message: Magi Witch Hats (mwh) has failed to load correctly java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRendererManager.getSkinMap()" because "manager" is null I guess something is working since it gave me this crash but I don't understand why manager is returning null.
  6. I put my event in the same place as my flying event so I assumed it was working
  7. When I was making custom witch hat models, I was having problems with the model not properly following the player head. I learned that I needed to keep them local so that there weren't issues like that and I have tested it with them being global vs them being local and it makes a difference. For the render part I think I was following a tutorial on out to import custom models and the render part was commented out. I'll uncomment the method though in case it makes a difference. Edit: Here is the website I used to help me make my witch hats https://championash5357.github.io/ChampionAsh5357/tutorial/minecraft/1.16.1/items/armor
  8. Oh ok! Is there a better way I can add the layer to the player?
  9. I added and item the allows the player to fly when if it is in the player's inventory and I want to have wings appear on the player when ever the item is in the inventory, Similar to how extra utilities does it with the angel rings it adds. I learned that I can to this with render layers. I followed the class structure for the elytra render layer and I saw that online I can add the layer in with an event but it is not rendering on my player. I'm not even getting any broken texture letting me know that at least my model is on the player. This is my layer class for my wings: package com.HeyImAmethyst.MagiWitchHats.render; import com.HeyImAmethyst.MagiWitchHats.client.model.magi_wings; import com.HeyImAmethyst.MagiWitchHats.util.RegistryHandler; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.PlayerRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.ElytraModel; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerModelPart; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class LayerWings<T extends LivingEntity, M extends EntityModel<T>> extends LayerRenderer<T, M> { private static final ResourceLocation TEXTURE_WINGS = new ResourceLocation("textures/models/armor/wing_butterfly"); private final magi_wings wings = new magi_wings(1); public LayerWings(IEntityRenderer<T, M> rendererIn) { super(rendererIn); } @SuppressWarnings("unchecked") public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if(entitylivingbaseIn instanceof PlayerEntity) { if(((PlayerEntity) entitylivingbaseIn).inventory.hasItemStack(new ItemStack(RegistryHandler.FAIRY_RING.get()))) { ItemStack itemstack = new ItemStack(RegistryHandler.FAIRY_RING.get()); if (shouldRender(itemstack, entitylivingbaseIn)) { ResourceLocation resourcelocation; if (entitylivingbaseIn instanceof AbstractClientPlayerEntity) { resourcelocation = getWingsTexture(itemstack, entitylivingbaseIn); } else { resourcelocation = getWingsTexture(itemstack, entitylivingbaseIn); } matrixStackIn.push(); matrixStackIn.translate(0.0D, 0.0D, 0.125D); this.getEntityModel().copyModelAttributesTo((EntityModel<T>) this.wings); //this.wings.setRotationAngles(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch); IVertexBuilder ivertexbuilder = ItemRenderer.func_239386_a_(bufferIn, RenderType.func_239263_a_(resourcelocation), false, itemstack.hasEffect()); this.wings.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); matrixStackIn.pop(); } } } } public boolean shouldRender(ItemStack stack, T entity) { return stack.getItem() == RegistryHandler.FAIRY_RING.get(); } public ResourceLocation getWingsTexture(ItemStack stack, T entity) { return TEXTURE_WINGS; } } This is the event I am using: @SubscribeEvent public void onPlayerRender(RenderPlayerEvent.Pre event) { event.getRenderer().addLayer(new LayerWings<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(event.getRenderer())); } And this is my wings model: // Made with Blockbench 3.6.6 // Exported for Minecraft version 1.12.2 or 1.15.2 (same format for both) for entity models animated with GeckoLib // Paste this class into your mod and follow the documentation for GeckoLib to use animations. You can find the documentation here: https://github.com/bernie-g/geckolib // Blockbench plugin created by Gecko package com.HeyImAmethyst.MagiWitchHats.client.model; import com.HeyImAmethyst.MagiWitchHats.items.ItemRing; import net.minecraft.client.renderer.entity.model.BipedModel; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ResourceLocation; import software.bernie.geckolib.animation.model.AnimatedEntityModel; import software.bernie.geckolib.animation.render.AnimatedModelRenderer; public class magi_wings extends BipedModel<LivingEntity> { public magi_wings(float size) { super(size, 0, 16, 16); ModelRenderer Wings; ModelRenderer wing1; ModelRenderer wing2; Wings = new ModelRenderer(this); Wings.setRotationPoint(0.0F, -8.0F, 0.0F); wing1 = new ModelRenderer(this); wing1.setRotationPoint(-1.0F, 0.0F, -1.25F); Wings.addChild(wing1); setRotationAngle(wing1, 0.0F, -0.6545F, 0.0F); wing1.setTextureOffset(0, 0).addBox(1.524F, -9.0F, 0.3653F, 13.0F, 16.0F, 0.0F, 0.0F, false); wing2 = new ModelRenderer(this); wing2.setRotationPoint(1.0F, 0.0F, -1.25F); Wings.addChild(wing2); setRotationAngle(wing2, 0.0F, 0.6545F, 0.0F); wing2.setTextureOffset(0, 0).addBox(-14.524F, -9.0F, 0.3653F, 13.0F, 16.0F, 0.0F, 0.0F, true); bipedBody.addChild(Wings); } // @Override // public void setRotationAngles(LivingEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) // { // } // @Override // public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ // Wings.render(matrixStack, buffer, packedLight, packedOverlay); // } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } }
  10. Yea, I realized how obvious it was after I wrote my comment XD. I'm going to try and get this to work. Thanks for your help!
  11. It doesn't? Wait so the does read method reads the json file and the write method writes it out? What would I need to put in read method then? Because in the documentation it says that the conditions are already deserialized or was that specific to that code? Im looking online about reading and writing json files and I saw these: https://stackoverflow.com/questions/10926353/how-to-read-json-file-into-java-with-simple-json-library https://stackoverflow.com/questions/2591098/how-to-parse-json-in-java https://www.geeksforgeeks.org/parse-json-java/ Is that what I need to do? Like figure out how to map the code to the json?
  12. Okay so I changed it, and I doubled and triple checked to see if I have everything written right and my .json files in the right place. But in my error log it is giving me this error [m[1;31m[12:11:24] [Render thread/ERROR] [ne.mi.co.lo.LootModifierManager/]: Couldn't parse loot modifier mwh:dust_drop java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonElement.isJsonObject()" because "element" is null at net.minecraftforge.common.loot.LootModifierManager.deserializeModifier(LootModifierManager.java:130) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraftforge.common.loot.LootModifierManager.lambda$apply$0(LootModifierManager.java:118) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {} at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:116) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraftforge.common.loot.LootModifierManager.apply(LootModifierManager.java:57) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.client.resources.ReloadListener.lambda$reload$1(ReloadListener.java:14) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:714) ~[?:?] {} at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478) ~[?:?] {} at net.minecraft.resources.AsyncReloader.lambda$new$3(AsyncReloader.java:66) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.Minecraft.func_238189_a_(Minecraft.java:1866) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_238195_a_(Minecraft.java:1719) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_238191_a_(Minecraft.java:1689) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214443_e(WorldSelectionList.java:364) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214438_a(WorldSelectionList.java:273) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_231044_a_(WorldSelectionList.java:228) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.widget.list.AbstractList.func_231044_a_(AbstractList.java:292) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.INestedGuiEventHandler.func_231044_a_(INestedGuiEventHandler.java:31) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:92) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.Screen.func_231153_a_(Screen.java:425) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:90) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$registerCallbacks$4(MouseHelper.java:185) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:184) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:93) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MainWindow.flipFrame(MainWindow.java:304) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1010) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:589) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-7.0.1.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-7.0.1.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.2-33.0.61_mapped_snapshot_20200514-1.16-recomp.jar:?] {} Its saying that "element" is null but I don't know what its referring to. Is it something is the doApply method or is it something in my Serializer? I removed somethings in my Serializer so it looks like this now: private static abstract class Serializer extends GlobalLootModifierSerializer<VanillaMobModifier> { @Override public VanillaMobModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { Item dust = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getString(object, "item"))); return new VanillaMobModifier(conditionsIn, dust); } } I noticed that in the documentation that the class was private and static but for me it gives me an error saying to add unimplemented methods or to make it abstract. when I click on add unimplemented methods, this method is added: @Override public JsonObject write(VanillaMobModifier instance) { // TODO Auto-generated method stub return null; } Making it abstract removes the error line under Serializer but I would still this NullPointerException error.
  13. I'm trying to make it so that witches drop a custom item I made. I read that I needed to use global loot modifiers and I am currently looking at the documentation as well as other posts online about how to use them and I can't seem to fully understand what I need to put in my code. This is my what I have in my global_loot_modifiers.json: { "replace": false, "entries": [ "global_loot_test:witch" ] } my witch.json: { "type": "mwh:dust_drop", "conditions": [ { "condition": "minecraft:killed_by_player" }, { "condition": "minecraft:entity_properties", "predicate": { "type": "minecraft:witch" }, "entity": "this" } ], "item": "mwh:witch_dust" } and my modifier class: class VanillaMobModifier extends LootModifier { private final int numSeedsToConvert; private final Item itemToCheck; private final Item itemReward; public VanillaMobModifier(ILootCondition[] conditionsIn, int numSeeds, Item itemCheck, Item reward) { super(conditionsIn); numSeedsToConvert = numSeeds; itemToCheck = itemCheck; itemReward = reward; } @Nonnull @Override public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { // // Additional conditions can be checked, though as much as possible should be parameterized via JSON data. // It is better to write a new ILootCondition implementation than to do things here. // int numSeeds = 0; for(ItemStack stack : generatedLoot) { if(stack.getItem() == itemToCheck) numSeeds+=stack.getCount(); } if(numSeeds >= numSeedsToConvert) { generatedLoot.removeIf(x -> x.getItem() == itemToCheck); generatedLoot.add(new ItemStack(itemReward, (numSeeds/numSeedsToConvert))); numSeeds = numSeeds%numSeedsToConvert; if(numSeeds > 0) generatedLoot.add(new ItemStack(itemToCheck, numSeeds)); } return generatedLoot; } @SuppressWarnings("unused") private static class Serializer extends GlobalLootModifierSerializer<VanillaMobModifier> { @Override public VanillaMobModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { int numSeeds = JSONUtils.getInt(object, "numSeeds"); Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((JSONUtils.getString(object, "seedItem")))); Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getString(object, "replacement"))); return new VanillaMobModifier(conditionsIn, numSeeds, seed, wheat); } @Override public JsonObject write(VanillaMobModifier instance) { // TODO Auto-generated method stub return null; } } } I don't know how to modify this part of the code to fit my needs. I only want just witches to have a chance at dropping my item when killed. And I saw that I needed to do something like this: @SubscribeEvent public static void registerModifierSerializers(@Nonnull final RegistryEvent.Register<GlobalLootModifierSerializer<?>> event) { if (ENABLE) { event.getRegistry().register(new VanillaMobDropsModifier.Serializer().setRegistryName(new ResourceLocation(MOD_ID,"dust_drop"))); } } buts it's giving me errors. Pretty sure I'm missing something. I bet I'm probably missing important or obvious but if anyone can point me in the right direction I would very my appreciate it.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.