fix several entities not protected on indirect non projectile player attacks (e.g. through player ignited tnt) fix #52
This commit is contained in:
parent
b2830bea2c
commit
54d0035b44
@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
|
|||||||
loader_version=0.9.1+build.205
|
loader_version=0.9.1+build.205
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.3.2
|
mod_version = 1.3.3
|
||||||
maven_group = com.flemmli97.flan
|
maven_group = com.flemmli97.flan
|
||||||
archives_base_name = flan
|
archives_base_name = flan
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import net.minecraft.entity.projectile.thrown.EnderPearlEntity;
|
|||||||
import net.minecraft.entity.projectile.thrown.PotionEntity;
|
import net.minecraft.entity.projectile.thrown.PotionEntity;
|
||||||
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
||||||
import net.minecraft.entity.vehicle.BoatEntity;
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
import net.minecraft.entity.vehicle.MinecartEntity;
|
|
||||||
import net.minecraft.entity.vehicle.StorageMinecartEntity;
|
import net.minecraft.entity.vehicle.StorageMinecartEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
|
import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
|
||||||
@ -165,9 +164,9 @@ public class EntityInteractEvents {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean preventDamage(LivingEntity entity, DamageSource source) {
|
public static boolean preventDamage(Entity entity, DamageSource source) {
|
||||||
if (source.getAttacker() instanceof ServerPlayerEntity)
|
if (source.getAttacker() instanceof ServerPlayerEntity)
|
||||||
return attackSimple((ServerPlayerEntity) source.getAttacker(), entity, false) != ActionResult.PASS;
|
return attackSimple((ServerPlayerEntity) source.getAttacker(), entity, true) != ActionResult.PASS;
|
||||||
else if (source.isExplosive() && !entity.world.isClient) {
|
else if (source.isExplosive() && !entity.world.isClient) {
|
||||||
IPermissionContainer claim = ClaimStorage.get((ServerWorld) entity.world).getForPermissionCheck(entity.getBlockPos());
|
IPermissionContainer claim = ClaimStorage.get((ServerWorld) entity.world).getForPermissionCheck(entity.getBlockPos());
|
||||||
return claim != null && !claim.canInteract(null, PermissionRegistry.EXPLOSIONS, entity.getBlockPos());
|
return claim != null && !claim.canInteract(null, PermissionRegistry.EXPLOSIONS, entity.getBlockPos());
|
||||||
@ -185,7 +184,7 @@ public class EntityInteractEvents {
|
|||||||
BlockPos pos = entity.getBlockPos();
|
BlockPos pos = entity.getBlockPos();
|
||||||
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
||||||
if (claim != null) {
|
if (claim != null) {
|
||||||
if (entity instanceof ArmorStandEntity || entity instanceof MinecartEntity || entity instanceof BoatEntity || entity instanceof ItemFrameEntity)
|
if (!(entity instanceof LivingEntity))
|
||||||
return claim.canInteract(player, PermissionRegistry.BREAKNONLIVING, pos, message) ? ActionResult.PASS : ActionResult.FAIL;
|
return claim.canInteract(player, PermissionRegistry.BREAKNONLIVING, pos, message) ? ActionResult.PASS : ActionResult.FAIL;
|
||||||
if (entity instanceof PlayerEntity)
|
if (entity instanceof PlayerEntity)
|
||||||
return claim.canInteract(player, PermissionRegistry.HURTPLAYER, pos, message) ? ActionResult.PASS : ActionResult.FAIL;
|
return claim.canInteract(player, PermissionRegistry.HURTPLAYER, pos, message) ? ActionResult.PASS : ActionResult.FAIL;
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.flemmli97.flan.mixin;
|
||||||
|
|
||||||
|
import com.flemmli97.flan.event.EntityInteractEvents;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import net.minecraft.entity.decoration.AbstractDecorationEntity;
|
||||||
|
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||||
|
import net.minecraft.entity.decoration.EndCrystalEntity;
|
||||||
|
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
||||||
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin({LivingEntity.class, Entity.class, AbstractDecorationEntity.class, AbstractMinecartEntity.class, ArmorStandEntity.class, BoatEntity.class
|
||||||
|
, EndCrystalEntity.class, ItemEntity.class})
|
||||||
|
public abstract class EntityDamageMixin {
|
||||||
|
|
||||||
|
@Inject(method = "damage", at = @At(value = "HEAD"), cancellable = true)
|
||||||
|
public void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
|
||||||
|
if (EntityInteractEvents.preventDamage((Entity) (Object) this, source)) {
|
||||||
|
info.setReturnValue(false);
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
package com.flemmli97.flan.mixin;
|
|
||||||
|
|
||||||
import com.flemmli97.flan.event.EntityInteractEvents;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(LivingEntity.class)
|
|
||||||
public abstract class LivingEntityMixin {
|
|
||||||
|
|
||||||
@Inject(method = "damage", at = @At(value = "HEAD"), cancellable = true)
|
|
||||||
public void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
|
|
||||||
if (EntityInteractEvents.preventDamage((LivingEntity) (Object) this, source)) {
|
|
||||||
info.setReturnValue(false);
|
|
||||||
info.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,7 @@
|
|||||||
"XpEntityMixin",
|
"XpEntityMixin",
|
||||||
"WitherMixin",
|
"WitherMixin",
|
||||||
"IPersistentProjectileVars",
|
"IPersistentProjectileVars",
|
||||||
"LivingEntityMixin",
|
"EntityDamageMixin",
|
||||||
"ItemStackMixin",
|
"ItemStackMixin",
|
||||||
"ILecternBlockValues",
|
"ILecternBlockValues",
|
||||||
"FluidMixin",
|
"FluidMixin",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user