mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Fixed crash when players have disguised as other players
This commit is contained in:
parent
9f6826ee7d
commit
67a894958c
5 changed files with 13 additions and 55 deletions
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import com.minelittlepony.unicopia.ability.magic.CasterView;
|
import com.minelittlepony.unicopia.ability.magic.CasterView;
|
||||||
import com.minelittlepony.unicopia.block.data.Ether;
|
import com.minelittlepony.unicopia.block.data.Ether;
|
||||||
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
|
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
|
||||||
import com.minelittlepony.unicopia.entity.player.dummy.DummyServerPlayerEntity;
|
|
||||||
import com.minelittlepony.unicopia.network.handler.ClientNetworkHandler;
|
import com.minelittlepony.unicopia.network.handler.ClientNetworkHandler;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
@ -99,9 +98,6 @@ public class InteractionManager {
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlayerEntity createPlayer(World world, GameProfile profile) {
|
public PlayerEntity createPlayer(World world, GameProfile profile) {
|
||||||
if (world instanceof ServerWorld) {
|
|
||||||
return new DummyServerPlayerEntity((ServerWorld)world, profile);
|
|
||||||
}
|
|
||||||
return new DummyPlayerEntity(world, profile);
|
return new DummyPlayerEntity(world, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ public class MindSwapSpell extends MimicSpell {
|
||||||
|
|
||||||
if (counterpart.getId().isPresent() && counterpart.get(caster.getReferenceWorld()) == null) {
|
if (counterpart.getId().isPresent() && counterpart.get(caster.getReferenceWorld()) == null) {
|
||||||
caster.getMaster().damage(DamageSource.MAGIC, Float.MAX_VALUE);
|
caster.getMaster().damage(DamageSource.MAGIC, Float.MAX_VALUE);
|
||||||
|
setDead();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,8 +194,6 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Caster.of(entity).ifPresent(c -> c.getSpellSlot().clear());
|
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
((LivingEntity) entity).getAttributeInstance(UEntityAttributes.ENTITY_GRAVTY_MODIFIER).clearModifiers();
|
((LivingEntity) entity).getAttributeInstance(UEntityAttributes.ENTITY_GRAVTY_MODIFIER).clearModifiers();
|
||||||
}
|
}
|
||||||
|
@ -343,9 +341,13 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
||||||
}
|
}
|
||||||
entityNbt.putString("playerName", profile.getName());
|
entityNbt.putString("playerName", profile.getName());
|
||||||
entityNbt.putByte("playerVisibleParts", player.getDataTracker().get(Disguise.PlayerAccess.getModelBitFlag()));
|
entityNbt.putByte("playerVisibleParts", player.getDataTracker().get(Disguise.PlayerAccess.getModelBitFlag()));
|
||||||
entityNbt.put("playerNbt", player.writeNbt(new NbtCompound()));
|
|
||||||
|
NbtCompound playerNbt = player.writeNbt(new NbtCompound());
|
||||||
|
playerNbt.remove("unicopia_caster");
|
||||||
|
entityNbt.put("playerNbt", playerNbt);
|
||||||
} else {
|
} else {
|
||||||
entity.saveSelfNbt(entityNbt);
|
entity.saveSelfNbt(entityNbt);
|
||||||
|
entityNbt.remove("unicopia_caster");
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityNbt;
|
return entityNbt;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.Owned;
|
import com.minelittlepony.unicopia.Owned;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -24,6 +25,11 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned<PlayerEntit
|
||||||
/*noop*/
|
/*noop*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBlockCollision(BlockState state) {
|
||||||
|
/*noop*/
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlayerEntity getMaster() {
|
public PlayerEntity getMaster() {
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.entity.player.dummy;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
|
||||||
import com.minelittlepony.unicopia.Owned;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
|
|
||||||
public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned<PlayerEntity> {
|
|
||||||
|
|
||||||
private PlayerEntity owner;
|
|
||||||
|
|
||||||
public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) {
|
|
||||||
super(world.getServer(), world, profile, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void playEquipSound(ItemStack stack) {
|
|
||||||
/*noop*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onBlockCollision(BlockState state) {
|
|
||||||
/*noop*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public PlayerEntity getMaster() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaster(PlayerEntity owner) {
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldRenderName() {
|
|
||||||
return !InteractionManager.instance().isClientPlayer(getMaster());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue