Custom Projectile help (crashed)

Started by KBEHAN on Mon, 02/27/2017 - 22:50

Topic category: Help with modding (Java Edition)

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Custom Projectile help (crashed)
Tue, 02/28/2017 - 11:41 (edited)

I just want to let anyone know that I made my own custom entity throwable, this is not a MCreator generated projectile.

So, I have problem with my custom entity throwable.  (1.7.10) I thought I have made it correctly. I made it so when the projectile onImpact with entity skeleton it will remove the skeletons bow by replacing the item in their slot 0 with air.

public class mcreator_expelliarmus {
 
    public static int mobid = 0;
    public Object instance;
 
    public void load(){}
 
    public void generateNether(World world, Random random, int chunkX, int chunkZ){}
    public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
    public int addFuel(ItemStack fuel){
        return 0;
    }
    @SideOnly(Side.CLIENT)
    public void registerRenderers(){
        RenderingRegistry.registerEntityRenderingHandler(mcreator_expelliarmus.Entityexpelliarmus.class, new RenderSnowball(mcreator_crucioCurse.block));
    }
 
 
    public void serverLoad(FMLServerStartingEvent event){}
    public void preInit(FMLPreInitializationEvent event){
        int entityID = EntityRegistry.findGlobalUniqueEntityId();
        mobid = entityID;
        EntityRegistry.registerGlobalEntityID(mcreator_expelliarmus.Entityexpelliarmus.class, "expelliarmus", entityID);
        EntityRegistry.registerModEntity(mcreator_expelliarmus.Entityexpelliarmus.class, "expelliarmus", entityID, instance, 64, 1, true);
      
 
      
    }
 
 
  public static class Entityexpelliarmus extends EntityThrowable{

int timer = 0;
 
public Entityexpelliarmus(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public Entityexpelliarmus(World par1World, EntityLivingBase par2EntityLivingBase)
{
super(par1World, par2EntityLivingBase);
}
public Entityexpelliarmus(World par1World)
{
super(par1World);
}

@Override
    
     public void onUpdate()
     {
          ++timer;
          super.onUpdate();
          if (timer % 2 == 0) {
               this.worldObj.spawnParticle("reddust", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
          }
         
          if (this.timer == 600) {
          this.setDead();
        }
     }
    
     protected float getGravityVelocity()
    {
        return 0.00F;
    }

/**
 * Called when this EntityThrowable hits a block or entity.
 */
@Override
public void onImpact(MovingObjectPosition mop) {
     if(mop.entityHit != null) {

          float throwDamage = 5;
          mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), throwDamage);

          if(mop.entityHit instanceof EntitySkeleton) {
               byte b0 = 18;

               switch(worldObj.difficultySetting) {
                    case NORMAL:
                         b0 = 10;
                         break;
                    case HARD:
                         b0 = 40;
                         break;
                    default:
                         break;
               }

               if(b0 > 0) {
                     EntitySkeleton skeleton = (EntitySkeleton) mop.entityHit;
                    skeleton.setCurrentItemOrArmor(0, new ItemStack(Blocks.air));
               }
          }
          if (!this.worldObj.isRemote)this.setDead();
          }
     this.setDead();
     }
}
}
  But after compile with no errors I go to test in game, but when I shoot it at a skeleton it stops and crashes game.  Here is console output:

 

at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1803)
   at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250)
   at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47)
   at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298)
   at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684)
   at net.minecraft.world.World.updateEntity(World.java:2258)
-- Entity being ticked --
Details:
   Entity Type: Skeleton (net.minecraft.entity.monster.EntitySkeleton)
      Entity's Exact location: 228.02, 62.67, 355.99
Entity ID: 7161
   Entity Name: Skeleton
   Entity's Block location: World: (228,62,355), Chunk: (at 4,3,3 in 14,22; contains blocks 224,0,352 to 239,255,367), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
* What went wrong:
   Entity's Momentum: 0.30, 0.37, -0.27
Execution failed for task ':runClient'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'* Try:
' finished with non-zero exit value 255
Stacktrace:
   at net.minecraft.world.World.updateEntities(World.java:2108)
   at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
-- Affected level --
Details:
   Level name: New World
   All players: 1 total; [EntityPlayerMP['Player101'/307, l='New World', x=225.23, y=64.27, z=358.55]]
   Chunk stats: ServerChunkCache: 923 Drop: 0
   Level seed: -637399917213340839
   Level generator: ID 00 - default, ver 1. Features enabled: true
   Level generator options: 
   Level spawn location: World: (144,64,248), Chunk: (at 0,4,8 in 9,15; contains blocks 144,0,240 to 159,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
   Level time: 17356 game time, 24701 day time
   Level dimension: 0
   Level storage version: 0x04ABD - Anvil
   Level weather: Rain time: 153862 (now: false), thunder time: 35794 (now: false)
   Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
   at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
   at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
   at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
   at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
   at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
-- System Details --
Details:
   Minecraft Version: 1.7.10
   Operating System: Mac OS X (x86_64) version 1   Java Version: 1.8.0_65, Oracle Corporation
0.10.5
   Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
   Memory: 552425224 bytes (526 MB) / 851968000 bytes (812 MB) up to 1908932608 bytes (1820 MB)
   JVM Flags: 0 total; 
   AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
   IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94
   FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
   States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
   UCHIJAAAA   mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
   UCHIJAAAA   FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
   UCHIJAAAA   Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
   UCHIJAAAA   TestEnvironmentMod{1.0} [TestEnvironmentMod] (modid-1.0.jar) 
   GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
   Profiler Position: N/A (disabled)
   Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
   Player Count: 1 / 8; [EntityPlayerMP['Player101'/307, l='New World', x=225.23, y=64.27, z=358.55]]
   Type: Integrated Server (map_client.txt)
   Is Modded: Definitely; Client brand changed to 'fml,forge'
[17:33:52] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393
[17:33:52] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[17:33:52] [Server thread/INFO]: Saving worlds
[17:33:52] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld
[17:33:52] [Server thread/ERROR] [FML]: An Entity type net.minecraft.entity.monster.EntitySkeleton has thrown an exception trying to write state. It will not persist. Report this to the mod author
net.minecraft.util.ReportedException: Saving entity NBT
   at net.minecraft.entity.Entity.writeToNBT(Entity.java:1553) ~[Entity.class:?]
   at net.minecraft.entity.Entity.writeToNBTOptional(Entity.java:1489) ~[Entity.class:?]
   at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:371) [AnvilChunkLoader.class:?]
   at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) [AnvilChunkLoader.class:?]
   at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287) [ChunkProviderServer.class:?]
   at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) [ChunkProviderServer.class:?]
   at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863) [WorldServer.class:?]
   at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) [MinecraftServer.class:?]
   at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:405) [MinecraftServer.class:?]
   at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:266) [IntegratedServer.class:?]
   at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:538) [MinecraftServer.class:?]
   at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.NullPointerException
   at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:889) ~[ItemStack.class:?]
   at net.minecraft.entity.EntityLivingBase.writeEntityToNBT(EntityLivingBase.java:491) ~[EntityLivingBase.class:?]
   at net.minecraft.entity.EntityLiving.writeEntityToNBT(EntityLiving.java:313) ~[EntityLiving.class:?]
   at net.minecraft.entity.monster.EntitySkeleton.writeEntityToNBT(EntitySkeleton.java:404) ~[EntitySkeleton.class:?]
   at net.minecraft.entity.Entity.writeToNBT(Entity.java:1536) ~[Entity.class:?]
   ... 11 more
[17:33:52] [Server thread/INFO]: Saving chunks for level 'New World'/Nether
[17:33:52] [Server thread/INFO]: Saving chunks for level 'New World'/The End
[17:33:53] [Server thread/INFO] [FML]: Unloading dimension 0
[17:33:53] [Server thread/INFO] [FML]: Unloading dimension -1
[17:33:53] [Server thread/INFO] [FML]: Unloading dimension 1
[17:33:53] [Server thread/INFO] [FML]: Applying holder lookups
[17:33:53] [Server thread/INFO] [FML]: Holder lookups applied
[17:33:53] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[17:33:53] [Client thread/INFO] [FML]: Server terminated.
:runClient FAILED
BUILD FAILED
Total time: 44.765 secs
Task completed with return code 1 in 46530 milliseconds


 

I believe from what I have read, that it has trouble converting the NBT data? I am not too sure.  If anyone can help please help me fix my entity throwable.
 

Edited by KBEHAN on Tue, 02/28/2017 - 11:41
Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I have tried the same with
Tue, 02/28/2017 - 19:03

I have tried the same with Zombie, but still same crash

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I will try with different
Wed, 03/01/2017 - 20:51

I will try with different item, maybe seeds.

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ok, so major update!  code
Wed, 03/01/2017 - 21:03

Ok, so major update!  code for wheat_seeds works.  So problem was with air.  Hmm, I must know what to put so the Skeleton is holding air