Jump to content

[Solved] Game Crashes When I Spawn A Chicken With My MOd


Recommended Posts

Posted (edited)

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:

  Reveal hidden contents

 

Edited by nov4e
Posted
  On 11/3/2018 at 12:24 AM, nov4e said:

When I spawn a chicken the game crashes:

Expand  

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.

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.