Jump to content

[1.7.2]Adding drops to vanilla mobs


pta2002
 Share

Recommended Posts

Hey guys, I'm making my mod and I would like to know how I add drops to vanilla mobs. I want them to drop an item that I added. If possible, I would like to know how to make them drop 25% of the time.

 

EDIT: I added the title (Whoops....)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).
    • I was trying to change item models with Model backer and ItemOverrides but it's too annoying so I looked for alternative ways: but for that I need to make many items, in this case for each model one item, however each item would have five models and I want to make about 30 items. That way I would have to make 600 items? this is a lot, can the forge handle it?
    • I originally posted here in error, as the issue I was having was for fabric, not forge, so I don't know anything about your issue but I solved my issue by downgrading my graphics drivers, here's a link to a post I made on Minecraft forum, I made an edit on the post with the solution that worked for me:   https://www.minecraftforum.net/forums/support/java-edition-support/3164709-solved-minecraft-fabric-modpack-crash-when#c4
    • 20:14:21.373 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Found mod file forge-1.19.2-43.1.43-universal.jar of type MOD with provider net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@5c92166b 20:14:21.386 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Failed to build unique mod list after mod discovery. net.minecraftforge.fml.loading.EarlyLoadingException: Duplicate mods found at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.UniqueModListBuilder.buildUniqueList(UniqueModListBuilder.java:78) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:105) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:166) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLServiceProvider.beginScanning(FMLServiceProvider.java:86) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:112) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:100) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:102) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:55) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:87) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) 20:14:21.399 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Mod Discovery failed. Skipping dependency discovery. 20:14:21.990 launcher main Exception in thread "main" java.lang.IllegalStateException: Failed to find system mod: minecraft at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.detectSystemMods(ModSorter.java:181) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.buildUniqueList(ModSorter.java:145) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.sort(ModSorter.java:53) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.moddiscovery.ModValidator.stage2Validation(ModValidator.java:101) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLLoader.completeScan(FMLLoader.java:175) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLServiceProvider.completeScan(FMLServiceProvider.java:91) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServiceDecorator.onCompleteScan(TransformationServiceDecorator.java:174) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.lambda$triggerScanCompletion$24(TransformationServicesHandler.java:145) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.triggerScanCompletion(TransformationServicesHandler.java:147) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:94) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) 20:14:21.990 monitor Process Monitor Process crashed with exit code 1
    • I am created a packet that spawns 3 golems and adds a timer to their persistant data along with the name of the owner who spawned them. public boolean handle(Supplier<NetworkEvent.Context> supplier){ NetworkEvent.Context context = supplier.get(); context.enqueueWork(()-> { Player p = context.getSender(); if(p.getPersistentData().contains(XprtData.SALUS_CLASS)){ if(!p.getPersistentData().contains(XprtData.SALUS_DEFENDER_TIMER)){ for(int i=0;i<3;i++){ IronGolem golem = (IronGolem) EntityType.IRON_GOLEM.spawn(p.createCommandSourceStack().getLevel(), null, null, p.blockPosition(), MobSpawnType.MOB_SUMMONED, true, false); golem.getPersistentData().putInt(XprtData.SALUS_DEFENDER_TIMER, Utils.Seconds(50)); golem.getPersistentData().putString(XprtData.SALUS_DEFENDER_OWNER, p.getScoreboardName()); golem.setCustomName(Component.literal(ChatFormatting.GOLD + "" + p.getScoreboardName() + "'s Defender")); } p.getPersistentData().putInt(XprtData.SALUS_DEFENDER_TIMER, Utils.Seconds(5)); } else { int time = p.getPersistentData().getInt(XprtData.SALUS_DEFENDER_TIMER); Utils.Message(p, ChatFormatting.RED + "You cannot summon defenders right now, " + Utils.TicksToSeconds(time) + " seconds remaining."); } } }); return true; } the problem is when I call upon their data in an external class here @SubscribeEvent public static void onLivingTick(LivingEvent.LivingTickEvent e){ LivingEntity entity = e.getEntity(); if(entity instanceof IronGolem){ if(entity.getPersistentData().contains(XprtData.SALUS_DEFENDER_TIMER)){ Mob mob = (Mob)entity; for(LivingEntity target : Utils.getNear(entity, 8)){ if(target instanceof Player || target instanceof Villager || target instanceof Wolf || target instanceof IronGolem){ mob.setTarget(null); } else { mob.setTarget(target); } } } if(entity.getPersistentData().contains(XprtData.SALUS_DEFENDER_OWNER)){ String owner = entity.getPersistentData().getString(XprtData.SALUS_DEFENDER_OWNER); for(String pNames : entity.getServer().getPlayerNames()){ if(pNames.equals(owner)){ Player p = entity.getServer().getPlayerList().getPlayerByName(owner); if(entity.distanceTo(p) >= 7f){ entity.teleportTo(p.getBlockX(), p.getBlockY()+1, p.getBlockZ()); } } } } } } neither XprtData.SALUS_DEFENDER_TIMER nor XprtData.SALUS_DEFENDER_OWNER contain any data, for the timer it starts off at 0 when it should be (22*50) and defender owner should contain the players name which instead contains a blank.   This isnt my first time doing something like this, ive done it will illagers and it worked perfectly but when it comes to golems it doesnt work at all. I could do with it the timer killing them at -(22*50) but it wont help that i still need the owners name to teleport them to the owner if they move to far away. Any Ideas? Im calling this packet from a keybind by the way   EDIT:  I figured out the issue, I guess when the packet is received by server and the entity is created there is a delay before the persistant data is created I guess, im not too sure...  Anyways I fixed it by just calling the persistant data twice 
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.