Jump to content

[1.15.2] Adding drops to mobs


DeJunky

Recommended Posts

I just started out learning forge modding so I'm creating a simple mod that adds an extra crop to the game. I would like to add a chance for zombies to drop the seed item for this crop and I'm not sure how to go about this.

Basically, how can I add my item to the loot table for zombies, or how could I inject my item into the loot table?

Edited by DeJunky
Update title
Link to comment
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

First of all, thanks for the help and the link to some great documentation. Perhaps it's just my lack of knowledge about loot tables but I was running into trouble trying to get a mob to drop the item. I was able to code up a condition for it to drop from a block and it worked just fine, however when I play test with this loot modifier

{
  "type":"onion:add_onion",
  "conditions": [
    {
      "condition": "minecraft:entity_properties",
      "entity": "this",
      "predicate": {
        "type": "minecraft:zombie"
      }
    }
  ]
}

 

I get a crash several seconds after loading into a world. I suspect that the issue is with the way I've written the conditions as it seems to be overloading checking entities(I'm guessing).

Here is a crash report.

[20:37:06] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[20:37:06] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[20:37:06] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:103]: ---- Minecraft Crash Report ----
// Why did you do that?

Time: 6/3/20 8:37 PM
Description: Exception while updating neighbours

java.lang.NullPointerException: Exception while updating neighbours
	at net.minecraft.world.storage.loot.conditions.EntityHasProperty.test(SourceFile:35) ~[?:?] {re:classloading}
	at net.minecraft.world.storage.loot.conditions.EntityHasProperty.test(SourceFile:19) ~[?:?] {re:classloading}
	at net.minecraftforge.common.loot.LootModifier.apply(LootModifier.java:53) ~[?:?] {re:classloading}
	at net.minecraftforge.common.ForgeHooks.modifyLoot(ForgeHooks.java:1194) ~[?:?] {re:classloading}
	at net.minecraft.world.storage.loot.LootTable.generate(LootTable.java:86) ~[?:?] {re:classloading}
	at net.minecraft.block.Block.getDrops(Block.java:517) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.block.BlockState.getDrops(BlockState.java:265) ~[?:?] {re:classloading}
	at net.minecraft.block.Block.getDrops(Block.java:523) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.block.Block.spawnDrops(Block.java:533) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.block.AbstractRailBlock.neighborChanged(AbstractRailBlock.java:88) ~[?:?] {re:classloading}
	at net.minecraft.block.BlockState.neighborChanged(BlockState.java:229) ~[?:?] {re:classloading}
	at net.minecraft.world.World.neighborChanged(World.java:321) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:279) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.World.notifyNeighbors(World.java:265) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.World.markAndNotifyBlock(World.java:214) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.World.setBlockState(World.java:190) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.World.removeBlock(World.java:238) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.block.FireBlock.onBlockAdded(FireBlock.java:234) ~[?:?] {re:classloading}
	at net.minecraft.block.BlockState.onBlockAdded(BlockState.java:241) ~[?:?] {re:classloading}
	at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:282) ~[?:?] {re:classloading}
	at net.minecraft.world.World.setBlockState(World.java:177) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.block.FireBlock.tryCatchFire(FireBlock.java:190) ~[?:?] {re:classloading}
	at net.minecraft.block.FireBlock.tick(FireBlock.java:131) ~[?:?] {re:classloading}
	at net.minecraft.block.BlockState.tick(BlockState.java:249) ~[?:?] {re:classloading}
	at net.minecraft.world.server.ServerWorld.tickBlock(ServerWorld.java:582) ~[?:?] {re:classloading}
	at net.minecraft.world.server.ServerTickList.tick(SourceFile:87) ~[?:?] {re:classloading}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:316) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:849) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:784) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:114) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:637) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_191] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraft.world.storage.loot.conditions.EntityHasProperty.test(SourceFile:35)
	at net.minecraft.world.storage.loot.conditions.EntityHasProperty.test(SourceFile:19)
	at net.minecraftforge.common.loot.LootModifier.apply(LootModifier.java:53)
	at net.minecraftforge.common.ForgeHooks.modifyLoot(ForgeHooks.java:1194)
	at net.minecraft.world.storage.loot.LootTable.generate(LootTable.java:86)
	at net.minecraft.block.Block.getDrops(Block.java:517)
	at net.minecraft.block.BlockState.getDrops(BlockState.java:265)
	at net.minecraft.block.Block.getDrops(Block.java:523)
	at net.minecraft.block.Block.spawnDrops(Block.java:533)
	at net.minecraft.block.AbstractRailBlock.neighborChanged(AbstractRailBlock.java:88)
	at net.minecraft.block.BlockState.neighborChanged(BlockState.java:229)

-- Block being updated --
Details:
	Source block type: ID #minecraft:fire (block.minecraft.fire // net.minecraft.block.FireBlock)
	Block: Block{minecraft:rail}[shape=east_west]
	Block location: World: (-122,16,-241), Chunk: (at 6,1,15 in -8,-16; contains blocks -128,0,-256 to -113,255,-241), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Stacktrace:
	at net.minecraft.world.World.neighborChanged(World.java:321)
	at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:279)
	at net.minecraft.world.World.notifyNeighbors(World.java:265)
	at net.minecraft.world.World.markAndNotifyBlock(World.java:214)
	at net.minecraft.world.World.setBlockState(World.java:190)
	at net.minecraft.world.World.removeBlock(World.java:238)
	at net.minecraft.block.FireBlock.onBlockAdded(FireBlock.java:234)
	at net.minecraft.block.BlockState.onBlockAdded(BlockState.java:241)
	at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:282)
	at net.minecraft.world.World.setBlockState(World.java:177)
	at net.minecraft.block.FireBlock.tryCatchFire(FireBlock.java:190)
	at net.minecraft.block.FireBlock.tick(FireBlock.java:131)
	at net.minecraft.block.BlockState.tick(BlockState.java:249)
	at net.minecraft.world.server.ServerWorld.tickBlock(ServerWorld.java:582)

-- Block being ticked --
Details:
	Block location: World: (-123,15,-241), Chunk: (at 5,0,15 in -8,-16; contains blocks -128,0,-256 to -113,255,-241), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Stacktrace:
	at net.minecraft.world.server.ServerTickList.tick(SourceFile:87)
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:316)

-- Affected level --
Details:
	All players: 1 total; [ServerPlayerEntity['Dev'/236, l='New World', x=-102.31, y=79.00, z=-212.43]]
	Chunk stats: ServerChunkCache: 2255
	Level dimension: DimensionType{minecraft:overworld}
	Level name: New World
	Level seed: -743399848020670749
	Level generator: ID 00 - default, ver 1. Features enabled: true
	Level generator options: {}
	Level spawn location: World: (-96,72,-224), Chunk: (at 0,4,0 in -6,-14; contains blocks -96,0,-224 to -81,255,-209), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
	Level time: 1446 game time, 1446 day time
	Known server brands: forge
	Level was modded: true
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 142250 (now: false), thunder time: 160957 (now: false)
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:849)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:784)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:114)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:637)
	at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_191, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 1074515400 bytes (1024 MB) / 2050490368 bytes (1955 MB) up to 3801088000 bytes (3625 MB)
	CPUs: 12
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.1.0+69+master.79f13f7
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.2.0-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-2.1.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.2
	Forge: net.minecraftforge:31.2.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		main Onion Mod {[email protected]_1.0.0 DONE}
		forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1.jar Forge {[email protected] DONE}
	Player Count: 1 / 8; [ServerPlayerEntity['Dev'/236, l='New World', x=-102.31, y=79.00, z=-212.43]]
	Data Packs: vanilla, mod:onion, mod:forge (incompatible)
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'forge'
[20:37:06] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:103]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2020-06-03_20.37.06-server.txt
[20:37:06] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Dev lost connection: Disconnected
[20:37:06] [Server thread/INFO] [minecraft/MinecraftServer]: Dev left the game
AL lib: (EE) alc_cleanup: 1 device not closed

 

 

 

 

Link to comment
Share on other sites

I haven't messed with entity predicates before, unfortunately, but it looks like something in EntityHasProperty.test() is throwing a null pointer.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Creating new loot conditions isn't that hard. Vanilla has tons of examples, and while I haven't done a condition, I have done advancement triggers, which are pretty similar. If you don't know how to implement the interface directly, copy an existing implementation, find the test() method, modify to return true when you want it to be true (adding undefined variables for the conditions specified by the json file) and working backwards until the errors are gone.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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