mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Fix issues disguising as crystal shards and prevent disguises from dropping items
This commit is contained in:
parent
1c2560c910
commit
c0cff59963
7 changed files with 40 additions and 22 deletions
|
@ -2,8 +2,14 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
|||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface Guest {
|
||||
void setHost(Caster<?> host);
|
||||
|
||||
Caster<?> getHost();
|
||||
|
||||
static boolean hasHost(Entity entity) {
|
||||
return ((Guest)entity).getHost() != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.minelittlepony.unicopia.entity.duck;
|
|||
import java.util.Set;
|
||||
|
||||
import com.minelittlepony.unicopia.compat.pehkui.PehkuiEntityExtensions;
|
||||
import com.minelittlepony.unicopia.entity.behaviour.Guest;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.Entity.RemovalReason;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
|
||||
public interface EntityDuck extends LavaAffine, PehkuiEntityExtensions {
|
||||
public interface EntityDuck extends LavaAffine, PehkuiEntityExtensions, Guest {
|
||||
|
||||
Set<TagKey<Fluid>> getSubmergedFluidTags();
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package com.minelittlepony.unicopia.entity.duck;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.behaviour.Guest;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public interface LivingEntityDuck extends Guest {
|
||||
public interface LivingEntityDuck extends EntityDuck {
|
||||
void updateItemUsage(Hand hand, ItemStack stack, int time);
|
||||
|
||||
boolean isJumping();
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.entity.behaviour.Guest;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||
|
||||
|
@ -172,9 +173,11 @@ public class CrystalShardsEntity extends StationaryObjectEntity {
|
|||
}
|
||||
}
|
||||
|
||||
if (isDead() || isInvalid(getWorld(), getBlockPos(), getAttachmentFace())) {
|
||||
kill();
|
||||
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, this, 10);
|
||||
if (!Guest.hasHost(this)) {
|
||||
if (isDead() || isInvalid(getWorld(), getBlockPos(), getAttachmentFace())) {
|
||||
kill();
|
||||
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, this, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ public abstract class StationaryObjectEntity extends Entity implements UDamageSo
|
|||
}
|
||||
|
||||
protected void onHurt() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.mixin;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -12,18 +13,35 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
import com.minelittlepony.unicopia.entity.duck.LavaAffine;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.duck.EntityDuck;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.Entity.PositionUpdater;
|
||||
import net.minecraft.entity.Entity.RemovalReason;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
abstract class MixinEntity implements EntityDuck {
|
||||
@Nullable
|
||||
private transient Caster<?> host;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Caster<?> getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHost(Caster<?> host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Accessor("submergedFluidTag")
|
||||
public abstract Set<TagKey<Fluid>> getSubmergedFluidTags();
|
||||
|
@ -83,4 +101,11 @@ abstract class MixinEntity implements EntityDuck {
|
|||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", at = @At("HEAD"), cancellable = true)
|
||||
private void onDropStack(ItemStack stack, float yOffset, CallbackInfoReturnable<ItemEntity> info) {
|
||||
if (getHost() != null) {
|
||||
info.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.mixin;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -41,8 +40,6 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ
|
|||
private Optional<BlockPos> climbingPos;
|
||||
|
||||
private Equine<?> caster;
|
||||
@Nullable
|
||||
private transient Caster<?> host;
|
||||
|
||||
private MixinLivingEntity() { super(null, null); }
|
||||
|
||||
|
@ -62,17 +59,6 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ
|
|||
return (Living<?>)caster;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Caster<?> getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHost(Caster<?> host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Accessor("jumping")
|
||||
public abstract boolean isJumping();
|
||||
|
|
Loading…
Reference in a new issue