From 376058ae61197c2416b75427d2e438198c7c6136 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 24 Sep 2020 00:14:23 +0200 Subject: [PATCH] Changelings disguised as spiders can climb walls --- .../unicopia/mixin/MixinLivingEntity.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java index e5ff403e..b7b1f4aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java @@ -1,6 +1,9 @@ package com.minelittlepony.unicopia.mixin; +import java.util.Optional; + import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; @@ -8,18 +11,24 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.Creature; import com.minelittlepony.unicopia.entity.PonyContainer; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.Equine; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.mob.SpiderEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; @Mixin(LivingEntity.class) abstract class MixinLivingEntity extends Entity implements PonyContainer> { + @Shadow + private Optional climbingPos; + private Equine caster; private MixinLivingEntity() { super(null, null); } @@ -37,6 +46,17 @@ abstract class MixinLivingEntity extends Entity implements PonyContainer info) { + if (get() instanceof Pony && horizontalCollision) { + DisguiseSpell disguise = ((Pony)get()).getSpell(DisguiseSpell.class, false); + if (disguise != null && disguise.getDisguise() instanceof SpiderEntity) { + climbingPos = Optional.of(getBlockPos()); + info.setReturnValue(true); + } + } + } + @Inject(method = "canSee(Lnet/minecraft/entity/Entity;)Z", at = @At("HEAD"), cancellable = true) private void onCanSee(Entity other, CallbackInfoReturnable info) { if (get().isInvisible()) {