From 63bd4258e1b1eadcc7d72d46b639dda1205c4959 Mon Sep 17 00:00:00 2001 From: Carbon5 <37130077+Carbon5@users.noreply.github.com> Date: Thu, 8 Jul 2021 20:52:39 -0400 Subject: [PATCH] Superglue follows mobGriefing gamerule --- .../structureMovement/glue/SuperGlueEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java index 54ec8d2a3..2e206b129 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java @@ -30,6 +30,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; +import net.minecraft.entity.MobEntity; import net.minecraft.entity.MoverType; import net.minecraft.entity.Pose; import net.minecraft.entity.effect.LightningBoltEntity; @@ -55,6 +56,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.GameRules; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; @@ -261,6 +263,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) return false; + + boolean mobGriefing = world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); + Entity trueSource = source.getTrueSource(); + if (!mobGriefing && trueSource instanceof MobEntity) + return false; + Entity immediateSource = source.getImmediateSource(); if (!isVisible() && immediateSource instanceof PlayerEntity) { if (!AllItems.SUPER_GLUE.isIn(((PlayerEntity) immediateSource).getHeldItemMainhand()))