mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Try and prevent cloned players from polluting the environment
This commit is contained in:
parent
3a18054752
commit
806538858e
1 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
|
@ -15,6 +16,7 @@ import com.minelittlepony.unicopia.entity.behaviour.Inventory;
|
|||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.FakePlayer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -180,6 +182,9 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
|||
final GameMode aMode = a.interactionManager.getGameMode();
|
||||
final GameMode bMode = b.interactionManager.getGameMode();
|
||||
|
||||
final UUID aUUid = a.getUuid();
|
||||
final UUID bUUid = b.getUuid();
|
||||
|
||||
final ServerPlayerEntity aClone = clonePlayer(a);
|
||||
final ServerPlayerEntity bClone = clonePlayer(b);
|
||||
|
||||
|
@ -189,6 +194,9 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
|||
a.copyFrom(bClone, true);
|
||||
b.copyFrom(aClone, true);
|
||||
|
||||
a.setUuid(aUUid);
|
||||
b.setUuid(bUUid);
|
||||
|
||||
a.interactionManager.changeGameMode(aMode);
|
||||
b.interactionManager.changeGameMode(bMode);
|
||||
|
||||
|
@ -208,11 +216,16 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
|||
}
|
||||
|
||||
private static ServerPlayerEntity clonePlayer(ServerPlayerEntity player) {
|
||||
ServerPlayerEntity clone = new ServerPlayerEntity(player.getServer(), player.getServerWorld(), player.getGameProfile()) {
|
||||
ServerPlayerEntity clone = new FakePlayer(player.getServerWorld(), player.getGameProfile()) {
|
||||
@Override
|
||||
public void tick() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuid(UUID uuid) {
|
||||
super.setUuid(UUID.randomUUID());
|
||||
}
|
||||
};
|
||||
|
||||
NbtCompound compound = player.writeNbt(new NbtCompound());
|
||||
|
|
Loading…
Reference in a new issue