Posted May 10, 201411 yr So I got this out of bounds error, and I see it's with the particle effects. I was shooting a weapon that leaves a particle effect trail, so I'm not sure how it got out of bounds. [19:08:26] [Client thread/FATAL]: Unreported exception thrown! java.lang.IndexOutOfBoundsException: Index: 3999, Size: 4000 at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.7.0_51] at java.util.ArrayList.get(Unknown Source) ~[?:1.7.0_51] at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:77) ~[EffectRenderer.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2153) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1036) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]
May 11, 201411 yr Author Can you show your particle spawning code? The code spawning it from the projectile: @Override public void onUpdate() { super.onUpdate(); for (int var3 = 0; var3 < 8; ++var3) { Powder var1 = new Powder(this.worldObj, this.posX, this.posY-1, this.posZ, 0.0D, 0.0D, 0.0D, 5); FMLClientHandler.instance().getClient().effectRenderer.addEffect(var1); } } And the actual particle code: @SideOnly(Side.CLIENT) public class Powder extends EntityFX { public float portalParticleScale; public int last; public Powder (World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int age) { super(par1World, par2, par4, par6, par8, par10, par12); this.last = age; this.motionX = par8 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; this.motionY = par10 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; this.motionZ = par12 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; float var14 = this.rand.nextFloat() * 0.6F + 0.4F; this.portalParticleScale = this.particleScale = this.rand.nextFloat() * 0.2F + 0.5F; this.particleRed = this.particleGreen = this.particleBlue = 1.0F * var14; this.particleGreen *= 0.3F; this.particleRed *= 0.9F; this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; this.particleMaxAge = (int)(16.0D / (this.rand.nextFloat() * 0.8D + 0.2D)) + 2; } /** * Called to update the entity's position/logic. */ @Override public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.particleAge++ >= this.particleMaxAge) { this.setDead(); } this.setParticleTextureIndex(7 - this.particleAge * last / this.particleMaxAge); this.motionY += 0.004D; this.motionX *= 0.8999999761581421D; this.motionY *= 0.8999999761581421D; this.motionZ *= 0.8999999761581421D; if (this.onGround) { this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; } } }
May 11, 201411 yr Author onUpdate get's called on both client & server. You must a) check for the client with world.isRemote and b) not call client-only stuff (particles) from common code (entities). My bad for B, I didn't actually copy this part, but right before the on update there is: @SideOnly(Side.CLIENT) <--- This @Override public void onUpdate() { super.onUpdate(); --- So I can assume the client only thing wasn't a problem. Now, for checking if the world is remote, I do this in the entity projectile file correct? So something like the following: @SideOnly(Side.CLIENT) @Override public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote) { for (int var3 = 0; var3 < 8; ++var3) { Powder var1 = new Powder(this.worldObj, this.posX, this.posY-1, this.posZ, 0.0D, 0.0D, 0.0D, 5); FMLClientHandler.instance().getClient().effectRenderer.addEffect(var1); } } }
May 11, 201411 yr Author @SideOnly does NOT do what you think it does. You should never actually use it. @SideOnly(Side.CLIENT) means the class/method/field will not be present in the minecraft_server.jar, only in the minecraft.jar. That means it WILL be present on the Integrated Server. isRemote doesn't do this and therefor is the way to go. Is the new place where I placed the isRemote [in previous post] correct? Also, in all my Render files I always have @SideOnly(Side.CLIENT) at the beginning because I was told a while back that's how you make things properly work for SMP. I assume this is okay for the render files though [like the mob render files]. However, for an entity I should always use the isRemote (I already had the isRemote in the weapon code for spawning the entity too)?
May 12, 201411 yr Author That is true. But then again: @SideOnly on the render files is not needed. If you do NOT have it and it crashes, adding it will most likely not fix it. Okay good to know. Thank you.
May 15, 201411 yr Author That is true. But then again: @SideOnly on the render files is not needed. If you do NOT have it and it crashes, adding it will most likely not fix it. So I just had this issue again, and with the previous fixes. Particle spawn: @Override public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote) { for (int var3 = 0; var3 < 8; ++var3) { Powder var1 = new Powder(this.worldObj, this.posX, this.posY-1, this.posZ, 0.0D, 0.0D, 0.0D, 5); FMLClientHandler.instance().getClient().effectRenderer.addEffect(var1); } } } Particle code: @SideOnly(Side.CLIENT) public class Powder extends EntityFX { public float portalParticleScale; public int last; public Powder (World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int age) { super(par1World, par2, par4, par6, par8, par10, par12); this.last = age; this.motionX = par8 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; this.motionY = par10 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; this.motionZ = par12 + (float)(Math.random() * 2.0D - 1.0D) * 0.05F; float var14 = this.rand.nextFloat() * 0.6F + 0.4F; this.portalParticleScale = this.particleScale = this.rand.nextFloat() * 0.2F + 0.5F; this.particleRed = this.particleGreen = this.particleBlue = 1.0F * var14; this.particleGreen *= 0.3F; this.particleRed *= 0.9F; this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; this.particleMaxAge = (int)(16.0D / (this.rand.nextFloat() * 0.8D + 0.2D)) + 2; } /** * Called to update the entity's position/logic. */ @Override public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.particleAge++ >= this.particleMaxAge) { this.setDead(); } this.setParticleTextureIndex(7 - this.particleAge * last / this.particleMaxAge); this.motionY += 0.004D; this.motionX *= 0.8999999761581421D; this.motionY *= 0.8999999761581421D; this.motionZ *= 0.8999999761581421D; if (this.onGround) { this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; } } }
May 15, 201411 yr You are now checking if the world is not remote, so if it's the server, you spawn the client-side particles and on the client it does nothing. I bet that's what you want 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/
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.