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 have it set to spawn in the nether, which it looks like it tries to do, because when I go to the nether, I get this error repeatedly until I leave or close the game:

 

java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.world.SpawnerAnimals.findChunksForSpawning(SpawnerAnimals.java:164)
at net.minecraft.world.WorldServer.tick(WorldServer.java:171)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:702)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)
Caused by: java.lang.NullPointerException
at f1repl4ce.unlogic.entities.CustomPig.applyEntityAttributes(CustomPig.java:44)
at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:168)
at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)
at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:38)
at net.minecraft.entity.EntityAgeable.<init>(EntityAgeable.java:17)
at net.minecraft.entity.passive.EntityAnimal.<init>(EntityAnimal.java:34)
at net.minecraft.entity.passive.EntityPig.<init>(EntityPig.java:33)
at f1repl4ce.unlogic.entities.CustomPig.<init>(CustomPig.java:24)
... 10 more

 

And this when I try using the spawn egg to spawn it:

 

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.entity.EntityList.createEntityByID(EntityList.java:221)
at net.minecraft.item.ItemMonsterPlacer.spawnCreature(ItemMonsterPlacer.java:173)
at net.minecraft.item.ItemMonsterPlacer.onItemUse(ItemMonsterPlacer.java:79)
at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:145)
at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:422)
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:591)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:247)
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762)
Caused by: java.lang.NullPointerException
at f1repl4ce.unlogic.entities.CustomPig.applyEntityAttributes(CustomPig.java:44)
at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:168)
at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)
at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:38)
at net.minecraft.entity.EntityAgeable.<init>(EntityAgeable.java:17)
at net.minecraft.entity.passive.EntityAnimal.<init>(EntityAnimal.java:34)
at net.minecraft.entity.passive.EntityPig.<init>(EntityPig.java:33)
at f1repl4ce.unlogic.entities.CustomPig.<init>(CustomPig.java:24)
... 19 more

 

The custom pig class:

 

package f1repl4ce.unlogic.entities;

import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIControlledByPlayer;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class CustomPig extends EntityPig{

public CustomPig(World p_i1689_1_) {
	super(p_i1689_1_);
        this.setSize(0.9F, 0.9F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.2D, Items.carrot, false));
        this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false));
        this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D));
        this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(8, new EntityAILookIdle(this));
}
@Override
protected void applyEntityAttributes()
{
	 super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(6.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D);
}
@Override
public void onStruckByLightning(EntityLightningBolt p_70077_1_){}
}

 

And this code is in the modbase for it:

 

//set egg colors
        public static void getEggColor(Class entityClass){
        	if(entityClass == CustomPig.class){
        		primaryColor = 11513775;
            	secondaryColor = 8519830;
        	}
        }
        //Entity Registry
    	public static void registerEntity(Class entityClass, String name)
    	{
    	int entityID = EntityRegistry.findGlobalUniqueEntityId();
    	primaryColor = 13132800;//RGB to RGB int at http://www.shodor.org/stella2java/rgbint.html
    	secondaryColor = 1310735;//RGB to RGB int at http://www.shodor.org/stella2java/rgbint.html
    	getEggColor(entityClass);

    	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
    	EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true);
    	EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor));
    	}
@EventHandler
        public void preInit(FMLPreInitializationEvent event) {
registerEntity(CustomPig.class, "CustomPig");
        	EntityRegistry.addSpawn(CustomPig.class, 1, 0, 1, EnumCreatureType.ambient, BiomeGenBase.hell);
}

 

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Where is your clientproxy, commonproxy, nothing ?! You need Render and Entity.

 

~ maybe i am wrong below but not above, you need to have render aside entity class.

Also you cant do CustomPig extends EntityPig. Some of the AI wont work if you dont have your own. Becouse some of them are only connected to EntityPig.

@proalt That doesn't have anything to do with the error.

 

@F1repl4ce

Caused by: java.lang.NullPointerException
at f1repl4ce.unlogic.entities.CustomPig.applyEntityAttributes(CustomPig.java:44)

Can you post line 44 of CustomPig.java?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

@proalt That doesn't have anything to do with the error.

 

@F1repl4ce

Caused by: java.lang.NullPointerException
at f1repl4ce.unlogic.entities.CustomPig.applyEntityAttributes(CustomPig.java:44)

Can you post line 44 of CustomPig.java?

Wow, I'm an idiot... I don't see how adding attackDamage to an animal could affect anything, but apparently it did.

Where is your clientproxy, commonproxy, nothing ?! You need Render and Entity.

 

~ maybe i am wrong below but not above, you need to have render aside entity class.

Also you cant do CustomPig extends EntityPig. Some of the AI wont work if you dont have your own. Becouse some of them are only connected to EntityPig.

I do have render classes and proxy classes. I didn't post them because I knew that wasn't the issue. Also, I was more concerned about getting it to spawn before working on the AI.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Guest
This topic is now closed to further replies.

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.