9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-27 10:49:14 +00:00

33/38 patches done (waiting for pufferfish)

This commit is contained in:
NONPLAYT
2024-05-09 01:52:49 +03:00
parent 067d8a8d9f
commit 71807931f7
23 changed files with 116 additions and 132 deletions

View File

@@ -1,76 +0,0 @@
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 5036941829e4d98adbcfb0354b35244c52fc4472..76ef5000bbd805c40e0c927dc709c20c17d72f79 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -338,7 +338,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) {
@@ -853,7 +864,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
@@ -925,7 +942,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);
+ }
}

View File

@@ -1,42 +0,0 @@
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 1c50c870e59c35a39c83a0f136ee5d3c70268763..51077190b147e58b547c059abf0088715b37fea8 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
@@ -221,6 +221,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);
+ }
}

View File

@@ -1,37 +0,0 @@
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 d6705dce3bc8c1964184fe425386b3f3c0a8202e..56811b7068450a56818dcc03d1777d082df88d52 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1046,20 +1046,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

View File

@@ -1,41 +0,0 @@
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()) {

View File

@@ -1,161 +0,0 @@
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 997ab942be9f742804041b07d607e7dd6473ba96..aea0b36a52b2e9794daf8043f6a4279e52fec931 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
@@ -774,7 +774,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
return pos.closerThan(this.blockPosition(), (double) distance);
}
- private class BeePollinateGoal extends Bee.BaseBeeGoal {
+ public class BeePollinateGoal extends Bee.BaseBeeGoal { // DivineMC - private -> public
private static final int MIN_POLLINATION_TICKS = 400;
private static final int MIN_FIND_FLOWER_RETRY_COOLDOWN = 20;
@@ -963,7 +963,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(Mob entity) {
super(entity);
@@ -999,7 +999,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();
@@ -1044,7 +1044,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();
@@ -1276,7 +1276,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;
@@ -1340,7 +1340,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;
@@ -1387,7 +1387,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
}
}
- private class BeeHurtByOtherGoal extends HurtByTargetGoal {
+ public class BeeHurtByOtherGoal extends HurtByTargetGoal { // DivineMC - private -> public
BeeHurtByOtherGoal(Bee entitybee) {
super(entitybee);
@@ -1407,7 +1407,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
@@ -1438,7 +1438,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 6af5e1dfcfd739e0bc857f648c189151d5a795c8..149ff2637ca70e26cb7a36ae35ed82508183daa7 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
@@ -568,7 +568,7 @@ public class Cat extends TamableAnimal implements VariantHolder<CatVariant> {
}
}
- private static class CatRelaxOnOwnerGoal extends Goal {
+ public static class CatRelaxOnOwnerGoal extends Goal { // DivineMC - private -> public
private final Cat cat;
@Nullable
@@ -714,7 +714,7 @@ public class Cat extends TamableAnimal implements VariantHolder<CatVariant> {
}
}
- 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/Pillager.java b/src/main/java/net/minecraft/world/entity/monster/Pillager.java
index d5becd13774f9a2ead77d58e777ffc9aea10cb60..7c9ed0f28116d4aad6bbabd5d710cd4bbfbd59dd 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Pillager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Pillager.java
@@ -103,7 +103,7 @@ public class Pillager extends AbstractIllager implements CrossbowAttackMob, Inve
super.registerGoals();
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
- this.goalSelector.addGoal(2, new Raider.HoldGroundAttackGoal(this, 10.0F));
+ this.goalSelector.addGoal(2, new HoldGroundAttackGoal(this, 10.0F));
this.goalSelector.addGoal(3, new RangedCrossbowAttackGoal<>(this, 1.0D, 8.0F));
this.goalSelector.addGoal(8, new RandomStrollGoal(this, 0.6D));
this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 15.0F, 1.0F));
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 960b5e2c290f82501384f79d4653f47bedf926fb..1f382f864209a4c8f654d019b0a5907734d44d0d 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
@@ -95,7 +95,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 b3912881892b4f1bca577761083c5da1568c8187..5e8c9177644896d8f9243c3e7ce903fcdc6e9fa2 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
@@ -355,7 +355,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;
@@ -503,7 +503,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;

View File

@@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Mon, 18 Sep 2023 00:35:27 +0300
Subject: [PATCH] Do not process chat/commands before player has joined
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 9ba9356260d54ec318f07a8af221e9567ee03b12..28c46673995549a879e222d52abb9a7d2c24d6ed 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
import com.mojang.logging.LogUtils;
+import space.bxteam.divinemc.configuration.DivineConfig;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
@@ -2338,6 +2339,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
return Optional.empty();
+ } else if (player.joining && DivineConfig.doNotProcessChatCommands) { // DivineMC - EMC - do not handle chat messages before they joined
+ return Optional.empty();
} else {
this.player.resetLastActionTime();
return optional;
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
index c10403d781d25e4bb9e43d3f064fb1aebde00bfb..ef7983863da3b4febef3da2fab93fe581fbd65af 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 doNotProcessChatCommands = true;
+ private static void doNotProcessChatCommands() {
+ doNotProcessChatCommands = getBoolean("settings.do-not-process-chat-commands", doNotProcessChatCommands);
+ }
}

View File

@@ -1,52 +0,0 @@
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 1e3c4131e9dd155e4a0830d4c3f76f7f93146fff..a59a786049bfe1ca341a6f8833163a01d51535c5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -265,6 +265,8 @@ import net.md_5.bungee.api.chat.BaseComponent; // Spigot
import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // DivineMC
+
public final class CraftServer implements Server {
private final String serverName = "DivineMC"; // Paper // Pufferfish // Purpur // DivineMC
private final String serverVersion;
@@ -281,6 +283,7 @@ public final class CraftServer implements Server {
protected final DedicatedServer console;
protected final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
+ private final Map<UUID, World> worldsByUUID = new Object2ObjectLinkedOpenHashMap<>(); // DivineMC - MultiPaper - optimize getWorld(UUID)
private final Map<Class<?>, Registry<?>> registries = new HashMap<>();
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
@@ -1481,6 +1484,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;
@@ -1499,6 +1503,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;
@@ -1522,6 +1527,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);
}

View File

@@ -1,52 +0,0 @@
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 d87124f5356180a37e581febc6141fdc5f1395a7..4ae4d1203df960c109c1b70d6d710eaa00537008 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -11,14 +11,9 @@ import com.google.gson.JsonParseException;
import com.mojang.datafixers.util.Pair;
import com.mojang.logging.LogUtils;
import com.mojang.serialization.JsonOps;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
@@ -137,7 +132,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).values());
+ return space.bxteam.divinemc.configuration.DivineConfig.recipeManagerOptimization ? new ArrayList<>(this.byType(type).values()) : List.copyOf(this.byType(type).values()); // 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 b9223f4778de0c2ed6efed6f8c192cb0212cbda8..6cf0675cf5affb989e75d6a1cbab69f0a3ce1e34 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
@@ -162,4 +162,9 @@ public class DivineConfig {
private static void chatMessageSignatures() {
chatMessageSignatures = getBoolean("settings.disable-chat-reports", chatMessageSignatures);
}
+
+ public static boolean recipeManagerOptimization = true;
+ private static void optimizations() {
+ recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
+ }
}

View File

@@ -1,167 +0,0 @@
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 6cf0675cf5affb989e75d6a1cbab69f0a3ce1e34..50db7431ec4a05a73ba3a5fb04b4c68427628982 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
@@ -164,7 +164,9 @@ public class DivineConfig {
}
public static boolean recipeManagerOptimization = true;
+ public static boolean biomeManagerOptimization = true;
private static void optimizations() {
recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
+ biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
}
}

View File

@@ -1,52 +0,0 @@
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 bf2c23fad919820512ce031cf28a000b249b2876..85f56c79d60fa5b5a269b044c5b3710ef30a827d 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
@@ -106,6 +106,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();
@@ -283,6 +284,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;
@@ -651,9 +658,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;

View File

@@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 8 Apr 2023 01:22:35 +0300
Subject: [PATCH] lithium: collections.goals
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/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
index a2cca3d528625d49411a94e2b6ec578fec9b10da..e5c8b62cd431a86d9f1e5e4f1e48adfef81518c8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
@@ -14,6 +14,7 @@ import java.util.function.Supplier;
import java.util.stream.Stream;
import net.minecraft.util.profiling.ProfilerFiller;
import org.slf4j.Logger;
+import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
public class GoalSelector {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -29,7 +30,7 @@ public class GoalSelector {
}
};
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
- private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet();
+ private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>(); // DivineMC - lithium: collections.goals
private final Supplier<ProfilerFiller> profiler;
private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be.
private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector

View File

@@ -1,29 +0,0 @@
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 4a340bd1f1859e43bb58e68aee4018fdb4ca7a5a..7f9345b195fe34129b28dd6c486abe9a1582364c 100644
--- a/src/main/java/net/minecraft/world/level/GameRules.java
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
@@ -28,6 +28,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 {
@@ -142,7 +143,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;

View File

@@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 13 Jan 2024 20:04:54 +0300
Subject: [PATCH] lithium: collections.attributes
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/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
index 74d4f017484f13754a1f266625331a4124976afe..ce48d8a8382b78262d20151ba721ca1c99a9e189 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
@@ -17,11 +17,13 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // DivineMC
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // DivineMC
public class AttributeMap {
private static final Logger LOGGER = LogUtils.getLogger();
- private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
- private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
+ private final Map<Attribute, AttributeInstance> attributes = new Reference2ReferenceOpenHashMap<>(0); // DivineMC
+ private final Set<AttributeInstance> dirtyAttributes = new ReferenceOpenHashSet<>(0); // DivineMC
private final AttributeSupplier supplier;
private final java.util.function.Function<Attribute, AttributeInstance> createInstance; // Pufferfish
private final net.minecraft.world.entity.LivingEntity entity; // Purpur

View File

@@ -1,32 +0,0 @@
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 ebad17e6ec90a7f385cd38c5ec6c2772798d4562..535359546393de76b86fd4e66fc5d9faebb5c854 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 java.util.stream.Collectors;
+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();

View File

@@ -1,28 +0,0 @@
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 b48736a9f60c92d904e31f1faaacb6caf47d4070..45b51affcdafc6afb5cf6fd043310c85eb3fb7d1 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2623,6 +2623,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) {
@@ -3660,6 +3661,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)) {

View File

@@ -1,130 +0,0 @@
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 658f7943d275267d3fc556572831cc095259d12e..5ee9005f65edcfc3e3d20198ec1f69108a6f8205 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
@@ -70,6 +70,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 {
@@ -457,21 +458,30 @@ public class Sheep extends Animal implements Shearable {
return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
}
+ // 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 50db7431ec4a05a73ba3a5fb04b4c68427628982..15e0aa2a82a0be51ef04736ec636932092b34b32 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
@@ -165,8 +165,10 @@ public class DivineConfig {
public static boolean recipeManagerOptimization = true;
public static boolean biomeManagerOptimization = true;
+ public static boolean sheepOptimization = true;
private static void optimizations() {
recipeManagerOptimization = getBoolean("settings.optimizations.recipe-manager-optimization", recipeManagerOptimization);
biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization);
+ 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;
+ }
+}

View File

@@ -1,30 +0,0 @@
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 bb412ca874b85d777c0e3565fcefcee15b23182b..e0a52d5b74754a5b30a1fc250b5a2200682b748b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -107,6 +107,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;
@@ -251,7 +253,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();

View File

@@ -1,45 +0,0 @@
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 04b98e23eed926d8473cc2464e04a5b9f18f1140..68463f809aea61d818fc428f1c8b80682b05538b 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 7e62ee9418d5add5b0b4ddb885d3a1745ce799b2..53082033dfb58b8097ac326025472ef64358b890 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -94,4 +94,9 @@ public class DivineWorldConfig {
private void despawnShulkerBulletsOnOwnerDeath() {
despawnShulkerBulletsOnOwnerDeath = getBoolean("gameplay-mechanics.mob.shulker.despawn-bullets-on-player-death", despawnShulkerBulletsOnOwnerDeath);
}
+
+ public boolean suppressErrorsFromDirtyAttributes = true;
+ private void suppressErrorsFromDirtyAttributes() {
+ suppressErrorsFromDirtyAttributes = getBoolean("suppress-errors-from-dirty-attributes", suppressErrorsFromDirtyAttributes);
+ }
}

View File

@@ -1,41 +0,0 @@
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 2702de4408df4c74fef1951add2e38d92abc144c..30b72f4434b9fe9e490890c30400d058ecf3fa13 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
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;
@@ -1119,6 +1120,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// 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");
@@ -4165,6 +4172,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
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,

View File

@@ -1,68 +0,0 @@
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 bb61e1132c28274175215a679befdcfa2496b099..8598b0ea5f4f847fa14ac5c3b32ba010bf909d6e 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 8b65a405a9a1f03c4df78aed5a587fe5eb7fd54a..7b3e5f1c8d917e42944639795dd260ae8674ab96 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -120,4 +120,11 @@ public class DivineWorldConfig {
}
linearCrashOnBrokenSymlink = getBoolean("region-format.linear.crash-on-broken-symlink", linearCrashOnBrokenSymlink);
}
+
+ 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);
+ }
}

View File

@@ -1,76 +0,0 @@
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 84a760fdc50bdafc9150f977e9c5d557a30ee220..8bfe5c8c559d5e68f5b95bea37f63363b343e9b1 100644
--- a/src/main/java/net/minecraft/core/Direction.java
+++ b/src/main/java/net/minecraft/core/Direction.java
@@ -39,7 +39,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