mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Global Loot Modifiers
This commit is contained in:
63 files changed
+1058
-1502
No files matched your search
@@ -15,8 +15,6 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.common.ServerboundClientInformationPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQuery;
|
||||
import net.minecraft.network.protocol.game.ServerboundChangeDifficultyPacket;
|
||||
@@ -76,7 +74,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* A basic fake server player implementation that can be used to simulate player actions.
|
||||
*/
|
||||
@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
// TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
public class FakePlayer extends ServerPlayer {
|
||||
protected FakePlayer(ServerLevel level, GameProfile name, ClientInformation info) {
|
||||
super(level.getServer(), level, name, info);
|
||||
|
||||
@@ -14,17 +14,14 @@ import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
|
||||
|
||||
@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
public class FakePlayerFactory
|
||||
{
|
||||
// TODO: Re-write this whole system to be less hacky. Use until we get a good replacement.
|
||||
public class FakePlayerFactory {
|
||||
private static final GameProfile MINECRAFT = new GameProfile(UUID.fromString("41C82C87-7AfB-4024-BA57-13D2C99CAE77"), "[Minecraft]");
|
||||
// Map of all active fake player usernames to their entities
|
||||
private static final Map<FakePlayerKey, FakePlayer> fakePlayers = Maps.newHashMap();
|
||||
private record FakePlayerKey(ServerLevel level, GameProfile username) { }
|
||||
|
||||
public static FakePlayer getMinecraft(ServerLevel level)
|
||||
{
|
||||
public static FakePlayer getMinecraft(ServerLevel level) {
|
||||
return get(level, MINECRAFT);
|
||||
}
|
||||
|
||||
@@ -34,14 +31,12 @@ public class FakePlayerFactory
|
||||
* WorldEvent.Unload and kill all references to prevent worlds staying in memory,
|
||||
* or call this function every time and let Forge take care of the cleanup.
|
||||
*/
|
||||
public static FakePlayer get(ServerLevel level, GameProfile username)
|
||||
{
|
||||
public static FakePlayer get(ServerLevel level, GameProfile username) {
|
||||
FakePlayerKey key = new FakePlayerKey(level, username);
|
||||
return fakePlayers.computeIfAbsent(key, FakePlayerFactory::create);
|
||||
}
|
||||
|
||||
public static void unloadLevel(ServerLevel level)
|
||||
{
|
||||
public static void unloadLevel(ServerLevel level) {
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().level() == level);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user