Skip to content

Commit

Permalink
update nms-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Dec 7, 2024
1 parent 70ec31a commit 0396e29
Show file tree
Hide file tree
Showing 107 changed files with 1,196 additions and 975 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorProjectile.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorProjectile.java
@@ -9,6 +9,13 @@
@@ -9,6 +9,12 @@
import net.minecraft.world.item.ProjectileItem;
import net.minecraft.world.level.block.BlockDispenser;

+// CraftBukkit start
+import net.minecraft.world.entity.Entity;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
Expand All @@ -14,14 +13,14 @@
public class DispenseBehaviorProjectile extends DispenseBehaviorItem {

private final ProjectileItem projectileItem;
@@ -31,8 +38,37 @@
@@ -31,8 +37,40 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
IPosition iposition = this.dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection);

- IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
- itemstack.shrink(1);
+ // CraftBukkit start
+ // this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
+ // IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // CraftBukkit - call when finish the BlockDispenseEvent
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
Expand All @@ -47,8 +46,11 @@
+ }
+ }
+
+ IProjectile iprojectile = IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
+ // SPIGOT-7923: Avoid create projectiles with empty item
+ if (!itemstack1.isEmpty()) {
+ IProjectile iprojectile = IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack1, enumdirection), worldserver, itemstack1, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
+ iprojectile.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
+ }
+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing
+ // CraftBukkit end
return itemstack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Logger LOGGER = LogUtils.getLogger();
@@ -90,14 +106,42 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack);
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(sourceblock.level().registryAccess(), itemstack);

+ // CraftBukkit start
+ WorldServer worldserver = sourceblock.level();
Expand Down
10 changes: 6 additions & 4 deletions nms-patches/net/minecraft/server/DispenserRegistry.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
--- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java
@@ -29,6 +29,12 @@
@@ -30,7 +30,13 @@
import net.minecraft.world.level.block.state.BlockBase;
import org.slf4j.Logger;

-@SuppressForbidden(a = "System.out setup")
+// CraftBukkit start
+import net.minecraft.util.datafix.fixes.DataConverterFlattenData;
+import net.minecraft.util.datafix.fixes.DataConverterMaterialId;
+import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg;
+// CraftBukkit end
+
+@SuppressForbidden(reason = "System.out setup")
+// CraftBukkit end
public class DispenserRegistry {

public static final PrintStream STDOUT = System.out;
@@ -40,6 +46,23 @@
@@ -42,6 +48,23 @@

public static void bootStrap() {
if (!DispenserRegistry.isBootstrapped) {
Expand All @@ -37,7 +39,7 @@
DispenserRegistry.isBootstrapped = true;
Instant instant = Instant.now();

@@ -59,6 +82,69 @@
@@ -61,6 +84,69 @@
wrapStreams();
DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
}
Expand Down
28 changes: 15 additions & 13 deletions nms-patches/net/minecraft/server/Main.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -60,6 +60,17 @@
@@ -61,16 +61,28 @@
import net.minecraft.world.level.storage.WorldInfo;
import org.slf4j.Logger;

Expand All @@ -18,9 +18,11 @@
public class Main {

private static final Logger LOGGER = LogUtils.getLogger();
@@ -67,8 +78,9 @@
public Main() {}

- @SuppressForbidden(a = "System.out needed before bootstrap")
+ @SuppressForbidden(reason = "System.out needed before bootstrap") // CraftBukkit - decompile error
@DontObfuscate
- public static void main(String[] astring) {
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
Expand All @@ -29,7 +31,7 @@
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -94,15 +106,18 @@
@@ -96,15 +108,18 @@
optionparser.printHelpOn(System.err);
return;
}
Expand All @@ -50,7 +52,7 @@
JvmProfiler.INSTANCE.start(Environment.SERVER);
}

@@ -110,14 +125,27 @@
@@ -112,14 +127,27 @@
DispenserRegistry.validate();
SystemUtils.startTimerHackThread();
Path path1 = Paths.get("server.properties");
Expand Down Expand Up @@ -80,7 +82,7 @@
Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
return;
}
@@ -127,11 +155,13 @@
@@ -129,11 +157,13 @@
return;
}

Expand All @@ -97,7 +99,7 @@
Dynamic dynamic;

if (convertable_conversionsession.hasWorldData()) {
@@ -172,13 +202,31 @@
@@ -174,13 +204,31 @@
}

Dynamic<?> dynamic1 = dynamic;
Expand Down Expand Up @@ -130,15 +132,15 @@

WorldStem worldstem;

@@ -187,6 +235,7 @@
@@ -189,6 +237,7 @@

worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
+ worldLoader.set(worldloader_a); // CraftBukkit
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM);

if (dynamic1 != null) {
@@ -199,7 +248,7 @@
@@ -201,7 +250,7 @@
WorldOptions worldoptions;
WorldDimensions worlddimensions;

Expand All @@ -147,7 +149,7 @@
worldsettings = MinecraftServer.DEMO_SETTINGS;
worldoptions = WorldOptions.DEMO_OPTIONS;
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
@@ -207,7 +256,7 @@
@@ -209,7 +258,7 @@
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();

worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration());
Expand All @@ -156,15 +158,15 @@
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
}

@@ -223,6 +272,7 @@
@@ -225,6 +274,7 @@
return;
}

+ /*
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
boolean flag1 = optionset.has(optionspec6);

@@ -235,20 +285,31 @@
@@ -237,20 +287,31 @@
SaveData savedata = worldstem.worldData();

convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
Expand Down Expand Up @@ -198,15 +200,15 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.halt(true);
@@ -257,6 +318,7 @@
@@ -259,6 +320,7 @@

thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
+ */ // CraftBukkit end
} catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
}
@@ -293,7 +355,7 @@
@@ -295,7 +357,7 @@
}

public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) {
Expand Down
2 changes: 1 addition & 1 deletion nms-patches/net/minecraft/server/MinecraftServer.patch
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
- this.forceDifficulty();
- this.prepareLevels(worldloadlistener);
if (profiledduration != null) {
profiledduration.finish();
profiledduration.finish(true);
}
@@ -387,23 +448,217 @@

Expand Down
6 changes: 3 additions & 3 deletions nms-patches/net/minecraft/server/commands/CommandTime.patch
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
+ // CraftBukkit end
}

commandlistenerwrapper.sendSuccess(() -> {
@@ -64,12 +75,18 @@
commandlistenerwrapper.getServer().forceTimeSynchronization();
@@ -65,12 +76,18 @@
}

public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) {
Expand All @@ -53,4 +53,4 @@
+ // CraftBukkit end
}

int j = getDayTime(commandlistenerwrapper.getLevel());
commandlistenerwrapper.getServer().forceTimeSynchronization();
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
public final boolean onlineMode = this.get("online-mode", true);
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
@@ -105,8 +110,10 @@
@@ -100,13 +105,15 @@
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList;
public final boolean enforceSecureProfile;
public final boolean logIPs;
- public final int pauseWhenEmptySeconds;
+ public int pauseWhenEmptySeconds;
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
public final WorldOptions worldOptions;
public boolean acceptsTransfers;

Expand Down
Loading

0 comments on commit 0396e29

Please sign in to comment.