Jump to content

Conkeegs

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Conkeegs

  1. I'm using the net.minecraftforge:forge:1.19.4-45.0.63 gradle dependency. For clarification, this does not occur when I remove the mod from my server. I've got an event listener in my mod that listens for explosions, cancels the original explosion, and creates a new custom one. I know this is probably not the best way to do this at all (if you know a better way feel free to let me know), but when the new explosion goes off, fps seems to drop in the chunk where the explosion occurred. It's very apparent when breaking blocks very fast (either in creative mode or with a high-efficiency pickaxe), and I'm afraid that the new explosion I created holds on to some resources under the hood? Not sure. When you move out of the chunk and mine blocks outside of it, the lag seems to go away. It's like one chunk is affected, and when the server restarts, the lag goes away in that chunk. It's only after explosions that the lag appears. Here's the event handler: private static final Map<String, Float> modifiedExplosions = ExplosionRegistry.getInstance().getAllEntities(); @SubscribeEvent public static void onExplosionDetonate(ExplosionEvent.Start event) { Explosion explosion = event.getExplosion(); Entity thingThatExploded = explosion.getExploder(); if (thingThatExploded != null) { String thingThatExplodedClassName = thingThatExploded.getClass().getSimpleName(); if (modifiedExplosions.containsKey(thingThatExplodedClassName)) { event.setCanceled(true); customExplosion = new Explosion( thingThatExploded.level, thingThatExploded, explosion.getDamageSource(), null, thingThatExploded.getX(), thingThatExploded.getY(), thingThatExploded.getZ(), modifiedExplosions.get(thingThatExplodedClassName), false, Explosion.BlockInteraction.DESTROY); customExplosion.explode(); customExplosion.finalizeExplosion(true); thingThatExploded.discard(); } } } And here's the explosion registry I created from the private variable above: package com.conkeegs.truehardcore.registries.explosions; import java.util.HashMap; import java.util.Map; import net.minecraft.world.entity.monster.Creeper; import net.minecraft.world.entity.projectile.LargeFireball; public class ExplosionRegistry { private static ExplosionRegistry instance; private Map<String, Float> entityMap; private ExplosionRegistry() { entityMap = new HashMap<>(); this.addEntity(Creeper.class.getSimpleName(), 10F); // fix power this.addEntity(LargeFireball.class.getSimpleName(), 10F); } public static ExplosionRegistry getInstance() { if (instance == null) { instance = new ExplosionRegistry(); } return instance; } public Map<String, Float> getAllEntities() { return entityMap; } private void addEntity(String entityName, Float explosionRadius) { entityMap.put(entityName, explosionRadius); } }
×
×
  • Create New...

Important Information

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