Prevent transforming into paintings, item frames, or leash knots. Fixes #39

This commit is contained in:
Sollace 2021-12-28 02:58:07 +02:00
parent 8edf3cee6c
commit c31eba5f04
4 changed files with 13 additions and 4 deletions

View file

@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.util.RayTraceHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.sound.SoundCategory;
@ -43,7 +44,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
RayTraceHelper.Trace trace = RayTraceHelper.doTrace(player, 10, 1, EntityPredicates.EXCEPT_SPECTATOR.and(e -> !(e instanceof LightningEntity)));
Entity looked = trace.getEntity().map(e -> {
Entity looked = trace.getEntity().filter(e -> !(e instanceof AbstractDecorationEntity)).map(e -> {
return e instanceof PlayerEntity ? Pony.of((PlayerEntity)e)
.getSpellSlot()
.get(SpellPredicate.IS_DISGUISE, true)

View file

@ -20,6 +20,7 @@ import net.minecraft.command.argument.NbtCompoundArgumentType;
import net.minecraft.command.suggestion.SuggestionProviders;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.command.CommandManager;
@ -77,7 +78,7 @@ public class DisguiseCommand {
}
static int disguise(ServerCommandSource source, PlayerEntity player, Entity entity) throws CommandSyntaxException {
if (entity == null) {
if (entity == null || entity instanceof AbstractDecorationEntity) {
throw FAILED_EXCEPTION.create();
}

View file

@ -269,7 +269,8 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
public boolean skipsUpdate() {
return entity instanceof FallingBlockEntity
|| entity instanceof AbstractDecorationEntity
|| entity instanceof PlayerEntity;
|| entity instanceof PlayerEntity
|| entity instanceof AbstractDecorationEntity;
}
public boolean isAxisAligned() {

View file

@ -20,6 +20,7 @@ import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.passive.LlamaEntity;
import net.minecraft.entity.passive.SnowGolemEntity;
@ -112,7 +113,12 @@ public class EntityBehaviour<T extends Entity> {
boolean clip = to.noClip;
to.noClip = false;
Vec3d vel = from.getRotationVec(1);
to.move(MovementType.SELF, vel);
if (!(to instanceof AbstractDecorationEntity)) {
to.move(MovementType.SELF, vel);
} else {
to.setVelocity(Vec3d.ZERO);
}
to.noClip = clip;
} else {
to.verticalCollision = from.verticalCollision;