Changelings disguised as spiders can climb walls

This commit is contained in:
Sollace 2020-09-24 00:14:23 +02:00
parent a4c0d936f4
commit 376058ae61

View file

@ -1,6 +1,9 @@
package com.minelittlepony.unicopia.mixin; package com.minelittlepony.unicopia.mixin;
import java.util.Optional;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject; 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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 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.Creature;
import com.minelittlepony.unicopia.entity.PonyContainer; import com.minelittlepony.unicopia.entity.PonyContainer;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.Equine; import com.minelittlepony.unicopia.entity.Equine;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.SpiderEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@Mixin(LivingEntity.class) @Mixin(LivingEntity.class)
abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<?>> { abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<?>> {
@Shadow
private Optional<BlockPos> climbingPos;
private Equine<?> caster; private Equine<?> caster;
private MixinLivingEntity() { super(null, null); } private MixinLivingEntity() { super(null, null); }
@ -37,6 +46,17 @@ abstract class MixinLivingEntity extends Entity implements PonyContainer<Equine<
return caster; return caster;
} }
@Inject(method = "isClimbing()Z", at = @At("HEAD"), cancellable = true)
public void onIsClimbing(CallbackInfoReturnable<Boolean> 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) @Inject(method = "canSee(Lnet/minecraft/entity/Entity;)Z", at = @At("HEAD"), cancellable = true)
private void onCanSee(Entity other, CallbackInfoReturnable<Boolean> info) { private void onCanSee(Entity other, CallbackInfoReturnable<Boolean> info) {
if (get().isInvisible()) { if (get().isInvisible()) {