mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* init 1.21.4, and boom! * build change, but weight not work * just work * Build changes, and delete timings * Fix API patches (#406) * Fix API patches * merge --------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> * 0006/0129 * 0009/0129 * 0011/0129 * 0018/0129 * 0030/0129 * 0035/0129 * 0043/0129 * 0048/0129 * 0049/0129 * 0057/0129 * 0065/0129 * 0086/0129 (#408) * 0072/0129 * 0080/0129 * Readd patch infos * 0086/0129 * Delete applied patches * 0087/0129 * 0091/0129 * 0097/0129 * 0101/0129 * 102/129 * 0107/0129 * 0112/0129 * 0118/0129 * 0129/0129, 100% patched * fix some * server work * Protocol... (#409) * Jade v7 * Fix changed part for Jade * Formatting imports, add Lms Paster protocol * REI payloads 5/8 * Add REI support, remove unnecessary content in Jade * Rename * Make jade better * Make action work * fix action jar * Fix some protocol * Fix bot action, and entity tickCount * Fix Warden GameEventListener register on load * Fix extra Raider drop * Fix grindstone overstacking * Update Paper, and some doc * Merge * [ci skip] Update Action --------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
87 lines
6.1 KiB
Diff
87 lines
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 16 Feb 2023 17:25:01 +0800
|
|
Subject: [PATCH] Configurable vanilla random
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index ea808042e8fc647603c213cc1bea2fa16d22e749..bf316830f199c3f83dc2fccccf51885431729389 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -255,7 +255,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
public double zOld;
|
|
public boolean noPhysics;
|
|
private boolean wasOnFire;
|
|
- public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
|
|
+ public final RandomSource random = org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? RandomSource.create() : SHARED_RANDOM; // Paper - Share random for entities to make them more random // Leaves - but mojang use it, optimize? no!
|
|
public int tickCount;
|
|
private int remainingFireTicks = -this.getFireImmuneTicks();
|
|
public boolean wasTouchingWater;
|
|
diff --git a/net/minecraft/world/entity/animal/Bee.java b/net/minecraft/world/entity/animal/Bee.java
|
|
index 94244b148533ef026bf5c56abbc2bb5cfa83c938..91725b42a01790e0ac7d00bdc4a132ebb942a787 100644
|
|
--- a/net/minecraft/world/entity/animal/Bee.java
|
|
+++ b/net/minecraft/world/entity/animal/Bee.java
|
|
@@ -801,7 +801,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
@VisibleForDebug
|
|
public class BeeGoToHiveGoal extends Bee.BaseBeeGoal {
|
|
public static final int MAX_TRAVELLING_TICKS = 2400;
|
|
- int travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
|
+ int travellingTicks = org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla
|
|
private static final int MAX_BLACKLISTED_TARGETS = 3;
|
|
final List<BlockPos> blacklistedTargets = Lists.newArrayList();
|
|
@Nullable
|
|
@@ -917,7 +917,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
|
|
public class BeeGoToKnownFlowerGoal extends Bee.BaseBeeGoal {
|
|
private static final int MAX_TRAVELLING_TICKS = 2400;
|
|
- int travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
|
+ int travellingTicks = org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla
|
|
|
|
BeeGoToKnownFlowerGoal() {
|
|
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
|
diff --git a/net/minecraft/world/entity/animal/Squid.java b/net/minecraft/world/entity/animal/Squid.java
|
|
index 687ac3f50ed517a0b4df70c0c0a01215691ac718..dd3a0b30ab99d3a6680243c1dfb6dbddd7af2dbc 100644
|
|
--- a/net/minecraft/world/entity/animal/Squid.java
|
|
+++ b/net/minecraft/world/entity/animal/Squid.java
|
|
@@ -46,7 +46,7 @@ public class Squid extends AgeableWaterCreature {
|
|
|
|
public Squid(EntityType<? extends Squid> entityType, Level level) {
|
|
super(entityType, level);
|
|
- //this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom) this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random // Leaves - vanilla plz
|
|
this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
|
index d2d258246e7f7332c0420077e33c05e222bda46d..4f5db8203189a413f410fe7648e4995bae171918 100644
|
|
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -63,7 +63,13 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
// Paper start - Don't use level random in entity constructors (to make them thread-safe)
|
|
this(EntityType.ITEM, level);
|
|
this.setPos(posX, posY, posZ);
|
|
- this.setDeltaMovement(this.random.nextDouble() * 0.2 - 0.1, 0.2, this.random.nextDouble() * 0.2 - 0.1);
|
|
+ // Leaves start - vanilla yes, safe no
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom) {
|
|
+ this.setDeltaMovement(level.random.nextDouble() * 0.2 - 0.1, 0.2, level.random.nextDouble() * 0.2 - 0.1);
|
|
+ } else {
|
|
+ this.setDeltaMovement(this.random.nextDouble() * 0.2 - 0.1, 0.2, this.random.nextDouble() * 0.2 - 0.1);
|
|
+ }
|
|
+ // Leaves end - vanilla yes, safe no
|
|
this.setItem(itemStack);
|
|
// Paper end - Don't use level random in entity constructors
|
|
}
|
|
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index 583864d73999e4e25f6c26920c0bf9a7504d8463..717d96fa6459c77db9274c9cb3bedec4a4ff1a90 100644
|
|
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -66,7 +66,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
|
|
this(EntityType.TNT, level);
|
|
this.setPos(x, y, z);
|
|
- double d = this.random.nextDouble() * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors
|
|
+ double d = (org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? level.random.nextDouble() : this.random.nextDouble()) * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors // Leaves - why?
|
|
this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02);
|
|
this.setFuse(80);
|
|
this.xo = x;
|