Skip to content

Commit

Permalink
it compiles \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Oct 27, 2024
1 parent ab8264e commit 76614d2
Show file tree
Hide file tree
Showing 92 changed files with 484 additions and 443 deletions.
7 changes: 4 additions & 3 deletions patches/server/0002-Purpur-config-files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ index a7524d3853d5b67b6385d2b74832b9267503dfe6..bc0353e4f41680d04f4d5e2dd85640d9
.withRequiredArg()
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..6176bc84e6896d2e60bb219e92e1d668bfbe8eac
index 0000000000000000000000000000000000000000..ceb45f313869ac3a0f650a4ee43ecff782c1be5f
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -0,0 +1,177 @@
@@ -0,0 +1,178 @@
+package org.purpurmc.purpur;
+
+import com.google.common.base.Throwables;
Expand All @@ -204,6 +204,7 @@ index 0000000000000000000000000000000000000000..6176bc84e6896d2e60bb219e92e1d668
+import net.minecraft.world.item.enchantment.Enchantment;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.state.BlockBehaviour;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.configuration.ConfigurationSection;
Expand Down Expand Up @@ -267,7 +268,7 @@ index 0000000000000000000000000000000000000000..6176bc84e6896d2e60bb219e92e1d668
+
+ readConfig(PurpurConfig.class, null);
+
+ Blocks.rebuildCache();
+ Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache);
+ }
+
+ protected static void log(String s) {
Expand Down
48 changes: 22 additions & 26 deletions patches/server/0006-Component-related-conveniences.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Component related conveniences


diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index eb6f95a37b26ac077423accc93492d9957456a1a..f00e708fe38454e228cf126199651b8104375891 100644
index eb6f95a37b26ac077423accc93492d9957456a1a..894f330399282c9db0b5c5dadc1d8502a06bac3e 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -2246,6 +2246,26 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand Down Expand Up @@ -35,6 +35,27 @@ index eb6f95a37b26ac077423accc93492d9957456a1a..f00e708fe38454e228cf126199651b81
@Override
public void displayClientMessage(Component message, boolean overlay) {
this.sendSystemMessage(message, overlay);
@@ -2470,6 +2490,20 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
return new CommandSourceStack(this.commandSource(), this.position(), this.getRotationVector(), this.serverLevel(), this.getPermissionLevel(), this.getName().getString(), this.getDisplayName(), this.server, this);
}

+ // Purpur Start
+ public void sendMiniMessage(@Nullable String message) {
+ if (message != null && !message.isEmpty()) {
+ this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message));
+ }
+ }
+
+ public void sendMessage(@Nullable net.kyori.adventure.text.Component message) {
+ if (message != null) {
+ this.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message));
+ }
+ }
+ // Purpur end
+
public void sendSystemMessage(Component message) {
this.sendSystemMessage(message, false);
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 511e7254d938733aca508efd5de82e61678c7620..75e5e540f03d28b64fa5fef1f342a157598c3fa7 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
Expand Down Expand Up @@ -80,28 +101,3 @@ index bb1a60180e58c1333e7bb33e8acf1b0225eda8a8..c83e80ebdbbfb2d0e08561a44486a308
public String getMsgId() {
return this.type().msgId();
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6817015f0cf39df03029e36cd845d590618031dc..62af796b2b883856a904647f504ff064a5fed463 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4468,6 +4468,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return SlotAccess.NULL;
}

+ // Purpur Start
+ public void sendMiniMessage(@Nullable String message) {
+ if (message != null && !message.isEmpty()) {
+ this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message));
+ }
+ }
+
+ public void sendMessage(@Nullable net.kyori.adventure.text.Component message) {
+ if (message != null) {
+ this.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message));
+ }
+ }
+ // Purpur end
+
public Level getCommandSenderWorld() {
return this.level();
}
82 changes: 46 additions & 36 deletions patches/server/0007-Ridables.patch
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ index a7420e4522e0dff72ce7f8a791b9cd4bfa270106..0fa5e0c80ad09e03452c4d412390cb8f
public LevelChunk getChunkIfLoaded(int x, int z) {
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index f00e708fe38454e228cf126199651b8104375891..7e796655dec9eb48d0c29c9ed06d30ebf67c25a5 100644
index 894f330399282c9db0b5c5dadc1d8502a06bac3e..d7b828937e58eea5f095863129a0844f25a25336 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1026,6 +1026,15 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand Down Expand Up @@ -79,7 +79,7 @@ index eef96e946b80064fe211039a65db4192ea7a52d3..352ade7acc9052e4d74ef840e085a86f
if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
entity.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 62af796b2b883856a904647f504ff064a5fed463..49a8b0d4f4a18c91a48291c316c420bd78428ca5 100644
index 6817015f0cf39df03029e36cd845d590618031dc..aa73875d8cb701d233ffa79c9bda4b7b474ba667 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -383,7 +383,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down Expand Up @@ -120,7 +120,7 @@ index 62af796b2b883856a904647f504ff064a5fed463..49a8b0d4f4a18c91a48291c316c420bd
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -5343,4 +5358,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5329,4 +5344,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return ((net.minecraft.server.level.ServerChunkCache) level.getChunkSource()).isPositionTicking(this);
}
// Paper end - Expose entity id counter
Expand Down Expand Up @@ -259,7 +259,7 @@ index 22b3d3d945cbddae25abfca7d900324c79d32293..7f896777fcff72230142fbe231471782
// Paper end - Add EntityMoveEvent
world = this.level();
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index dbd321f3dc3cc80737830db63aed47a6935e8e89..cd456edd2caf087d1dbeb97d3373bd2bf9112fc2 100644
index dbd321f3dc3cc80737830db63aed47a6935e8e89..bc2380a71aa65c40f326c1f6bdf15ee25346ffee 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -163,8 +163,8 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
Expand All @@ -282,7 +282,7 @@ index dbd321f3dc3cc80737830db63aed47a6935e8e89..cd456edd2caf087d1dbeb97d3373bd2b
}

public boolean isWithinRestriction() {
@@ -1813,4 +1813,56 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -1813,4 +1813,58 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
public float[] getArmorDropChances() {
return this.armorDropChances;
}
Expand Down Expand Up @@ -326,7 +326,9 @@ index dbd321f3dc3cc80737830db63aed47a6935e8e89..cd456edd2caf087d1dbeb97d3373bd2b
+ }
+ }
+ if (!player.getBukkitEntity().hasPermission("allow.ride." + net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getKey(getType()).getPath())) {
+ player.sendMiniMessage(org.purpurmc.purpur.PurpurConfig.cannotRideMob);
+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
+ serverPlayer.sendMiniMessage(org.purpurmc.purpur.PurpurConfig.cannotRideMob);
+ }
+ return InteractionResult.PASS;
+ }
+ player.setYRot(this.getYRot());
Expand Down Expand Up @@ -1792,7 +1794,7 @@ index fd9f6c17448a4d87f940eb8f544ecb9669068582..3a0b71cad2c68e972c5989bd37de8395
}

diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java
index f9fdc600dc680c55219fcbf9bc8f151a733a093c..93c16d7522d76f35de2c87cab0e7db3d6f7ab6c7 100644
index f9fdc600dc680c55219fcbf9bc8f151a733a093c..4144d82ca0a9c5b5384d4ab080013ad76014199b 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Squid.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java
@@ -50,9 +50,32 @@ public class Squid extends AgeableWaterCreature {
Expand Down Expand Up @@ -1856,9 +1858,9 @@ index f9fdc600dc680c55219fcbf9bc8f151a733a093c..93c16d7522d76f35de2c87cab0e7db3d
+ }
+ }
+ if (forward != 0.0F || strafe != 0.0F) {
+ squid.setMovementVector((float) dir.getX(), (float) dir.getY(), (float) dir.getZ());
+ squid.movementVector = new Vec3((float) dir.getX(), (float) dir.getY(), (float) dir.getZ());
+ } else {
+ squid.setMovementVector(0.0F, 0.0F, 0.0F);
+ squid.movementVector = Vec3.ZERO;
+ }
+ return;
+ }
Expand Down Expand Up @@ -2445,7 +2447,7 @@ index b5ec7c8ad0e482930d1a54b590b26093f4e477ea..0ec18aecb7774db219a8ca5ed60ae999
protected void randomizeAttributes(RandomSource random) {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue((double)generateMaxHealth(random::nextInt));
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
index 18bd483fe46de3d9dc129bffbccfba9d4cab9550..f373728d357faf68a576dc2f6363e36f5ac2a4b4 100644
index 18bd483fe46de3d9dc129bffbccfba9d4cab9550..29b4c4ba7e80fe58a005064da4b0479e367d90b0 100644
--- a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
@@ -77,7 +77,51 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
Expand Down Expand Up @@ -2494,7 +2496,7 @@ index 18bd483fe46de3d9dc129bffbccfba9d4cab9550..f373728d357faf68a576dc2f6363e36f
+
+ @Override
+ public boolean isSaddled() {
+ return super.isSaddled() || (isTamed() && getSwag() != null);
+ return super.isSaddled() || (isTamed());
}
+ // Purpur end

Expand Down Expand Up @@ -3167,7 +3169,7 @@ index 4e621a7f36b3d718695434a2a4e3060283667bb2..86a14550482438bfaad47f9bf96d336a
public boolean doHurtTarget(ServerLevel world, Entity target) {
if (super.doHurtTarget(world, target)) {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
index 1906dfc22af208d6e801ad4a8f2f9e9702432691..6d5ad18bc85769737060b5dff520fc4a87e30e57 100644
index 1906dfc22af208d6e801ad4a8f2f9e9702432691..7e5f447c23c817bf89508dc4049df2b6b7efbab9 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -60,21 +60,98 @@ public class Creeper extends Monster {
Expand Down Expand Up @@ -3201,7 +3203,7 @@ index 1906dfc22af208d6e801ad4a8f2f9e9702432691..6d5ad18bc85769737060b5dff520fc4a
+ }
+
+ @Override
+ protected void customServerAiStep() {
+ protected void customServerAiStep(ServerLevel world) {
+ if (powerToggleDelay > 0) {
+ powerToggleDelay--;
+ }
Expand All @@ -3216,7 +3218,7 @@ index 1906dfc22af208d6e801ad4a8f2f9e9702432691..6d5ad18bc85769737060b5dff520fc4a
+ }
+ prevSpacebarCharge = spacebarCharge;
+ }
+ super.customServerAiStep();
+ super.customServerAiStep(world);
+ }
+
+ @Override
Expand Down Expand Up @@ -3365,7 +3367,7 @@ index 378694a38115c012978e1fea59d049d1ebd04110..4364ac531826524fc3c099b9900406b2
return Guardian.createAttributes().add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D).add(Attributes.ATTACK_DAMAGE, 8.0D).add(Attributes.MAX_HEALTH, 80.0D);
}
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..9e90b2c3474bb6c4ea6caf3f060dcb668c4bd15b 100644
index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..bd08a90aa9128d7d31dbbe7e075d32a8b8aad724 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -95,9 +95,27 @@ public class EnderMan extends Monster implements NeutralMob {
Expand Down Expand Up @@ -3417,7 +3419,7 @@ index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..9e90b2c3474bb6c4ea6caf3f060dcb66
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
if (this.isInvulnerableTo(world, source)) {
return false;
+ } else if (getRider() != null && this.isControllable()) { return super.hurt(source, amount); // Purpur - no teleporting on damage
+ } else if (getRider() != null && this.isControllable()) { return super.hurtServer(world, source, amount); // Purpur - no teleporting on damage
} else {
boolean flag = source.getDirectEntity() instanceof ThrownPotion;
boolean flag1;
Expand Down Expand Up @@ -4403,7 +4405,7 @@ index 711b7eb8e9fdedbc87965828e573fe8d5c357d53..2214e3e473214a8e8340c4ded0e2c797
if (flag && !this.isSilent()) {
this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.STRIDER_EAT, this.getSoundSource(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
index 183a33b7d666d652b455baa7e8339e9c4a870a58..06269780121424129be777e83e2ad4ca3e616b23 100644
index 183a33b7d666d652b455baa7e8339e9c4a870a58..3452623771ba6856e5c4049a0c932440b93db412 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
@@ -59,6 +59,50 @@ public class Vex extends Monster implements TraceableEntity {
Expand Down Expand Up @@ -4443,7 +4445,7 @@ index 183a33b7d666d652b455baa7e8339e9c4a870a58..06269780121424129be777e83e2ad4ca
+ }
+ setSpeed(speed);
+ Vec3 mot = getDeltaMovement();
+ move(MoverType.SELF, mot.multiply(speed, 1.0, speed));
+ move(net.minecraft.world.entity.MoverType.SELF, mot.multiply(speed, 1.0, speed));
+ setDeltaMovement(mot.scale(0.9D));
+ }
+ }
Expand Down Expand Up @@ -5138,10 +5140,10 @@ index 6c60bb4f4d1133844a4232df518c062216847fdc..c9f5047bfa48c12a9090cb8da4bb9045
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 6176bc84e6896d2e60bb219e92e1d668bfbe8eac..f34d12ea5681a944ae2c08fb2cb69b8f662fcdf6 100644
index ceb45f313869ac3a0f650a4ee43ecff782c1be5f..09e7a11a241b6e306d5043fe66f14fd4f2aae963 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -174,4 +174,9 @@ public class PurpurConfig {
@@ -175,4 +175,9 @@ public class PurpurConfig {
}
return builder.build();
}
Expand Down Expand Up @@ -6390,10 +6392,10 @@ index 0000000000000000000000000000000000000000..89c476c740b4efb4f44c1dcd384b9086
+}
diff --git a/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0b7e0eeffdf31b88662232b07944bf3e6fa2148
index 0000000000000000000000000000000000000000..d7f5686fe897f3c2424b146c8e7d2862223d1eaf
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/entity/PhantomFlames.java
@@ -0,0 +1,114 @@
@@ -0,0 +1,122 @@
+package org.purpurmc.purpur.entity;
+
+import net.minecraft.core.particles.ParticleTypes;
Expand Down Expand Up @@ -6484,28 +6486,36 @@ index 0000000000000000000000000000000000000000..c0b7e0eeffdf31b88662232b07944bf3
+
+ @Override
+ protected void onHitEntity(EntityHitResult entityHitResult) {
+ Entity shooter = this.getOwner();
+ if (shooter instanceof LivingEntity) {
+ Entity target = entityHitResult.getEntity();
+ if (canGrief || (target instanceof LivingEntity && !(target instanceof ArmorStand))) {
+ boolean hurt = target.hurt(target.damageSources().mobProjectile(this, (LivingEntity) shooter), level().purpurConfig.phantomFlameDamage);
+ if (hurt && level().purpurConfig.phantomFlameFireTime > 0) {
+ target.igniteForSeconds(level().purpurConfig.phantomFlameFireTime);
+ Level world = this.level();
+
+ if (world instanceof ServerLevel worldserver) {
+ Entity shooter = this.getOwner();
+ if (shooter instanceof LivingEntity) {
+ Entity target = entityHitResult.getEntity();
+ if (canGrief || (target instanceof LivingEntity && !(target instanceof ArmorStand))) {
+ boolean hurt = target.hurtServer(worldserver, target.damageSources().mobProjectile(this, (LivingEntity) shooter), worldserver.purpurConfig.phantomFlameDamage);
+ if (hurt && worldserver.purpurConfig.phantomFlameFireTime > 0) {
+ target.igniteForSeconds(worldserver.purpurConfig.phantomFlameFireTime);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onHitBlock(BlockHitResult blockHitResult) {
+ if (this.hitCancelled) {
+ return;
+ }
+ if (this.canGrief) {
+ BlockState state = this.level().getBlockState(blockHitResult.getBlockPos());
+ state.onProjectileHit(this.level(), state, blockHitResult, this);
+ Level world = this.level();
+
+ if (world instanceof ServerLevel worldserver) {
+ if (this.hitCancelled) {
+ return;
+ }
+ if (this.canGrief) {
+ BlockState state = worldserver.getBlockState(blockHitResult.getBlockPos());
+ state.onProjectileHit(worldserver, state, blockHitResult, this);
+ }
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ }
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ }
+}
diff --git a/src/main/java/org/purpurmc/purpur/entity/ai/HasRider.java b/src/main/java/org/purpurmc/purpur/entity/ai/HasRider.java
Expand Down
Loading

0 comments on commit 76614d2

Please sign in to comment.