Updated SparklyPaper port to latest

This commit is contained in:
AlphaKR93
2024-10-25 19:14:52 +09:00
parent 32243963f5
commit 98cf5b2d13
8 changed files with 8096 additions and 41 deletions

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Fri, 25 Oct 2024 19:11:40 +0900
Subject: [PATCH] Reset dirty flag when loading maps from the disk
Based on SparklyPaper, Copyright (C) 2024 SparklyPower
commit: c023b928439b9c71277f27cc9b5bd36ca32624ea
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 769d283cd98cba829262e45020ce3936c484938a..726c3e81d04731fe6ac92f0b612ce33e53803132 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -209,6 +209,7 @@ public class MapItemSavedData extends SavedData {
}
}
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.resetDirtyWhenLoadingMapsFromDisk) worldmap.setDirty(false); // Plazma - Reset dirty flag when loading maps from the disk
return worldmap;
}
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
index d781a7ba785789c9657c94fb0d164e532daccc96..fd1c84a86b16265400c9cd4e504b23632c5d0aa8 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
@@ -115,6 +115,7 @@ public class GlobalConfiguration extends ConfigurationPart {
public boolean reduceRandom = OPTIMIZE;
public boolean ignoreThreadSafeRandom = false;
+ public boolean resetDirtyWhenLoadingMapsFromDisk = false;
}

View File

@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Fri, 25 Oct 2024 19:13:21 +0900
Subject: [PATCH] Allow throttling hopper checks if the target container is
full
Based on SparklyPaper, Copyright (C) 2024 SparklyPower.
commit: c023b928439b9c71277f27cc9b5bd36ca32624ea
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index cab403efd471bb61835224eea4e99570d34dcaaa..4b4d31cb3c379a59c43c7356522a5b67c5a87de5 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -441,6 +441,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
Direction enumdirection = blockEntity.facing.getOpposite();
if (HopperBlockEntity.isFullContainer(iinventory, enumdirection)) {
+ if (world.plazmaConfig().block.hopper.fullCooldown != 0) blockEntity.setCooldown(world.plazmaConfig().block.hopper.fullCooldown); // Plazma - Allow throttling hopper checks if the target container is full
return false;
} else {
// Paper start - Perf: Optimize Hoppers
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index 5978970f80b1b4672298426dcd8026e453025a52..c74209e70a6fab1fd2a17605abf95f54e2156004 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -107,6 +107,13 @@ public class WorldConfigurations extends ConfigurationPart {
}
+ public Hopper hopper;
+ public class Hopper extends ConfigurationPart {
+
+ public int fullCooldown = 0;
+
+ }
+
}
}

View File

@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Fri, 25 Oct 2024 19:26:15 +0900
Subject: [PATCH] Suppress errors from dirty attributes
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0d48209efc607dd7f81deffa96af2ff05ccd37b7..9ab19aa8d05384bc03c8250f8ea628a9b0a00fa2 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1348,7 +1348,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
private void refreshDirtyAttributes() {
- Set<AttributeInstance> set = this.getAttributes().getAttributesToUpdate();
+ Set<AttributeInstance> attr = this.getAttributes().getAttributesToUpdate(); // Plazma - Suppress errors from dirty attributes
+ final Set<AttributeInstance> set = level().plazmaConfig().entity.suppressErrorsFromDirtyAttributes ? java.util.Collections.synchronizedSet(attr) : attr; // Plazma - Suppress errors from dirty attributes
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
@@ -1357,7 +1358,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.onAttributeUpdated(attributemodifiable.getAttribute());
}
- set.clear();
+ attr.clear(); // Plazma - Suppress errors from dirty attributes
}
private void onAttributeUpdated(Holder<Attribute> attribute) {
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index c74209e70a6fab1fd2a17605abf95f54e2156004..0be2dc76d868265a4a51ff077b971938b13d72c7 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -30,6 +30,7 @@ public class WorldConfigurations extends ConfigurationPart {
public class Entity extends ConfigurationPart {
public int sensorTick = 1;
+ public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE;
public Phantom phantom;
public class Phantom extends ConfigurationPart {

View File

@@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Mon, 4 Dec 2023 23:15:43 +0900
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 2b4d3db901784a82e1ed91520a5e3d1fb8ca6b3e..b66a56ea65cb323953278f80d210473f9f571722 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -415,7 +415,8 @@ public class ServerEntity {
}
if (this.entity instanceof LivingEntity) {
- Set<AttributeInstance> set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
+ Set<AttributeInstance> attributes = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); // Plazma - Suppress errors from dirty attributes
+ final Set<AttributeInstance> set = this.level.plazmaConfig().entity.suppressErrorsFromDirtyAttributes ? Collections.synchronizedSet(attributes) : attributes; // Plazma - Suppress errors from dirty attributes
if (!set.isEmpty()) {
// CraftBukkit start - Send scaled max health
@@ -426,7 +427,7 @@ public class ServerEntity {
this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set));
}
- set.clear();
+ attributes.clear(); // Plazma - Suppress errors from dirty attributes
}
}
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index bc35244533621436e3c0fb871edf7834ad937f81..a9c8a5918184a2ea364261e279edf7169ae270c7 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -31,6 +31,7 @@ public class WorldConfigurations extends ConfigurationPart {
public boolean ignoreUselessPackets = OPTIMIZE;
public int sensorTick = 1;
+ public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE;
public Phantom phantom;
public class Phantom extends ConfigurationPart {

View File

@@ -0,0 +1,311 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?IPECTER=20=EC=9D=B4=ED=8C=A9=ED=84=B0?=
<80433772+IPECTER@users.noreply.github.com>
Date: Wed, 21 Aug 2024 16:16:22 +0900
Subject: [PATCH] Implement-CarpetFixes
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..8ad02b079c729320f5968eee5e6284371d11250e 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
@@ -460,17 +460,25 @@ public class Sheep extends Animal implements Shearable {
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;
- });
+ // Plazma start - Implement CarpetFixes
+ if (this.level().plazmaConfig().carpetFixes.preparedSheepChildColor()) {
+ DyeColor col = org.plazmamc.plazma.util.CarpetFixesUtils.properDyeMixin(enumcolor, enumcolor1);
+ if (col == null) col = this.level().random.nextBoolean() ? enumcolor : enumcolor1;
+ return col;
+ } else {
+ 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;
+ });
+ }
+ // Plazma end
}
private static CraftingContainer makeContainer(DyeColor firstColor, DyeColor secondColor) {
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 681e3fcd759a26578e054f88e8048e392312b84b..253819783d577c4c2abe737e0c76ac88121387db 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -137,7 +137,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 org.plazmamc.plazma.configurations.GlobalConfiguration.get().carpetFixes.fasterRecipeList() ? new java.util.ArrayList<>(this.byType(type).values()) : List.copyOf(this.byType(type).values()); // Plazma - Implement CarpetFixes
}
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/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
index 01352cc83b25eb0e30b7e0ff521fc7c1b3d5155b..e6544cf89bc5e85d9b7fb9b278ffc765c5268f37 100644
--- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
@@ -12,6 +12,7 @@ public class BiomeManager {
private static final int ZOOM_BITS = 2;
private static final int ZOOM = 4;
private static final int ZOOM_MASK = 3;
+ private static final double maxOffset = 0.4500000001D; // Plazma - Implement CarpetFixes
private final BiomeManager.NoiseBiomeSource noiseBiomeSource;
private final long biomeZoomSeed;
@@ -29,39 +30,104 @@ 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;
+ // Plazma start - Implement CarpetFixes
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().carpetFixes.optimizedBiomeAccess()) {
+ 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;
+
+ //This code block is new
+ 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);
+ }
+ // Plazma end
}
public Holder<Biome> getNoiseBiomeAtPosition(double x, double y, double z) {
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
index 98f26e3de66a881163e84295e9156c7f362bf7cb..9af184b55fd32d16194b669c42bfbf9b18e96e26 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
@@ -109,4 +109,21 @@ public class GlobalConfiguration extends ConfigurationPart {
}
+ public CarpetFixes carpetFixes;
+ public class CarpetFixes extends ConfigurationPart {
+
+ public boolean enabled = OPTIMIZE;
+ boolean optimizedBiomeAccess = true;
+ boolean fasterRecipeList = true;
+
+ public boolean optimizedBiomeAccess() {
+ return enabled && optimizedBiomeAccess;
+ }
+
+ public boolean fasterRecipeList() {
+ return enabled && fasterRecipeList;
+ }
+
+ }
+
}
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index 6a0cfec24618227d9a5ddc6c71e37d1986147799..9d6d4400be8bf189308cbd0cb14afa1ff0191a57 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -90,4 +90,16 @@ public class WorldConfigurations extends ConfigurationPart {
}
+ public CarpetFixes carpetFixes;
+ public class CarpetFixes extends ConfigurationPart {
+
+ public boolean enabled = OPTIMIZE;
+ boolean preparedSheepChildColor = true;
+
+ public boolean preparedSheepChildColor() {
+ return enabled && preparedSheepChildColor;
+ }
+
+ }
+
}
diff --git a/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java b/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d6deb61ef10039a551849e9b83798916f1dc58c
--- /dev/null
+++ b/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java
@@ -0,0 +1,48 @@
+package org.plazmamc.plazma.util;
+
+import net.minecraft.world.item.DyeColor;
+
+public class CarpetFixesUtils {
+
+ //If I was actually implementing this, the color values would have been binary in order for fast calculations.
+ //Never do this in a production build, although this is better than using the RecipeManager xD
+ public static DyeColor properDyeMixin(DyeColor col1, DyeColor col2) {
+ if (col1.equals(col2)) return col1;
+ switch(col1) {
+ case WHITE -> {
+ switch(col2) {
+ 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(col2) {
+ case WHITE -> {return DyeColor.LIGHT_BLUE;}
+ case GREEN -> {return DyeColor.CYAN;}
+ case RED -> {return DyeColor.PURPLE;}
+ }
+ }
+ case RED -> {
+ switch(col2) {
+ case YELLOW -> {return DyeColor.ORANGE;}
+ case WHITE -> {return DyeColor.PINK;}
+ case BLUE -> {return DyeColor.PURPLE;}
+ }
+ }case GREEN -> {
+ switch(col2) {
+ case BLUE -> {return DyeColor.CYAN;}
+ case WHITE -> {return DyeColor.LIME;}
+ }
+ }
+ case YELLOW -> {if (col2.equals(DyeColor.RED)) return DyeColor.ORANGE;}
+ case PURPLE -> {if (col2.equals(DyeColor.PINK)) return DyeColor.MAGENTA;}
+ case PINK -> {if (col2.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;}
+ case GRAY -> {if (col2.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;}
+ case BLACK -> {if (col2.equals(DyeColor.WHITE)) return DyeColor.GRAY;}
+ }
+ return null;
+ }
+}
\ No newline at end of file

View File

@@ -0,0 +1,161 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?IPECTER=20=EC=9D=B4=ED=8C=A9=ED=84=B0?=
<80433772+IPECTER@users.noreply.github.com>
Date: Wed, 21 Aug 2024 17:31:03 +0900
Subject: [PATCH] Implement-Noisium
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index 2422ca3ffc6ab7178cacf933b8013f85e7de4bd9..ddfcabf64bb43447379f74314a30afbf36477f0c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -19,9 +19,10 @@ public class LevelChunkSection {
public static final int SECTION_HEIGHT = 16;
public static final int SECTION_SIZE = 4096;
public static final int BIOME_CONTAINER_BITS = 2;
- short nonEmptyBlockCount; // Paper - package private
- private short tickingBlockCount;
- private short tickingFluidCount;
+ private static final int SLICE_SIZE = 4; // Plazma - Implement Noisium
+ public short nonEmptyBlockCount; // Paper - package private // Plazma - Implement Noisium - package public
+ public short tickingBlockCount; // Plazma - Implement Noisium - package public
+ public short tickingFluidCount; // Plazma - Implement Noisium - package public
public final PalettedContainer<BlockState> states;
// CraftBukkit start - read/write
private PalettedContainer<Holder<Biome>> biomes;
@@ -231,16 +232,16 @@ public class LevelChunkSection {
public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) {
PalettedContainer<Holder<Biome>> datapaletteblock = this.biomes.recreate();
- boolean flag = true;
-
- for (int l = 0; l < 4; ++l) {
- for (int i1 = 0; i1 < 4; ++i1) {
- for (int j1 = 0; j1 < 4; ++j1) {
+ // Plazma start - Implement Noisium
+ for (int l = 0; l < SLICE_SIZE; ++l) {
+ for (int i1 = 0; i1 < SLICE_SIZE; ++i1) {
+ for (int j1 = 0; j1 < SLICE_SIZE; ++j1) {
datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeSupplier.getNoiseBiome(x + l, y + i1, z + j1, sampler));
}
}
}
this.biomes = datapaletteblock;
+ // Plazma end
}
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index adfbdca12fbdee2602feb0158674166d5256e49e..b8ffc5faa904cce898c792f9bd7846304c72b353 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -29,8 +29,8 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> 0;
public final IdMap<T> registry;
private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values
- private volatile PalettedContainer.Data<T> data;
- private final PalettedContainer.Strategy strategy;
+ public volatile PalettedContainer.Data<T> data; // Plazma - Implement Noisium - package public
+ public final PalettedContainer.Strategy strategy; // Plazma - Implement Noisium - package public
// private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused
public void acquire() {
@@ -394,7 +394,8 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
void accept(T object, int count);
}
- static record Data<T>(PalettedContainer.Configuration<T> configuration, BitStorage storage, Palette<T> palette) {
+ public static record Data<T>(PalettedContainer.Configuration<T> configuration, BitStorage storage, Palette<T> palette) {
+ //public Palette<T> palette() { return palette; } // Plazma - Implement Noisium
public void copyFrom(Palette<T> palette, BitStorage storage) {
for (int i = 0; i < storage.getSize(); i++) {
T object = palette.valueFor(storage.get(i));
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
index a85b1ebb4236f131b9be0104c4aa56f22e661441..25f51220e070d5cd4eb9550291dea864d20f2362 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -371,7 +371,8 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
iblockdata = this.debugPreliminarySurfaceLevel(noisechunk, j4, j3, i5, iblockdata);
if (iblockdata != NoiseBasedChunkGenerator.AIR && !SharedConstants.debugVoidTerrain(chunk.getPos())) {
- chunksection.setBlockState(k4, k3, j5, iblockdata, false);
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().noisium.enabled) setBlockState(chunksection, k4, k3, j5, iblockdata);
+ else chunksection.setBlockState(k4, k3, j5, iblockdata, false);
heightmap.update(k4, j3, j5, iblockdata);
heightmap1.update(k4, j3, j5, iblockdata);
if (aquifer.shouldScheduleFluidUpdate() && !iblockdata.getFluidState().isEmpty()) {
@@ -392,6 +393,26 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
return chunk;
}
+ // Plazma start - Implement Noisium
+ private BlockState setBlockState(LevelChunkSection chunkSection, int x, int y, int z, BlockState blockState) {
+ chunkSection.nonEmptyBlockCount += 1;
+
+ if (!blockState.getFluidState().isEmpty()) {
+ chunkSection.tickingFluidCount += 1;
+ }
+
+ if (blockState.isRandomlyTicking()) {
+ chunkSection.tickingBlockCount += 1;
+ }
+
+ var blockStateId = chunkSection.states.data.palette().idFor(blockState);
+ chunkSection.states.data.storage().set(
+ chunkSection.states.strategy.getIndex(x, y, z), blockStateId);
+
+ return blockState;
+ }
+ // Plazma end
+
private BlockState debugPreliminarySurfaceLevel(NoiseChunk chunkNoiseSampler, int x, int y, int z, BlockState state) {
return state;
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
index 31f4862f480c210a6dd7bd8de6a2528b4a0f50e3..c566c94b1f440a319e52174c73db9fc4addf948c 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseSettings.java
@@ -8,7 +8,12 @@ import net.minecraft.core.QuartPos;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.dimension.DimensionType;
-public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int noiseSizeVertical) {
+// Plazma start -
+record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int noiseSizeVertical, int cellHeight, int cellWidth) {
+ public NoiseSettings(int minY, int height, int noiseSizeHorizontal, int noiseSizeVertical) {
+ this(minY, height, noiseSizeHorizontal, noiseSizeVertical, QuartPos.toBlock(noiseSizeHorizontal), QuartPos.toBlock(noiseSizeVertical));
+ }
+// Plazma end
public static final Codec<NoiseSettings> CODEC = RecordCodecBuilder.<NoiseSettings>create(
instance -> instance.group(
Codec.intRange(DimensionType.MIN_Y, DimensionType.MAX_Y).fieldOf("min_y").forGetter(NoiseSettings::minY),
@@ -44,11 +49,11 @@ public record NoiseSettings(int minY, int height, int noiseSizeHorizontal, int n
}
public int getCellHeight() {
- return QuartPos.toBlock(this.noiseSizeVertical());
+ return this.cellHeight; // Plazma - Implement Noisium
}
public int getCellWidth() {
- return QuartPos.toBlock(this.noiseSizeHorizontal());
+ return this.cellWidth; // Plazma - Implement Noisium
}
public NoiseSettings clampToHeightAccessor(LevelHeightAccessor world) {
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
index 9af184b55fd32d16194b669c42bfbf9b18e96e26..cd3bc8b6b6b6b8282bf0cbdde170ae853f55727a 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
@@ -126,4 +126,11 @@ public class GlobalConfiguration extends ConfigurationPart {
}
+ public Noisium noisium;
+ public class Noisium extends ConfigurationPart {
+
+ public boolean enabled = OPTIMIZE;
+
+ }
+
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,282 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?IPECTER=20=EC=9D=B4=ED=8C=A9=ED=84=B0?=
<80433772+IPECTER@users.noreply.github.com>
Date: Sun, 25 Aug 2024 05:21:35 +0900
Subject: [PATCH] Blazingly-simple-farm-checks
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
index 2077cb5dcf2352c9d5b502744aeb9a66df256939..e5db5467863e7e408e3ca23dbaed3879d9b31110 100644
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
@@ -81,28 +81,81 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
int i = this.getAge(state);
if (i < this.getMaxAge()) {
- float f = CropBlock.getGrowthSpeed(this, world, pos);
-
- // Spigot start
- int modifier;
- if (this == Blocks.BEETROOTS) {
- modifier = world.spigotConfig.beetrootModifier;
- } else if (this == Blocks.CARROTS) {
- modifier = world.spigotConfig.carrotModifier;
- } else if (this == Blocks.POTATOES) {
- modifier = world.spigotConfig.potatoModifier;
- // Paper start - Fix Spigot growth modifiers
- } else if (this == Blocks.TORCHFLOWER_CROP) {
- modifier = world.spigotConfig.torchFlowerModifier;
- // Paper end - Fix Spigot growth modifiers
+ // Plazma start - Blazingly simple farm checks
+ if (world.plazmaConfig().blazinglySimpleFarmChecks.enabled) {
+ // These checks are similar to getGrowthSpeed, but we have "inlined" them because we want to access stuff like the farm block data later on
+ // Is the block below us moisturised?
+ BlockPos farmlandBelowTheCurrentBlock = pos.below();
+ BlockState farmlandBelowTheCurrentBlockData = world.getBlockState(farmlandBelowTheCurrentBlock);
+ double f = world.plazmaConfig().blazinglySimpleFarmChecks.defaultGrowthSpeed;
+ boolean isCurrentFarmlandStateMoist = false;
+ if (farmlandBelowTheCurrentBlockData.is(Blocks.FARMLAND)) {
+ if ((Integer) farmlandBelowTheCurrentBlockData.getValue(FarmBlock.MOISTURE) > 0) {
+ // If we are currently moist, increase the speed!
+ f = world.plazmaConfig().blazinglySimpleFarmChecks.moistGrowthSpeed;
+ isCurrentFarmlandStateMoist = true;
+ }
+ }
+ // If we are skipping the middle aging stages, we need to change the growth speed and the next stage accordingly
+ if (world.plazmaConfig().blazinglySimpleFarmChecks.skipMiddleAgingStagesForCrops) {
+ f = f / getMaxAge();
+ i = getMaxAge() - 1;
+ }
+
+ // Spigot start
+ int modifier;
+ if (this == Blocks.BEETROOTS) {
+ modifier = world.spigotConfig.beetrootModifier;
+ } else if (this == Blocks.CARROTS) {
+ modifier = world.spigotConfig.carrotModifier;
+ } else if (this == Blocks.POTATOES) {
+ modifier = world.spigotConfig.potatoModifier;
+ // Paper start
+ } else if (this == Blocks.TORCHFLOWER_CROP) {
+ modifier = world.spigotConfig.torchFlowerModifier;
+ // Paper end
+ } else {
+ modifier = world.spigotConfig.wheatModifier;
+ }
+
+ if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
+ // Spigot end
+ if (!CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2)) {
+ return;
+ }
+
+ // Now that we know that the crop will grow... is the next stage the crop's max age? If yes, we are going to check if the farm land is moist!
+ if (i + 1 == getMaxAge() && isCurrentFarmlandStateMoist && !FarmBlock.isNearWater(world, farmlandBelowTheCurrentBlock)) {
+ // Whoops, farm land ain't moist!
+ // From FarmBlock, set the moisture to 0
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, farmlandBelowTheCurrentBlock, (BlockState) farmlandBelowTheCurrentBlockData.setValue(FarmBlock.MOISTURE, 0), 2); // CraftBukkit
+ }
+ }
} else {
- modifier = world.spigotConfig.wheatModifier;
- }
+ float f = CropBlock.getGrowthSpeed(this, world, pos);
+
+ // Spigot start
+ int modifier;
+ if (this == Blocks.BEETROOTS) {
+ modifier = world.spigotConfig.beetrootModifier;
+ } else if (this == Blocks.CARROTS) {
+ modifier = world.spigotConfig.carrotModifier;
+ } else if (this == Blocks.POTATOES) {
+ modifier = world.spigotConfig.potatoModifier;
+ // Paper start - Fix Spigot growth modifiers
+ } else if (this == Blocks.TORCHFLOWER_CROP) {
+ modifier = world.spigotConfig.torchFlowerModifier;
+ // Paper end - Fix Spigot growth modifiers
+ } else {
+ modifier = world.spigotConfig.wheatModifier;
+ }
- if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
- // Spigot end
- CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
+ if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
+ // Spigot end
+ CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
+ }
}
+ // Plazma end
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index 0c39126ce51439cce05747161aba43bce33a12d8..2016e3d7832ba75331697c46803f8e4142bf01ee 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -92,6 +92,19 @@ public class FarmBlock extends Block {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
int i = (Integer) state.getValue(FarmBlock.MOISTURE);
+ // Plazma start - Blazingly simple farm checks
+ if (world.plazmaConfig().blazinglySimpleFarmChecks.enabled) {
+ if (i == 0) { // We only care about non-moisturised farm blocks
+ if (FarmBlock.isNearWater(world, pos)) {
+ // Make it MOIST!
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, pos, (BlockState) state.setValue(FarmBlock.MOISTURE, 7), 2); // CraftBukkit
+ } else if (!FarmBlock.shouldMaintainFarmland(world, pos)) {
+ FarmBlock.turnToDirt((Entity) null, state, world, pos);
+ }
+ }
+ return;
+ }
+ // Plazma end
if (i > 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
@@ -166,7 +179,7 @@ public class FarmBlock extends Block {
return world.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND);
}
- private static boolean isNearWater(LevelReader world, BlockPos pos) {
+ public static boolean isNearWater(LevelReader world, BlockPos pos) { // Plazma - Blazingly simple farm checks - private -> public
// Paper start - Perf: remove abstract block iteration
int xOff = pos.getX();
int yOff = pos.getY();
diff --git a/src/main/java/net/minecraft/world/level/block/StemBlock.java b/src/main/java/net/minecraft/world/level/block/StemBlock.java
index 121a872cd750a87b779895687ae1abf5bb77b088..53e55b51c53995e2ec9314e1fc656dd5cd22dd67 100644
--- a/src/main/java/net/minecraft/world/level/block/StemBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/StemBlock.java
@@ -73,36 +73,87 @@ public class StemBlock extends BushBlock implements BonemealableBlock {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (world.getRawBrightness(pos, 0) >= 9) {
- float f = CropBlock.getGrowthSpeed(this, world, pos);
-
- if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
- int i = (Integer) state.getValue(StemBlock.AGE);
-
- if (i < 7) {
- state = (BlockState) state.setValue(StemBlock.AGE, i + 1);
- CraftEventFactory.handleBlockGrowEvent(world, pos, state, 2); // CraftBukkit
- } else {
- Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
- BlockPos blockposition1 = pos.relative(enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition1.below());
-
- if (world.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) {
- Registry<Block> iregistry = world.registryAccess().registryOrThrow(Registries.BLOCK);
- Optional<Block> optional = iregistry.getOptional(this.fruit);
- Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
-
- if (optional.isPresent() && optional1.isPresent()) {
- // CraftBukkit start
- if (!CraftEventFactory.handleBlockGrowEvent(world, blockposition1, ((Block) optional.get()).defaultBlockState())) {
- return;
+ // Plazma start - Blazingly simple farm checks
+ if (world.plazmaConfig().blazinglySimpleFarmChecks.enabled) {
+ // These checks are similar to getGrowthSpeed, but we have "inlined" them because we want to access stuff like the farm block data later on
+ // Is the block below us moisturised?
+ BlockPos farmlandBelowTheCurrentBlock = pos.below();
+ BlockState farmlandBelowTheCurrentBlockData = world.getBlockState(farmlandBelowTheCurrentBlock);
+ double f = world.plazmaConfig().blazinglySimpleFarmChecks.defaultGrowthSpeed;
+ boolean isCurrentFarmlandStateMoist = false;
+ if (farmlandBelowTheCurrentBlockData.is(Blocks.FARMLAND)) {
+ if ((Integer) farmlandBelowTheCurrentBlockData.getValue(FarmBlock.MOISTURE) > 0) {
+ // If we are currently moist, increase the speed!
+ f = world.plazmaConfig().blazinglySimpleFarmChecks.moistGrowthSpeed;
+ isCurrentFarmlandStateMoist = true;
+ }
+ }
+
+ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
+ int i = (Integer) state.getValue(StemBlock.AGE);
+
+ if (i < 7) {
+ state = (BlockState) state.setValue(StemBlock.AGE, i + 1);
+ CraftEventFactory.handleBlockGrowEvent(world, pos, state, 2); // CraftBukkit
+ } else {
+ Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
+ BlockPos blockposition1 = pos.relative(enumdirection);
+ BlockState iblockdata1 = world.getBlockState(blockposition1.below());
+
+ if (world.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) {
+ Registry<Block> iregistry = world.registryAccess().registryOrThrow(Registries.BLOCK);
+ Optional<Block> optional = iregistry.getOptional(this.fruit);
+ Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
+
+ if (optional.isPresent() && optional1.isPresent()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(world, blockposition1, ((Block) optional.get()).defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
+ // Now that we know that the crop will grow... is the next stage the crop's max age? If yes, we are going to check if the farm land is moist!
+ if (isCurrentFarmlandStateMoist && !FarmBlock.isNearWater(world, farmlandBelowTheCurrentBlock)) {
+ // Whoops, farm land ain't moist!
+ // From FarmBlock, set the moisture to 0
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, farmlandBelowTheCurrentBlock, (BlockState) farmlandBelowTheCurrentBlockData.setValue(FarmBlock.MOISTURE, 0), 2); // CraftBukkit
+ }
+ world.setBlockAndUpdate(pos, (BlockState) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
+ }
+ }
+ }
+ }
+ } else {
+ float f = CropBlock.getGrowthSpeed(this, world, pos);
+
+ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? world.spigotConfig.pumpkinModifier : world.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / f) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution
+ int i = (Integer) state.getValue(StemBlock.AGE);
+
+ if (i < 7) {
+ state = (BlockState) state.setValue(StemBlock.AGE, i + 1);
+ CraftEventFactory.handleBlockGrowEvent(world, pos, state, 2); // CraftBukkit
+ } else {
+ Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
+ BlockPos blockposition1 = pos.relative(enumdirection);
+ BlockState iblockdata1 = world.getBlockState(blockposition1.below());
+
+ if (world.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) {
+ Registry<Block> iregistry = world.registryAccess().registryOrThrow(Registries.BLOCK);
+ Optional<Block> optional = iregistry.getOptional(this.fruit);
+ Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
+
+ if (optional.isPresent() && optional1.isPresent()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(world, blockposition1, ((Block) optional.get()).defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
+ world.setBlockAndUpdate(pos, (BlockState) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
}
- // CraftBukkit end
- world.setBlockAndUpdate(pos, (BlockState) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
}
}
}
}
-
+ // Plazma end
}
}
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index 9d6d4400be8bf189308cbd0cb14afa1ff0191a57..f96305be3b6e7c33d553764bdf4d8f2635939f9d 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -102,4 +102,15 @@ public class WorldConfigurations extends ConfigurationPart {
}
+ public BlazinglySimpleFarmChecks blazinglySimpleFarmChecks;
+ public class BlazinglySimpleFarmChecks extends ConfigurationPart {
+
+ public boolean enabled = OPTIMIZE;ㅈ
+ public double defaultGrowthSpeed = 1.0;
+ public double moistGrowthSpeed = 5.0;
+ public boolean skipMiddleAgingStagesForCrops = false;
+
+
+ }
+
}