diff --git a/patches/net/minecraft/commands/CommandSource.java.patch b/patches/net/minecraft/commands/CommandSource.java.patch new file mode 100644 index 00000000..a1408133 --- /dev/null +++ b/patches/net/minecraft/commands/CommandSource.java.patch @@ -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); + } + } diff --git a/patches/net/minecraft/commands/CommandSourceStack.java.patch b/patches/net/minecraft/commands/CommandSourceStack.java.patch index 09ebb7cb..59d65a89 100644 --- a/patches/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/net/minecraft/commands/CommandSourceStack.java.patch @@ -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; @@ -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_, diff --git a/patches/net/minecraft/network/Connection.java.patch b/patches/net/minecraft/network/Connection.java.patch index 49877aef..9415aaa7 100644 --- a/patches/net/minecraft/network/Connection.java.patch +++ b/patches/net/minecraft/network/Connection.java.patch @@ -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_; diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index f6874df7..e12e7cb6 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -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 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 processQueue = new ConcurrentLinkedQueue(); ++ 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 spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); - Thread thread = new Thread(() -> atomicreference.get().runServer(), "Server thread"); diff --git a/patches/net/minecraft/server/commands/DebugCommand.java.patch b/patches/net/minecraft/server/commands/DebugCommand.java.patch new file mode 100644 index 00000000..c6ed6dfe --- /dev/null +++ b/patches/net/minecraft/server/commands/DebugCommand.java.patch @@ -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; + } + } + } diff --git a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch index 1085bf08..84f61852 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -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; @@ -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; + } + } diff --git a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index b9a564b4..4f163736 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -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_); diff --git a/patches/net/minecraft/server/level/DistanceManager.java.patch b/patches/net/minecraft/server/level/DistanceManager.java.patch index fb0d0488..2f714efe 100644 --- a/patches/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/net/minecraft/server/level/DistanceManager.java.patch @@ -3,7 +3,7 @@ @@ -50,6 +_,7 @@ final Executor mainThreadExecutor; private long ticketTickCounter; - private int simulationDistance = 10; + public int simulationDistance = 10; + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); protected DistanceManager(Executor p_140774_, Executor p_140775_) { diff --git a/patches/net/minecraft/server/level/Ticket.java.patch b/patches/net/minecraft/server/level/Ticket.java.patch index 51e6d151..b33b9fd8 100644 --- a/patches/net/minecraft/server/level/Ticket.java.patch +++ b/patches/net/minecraft/server/level/Ticket.java.patch @@ -3,7 +3,7 @@ @@ -9,9 +_,14 @@ private long createdTick; - protected Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { + public Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { + this(p_9425_, p_9426_, p_9427_, false); + } + diff --git a/patches/net/minecraft/server/packs/repository/Pack.java.patch b/patches/net/minecraft/server/packs/repository/Pack.java.patch index 953df7b3..ccd09d63 100644 --- a/patches/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/net/minecraft/server/packs/repository/Pack.java.patch @@ -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 diff --git a/patches/net/minecraft/server/players/PlayerList.java.patch b/patches/net/minecraft/server/players/PlayerList.java.patch index a3c0ab67..39f59ae8 100644 --- a/patches/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/net/minecraft/server/players/PlayerList.java.patch @@ -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); diff --git a/patches/net/minecraft/world/entity/Entity.java.patch b/patches/net/minecraft/world/entity/Entity.java.patch index 35d70c49..90b52ff4 100644 --- a/patches/net/minecraft/world/entity/Entity.java.patch +++ b/patches/net/minecraft/world/entity/Entity.java.patch @@ -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 { @@ -19,8 +32,8 @@ 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> fluidHeight = new Object2DoubleArrayMap<>(2); protected boolean wasEyeInWater; @@ -28,6 +41,86 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; +@@ -252,6 +_,65 @@ + private final Set 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 = 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(); diff --git a/patches/net/minecraft/world/entity/LivingEntity.java.patch b/patches/net/minecraft/world/entity/LivingEntity.java.patch index 2527407c..d9953756 100644 --- a/patches/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/net/minecraft/world/entity/LivingEntity.java.patch @@ -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 ); diff --git a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch index 0b105e15..059a28c9 100644 --- a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -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. diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index febb3543..282531f9 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +@@ -20,6 +_,8 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.phys.Vec3; ++import org.bukkit.command.CommandSender; ++import org.bukkit.craftbukkit.entity.CraftMinecartCommand; + + public class MinecartCommandBlock extends AbstractMinecart { + public static final EntityDataAccessor DATA_ID_COMMAND_NAME = SynchedEntityData.defineId(MinecartCommandBlock.class, EntityDataSerializers.STRING); @@ -82,6 +_,8 @@ @Override @@ -9,3 +18,15 @@ return this.commandBlock.usedBy(p_38522_); } +@@ -137,6 +_,11 @@ + @Override + public boolean isValid() { + return !MinecartCommandBlock.this.isRemoved(); ++ } ++ ++ @Override ++ public CommandSender getBukkitSender(CommandSourceStack wrapper) { ++ return (CraftMinecartCommand) MinecartCommandBlock.this.getBukkitEntity(); + } + } + } diff --git a/patches/net/minecraft/world/flag/FeatureFlag.java.patch b/patches/net/minecraft/world/flag/FeatureFlag.java.patch index bfc3f2e4..b9804ccc 100644 --- a/patches/net/minecraft/world/flag/FeatureFlag.java.patch +++ b/patches/net/minecraft/world/flag/FeatureFlag.java.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/world/flag/FeatureFlag.java @@ -3,9 +_,25 @@ public class FeatureFlag { - final FeatureFlagUniverse universe; - final long mask; + public final FeatureFlagUniverse universe; + public final long mask; + final int extMaskIndex; + final boolean modded; diff --git a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch index a7604a0a..8843005c 100644 --- a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -3,7 +3,7 @@ @@ -23,16 +_,20 @@ import net.minecraft.world.level.ItemLike; - public final class Ingredient implements StackedContents.IngredientInfo>, Predicate { + public class Ingredient implements StackedContents.IngredientInfo>, Predicate { - public static final StreamCodec CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) - .map(Ingredient::new, p_360055_ -> p_360055_.values); - public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) diff --git a/patches/net/minecraft/world/level/Level.java.patch b/patches/net/minecraft/world/level/Level.java.patch index e76860b3..a6881c8a 100644 --- a/patches/net/minecraft/world/level/Level.java.patch +++ b/patches/net/minecraft/world/level/Level.java.patch @@ -1,15 +1,55 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -79,7 +_,7 @@ +@@ -2,10 +_,14 @@ + + import com.google.common.collect.Lists; + import com.mojang.serialization.Codec; ++import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; + import java.io.IOException; + import java.util.Collection; ++import java.util.HashMap; + import java.util.Iterator; ++import java.util.LinkedHashMap; + import java.util.List; ++import java.util.Map; + import java.util.function.Consumer; + import java.util.function.Predicate; + import javax.annotation.Nullable; +@@ -42,6 +_,7 @@ + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.boss.EnderDragonPart; + import net.minecraft.world.entity.boss.enderdragon.EnderDragon; ++import net.minecraft.world.entity.item.ItemEntity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.alchemy.PotionBrewing; +@@ -61,6 +_,7 @@ + import net.minecraft.world.level.chunk.LevelChunk; + import net.minecraft.world.level.chunk.status.ChunkStatus; + import net.minecraft.world.level.dimension.DimensionType; ++import net.minecraft.world.level.dimension.LevelStem; + import net.minecraft.world.level.entity.EntityTypeTest; + import net.minecraft.world.level.entity.LevelEntityGetter; + import net.minecraft.world.level.gameevent.GameEvent; +@@ -78,8 +_,16 @@ + import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.CraftServer; ++import org.bukkit.craftbukkit.CraftWorld; ++import org.bukkit.craftbukkit.block.CapturedBlockState; ++import org.bukkit.entity.SpawnCategory; ++import org.bukkit.generator.BiomeProvider; ++import org.bukkit.generator.ChunkGenerator; ++import org.spigotmc.SpigotWorldConfig; -public abstract class Level implements LevelAccessor, AutoCloseable { +public abstract class Level extends net.neoforged.neoforge.attachment.AttachmentHolder implements LevelAccessor, AutoCloseable, net.neoforged.neoforge.common.extensions.ILevelExtension { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -116,6 +_,11 @@ +@@ -116,6 +_,48 @@ private final RegistryAccess registryAccess; private final DamageSources damageSources; private long subTickCount; @@ -18,6 +58,43 @@ + public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); + private final java.util.ArrayList freshBlockEntities = new java.util.ArrayList<>(); + private final java.util.ArrayList pendingFreshBlockEntities = new java.util.ArrayList<>(); ++ ++ // CraftBukkit start Added the following ++ public CraftWorld world; ++ public boolean pvpMode; ++ public boolean keepSpawnInMemory = true; ++ public static ChunkGenerator generator; ++ public static Environment environment; ++ public static BiomeProvider biomeProvider; ++ ++ public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 ++ public boolean captureBlockStates = false; ++ public boolean captureTreeGeneration = false; ++ public Map capturedBlockStates = new LinkedHashMap<>(); ++ public Map capturedTileEntities = new HashMap<>(); ++ public List captureDrops; ++ public final Object2LongOpenHashMap ticksPerSpawnCategory = new Object2LongOpenHashMap<>(); ++ public boolean populating; ++ public SpigotWorldConfig spigotConfig; // Spigot ++ public static BlockPos lastPhysicsProblem; // Spigot ++ ++ public CraftWorld getWorld() { ++ return this.world; ++ } ++ ++ public CraftServer getCraftServer() { ++ return (CraftServer) Bukkit.getServer(); ++ } ++ ++ public ResourceKey getTypeKey() { ++ return Registries.levelToLevelStem(dimension); ++ } ++ ++ public static void craftWorldData(ChunkGenerator gen, Environment env, BiomeProvider bp) { ++ generator = gen; ++ environment = env; ++ biomeProvider = bp; ++ } protected Level( WritableLevelData p_270739_, diff --git a/patches/net/minecraft/world/level/LevelAccessor.java.patch b/patches/net/minecraft/world/level/LevelAccessor.java.patch new file mode 100644 index 00000000..57e889bc --- /dev/null +++ b/patches/net/minecraft/world/level/LevelAccessor.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/level/LevelAccessor.java ++++ b/net/minecraft/world/level/LevelAccessor.java +@@ -8,6 +_,7 @@ + import net.minecraft.core.registries.Registries; + import net.minecraft.resources.ResourceKey; + import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundSource; + import net.minecraft.util.RandomSource; +@@ -101,4 +_,6 @@ + default void gameEvent(ResourceKey p_316780_, BlockPos p_316509_, GameEvent.Context p_316524_) { + this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(p_316780_), p_316509_, p_316524_); + } ++ ++ ServerLevel getMinecraftWorld(); // CraftBukkit + } diff --git a/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch b/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch new file mode 100644 index 00000000..5b453b5f --- /dev/null +++ b/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/level/ServerLevelAccessor.java ++++ b/net/minecraft/world/level/ServerLevelAccessor.java +@@ -2,6 +_,7 @@ + + import net.minecraft.server.level.ServerLevel; + import net.minecraft.world.entity.Entity; ++import org.bukkit.event.entity.CreatureSpawnEvent; + + public interface ServerLevelAccessor extends LevelAccessor { + ServerLevel getLevel(); +@@ -9,4 +_,15 @@ + default void addFreshEntityWithPassengers(Entity p_47206_) { + p_47206_.getSelfAndPassengers().forEach(this::addFreshEntity); + } ++ ++ // CraftBukkit start ++ default void addFreshEntityWithPassengers(Entity pEntity, CreatureSpawnEvent.SpawnReason reason) { ++ pEntity.getSelfAndPassengers().forEach((e) -> this.addFreshEntity(e, reason)); ++ } ++ ++ @Override ++ default ServerLevel getMinecraftWorld() { ++ return getLevel(); ++ } ++ // CraftBukkit end + } diff --git a/patches/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/net/minecraft/world/level/block/ChestBlock.java.patch index 05a8241f..3ad90d58 100644 --- a/patches/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChestBlock.java.patch @@ -10,3 +10,39 @@ } @Override +@@ -380,4 +_,35 @@ + ((ChestBlockEntity)blockentity).recheckOpen(); + } + } ++ ++ // CraftBukkit start ++ public static class DoubleInventory implements MenuProvider { ++ ++ private final ChestBlockEntity tileentitychest; ++ private final ChestBlockEntity tileentitychest1; ++ public final CompoundContainer inventorylargechest; ++ ++ public DoubleInventory(ChestBlockEntity tileentitychest, ChestBlockEntity tileentitychest1, CompoundContainer inventorylargechest) { ++ this.tileentitychest = tileentitychest; ++ this.tileentitychest1 = tileentitychest1; ++ this.inventorylargechest = inventorylargechest; ++ } ++ ++ @Nullable ++ @Override ++ public AbstractContainerMenu createMenu(int i, net.minecraft.world.entity.player.Inventory playerinventory, net.minecraft.world.entity.player.Player entityhuman) { ++ if (this.tileentitychest.canOpen(entityhuman) && this.tileentitychest1.canOpen(entityhuman)) { ++ this.tileentitychest.unpackLootTable(playerinventory.player); ++ this.tileentitychest1.unpackLootTable(playerinventory.player); ++ return ChestMenu.sixRows(i, playerinventory, this.inventorylargechest); ++ } ++ return null; ++ } ++ ++ @Override ++ public net.minecraft.network.chat.Component getDisplayName() { ++ return this.tileentitychest.hasCustomName() ? this.tileentitychest.getDisplayName() : (this.tileentitychest1.hasCustomName() ? this.tileentitychest1.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : Component.translatable("container.chestDouble"))); ++ } ++ } ++ // CraftBukkit end + } diff --git a/patches/net/minecraft/world/level/block/SaplingBlock.java.patch b/patches/net/minecraft/world/level/block/SaplingBlock.java.patch index a0b98fc1..6fc789c9 100644 --- a/patches/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -1,5 +1,21 @@ --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java +@@ -17,6 +_,7 @@ + import net.minecraft.world.level.block.state.properties.IntegerProperty; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.TreeType; + + public class SaplingBlock extends BushBlock implements BonemealableBlock { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( +@@ -27,6 +_,7 @@ + protected static final float AABB_OFFSET = 6.0F; + protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0); + protected final TreeGrower treeGrower; ++ public static TreeType treeType; // CraftBukkit + + @Override + public MapCodec codec() { @@ -46,6 +_,7 @@ @Override diff --git a/patches/net/minecraft/world/level/block/SoundType.java.patch b/patches/net/minecraft/world/level/block/SoundType.java.patch index f1783659..48d0b41c 100644 --- a/patches/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/net/minecraft/world/level/block/SoundType.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java @@ -801,6 +_,7 @@ - private final SoundEvent hitSound; + public final SoundEvent hitSound; private final SoundEvent fallSound; + @Deprecated // Forge: Use {@link net.neoforged.neoforge.common.util.DeferredSoundType} instead for suppliers diff --git a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch index c2a70f7e..b5cbb79e 100644 --- a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -10,7 +10,7 @@ + @Deprecated // Neo: always use getType() private final BlockEntityType type; @Nullable - protected Level level; + public Level level; @@ -35,6 +_,8 @@ protected boolean remove; private BlockState blockState; diff --git a/patches/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch new file mode 100644 index 00000000..4d9f0f38 --- /dev/null +++ b/patches/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java +@@ -15,6 +_,8 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.phys.Vec2; + import net.minecraft.world.phys.Vec3; ++import org.bukkit.command.CommandSender; ++import org.bukkit.craftbukkit.command.CraftBlockCommandSender; + + public class CommandBlockEntity extends BlockEntity { + private boolean powered; +@@ -62,6 +_,11 @@ + @Override + public boolean isValid() { + return !CommandBlockEntity.this.isRemoved(); ++ } ++ ++ @Override ++ public CommandSender getBukkitSender(CommandSourceStack wrapper) { ++ return new CraftBlockCommandSender(wrapper, CommandBlockEntity.this); + } + }; + diff --git a/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch index 23ac00f2..60e8344a 100644 --- a/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -7,4 +7,4 @@ + // TODO: forceBits-parametered setBits function. -C private static final int MIN_PALETTE_BITS = 0; private final PaletteResize dummyPaletteResize = (p_238275_, p_238276_) -> 0; - private final IdMap registry; + public final IdMap registry;