Jump to content

1.7.10 | Game Crashes after particles spawn in (Instant or after period of time)


Recommended Posts

Posted

Having a few issues when spawning in a custom Particle Entity.

 

When particles spawn in, game crashes with an error like following:

Reported exception thrown!

net.minecraft.util.ReportedException: Ticking Particle

at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:102) ~[EffectRenderer.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2146) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]

at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: java.lang.NullPointerException

at net.minecraft.entity.Entity.moveEntity(Entity.java:692) ~[Entity.class:?]

at net.minecraft.client.particle.EntityAuraFX.onUpdate(EntityAuraFX.java:37) ~[EntityAuraFX.class:?]

at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:79) ~[EffectRenderer.class:?]

... 12 more

[00:15:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----

// Hey, that tickles! Hehehe!

 

Event Handler to spawn in particles (Blood):

public class DamageHandler {

 

    @SubscribeEvent

    public void playerTick(LivingHurtEvent event) {

        if (event.entity instanceof EntityPlayer) {

            EntityPlayer theEntity = (EntityPlayer) event.entity;

            double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            for (int i = 1; i < 4; i++) {

                EntityFX particleBlood = new EntityParticleBlood(theEntity.worldObj,

                        theEntity.posX + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        theEntity.posY + 0.5D + theEntity.worldObj.rand.nextFloat() * theEntity.height,

                        theEntity.posZ + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        motionX, motionY, motionZ);

                Minecraft.getMinecraft().effectRenderer.addEffect(particleBlood);

            }

        }

        if (event.entity instanceof EntityInfected) {

            EntityInfected theEntity = (EntityInfected) event.entity;

            double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D;

            for (int i = 1; i < 4; i++) {

                EntityFX particleInfectedBlood = new EntityParticleInfectedBlood(theEntity.worldObj,

                        theEntity.posX + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        theEntity.posY + 0.5D + theEntity.worldObj.rand.nextFloat() * theEntity.height,

                        theEntity.posZ + theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F - theEntity.width,

                        motionX, motionY, motionZ);

                Minecraft.getMinecraft().effectRenderer.addEffect(particleInfectedBlood);

            }

        }

    }

 

}

Actual Particle Entity:

public class EntityParticleInfectedBlood extends EntityAuraFX

{

    public EntityParticleInfectedBlood(World parWorld,

                                      double parX, double parY, double parZ,

                                      double parMotionX, double parMotionY, double parMotionZ)

    {

        super(parWorld, parX, parY, parZ, parMotionX, parMotionY, parMotionZ);

        setParticleTextureIndex(80); // same as happy villager

        particleScale = 2.0F;

        particleGravity = 5.5F;

        motionY = -0.2D;

        setRBGColorF(0x88, 0x00, 0x88);

        noClip = false;

    }

}

 

Event Handler is registered under preInit stage:

        if (event.getSide() == Side.CLIENT) {

            this.keyHandler = new InputHandler();

            FMLCommonHandler.instance().bus().register((Object)this.keyHandler);

            FMLCommonHandler.instance().bus().register(new DamageHandler());

            MinecraftForge.EVENT_BUS.register(new DamageHandler());

 

        }

 

If anyone knows how to fix this error, please let me know. Thanks :)

Posted

Considering that you are working on project such as yours, one could expect that you know what you are doing - yet, you know nothing about not only internals but also the game design itself.

 

This had to be said, because "for my next trick" I will send you back to absolute ROOTS of modding! YAY! :)

Those roots are obviously - SIDES!

http://mcforge.readthedocs.io/en/latest/concepts/sides/

 

You are referring to @SideOnly stuff (Minecraft.class) from common code. If that was not bad enough - you are doing it from code that is fired ONLY on server (LivingHurtEvent). That all basically means you are accessing client thread from server thread (particles from hurt event) which is HERESY in modding world. In addition you are using stuff that was NEVER supposed to be used (event.getSide(), which can be effectively eliminated using @SidedProxy). There are also minor problems like wtf is that Object cast doing in key handler?

 

Like for reals man - If I were to explain where lies your problem I'd have to write whole damn essay on how to do things right.

 

 

 

That is why I am sending you to actually read good portion of docs and maybe other sources (google?).

After that - redesign your structures from ground up, apply @SidedProxy, make some experiments (like on which side and when event is fired - simple Syso can show you), check callbacks of events to know how they work. Idk... all kinds of stuff.

 

You don't dive in serious modding if you are not prepared! That will only cause that in few weeks you will have to rewrite everything you wrote.

 

Not to mention the fact that you are on 1.7.10... Jeeeeez - have fun updating after, when you finish your mod, it will turn out that noone is playing 1.7 anymore (1.7 code is so different that it will basically go to trashcan). Like for real - 1.8+ is million times better than previous (in structure... no wait - everything!).

1.7.10 is no longer supported by forge, you are on your own.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
  • Topics

×
×
  • Create New...

Important Information

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