Help with fixing exploit in my mod.

Started by unlisted eevee on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 12:32, 17. May 2024
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with fixing exploit in my mod.

There exists a bug inside of my mod where a projectile when thrown upwards in the air does not disappear upon hitting a player. The projectile seems to stay on top of the player. This is bad because when the projectile hits a player, a procedure is executed that gives effects to the player, making this bug an exploit as you can get the effects infinitely. I have only observed this behavior with player entities. I have attached the procedure that is executed when the projectile hits the player, and the genreated code. 

package net.mcreator.impossiblecore.procedures;

/* imports omitted */

public class SpiderVenomThrownHitsEntityProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		assert Boolean.TRUE; //#dbg:SpiderVenomThrownHitsEntity:mixinsProjectilesSpiderVenomThrownHitsEntity
		if (!entity.getType().is(TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation("minecraft:venom_immune_entites")))) {
			if (world instanceof Level _level) {
				if (!_level.isClientSide()) {
					_level.playSound(null, BlockPos.containing(x, y, z), BuiltInRegistries.SOUND_EVENT.get(new ResourceLocation("entity.splash_potion.break")), SoundSource.PLAYERS, 1, 1);
				} else {
					_level.playLocalSound(x, y, z, BuiltInRegistries.SOUND_EVENT.get(new ResourceLocation("entity.splash_potion.break")), SoundSource.PLAYERS, 1, 1, false);
				}
			}
			if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
				_entity.addEffect(new MobEffectInstance(MobEffects.POISON, 1200, 2));
			if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
				_entity.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1200, 6));
			if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
				_entity.addEffect(new MobEffectInstance(MobEffects.WEAKNESS, 1200, 6));
			if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
				_entity.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 1200, 2));
			if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
				_entity.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 600, 2));
		}
	}
}

Good things to know: The player entity is NOT tagged in venom_immune_entites