Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to add chickens that drops feathers after tot ticks.

package com.nov4e.nex.tweaks;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class TChickenDropsFeather {
	
	boolean str_001;
	boolean str_002;
	int str_003;
	
	@SubscribeEvent
	public void onLivingUpdate(LivingUpdateEvent e_001) {
		if(e_001.getEntity().getEntityWorld().isRemote || !(e_001.getEntity() instanceof EntityChicken))
			return;

		EntityChicken str_004 = (EntityChicken) e_001.getEntity();
		if((str_001 || !str_004.isChild()) && str_004.getEntityWorld().rand.nextInt(str_003) == 0)
			str_004.dropItem(Items.FEATHER, 1);
	}

	@SubscribeEvent
	public void onLivingDrops(LivingDropsEvent e_002) {
		if(!str_002 || e_002.getEntity().getEntityWorld().isRemote || !(e_002.getEntity() instanceof EntityChicken) || !((EntityChicken)e_002.getEntity()).isChild() && !str_001)
			return;

		EntityChicken str_005 = (EntityChicken) e_002.getEntity();
		boolean str_006 = false;

		for(EntityItem str_007 : e_002.getDrops())
			if(!str_007.getItem().isEmpty() && str_007.getItem().getItem().equals(Items.FEATHER)) {
				str_006 = true;
				break;
			}

		if(!str_006)
			e_002.getDrops().add(new EntityItem(e_002.getEntity().getEntityWorld(), str_005.posX, str_005.posY, str_005.posZ, new ItemStack(Items.FEATHER, 1)));
	}


}

 

When I spawn a chicken the game crashes:

Spoiler

[01:23:25] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.entity.living.LivingEvent$LivingUpdateEvent@2ab56be3:
java.lang.IllegalArgumentException: bound must be positive
	at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_181]
	at com.nov4e.nex.tweaks.TChickenDropsFeather.onLivingUpdate(TChickenDropsFeather.java:23) ~[TChickenDropsFeather.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_49_TChickenDropsFeather_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:567) [ForgeHooks.class:?]
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2314) [EntityLivingBase.class:?]
	at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:346) [EntityLiving.class:?]
	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171) [World.class:?]
	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) [WorldServer.class:?]
	at net.minecraft.world.World.updateEntity(World.java:2130) [World.class:?]
	at net.minecraft.world.World.updateEntities(World.java:1931) [World.class:?]
	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) [WorldServer.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
[01:23:25] [Server thread/ERROR] [FML]: Index: 3 Listeners:
[01:23:25] [Server thread/ERROR] [FML]: 0: NORMAL
[01:23:25] [Server thread/ERROR] [FML]: 1: ASM: com.nov4e.nex.tweaks.TDoubleDoorsOpen@3b0f224c onEntityTick(Lnet/minecraftforge/event/entity/living/LivingEvent$LivingUpdateEvent;)V
[01:23:25] [Server thread/ERROR] [FML]: 2: ASM: com.nov4e.nex.tweaks.TBabyZombie@53517736 entityUpdate(Lnet/minecraftforge/event/entity/living/LivingEvent$LivingUpdateEvent;)V
[01:23:25] [Server thread/ERROR] [FML]: 3: ASM: com.nov4e.nex.tweaks.TChickenDropsFeather@28f9873c onLivingUpdate(Lnet/minecraftforge/event/entity/living/LivingEvent$LivingUpdateEvent;)V
[01:23:25] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking entity
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:848) ~[MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) ~[MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: java.lang.IllegalArgumentException: bound must be positive
	at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_181]
	at com.nov4e.nex.tweaks.TChickenDropsFeather.onLivingUpdate(TChickenDropsFeather.java:23) ~[TChickenDropsFeather.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_49_TChickenDropsFeather_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?]
	at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:567) ~[ForgeHooks.class:?]
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2314) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:346) ~[EntityLiving.class:?]
	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171) ~[World.class:?]
	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) ~[WorldServer.class:?]
	at net.minecraft.world.World.updateEntity(World.java:2130) ~[World.class:?]
	at net.minecraft.world.World.updateEntities(World.java:1931) ~[World.class:?]
	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) ~[WorldServer.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) ~[MinecraftServer.class:?]
	... 4 more
[01:23:25] [Server thread/ERROR] [minecraft/MinecraftServer]: This crash report has been saved to: C:\Users\Utente\Desktop\Quest For Perfection [1.12.2]\Workspace QFP\run\.\crash-reports\crash-2018-11-03_01.23.25-server.txt
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/overworld
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/the_nether
[01:23:25] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'New World'/the_end
[01:23:25] [Server thread/INFO] [FML]: Unloading dimension 0
[01:23:25] [Server thread/INFO] [FML]: Unloading dimension -1
[01:23:25] [Server thread/INFO] [FML]: Unloading dimension 1
[01:23:25] [Server thread/INFO] [FML]: Applying holder lookups
[01:23:25] [Server thread/INFO] [FML]: Holder lookups applied
[01:23:25] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[01:23:27] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// My bad.

Time: 11/3/18 1:23 AM
Description: Ticking entity

java.lang.IllegalArgumentException: bound must be positive
	at java.util.Random.nextInt(Unknown Source)
	at com.nov4e.nex.tweaks.TChickenDropsFeather.onLivingUpdate(TChickenDropsFeather.java:23)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_49_TChickenDropsFeather_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:567)
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2314)
	at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:346)
	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171)
	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871)
	at net.minecraft.world.World.updateEntity(World.java:2130)
	at net.minecraft.world.World.updateEntities(World.java:1931)
	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
	at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Client thread
Stacktrace:
	at java.util.Random.nextInt(Unknown Source)
	at com.nov4e.nex.tweaks.TChickenDropsFeather.onLivingUpdate(TChickenDropsFeather.java:23)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_49_TChickenDropsFeather_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:567)
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2314)
	at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:346)
	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171)
	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871)
	at net.minecraft.world.World.updateEntity(World.java:2130)

-- Entity being ticked --
Details:
	Entity Type: minecraft:chicken (net.minecraft.entity.passive.EntityChicken)
	Entity ID: 174
	Entity Name: Chicken
	Entity's Exact location: 300.50, 74.00, -124.50
	Entity's Block location: World: (300,74,-125), Chunk: (at 12,4,3 in 18,-8; contains blocks 288,0,-128 to 303,255,-113), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Entity's Momentum: 0.00, 0.00, 0.00
	Entity's Passengers: []
	Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
	at net.minecraft.world.World.updateEntities(World.java:1931)
	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643)

-- Affected level --
Details:
	Level name: New World
	All players: 0 total; []
	Chunk stats: ServerChunkCache: 625 Drop: 0
	Level seed: 9104942932760931954
	Level generator: ID 00 - default, ver 1. Features enabled: true
	Level generator options: 
	Level spawn location: World: (240,64,-140), Chunk: (at 0,4,4 in 15,-9; contains blocks 240,0,-144 to 255,255,-129), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Level time: 420 game time, 420 day time
	Level dimension: 0
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 108007 (now: false), thunder time: 45096 (now: false)
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
	at java.lang.Thread.run(Unknown Source)

 

 

Edited by nov4e

6 minutes ago, nov4e said:

When I spawn a chicken the game crashes:

You never set... wait why are your fields named like that...?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Finishing @Animefan8888's response - you've never set this

13 minutes ago, nov4e said:

int str_003;

to anything. So it's zero by default and Random.nextInt(0) will crash. And yeah, those field names...

 

Also if you want to add something to the drops of an entity use loottables

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.