mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-04-18 14:50:49 +08:00
Use same fake player system between Fabric & Forge
This commit is contained in:
parent
b9c39c9a74
commit
deb04a5ecb
@ -16,7 +16,7 @@ val minecraftVersion = "1.20.2"
|
||||
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
||||
"$useless.${major.toInt() + 1}"
|
||||
}
|
||||
val forgeVersion = "48.0.1"
|
||||
val forgeVersion = "48.0.20"
|
||||
|
||||
val apiClasspath = configurations.create("apiClasspath") {
|
||||
isCanBeResolved = true
|
||||
|
@ -20,34 +20,46 @@
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ClientInformation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WorldEditFakePlayer extends FakePlayer {
|
||||
private static final GameProfile FAKE_GAME_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
|
||||
public class WorldEditFakePlayer extends ServerPlayer {
|
||||
private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
|
||||
private static final ClientInformation FAKE_CLIENT_INFO = new ClientInformation(
|
||||
"en_US", 16, ChatVisiblity.FULL, true, 0, HumanoidArm.LEFT, false, false
|
||||
);
|
||||
|
||||
public WorldEditFakePlayer(ServerLevel world) {
|
||||
super(world, FAKE_GAME_PROFILE, FAKE_CLIENT_INFO);
|
||||
super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, FAKE_CLIENT_INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(boolean checkHunger) {
|
||||
public void tick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int incrementer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayClientMessage(Component message, boolean actionBar) {
|
||||
super.displayClientMessage(message, actionBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource damageSource) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionalInt openMenu(@Nullable MenuProvider menuProvider) {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user