Skip to content

Commit

Permalink
Rebuild patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Dec 7, 2024
1 parent f71e865 commit 70ec31a
Show file tree
Hide file tree
Showing 26 changed files with 500 additions and 20 deletions.
26 changes: 26 additions & 0 deletions patches/net/minecraft/commands/CommandSource.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/net/minecraft/commands/CommandSource.java
+++ b/net/minecraft/commands/CommandSource.java
@@ -22,6 +_,13 @@
public boolean shouldInformAdmins() {
return false;
}
+
+ // CraftBukkit start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return wrapper.getServer().console;
+ }
+ // CraftBukkit end
};

void sendSystemMessage(Component p_230797_);
@@ -34,5 +_,9 @@

default boolean alwaysAccepts() {
return false;
+ }
+
+ default org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return NULL.getBukkitSender(wrapper);
}
}
22 changes: 22 additions & 0 deletions patches/net/minecraft/commands/CommandSourceStack.java.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
--- a/net/minecraft/commands/CommandSourceStack.java
+++ b/net/minecraft/commands/CommandSourceStack.java
@@ -9,6 +_,7 @@
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import com.mojang.brigadier.tree.CommandNode;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
@@ -46,7 +_,7 @@
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
Expand All @@ -9,3 +17,17 @@
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
public final CommandSource source;
@@ -64,6 +_,13 @@
private final Vec2 rotation;
private final CommandSigningContext signingContext;
private final TaskChainer chatMessageChainer;
+ public volatile CommandNode currentCommand; // CraftBukkit
+
+ // CraftBukkit start
+ public org.bukkit.command.CommandSender getBukkitSender() {
+ return source.getBukkitSender(this);
+ }
+ // CraftBukkit end

public CommandSourceStack(
CommandSource p_81302_,
4 changes: 3 additions & 1 deletion patches/net/minecraft/network/Connection.java.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -107,6 +_,8 @@
@@ -107,6 +_,10 @@
private volatile DisconnectionDetails delayedDisconnect;
@Nullable
BandwidthDebugMonitor bandwidthDebugMonitor;
+ @Nullable
+ private ProtocolInfo<?> inboundProtocol;
+
+ public String hostname = ""; // CraftBukkit - add field

public Connection(PacketFlow p_129482_) {
this.receiving = p_129482_;
Expand Down
69 changes: 68 additions & 1 deletion patches/net/minecraft/server/MinecraftServer.java.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,74 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -275,7 +_,7 @@
@@ -37,10 +_,12 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
@@ -51,6 +_,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
+import joptsimple.OptionSet;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.FileUtil;
@@ -172,6 +_,10 @@
import net.minecraft.world.level.storage.WorldData;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.Bukkit;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.craftbukkit.CraftRegistry;
+import org.bukkit.craftbukkit.CraftServer;
import org.slf4j.Logger;

public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements ServerInfo, ChunkIOErrorReporter, CommandSource {
@@ -273,9 +_,42 @@
private final SuppressedExceptionCollector suppressedExceptions = new SuppressedExceptionCollector();
private final DiscontinuousFrame tickFrame;

+ // CraftBukkit start
+ public static WorldLoader.DataLoadContext worldLoader;
+ public CraftServer server;
+ public static OptionSet options;
+ public ConsoleCommandSender console;
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
+ public Queue<Runnable> processQueue = new ConcurrentLinkedQueue<Runnable>();
+ public int autosavePeriod;
+ public Commands vanillaCommandDispatcher;
+ private boolean forceTicks;
+ // CraftBukkit end
+ // Spigot start
+ public static final int TPS = 20;
+ public static final int TICK_TIME = 1000000000 / TPS;
+ private static final int SAMPLE_INTERVAL = 100;
+ public final double[] recentTps = new double[ 3 ];
+ // Spigot end
+
+ // CraftBukkit start
+ public static MinecraftServer getServer() {
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+ }
+
+ @Deprecated
+ public static RegistryAccess getDefaultRegistryAccess() {
+ return CraftRegistry.getMinecraftRegistry();
+ }
+
+ public boolean isDebugging() {
+ return false;
+ }
+ // CraftBukkit end
+
public static <S extends MinecraftServer> S spin(Function<Thread, S> p_129873_) {
AtomicReference<S> atomicreference = new AtomicReference<>();
- Thread thread = new Thread(() -> atomicreference.get().runServer(), "Server thread");
Expand Down
22 changes: 22 additions & 0 deletions patches/net/minecraft/server/commands/DebugCommand.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/net/minecraft/server/commands/DebugCommand.java
+++ b/net/minecraft/server/commands/DebugCommand.java
@@ -37,6 +_,7 @@
import net.minecraft.util.TimeUtil;
import net.minecraft.util.profiling.ProfileResults;
import org.apache.commons.io.IOUtils;
+import org.bukkit.command.CommandSender;
import org.slf4j.Logger;

public class DebugCommand {
@@ -263,6 +_,11 @@
@Override
public void close() {
IOUtils.closeQuietly((Writer)this.output);
+ }
+
+ @Override
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -57,6 +_,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.level.storage.LevelStorageSource;
+import org.bukkit.command.CommandSender;
import org.slf4j.Logger;

public class DedicatedServer extends MinecraftServer implements ServerInterface {
@@ -79,6 +_,8 @@
@Nullable
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
private final ServerLinks serverLinks;
public ServerLinks serverLinks;
+ @Nullable
+ private net.minecraft.client.server.LanServerPinger dediLanPinger;

Expand Down Expand Up @@ -68,3 +76,19 @@
Util.shutdownExecutors();
SkullBlockEntity.clear();
}
@@ -625,5 +_,15 @@
return Optional.empty();
}
}
+ }
+
+ // CraftBukkit start
+ public boolean isDebugging() {
+ return this.getProperties().debug;
+ }
+
+ @Override
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return console;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
public final boolean pvp = this.get("pvp", true);
@@ -103,6 +_,7 @@
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
public final WorldOptions worldOptions;
public boolean acceptsTransfers = this.get("accepts-transfers", false);
+ public final boolean debug = this.get("debug", false); // CraftBukkit

public DedicatedServerProperties(Properties p_180926_) {
super(p_180926_);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@@ -50,6 +_,7 @@
final Executor mainThreadExecutor;
private long ticketTickCounter;
private int simulationDistance = 10;
public int simulationDistance = 10;
+ private final Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> forcedTickets = new Long2ObjectOpenHashMap<>();

protected DistanceManager(Executor p_140774_, Executor p_140775_) {
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/server/level/Ticket.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@@ -9,9 +_,14 @@
private long createdTick;

protected Ticket(TicketType<T> p_9425_, int p_9426_, T p_9427_) {
public Ticket(TicketType<T> p_9425_, int p_9426_, T p_9427_) {
+ this(p_9425_, p_9426_, p_9427_, false);
+ }
+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/packs/repository/Pack.java
+++ b/net/minecraft/server/packs/repository/Pack.java
@@ -23,6 +_,16 @@
private final Pack.ResourcesSupplier resources;
public final Pack.ResourcesSupplier resources;
private final Pack.Metadata metadata;
private final PackSelectionConfig selectionConfig;
+ private final boolean hidden; // Neo: Allow packs to be hidden from the UI entirely
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/server/players/PlayerList.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
+ net.neoforged.neoforge.event.EventHooks.firePlayerLoggedIn( p_11263_ );
}

protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) {
public void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) {
@@ -301,6 +_,7 @@
optional = Optional.of(compoundtag);
p_11225_.load(compoundtag);
Expand Down
99 changes: 96 additions & 3 deletions patches/net/minecraft/world/entity/Entity.java.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -136,7 +_,7 @@
@@ -24,6 +_,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -134,9 +_,12 @@
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.ScoreHolder;
import net.minecraft.world.scores.Team;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.slf4j.Logger;

-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
Expand All @@ -19,15 +32,95 @@
public boolean blocksBuilding;
@@ -201,8 +_,10 @@
public int tickCount;
private int remainingFireTicks = -this.getFireImmuneTicks();
protected boolean wasTouchingWater;
public int remainingFireTicks = -this.getFireImmuneTicks();
public boolean wasTouchingWater;
+ @Deprecated // Forge: Use forgeFluidTypeHeight instead
protected Object2DoubleMap<TagKey<Fluid>> fluidHeight = new Object2DoubleArrayMap<>(2);
protected boolean wasEyeInWater;
+ @Deprecated // Forge: Use forgeFluidTypeOnEyes instead
private final Set<TagKey<Fluid>> fluidOnEyes = new HashSet<>();
public int invulnerableTime;
protected boolean firstTick = true;
@@ -252,6 +_,65 @@
private final Set<BlockState> blocksInside = new ReferenceArraySet<>();
private final LongSet visitedBlocks = new LongOpenHashSet();

+ // CraftBukkit start
+ public boolean persist = true;
+ public boolean visibleByDefault = true;
+ public boolean valid;
+ public boolean inWorld = false;
+ public boolean generation;
+ public int maxAirTicks = getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
+ public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
+ public boolean persistentInvisibility = false;
+ public BlockPos lastLavaContact;
+ // Marks an entity, that it was removed by a plugin via Entity#remove
+ // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed
+ public boolean pluginRemoved = false;
+ // CraftBukkit end
+
+ // Spigot start
+ public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
+ public final boolean defaultActivationState;
+ public long activatedTick = Integer.MIN_VALUE;
+ // Spigot end
+
+ public AtomicReference<SpawnReason> spawnReason = new AtomicReference<>(CreatureSpawnEvent.SpawnReason.DEFAULT);
+
+ public void spawnReason(CreatureSpawnEvent.SpawnReason spawnReason) {
+ this.spawnReason.set(spawnReason);
+ }
+
+ public float getBukkitYaw() {
+ return this.yRot;
+ }
+
+ private static final int CURRENT_LEVEL = 2;
+ static boolean isLevelAtLeast(CompoundTag tag, int level) {
+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
+ }
+
+ private CraftEntity bukkitEntity;
+ public CraftEntity getBukkitEntity() {
+ if (bukkitEntity == null) {
+ bukkitEntity = CraftEntity.getEntity(level.getCraftServer(), this);
+ }
+ return bukkitEntity;
+ }
+
+ public void setBukkitEntity(CraftEntity bukkitEntity) {
+ this.bukkitEntity = bukkitEntity;
+ }
+
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return TOTAL_AIR_SUPPLY;
+ }
+
+ public boolean isChunkLoaded() {
+ return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
+ }
+ // CraftBukkit end
+
public Entity(EntityType<?> p_19870_, Level p_19871_) {
this.type = p_19870_;
this.level = p_19871_;
@@ -259,6 +_,13 @@
this.position = Vec3.ZERO;
this.blockPosition = BlockPos.ZERO;
this.chunkPosition = ChunkPos.ZERO;
+ // Spigot start
+ if (p_19871_ != null && p_19871_ instanceof ServerLevel) {
+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, p_19871_.spigotConfig);
+ } else {
+ this.defaultActivationState = false;
+ }
+ // Spigot end
SynchedEntityData.Builder synchedentitydata$builder = new SynchedEntityData.Builder(this);
synchedentitydata$builder.define(DATA_SHARED_FLAGS_ID, (byte)0);
synchedentitydata$builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply());
@@ -271,7 +_,10 @@
this.defineSynchedData(synchedentitydata$builder);
this.entityData = synchedentitydata$builder.build();
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/world/entity/LivingEntity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
+ return PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET.test(p_379074_, null);
};
private final AttributeMap attributes;
private final CombatTracker combatTracker = new CombatTracker(this);
public CombatTracker combatTracker = new CombatTracker(this);
@@ -266,6 +_,14 @@
EquipmentSlot.class
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -49,6 +_,10 @@
@Nullable
private UUID target;
public UUID target;
public final float bobOffs;
+ /**
+ * The maximum age of this EntityItem. The item is expired once this is reached.
Expand Down
Loading

0 comments on commit 70ec31a

Please sign in to comment.