mirror of
https://github.com/BX-Team/DivineMC.git
synced 2026-01-04 15:31:43 +00:00
33/38 patches done (waiting for pufferfish)
This commit is contained in:
76
patches/server/0016-Boat-Settings.patch
Normal file
76
patches/server/0016-Boat-Settings.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 10 Jun 2023 13:01:08 +0300
|
||||
Subject: [PATCH] Boat Settings
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index 13e1c7594bf304b35ce8dcab2951329c527d7dea..efb2fac41a546ba312f4925f206f0975a0336406 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -331,7 +331,18 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide && this.outOfControlTicks >= 60.0F) {
|
||||
- this.ejectPassengers();
|
||||
+ // DivineMC start - Don't eject players
|
||||
+ if (this.level().divinemcConfig.dontEjectPlayerFromBoatUnderwater) {
|
||||
+ for (int i = this.passengers.size() - 1; i >= 0; --i) {
|
||||
+ Entity passenger = this.passengers.get(i);
|
||||
+ if (!(passenger instanceof Player)) {
|
||||
+ passenger.stopRiding();
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ this.ejectPassengers();
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
if (this.getHurtTime() > 0) {
|
||||
@@ -850,7 +861,13 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
|
||||
@Override
|
||||
public InteractionResult interact(Player player, InteractionHand hand) {
|
||||
- return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
|
||||
+ // DivineMC start - always allow to enter the boat
|
||||
+ if (this.level().divinemcConfig.alwaysAllowToEnterTheBoat) {
|
||||
+ return player.isSecondaryUseActive() ? InteractionResult.PASS : (true || this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
|
||||
+ } else {
|
||||
+ return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -922,7 +939,13 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
|
||||
@Override
|
||||
protected boolean canAddPassenger(Entity passenger) {
|
||||
- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER);
|
||||
+ // DivineMC start - always allow to enter the boat
|
||||
+ if (this.level().divinemcConfig.alwaysAllowToEnterTheBoat) {
|
||||
+ return this.getPassengers().size() < this.getMaxPassengers()/* && !this.isEyeInFluid(FluidTags.WATER)*/;
|
||||
+ } else {
|
||||
+ return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
protected int getMaxPassengers() {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
index 243b3d4379f4f6f273222a3611d8a463053d3e70..e1274fe3b0ff369d1f6f229026ced2e03ea335ca 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
@@ -82,4 +82,11 @@ public class DivineWorldConfig {
|
||||
private void saveFireworks() {
|
||||
saveFireworks = getBoolean("gameplay-mechanics.should-save-fireworks", saveFireworks);
|
||||
}
|
||||
+
|
||||
+ public boolean dontEjectPlayerFromBoatUnderwater = true;
|
||||
+ public boolean alwaysAllowToEnterTheBoat = true;
|
||||
+ private void boatFeatures() {
|
||||
+ dontEjectPlayerFromBoatUnderwater = getBoolean("gameplay-mechanics.boat.dont-eject-players-from-boat-underwater", dontEjectPlayerFromBoatUnderwater);
|
||||
+ alwaysAllowToEnterTheBoat = getBoolean("gameplay-mechanics.boat.always-allow-to-enter-the-boat", alwaysAllowToEnterTheBoat);
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 10 Jun 2023 13:12:59 +0300
|
||||
Subject: [PATCH] Despawn shulker bullets on owner death
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
|
||||
index 8242d0f292120be6cf3d6dcec2820a35809d83dd..4404b39d0777b314797ef86efdb996464c6200a9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
|
||||
@@ -225,6 +225,17 @@ public class ShulkerBullet extends Projectile {
|
||||
Vec3 vec3d;
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
+ // DivineMC start - despawn shulker bullets on owner death
|
||||
+ if (this.level().divinemcConfig.despawnShulkerBulletsOnOwnerDeath) {
|
||||
+ if (!isInvulnerable()) {
|
||||
+ var owner = getOwner();
|
||||
+ if (owner == null || !owner.isAlive()) {
|
||||
+ discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
if (this.finalTarget == null && this.targetId != null) {
|
||||
this.finalTarget = ((ServerLevel) this.level()).getEntity(this.targetId);
|
||||
if (this.finalTarget == null) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
index e1274fe3b0ff369d1f6f229026ced2e03ea335ca..7e62ee9418d5add5b0b4ddb885d3a1745ce799b2 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
@@ -89,4 +89,9 @@ public class DivineWorldConfig {
|
||||
dontEjectPlayerFromBoatUnderwater = getBoolean("gameplay-mechanics.boat.dont-eject-players-from-boat-underwater", dontEjectPlayerFromBoatUnderwater);
|
||||
alwaysAllowToEnterTheBoat = getBoolean("gameplay-mechanics.boat.always-allow-to-enter-the-boat", alwaysAllowToEnterTheBoat);
|
||||
}
|
||||
+
|
||||
+ public boolean despawnShulkerBulletsOnOwnerDeath = true;
|
||||
+ private void despawnShulkerBulletsOnOwnerDeath() {
|
||||
+ despawnShulkerBulletsOnOwnerDeath = getBoolean("gameplay-mechanics.mob.shulker.despawn-bullets-on-player-death", despawnShulkerBulletsOnOwnerDeath);
|
||||
+ }
|
||||
}
|
||||
37
patches/server/0018-Reduce-sensor-work.patch
Normal file
37
patches/server/0018-Reduce-sensor-work.patch
Normal file
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 10 Jun 2023 19:43:52 +0300
|
||||
Subject: [PATCH] Reduce sensor work
|
||||
|
||||
Original project: Bloom-host/Petal
|
||||
Link: https://github.com/Bloom-host/Petal
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 66c353e3dcca3704094ec71c38219bf74e7d7fbb..8b946ed4f252c2ae881e179183559bb9aa98ea79 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1068,20 +1068,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
EntityType<?> entitytypes = entity.getType();
|
||||
|
||||
// Purpur start
|
||||
- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)) {
|
||||
+ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) { // DivineMC - Reduce sensor work
|
||||
d0 *= entity.level().purpurConfig.skeletonHeadVisibilityPercent;
|
||||
}
|
||||
- else if (entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)) {
|
||||
+ else if (entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) { // DivineMC - Reduce sensor work
|
||||
d0 *= entity.level().purpurConfig.zombieHeadVisibilityPercent;
|
||||
}
|
||||
- else if (entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) {
|
||||
+ else if (entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // DivineMC - Reduce sensor work
|
||||
d0 *= entity.level().purpurConfig.creeperHeadVisibilityPercent;
|
||||
}
|
||||
- else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && itemstack.is(Items.PIGLIN_HEAD)) {
|
||||
+ else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD)) { // DivineMC - Reduce sensor work
|
||||
d0 *= entity.level().purpurConfig.piglinHeadVisibilityPercent;
|
||||
}
|
||||
// Purpur end
|
||||
41
patches/server/0019-Optimize-Paper-Event-Manager.patch
Normal file
41
patches/server/0019-Optimize-Paper-Event-Manager.patch
Normal file
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 25 Jun 2023 13:38:03 +0300
|
||||
Subject: [PATCH] Optimize Paper Event Manager
|
||||
|
||||
Original project: lynxplay/ktp
|
||||
Link: https://github.com/lynxplay/ktp
|
||||
Modified by NONPLAYT
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..0e3bed7a75f8f4611f9f44a1f78fd70cc06eaa54 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -36,14 +36,21 @@ class PaperEventManager {
|
||||
|
||||
// SimplePluginManager
|
||||
public void callEvent(@NotNull Event event) {
|
||||
- if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
||||
- throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
- } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||
- throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
- }
|
||||
-
|
||||
+ // DivineMC start - Optimize Paper Event Manager
|
||||
HandlerList handlers = event.getHandlers();
|
||||
RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
+ if (listeners.length == 0) return;
|
||||
+
|
||||
+ if (event.asynchronous() != net.kyori.adventure.util.TriState.NOT_SET) {
|
||||
+ final boolean onPrimaryThread = this.server.isPrimaryThread();
|
||||
+ final boolean isAsync = event.isAsynchronous();
|
||||
+ if (isAsync && onPrimaryThread) {
|
||||
+ throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
+ } else if (!isAsync && !onPrimaryThread && !this.server.isStopping()) {
|
||||
+ throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
+ }
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
|
||||
for (RegisteredListener registration : listeners) {
|
||||
if (!registration.getPlugin().isEnabled()) {
|
||||
148
patches/server/0020-Make-entity-goals-public.patch
Normal file
148
patches/server/0020-Make-entity-goals-public.patch
Normal file
@@ -0,0 +1,148 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 16 Jul 2023 11:37:32 +0300
|
||||
Subject: [PATCH] Make entity goals public
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index 539170813921de2dfcd7ef84dd7512d73cd27e68..b5609aae461d7b9353287d99a6ebe517e2b3b82e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -757,7 +757,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
this.hivePos = pos;
|
||||
}
|
||||
|
||||
- private class BeePollinateGoal extends Bee.BaseBeeGoal {
|
||||
+ public class BeePollinateGoal extends Bee.BaseBeeGoal {
|
||||
|
||||
private static final int MIN_POLLINATION_TICKS = 400;
|
||||
private static final int MIN_FIND_FLOWER_RETRY_COOLDOWN = 20;
|
||||
@@ -946,7 +946,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeLookControl extends org.purpurmc.purpur.controller.LookControllerWASD { // Purpur
|
||||
+ public class BeeLookControl extends org.purpurmc.purpur.controller.LookControllerWASD { // Purpur // DivineMC - private -> public
|
||||
|
||||
BeeLookControl(final Mob entity) {
|
||||
super(entity);
|
||||
@@ -982,7 +982,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeEnterHiveGoal extends Bee.BaseBeeGoal {
|
||||
+ public class BeeEnterHiveGoal extends Bee.BaseBeeGoal { // DivineMC - private -> public
|
||||
|
||||
BeeEnterHiveGoal() {
|
||||
super();
|
||||
@@ -1025,7 +1025,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeLocateHiveGoal extends Bee.BaseBeeGoal {
|
||||
+ public class BeeLocateHiveGoal extends Bee.BaseBeeGoal { // DivineMC - private -> public
|
||||
|
||||
BeeLocateHiveGoal() {
|
||||
super();
|
||||
@@ -1257,7 +1257,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeGrowCropGoal extends Bee.BaseBeeGoal {
|
||||
+ public class BeeGrowCropGoal extends Bee.BaseBeeGoal { // DivineMC - private -> public
|
||||
|
||||
static final int GROW_CHANCE = 30;
|
||||
|
||||
@@ -1321,7 +1321,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeWanderGoal extends Goal {
|
||||
+ public class BeeWanderGoal extends Goal { // DivineMC - private -> public
|
||||
|
||||
private static final int WANDER_THRESHOLD = 22;
|
||||
|
||||
@@ -1368,7 +1368,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private class BeeHurtByOtherGoal extends HurtByTargetGoal {
|
||||
+ public class BeeHurtByOtherGoal extends HurtByTargetGoal { // DivineMC - private -> public
|
||||
|
||||
BeeHurtByOtherGoal(final Bee entitybee) {
|
||||
super(entitybee);
|
||||
@@ -1388,7 +1388,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private static class BeeBecomeAngryTargetGoal extends NearestAttackableTargetGoal<Player> {
|
||||
+ public static class BeeBecomeAngryTargetGoal extends NearestAttackableTargetGoal<Player> { // DivineMC - private -> public
|
||||
|
||||
BeeBecomeAngryTargetGoal(Bee bee) {
|
||||
// Objects.requireNonNull(entitybee); // CraftBukkit - decompile error
|
||||
@@ -1419,7 +1419,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
- private abstract class BaseBeeGoal extends Goal {
|
||||
+ public abstract class BaseBeeGoal extends Goal { // DivineMC - private -> public
|
||||
|
||||
BaseBeeGoal() {}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
index 3e1345f1c534320e07820d573f5c8dba49746425..26ddab27ac1ca1902f849f98d000ffb801610691 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
@@ -575,7 +575,7 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian
|
||||
}
|
||||
}
|
||||
|
||||
- private static class CatRelaxOnOwnerGoal extends Goal {
|
||||
+ public static class CatRelaxOnOwnerGoal extends Goal { // DivineMC - private -> public
|
||||
|
||||
private final Cat cat;
|
||||
@Nullable
|
||||
@@ -721,7 +721,7 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian
|
||||
}
|
||||
}
|
||||
|
||||
- private static class CatAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> {
|
||||
+ public static class CatAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> { // DivineMC - private -> public
|
||||
|
||||
private final Cat cat;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
|
||||
index e7703aa5467e7551bff06fab4c11d76237bda2e0..e5944bd3598bd82b2891f576462013a4692c1609 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
|
||||
@@ -89,7 +89,7 @@ public class Vindicator extends AbstractIllager {
|
||||
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
||||
this.goalSelector.addGoal(1, new Vindicator.VindicatorBreakDoorGoal(this));
|
||||
this.goalSelector.addGoal(2, new AbstractIllager.RaiderOpenDoorGoal(this));
|
||||
- this.goalSelector.addGoal(3, new Raider.HoldGroundAttackGoal(this, 10.0F));
|
||||
+ this.goalSelector.addGoal(3, new HoldGroundAttackGoal(this, 10.0F));
|
||||
this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0, false));
|
||||
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Raider.class).setAlertOthers());
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
index 4a8fa7e5844b5cd12ef6b113f988b715c7a3ef64..f6e89565e793d346302498c1108069d3435ab082 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -374,7 +374,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||
}
|
||||
}
|
||||
|
||||
- private static class RaiderMoveThroughVillageGoal extends Goal {
|
||||
+ public class RaiderMoveThroughVillageGoal extends Goal { // DivineMC - private -> public
|
||||
|
||||
private final Raider raider;
|
||||
private final double speedModifier;
|
||||
@@ -522,7 +522,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||
}
|
||||
}
|
||||
|
||||
- public class HoldGroundAttackGoal extends Goal {
|
||||
+ public static class HoldGroundAttackGoal extends Goal { // DivineMC - public -> public static
|
||||
|
||||
private final Raider mob;
|
||||
private final float hostileRadiusSqr;
|
||||
51
patches/server/0021-Optimize-CraftServer.getWorld-UUID.patch
Normal file
51
patches/server/0021-Optimize-CraftServer.getWorld-UUID.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 13:36:55 +0300
|
||||
Subject: [PATCH] Optimize CraftServer.getWorld(UUID)
|
||||
|
||||
Original code by MultiPaper - https://github.com/MultiPaper/MultiPaper
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 8d75e43d1c0d8a65ebbf146dcccd23509c236540..71b40f824949dedfe35fe3012b9715a7c598dfb8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -268,6 +268,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
import space.bxteam.divinemc.configuration.DivineConfig; // DivineMC
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // DivineMC
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
private final String serverName = "DivineMC"; // Paper // Pufferfish // Purpur // DivineMC
|
||||
@@ -286,6 +287,7 @@ public final class CraftServer implements Server {
|
||||
protected final DedicatedPlayerList playerList;
|
||||
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
|
||||
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
|
||||
+ private final Map<UUID, World> worldsByUUID = new Object2ObjectLinkedOpenHashMap<>(); // DivineMC - MultiPaper - optimize getWorld(UUID)
|
||||
private YamlConfiguration configuration;
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
@@ -1483,6 +1485,7 @@ public final class CraftServer implements Server {
|
||||
this.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
+ this.worldsByUUID.remove(world.getUID()); // DivineMC - MultiPaper - optimize getWorld(UUID)
|
||||
this.worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH));
|
||||
this.console.removeLevel(handle);
|
||||
return true;
|
||||
@@ -1501,6 +1504,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public World getWorld(UUID uid) {
|
||||
+ if (true) return this.worldsByUUID.get(uid); // DivineMC - MultiPaper - optimize getWorld(UUID)
|
||||
for (World world : this.worlds.values()) {
|
||||
if (world.getUID().equals(uid)) {
|
||||
return world;
|
||||
@@ -1524,6 +1528,7 @@ public final class CraftServer implements Server {
|
||||
System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world.");
|
||||
return;
|
||||
}
|
||||
+ this.worldsByUUID.put(world.getUID(), world); // DivineMC - MultiPaper - optimize getWorld(UUID)
|
||||
this.worlds.put(world.getName().toLowerCase(java.util.Locale.ENGLISH), world);
|
||||
}
|
||||
|
||||
167
patches/server/0022-Carpet-Fixes-getBiome-Optimize.patch
Normal file
167
patches/server/0022-Carpet-Fixes-getBiome-Optimize.patch
Normal file
@@ -0,0 +1,167 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 19:19:16 +0300
|
||||
Subject: [PATCH] Carpet-Fixes: getBiome Optimize
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
index 01352cc83b25eb0e30b7e0ff521fc7c1b3d5155b..c042287e12b5ce814afe8557e4dfa8e8b16b0f5a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
@@ -14,6 +14,7 @@ public class BiomeManager {
|
||||
private static final int ZOOM_MASK = 3;
|
||||
private final BiomeManager.NoiseBiomeSource noiseBiomeSource;
|
||||
private final long biomeZoomSeed;
|
||||
+ private static final double maxOffset = 0.4500000001D; // DivineMC - Carpet-Fixes: getBiome Optimize
|
||||
|
||||
public BiomeManager(BiomeManager.NoiseBiomeSource storage, long seed) {
|
||||
this.noiseBiomeSource = storage;
|
||||
@@ -29,39 +30,103 @@ public class BiomeManager {
|
||||
}
|
||||
|
||||
public Holder<Biome> getBiome(BlockPos pos) {
|
||||
- int i = pos.getX() - 2;
|
||||
- int j = pos.getY() - 2;
|
||||
- int k = pos.getZ() - 2;
|
||||
- int l = i >> 2;
|
||||
- int m = j >> 2;
|
||||
- int n = k >> 2;
|
||||
- double d = (double)(i & 3) / 4.0;
|
||||
- double e = (double)(j & 3) / 4.0;
|
||||
- double f = (double)(k & 3) / 4.0;
|
||||
- int o = 0;
|
||||
- double g = Double.POSITIVE_INFINITY;
|
||||
-
|
||||
- for (int p = 0; p < 8; p++) {
|
||||
- boolean bl = (p & 4) == 0;
|
||||
- boolean bl2 = (p & 2) == 0;
|
||||
- boolean bl3 = (p & 1) == 0;
|
||||
- int q = bl ? l : l + 1;
|
||||
- int r = bl2 ? m : m + 1;
|
||||
- int s = bl3 ? n : n + 1;
|
||||
- double h = bl ? d : d - 1.0;
|
||||
- double t = bl2 ? e : e - 1.0;
|
||||
- double u = bl3 ? f : f - 1.0;
|
||||
- double v = getFiddledDistance(this.biomeZoomSeed, q, r, s, h, t, u);
|
||||
- if (g > v) {
|
||||
- o = p;
|
||||
- g = v;
|
||||
+ // DivineMC start - Carpet-Fixes: getBiome Optimize
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.biomeManagerOptimization) {
|
||||
+ int xMinus2 = pos.getX() - 2;
|
||||
+ int yMinus2 = pos.getY() - 2;
|
||||
+ int zMinus2 = pos.getZ() - 2;
|
||||
+ int x = xMinus2 >> 2; // BlockPos to BiomePos
|
||||
+ int y = yMinus2 >> 2;
|
||||
+ int z = zMinus2 >> 2;
|
||||
+ double quartX = (double) (xMinus2 & 3) / 4.0D; // quartLocal divided by 4
|
||||
+ double quartY = (double) (yMinus2 & 3) / 4.0D; // 0/4, 1/4, 2/4, 3/4
|
||||
+ double quartZ = (double) (zMinus2 & 3) / 4.0D; // [0, 0.25, 0.5, 0.75]
|
||||
+ int smallestX = 0;
|
||||
+ double smallestDist = Double.POSITIVE_INFINITY;
|
||||
+ for (int biomeX = 0; biomeX < 8; ++biomeX) {
|
||||
+ boolean everyOtherQuad = (biomeX & 4) == 0; // 1 1 1 1 0 0 0 0
|
||||
+ boolean everyOtherPair = (biomeX & 2) == 0; // 1 1 0 0 1 1 0 0
|
||||
+ boolean everyOther = (biomeX & 1) == 0; // 1 0 1 0 1 0 1 0
|
||||
+ double quartXX = everyOtherQuad ? quartX : quartX - 1.0D; //[-1.0,-0.75,-0.5,-0.25,0.0,0.25,0.5,0.75]
|
||||
+ double quartYY = everyOtherPair ? quartY : quartY - 1.0D;
|
||||
+ double quartZZ = everyOther ? quartZ : quartZ - 1.0D;
|
||||
+
|
||||
+ double maxQuartYY = 0.0D, maxQuartZZ = 0.0D;
|
||||
+ if (biomeX != 0) {
|
||||
+ maxQuartYY = Mth.square(Math.max(quartYY + maxOffset, Math.abs(quartYY - maxOffset)));
|
||||
+ maxQuartZZ = Mth.square(Math.max(quartZZ + maxOffset, Math.abs(quartZZ - maxOffset)));
|
||||
+ double maxQuartXX = Mth.square(Math.max(quartXX + maxOffset, Math.abs(quartXX - maxOffset)));
|
||||
+ if (smallestDist < maxQuartXX + maxQuartYY + maxQuartZZ) continue;
|
||||
+ }
|
||||
+
|
||||
+ int xx = everyOtherQuad ? x : x + 1;
|
||||
+ int yy = everyOtherPair ? y : y + 1;
|
||||
+ int zz = everyOther ? z : z + 1;
|
||||
+
|
||||
+ //I transferred the code from method_38106 to here, so I could call continue halfway through
|
||||
+ long seed = LinearCongruentialGenerator.next(this.biomeZoomSeed, xx);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, yy);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, zz);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, xx);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, yy);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, zz);
|
||||
+ double offsetX = getFiddle(seed);
|
||||
+ double sqrX = Mth.square(quartXX + offsetX);
|
||||
+ if (biomeX != 0 && smallestDist < sqrX + maxQuartYY + maxQuartZZ) continue; //skip the rest of the loop
|
||||
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||
+ double offsetY = getFiddle(seed);
|
||||
+ double sqrY = Mth.square(quartYY + offsetY);
|
||||
+ if (biomeX != 0 && smallestDist < sqrX + sqrY + maxQuartZZ) continue; // skip the rest of the loop
|
||||
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||
+ double offsetZ = getFiddle(seed);
|
||||
+ double biomeDist = sqrX + sqrY + Mth.square(quartZZ + offsetZ);
|
||||
+
|
||||
+ if (smallestDist > biomeDist) {
|
||||
+ smallestX = biomeX;
|
||||
+ smallestDist = biomeDist;
|
||||
+ }
|
||||
+ }
|
||||
+ return this.noiseBiomeSource.getNoiseBiome(
|
||||
+ (smallestX & 4) == 0 ? x : x + 1,
|
||||
+ (smallestX & 2) == 0 ? y : y + 1,
|
||||
+ (smallestX & 1) == 0 ? z : z + 1
|
||||
+ );
|
||||
+ } else {
|
||||
+ int i = pos.getX() - 2;
|
||||
+ int j = pos.getY() - 2;
|
||||
+ int k = pos.getZ() - 2;
|
||||
+ int l = i >> 2;
|
||||
+ int m = j >> 2;
|
||||
+ int n = k >> 2;
|
||||
+ double d = (double)(i & 3) / 4.0;
|
||||
+ double e = (double)(j & 3) / 4.0;
|
||||
+ double f = (double)(k & 3) / 4.0;
|
||||
+ int o = 0;
|
||||
+ double g = Double.POSITIVE_INFINITY;
|
||||
+
|
||||
+ for (int p = 0; p < 8; p++) {
|
||||
+ boolean bl = (p & 4) == 0;
|
||||
+ boolean bl2 = (p & 2) == 0;
|
||||
+ boolean bl3 = (p & 1) == 0;
|
||||
+ int q = bl ? l : l + 1;
|
||||
+ int r = bl2 ? m : m + 1;
|
||||
+ int s = bl3 ? n : n + 1;
|
||||
+ double h = bl ? d : d - 1.0;
|
||||
+ double t = bl2 ? e : e - 1.0;
|
||||
+ double u = bl3 ? f : f - 1.0;
|
||||
+ double v = getFiddledDistance(this.biomeZoomSeed, q, r, s, h, t, u);
|
||||
+ if (g > v) {
|
||||
+ o = p;
|
||||
+ g = v;
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
|
||||
- int w = (o & 4) == 0 ? l : l + 1;
|
||||
- int x = (o & 2) == 0 ? m : m + 1;
|
||||
- int y = (o & 1) == 0 ? n : n + 1;
|
||||
- return this.noiseBiomeSource.getNoiseBiome(w, x, y);
|
||||
+ int w = (o & 4) == 0 ? l : l + 1;
|
||||
+ int x = (o & 2) == 0 ? m : m + 1;
|
||||
+ int y = (o & 1) == 0 ? n : n + 1;
|
||||
+ return this.noiseBiomeSource.getNoiseBiome(w, x, y);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
public Holder<Biome> getNoiseBiomeAtPosition(double x, double y, double z) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index c10403d781d25e4bb9e43d3f064fb1aebde00bfb..73b6c3590dad95cddd9cc1a1cff36492175da232 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -152,4 +152,9 @@ public class DivineConfig {
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
+
|
||||
+ public static boolean biomeManagerOptimization = true;
|
||||
+ private static void optimizations() {
|
||||
+ biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 18:58:14 +0300
|
||||
Subject: [PATCH] Carpet-Fixes: RecipeManager Optimize
|
||||
|
||||
Original project: https://github.com/fxmorin/carpet-fixes
|
||||
Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index a31326e24cb68472c81cd781c5e3041772712862..6113cf0ff4090e06c40a6f439fde07bf74a34745 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -12,15 +12,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
-import java.util.Collection;
|
||||
-import java.util.Comparator;
|
||||
-import java.util.Iterator;
|
||||
-import java.util.List;
|
||||
-import java.util.Map;
|
||||
-import java.util.Map.Entry;
|
||||
-import java.util.Optional;
|
||||
-import java.util.stream.Collectors;
|
||||
-import java.util.stream.Stream;
|
||||
+import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -132,7 +124,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getAllRecipesFor(RecipeType<T> type) {
|
||||
- return List.copyOf(this.byType(type));
|
||||
+ return space.bxteam.divinemc.configuration.DivineConfig.recipeManagerOptimization ? new ArrayList<>(this.byType(type)) : List.copyOf(this.byType(type)); // DivineMC - Carpet-Fixes: RecipeManager Optimize
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<RecipeHolder<T>> getRecipesFor(RecipeType<T> type, C inventory, Level world) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index 73b6c3590dad95cddd9cc1a1cff36492175da232..67ff4450b58c1df2f595a136c53d60bbefa2e8d5 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -154,7 +154,9 @@ public class DivineConfig {
|
||||
}
|
||||
|
||||
public static boolean biomeManagerOptimization = true;
|
||||
+ public static boolean recipeManagerOptimization = true;
|
||||
private static void optimizations() {
|
||||
biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
|
||||
+ recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Fri, 26 Jan 2024 17:42:42 +0300
|
||||
Subject: [PATCH] vmp: skip entity move if movement is zero
|
||||
|
||||
Original code by RelativityMC, licensed under MIT
|
||||
You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 288edb7bcf2159822d6bd14e9a6378a8bad0c689..0acd53f74682b968828c539055c7a7cb6f3dc705 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -320,6 +320,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public float yRotO;
|
||||
public float xRotO;
|
||||
private AABB bb;
|
||||
+ private boolean boundingBoxChanged = false; // DivineMC - vmp: skip entity move if movement is zero
|
||||
public boolean onGround;
|
||||
public boolean horizontalCollision;
|
||||
public boolean verticalCollision;
|
||||
@@ -1153,6 +1154,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// Paper end - detailed watchdog information
|
||||
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
+ // DivineMC start - vmp: skip entity move if movement is zero
|
||||
+ if (!boundingBoxChanged && movement.equals(Vec3.ZERO)) {
|
||||
+ boundingBoxChanged = false;
|
||||
+ return;
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -4217,6 +4224,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AABB boundingBox) {
|
||||
+ if (!this.bb.equals(boundingBox)) boundingBoxChanged = true; // DivineMC - vmp: skip entity move if movement is zero
|
||||
// CraftBukkit start - block invalid bounding boxes
|
||||
double minX = boundingBox.minX,
|
||||
minY = boundingBox.minY,
|
||||
@@ -0,0 +1,30 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 14 Jan 2024 14:50:10 +0300
|
||||
Subject: [PATCH] vmp: use linked map for entity trackers for faster iteration
|
||||
|
||||
Original code by RelativityMC, licensed under MIT
|
||||
You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 4e6fccec4f5ca14562bf5bae495ac36c14982d85..be8870d01262b37d130d518a500db7117f568950 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -110,6 +110,8 @@ import org.slf4j.Logger;
|
||||
import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
|
||||
// CraftBukkit end
|
||||
|
||||
+import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; // DivineMC - vmp: use linked map for entity trackers for faster iteration
|
||||
+
|
||||
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
|
||||
|
||||
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
||||
@@ -254,7 +256,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper - rewrite chunk system
|
||||
this.tickingGenerated = new AtomicInteger();
|
||||
this.playerMap = new PlayerMap();
|
||||
- this.entityMap = new Int2ObjectOpenHashMap();
|
||||
+ this.entityMap = new Int2ObjectLinkedOpenHashMap<>(); // DivineMC - vmp: use linked map for entity trackers for faster iteration
|
||||
this.chunkTypeCache = new Long2ByteOpenHashMap();
|
||||
this.chunkSaveCooldowns = new Long2LongOpenHashMap();
|
||||
this.unloadQueue = Queues.newConcurrentLinkedQueue();
|
||||
52
patches/server/0026-lithium-ai.raid.patch
Normal file
52
patches/server/0026-lithium-ai.raid.patch
Normal file
@@ -0,0 +1,52 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 8 Apr 2023 23:45:11 +0300
|
||||
Subject: [PATCH] lithium: ai.raid
|
||||
|
||||
This patch is based on the following mixin:
|
||||
"me/jellysquid/mods/lithium/mixin/ai/raid/RaidMixin.java"
|
||||
By: Angeline <jellysquid3@users.noreply.github.com>
|
||||
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||
index fdff9788eaf663be79214b2ca491f0f0444f6136..e09f137f4f412eee55a18c0d14593f7b5b7c6319 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
||||
@@ -110,6 +110,7 @@ public class Raid {
|
||||
private Raid.RaidStatus status;
|
||||
private int celebrationTicks;
|
||||
private Optional<BlockPos> waveSpawnPos;
|
||||
+ private boolean isBarDirty; // DivineMC - lithium: ai.raid
|
||||
// Paper start
|
||||
private static final String PDC_NBT_KEY = "BukkitValues";
|
||||
private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
|
||||
@@ -295,6 +296,12 @@ public class Raid {
|
||||
|
||||
public void tick() {
|
||||
if (!this.isStopped()) {
|
||||
+ // DivineMC start - lithium: ai.raid
|
||||
+ if (this.isBarDirty) {
|
||||
+ this.updateBossbarInternal();
|
||||
+ this.isBarDirty = false;
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
if (this.status == Raid.RaidStatus.ONGOING) {
|
||||
boolean flag = this.active;
|
||||
|
||||
@@ -663,9 +670,15 @@ public class Raid {
|
||||
|
||||
}
|
||||
|
||||
+ // DivineMC start - lithium: ai.raid
|
||||
public void updateBossbar() {
|
||||
+ this.isBarDirty = true;
|
||||
+ }
|
||||
+
|
||||
+ private void updateBossbarInternal() {
|
||||
this.raidEvent.setProgress(Mth.clamp(this.getHealthOfLivingRaiders() / this.totalHealth, 0.0F, 1.0F));
|
||||
}
|
||||
+ // DivineMC end
|
||||
|
||||
public float getHealthOfLivingRaiders() {
|
||||
float f = 0.0F;
|
||||
29
patches/server/0027-lithium-collections.gamerules.patch
Normal file
29
patches/server/0027-lithium-collections.gamerules.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 8 Apr 2023 01:28:01 +0300
|
||||
Subject: [PATCH] lithium: collections.gamerules
|
||||
|
||||
Original code by CaffeineMC, licensed under LGPL v3
|
||||
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
index 89e327bc3a45879fe68887c7aadb077f31a770eb..bb0fcf15fa49d6b352b11d4cffe4e2c8b0fe5c30 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.slf4j.Logger;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
|
||||
public class GameRules {
|
||||
|
||||
@@ -149,7 +150,7 @@ public class GameRules {
|
||||
}
|
||||
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) {
|
||||
- this.rules = rules;
|
||||
+ this.rules = new Object2ObjectOpenHashMap<>(rules); // DivineMC - lithium: collections.gamerules
|
||||
|
||||
// Paper start - Perf: Use array for gamerule storage
|
||||
int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;
|
||||
32
patches/server/0028-lithium-collections.entity_by_type.patch
Normal file
32
patches/server/0028-lithium-collections.entity_by_type.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 20:12:23 +0300
|
||||
Subject: [PATCH] lithium: collections.entity_by_type
|
||||
|
||||
Original code by CaffeineMC, licensed under LGPL v3
|
||||
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||
index 038710ba934a9a57815dfe9f414b98223b848385..f631aa8bc724d0fc899783967417c3e01aac3c9c 100644
|
||||
--- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||
+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java
|
||||
@@ -3,7 +3,6 @@ package net.minecraft.util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
-import com.google.common.collect.Maps;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -12,9 +11,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.Util;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // DivineMC
|
||||
|
||||
public class ClassInstanceMultiMap<T> extends AbstractCollection<T> {
|
||||
- private final Map<Class<?>, List<T>> byClass = Maps.newHashMap();
|
||||
+ private final Map<Class<?>, List<T>> byClass = new Reference2ReferenceOpenHashMap<>(); // DivineMC
|
||||
private final Class<T> baseClass;
|
||||
private final List<T> allInstances = Lists.newArrayList();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 20:37:54 +0300
|
||||
Subject: [PATCH] lithium: entity.fast_elytra_check + entity.fast_hand_swing
|
||||
|
||||
Original code by CaffeineMC, licensed under LGPL v3
|
||||
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 8b946ed4f252c2ae881e179183559bb9aa98ea79..9a29daf32c31a33babb5526bbf21907aaa0aeca3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2653,6 +2653,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void updateSwingTime() {
|
||||
+ if (!this.swinging && this.swingTime == 0) return; // DivineMC - lithium: entity.fast_hand_swing
|
||||
int i = this.getCurrentSwingDuration();
|
||||
|
||||
if (this.swinging) {
|
||||
@@ -3626,6 +3627,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
private void updateFallFlying() {
|
||||
+ if (!this.isFallFlying()) return; // DivineMC - lithium: entity.fast_elytra_check
|
||||
boolean flag = this.getSharedFlag(7);
|
||||
|
||||
if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) {
|
||||
76
patches/server/0030-lithium-precompute-shape-arrays.patch
Normal file
76
patches/server/0030-lithium-precompute-shape-arrays.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Wed, 17 Apr 2024 02:08:02 +0300
|
||||
Subject: [PATCH] lithium: precompute shape arrays
|
||||
|
||||
Original code by CaffeineMC, licensed under LGPL v3
|
||||
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
||||
index ab289a6ca85459e03acb2089c6b9e931caa9c873..377e327432ae2ba7edde7fac807d542f16568e3d 100644
|
||||
--- a/src/main/java/net/minecraft/core/Direction.java
|
||||
+++ b/src/main/java/net/minecraft/core/Direction.java
|
||||
@@ -46,7 +46,7 @@ public enum Direction implements StringRepresentable {
|
||||
private final Direction.Axis axis;
|
||||
private final Direction.AxisDirection axisDirection;
|
||||
private final Vec3i normal;
|
||||
- private static final Direction[] VALUES = values();
|
||||
+ public static final Direction[] VALUES = values(); // DivineMC - lithium: precompute shape arrays
|
||||
private static final Direction[] BY_3D_DATA = Arrays.stream(VALUES)
|
||||
.sorted(Comparator.comparingInt(direction -> direction.data3d))
|
||||
.toArray(Direction[]::new);
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
||||
index a544db042c8d2ecec8d323770552c4f10ca758a6..fc6a8b1cf33427320a60e3f2d9894ed2f0177bf7 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
||||
@@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList;
|
||||
|
||||
public class CubePointRange extends AbstractDoubleList {
|
||||
private final int parts;
|
||||
+ private double scale; // DivineMC - lithium: precompute shape arrays
|
||||
|
||||
CubePointRange(int sectionCount) {
|
||||
if (sectionCount <= 0) {
|
||||
@@ -11,10 +12,11 @@ public class CubePointRange extends AbstractDoubleList {
|
||||
} else {
|
||||
this.parts = sectionCount;
|
||||
}
|
||||
+ this.scale = 1.0D / sectionCount; // DivineMC - lithium: precompute shape arrays
|
||||
}
|
||||
|
||||
public double getDouble(int i) {
|
||||
- return (double)i / (double)this.parts;
|
||||
+ return i * this.scale; // DivineMC - lithium: precompute shape arrays
|
||||
}
|
||||
|
||||
public int size() {
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
index b9af1d14c7815c99273bce8165cf384d669c1a75..16bf73856465c10e1ab84c17e7b317ef9081704d 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public final class CubeVoxelShape extends VoxelShape {
|
||||
+ private DoubleList[] list; // DivineMC - lithium: precompute shape arrays
|
||||
+
|
||||
protected CubeVoxelShape(DiscreteVoxelShape voxels) {
|
||||
super(voxels);
|
||||
this.initCache(); // Paper - optimise collisions
|
||||
@@ -12,7 +14,15 @@ public final class CubeVoxelShape extends VoxelShape {
|
||||
|
||||
@Override
|
||||
protected DoubleList getCoords(Direction.Axis axis) {
|
||||
- return new CubePointRange(this.shape.getSize(axis));
|
||||
+ // DivineMC start - lithium: precompute shape arrays
|
||||
+ if (this.list == null) {
|
||||
+ this.list = new DoubleList[Direction.Axis.VALUES.length];
|
||||
+ for (Direction.Axis existingAxis : Direction.Axis.VALUES) {
|
||||
+ this.list[existingAxis.ordinal()] = new CubePointRange(this.shape.getSize(axis));
|
||||
+ }
|
||||
+ }
|
||||
+ return this.list[axis.ordinal()];
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
@Override
|
||||
130
patches/server/0031-Carpet-Fixes-Sheep-Optimization.patch
Normal file
130
patches/server/0031-Carpet-Fixes-Sheep-Optimization.patch
Normal file
@@ -0,0 +1,130 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 20:59:28 +0300
|
||||
Subject: [PATCH] Carpet-Fixes: Sheep Optimization
|
||||
|
||||
Original project: https://github.com/fxmorin/carpet-fixes
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
index 6b1244d3957e7f62c96ffd34692b8916337839fd..994d81bb16040439ecbdf427dfde70d255a9076c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
@@ -68,6 +68,7 @@ import net.minecraft.world.item.Item;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
+import space.bxteam.divinemc.util.carpetfixes.ProperDyeMixin;
|
||||
// CraftBukkit end
|
||||
|
||||
public class Sheep extends Animal implements Shearable {
|
||||
@@ -460,21 +461,30 @@ public class Sheep extends Animal implements Shearable {
|
||||
return super.finalizeSpawn(world, difficulty, spawnReason, entityData);
|
||||
}
|
||||
|
||||
+ // DivineMC start - Carpet-Fixes: Sheep Optimization
|
||||
private DyeColor getOffspringColor(Animal firstParent, Animal secondParent) {
|
||||
- DyeColor enumcolor = ((Sheep) firstParent).getColor();
|
||||
- DyeColor enumcolor1 = ((Sheep) secondParent).getColor();
|
||||
- CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1);
|
||||
- Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
|
||||
- return ((CraftingRecipe) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess());
|
||||
- }).map(ItemStack::getItem);
|
||||
-
|
||||
- Objects.requireNonNull(DyeItem.class);
|
||||
- optional = optional.filter(DyeItem.class::isInstance);
|
||||
- Objects.requireNonNull(DyeItem.class);
|
||||
- return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
|
||||
- return this.level().random.nextBoolean() ? enumcolor : enumcolor1;
|
||||
- });
|
||||
+ DyeColor firstColor = ((Sheep) firstParent).getColor();
|
||||
+ DyeColor secondColor = ((Sheep) secondParent).getColor();
|
||||
+
|
||||
+ if (space.bxteam.divinemc.configuration.DivineConfig.sheepOptimization) {
|
||||
+ DyeColor col = ProperDyeMixin.properDye(firstColor, secondColor);
|
||||
+ if (col == null) col = this.level().random.nextBoolean() ? firstColor : secondColor;
|
||||
+ return col;
|
||||
+ } else {
|
||||
+ CraftingContainer inventorycrafting = Sheep.makeContainer(firstColor, secondColor);
|
||||
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
|
||||
+ return ((CraftingRecipe) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess());
|
||||
+ }).map(ItemStack::getItem);
|
||||
+
|
||||
+ Objects.requireNonNull(DyeItem.class);
|
||||
+ optional = optional.filter(DyeItem.class::isInstance);
|
||||
+ Objects.requireNonNull(DyeItem.class);
|
||||
+ return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
|
||||
+ return this.level().random.nextBoolean() ? firstColor : secondColor;
|
||||
+ });
|
||||
+ }
|
||||
}
|
||||
+ // DivineMC end
|
||||
|
||||
private static CraftingContainer makeContainer(DyeColor firstColor, DyeColor secondColor) {
|
||||
TransientCraftingContainer transientcraftingcontainer = new TransientCraftingContainer(new AbstractContainerMenu((MenuType) null, -1) {
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
index 67ff4450b58c1df2f595a136c53d60bbefa2e8d5..13ea61e380ea8d0772107b06008bf86e274e5f91 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
|
||||
@@ -155,8 +155,10 @@ public class DivineConfig {
|
||||
|
||||
public static boolean biomeManagerOptimization = true;
|
||||
public static boolean recipeManagerOptimization = true;
|
||||
+ public static boolean sheepOptimization = true;
|
||||
private static void optimizations() {
|
||||
biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
|
||||
recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
|
||||
+ sheepOptimization = getBoolean("settings.optimizations.sheep-optimization", sheepOptimization);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java b/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6cbcf1580312a9275e41813a26b36e42a2481a2c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package space.bxteam.divinemc.util.carpetfixes;
|
||||
+
|
||||
+import net.minecraft.world.item.DyeColor;
|
||||
+
|
||||
+public class ProperDyeMixin {
|
||||
+ public static DyeColor properDye(DyeColor firstColor, DyeColor secondColor) {
|
||||
+ if (firstColor.equals(secondColor)) return firstColor;
|
||||
+ switch (firstColor) {
|
||||
+ case WHITE -> {
|
||||
+ switch (secondColor) {
|
||||
+ case BLUE -> {return DyeColor.LIGHT_BLUE;}
|
||||
+ case GRAY -> {return DyeColor.LIGHT_GRAY;}
|
||||
+ case BLACK -> {return DyeColor.GRAY;}
|
||||
+ case GREEN -> {return DyeColor.LIME;}
|
||||
+ case RED -> {return DyeColor.PINK;}
|
||||
+ }
|
||||
+ }
|
||||
+ case BLUE -> {
|
||||
+ switch (secondColor) {
|
||||
+ case WHITE -> {return DyeColor.LIGHT_BLUE;}
|
||||
+ case GREEN -> {return DyeColor.CYAN;}
|
||||
+ case RED -> {return DyeColor.PURPLE;}
|
||||
+ }
|
||||
+ }
|
||||
+ case RED -> {
|
||||
+ switch (secondColor) {
|
||||
+ case YELLOW -> {return DyeColor.ORANGE;}
|
||||
+ case WHITE -> {return DyeColor.PINK;}
|
||||
+ case BLUE -> {return DyeColor.PURPLE;}
|
||||
+ }
|
||||
+ }
|
||||
+ case GREEN -> {
|
||||
+ switch (secondColor) {
|
||||
+ case BLUE -> {return DyeColor.CYAN;}
|
||||
+ case WHITE -> {return DyeColor.LIME;}
|
||||
+ }
|
||||
+ }
|
||||
+ case YELLOW -> {if (secondColor.equals(DyeColor.RED)) return DyeColor.ORANGE;}
|
||||
+ case PURPLE -> {if (secondColor.equals(DyeColor.PINK)) return DyeColor.MAGENTA;}
|
||||
+ case PINK -> {if (secondColor.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;}
|
||||
+ case GRAY -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;}
|
||||
+ case BLACK -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.GRAY;}
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+}
|
||||
68
patches/server/0032-Snowball-and-Egg-knockback.patch
Normal file
68
patches/server/0032-Snowball-and-Egg-knockback.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Wed, 17 Apr 2024 02:02:02 +0300
|
||||
Subject: [PATCH] Snowball and Egg knockback
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||
index 1b9d0e28e518c501b4b93ae385ddd64aeade97d5..727df038b20bb826a630d3f2c835c7ad7d9d651e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.projectile;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -61,6 +62,13 @@ public class Snowball extends ThrowableItemProjectile {
|
||||
int i = entity.level().purpurConfig.snowballDamage >= 0 ? entity.level().purpurConfig.snowballDamage : entity instanceof Blaze ? 3 : 0; // Purpur
|
||||
|
||||
entity.hurt(this.damageSources().thrown(this, this.getOwner()), (float) i);
|
||||
+
|
||||
+ // DivineMC start - Snowball and Egg knockback
|
||||
+ if (this.level().divinemcConfig.snowballCanKnockback && entity instanceof ServerPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ ((ServerPlayer) entity).knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ(), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.DAMAGE);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
// Purpur start - borrowed and modified code from ThrownPotion#onHitBlock and ThrownPotion#dowseFire
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
index 82bb8004635865f5202578d5a6f520048e7269d5..f1ac568258170d76c242d4083c080ae5080cc368 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
@@ -46,7 +46,15 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
@Override
|
||||
protected void onHitEntity(EntityHitResult entityHitResult) {
|
||||
super.onHitEntity(entityHitResult);
|
||||
+ Entity entity = entityHitResult.getEntity(); // DivineMC
|
||||
entityHitResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F);
|
||||
+
|
||||
+ // DivineMC start - Snowball and Egg knockback
|
||||
+ if (this.level().divinemcConfig.eggCanKnockback && entity instanceof ServerPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ ((ServerPlayer) entity).knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ(), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.DAMAGE);
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
index 7e62ee9418d5add5b0b4ddb885d3a1745ce799b2..242da697c957508c8e75bfd232c44ea34ba3a62a 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
@@ -94,4 +94,11 @@ public class DivineWorldConfig {
|
||||
private void despawnShulkerBulletsOnOwnerDeath() {
|
||||
despawnShulkerBulletsOnOwnerDeath = getBoolean("gameplay-mechanics.mob.shulker.despawn-bullets-on-player-death", despawnShulkerBulletsOnOwnerDeath);
|
||||
}
|
||||
+
|
||||
+ public boolean snowballCanKnockback = true;
|
||||
+ public boolean eggCanKnockback = true;
|
||||
+ private void setSnowballAndEggKnockback() {
|
||||
+ snowballCanKnockback = getBoolean("gameplay-mechanics.projectiles.snowball.knockback", snowballCanKnockback);
|
||||
+ eggCanKnockback = getBoolean("gameplay-mechanics.projectiles.egg.knockback", eggCanKnockback);
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sun, 14 Jan 2024 22:58:43 +0300
|
||||
Subject: [PATCH] Suppress errors from dirty attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 39e7dcf3c92c9203c190782be401c00c010b8aeb..78ce9687a163255098eb8408dacefa1c9525b636 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -386,7 +386,10 @@ public class ServerEntity {
|
||||
}
|
||||
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
- Set<AttributeInstance> set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
|
||||
+ // DivineMC start - Suppress errors from dirty attributes
|
||||
+ Set<AttributeInstance> attributes = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
|
||||
+ final Set<AttributeInstance> set = this.level.divinemcConfig.suppressErrorsFromDirtyAttributes ? Collections.synchronizedSet(attributes) : attributes;
|
||||
+ // DivineMC end
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
// CraftBukkit start - Send scaled max health
|
||||
@@ -397,7 +400,7 @@ public class ServerEntity {
|
||||
this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set));
|
||||
}
|
||||
|
||||
- set.clear();
|
||||
+ attributes.clear(); // DivineMC
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
index 242da697c957508c8e75bfd232c44ea34ba3a62a..d94c51ea18d299dd52b9a8521a9cdc0d95b79356 100644
|
||||
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
|
||||
@@ -101,4 +101,9 @@ public class DivineWorldConfig {
|
||||
snowballCanKnockback = getBoolean("gameplay-mechanics.projectiles.snowball.knockback", snowballCanKnockback);
|
||||
eggCanKnockback = getBoolean("gameplay-mechanics.projectiles.egg.knockback", eggCanKnockback);
|
||||
}
|
||||
+
|
||||
+ public boolean suppressErrorsFromDirtyAttributes = true;
|
||||
+ private void suppressErrorsFromDirtyAttributes() {
|
||||
+ suppressErrorsFromDirtyAttributes = getBoolean("suppress-errors-from-dirty-attributes", suppressErrorsFromDirtyAttributes);
|
||||
+ }
|
||||
}
|
||||
Reference in New Issue
Block a user