mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2026-01-06 15:41:56 +00:00
Optimize sheep offspring color
This commit is contained in:
137
patches/server/0095-Optimize-sheep-offspring-color.patch
Normal file
137
patches/server/0095-Optimize-sheep-offspring-color.patch
Normal file
@@ -0,0 +1,137 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Fri, 23 Dec 2022 22:47:38 +0100
|
||||
Subject: [PATCH] Optimize sheep offspring color
|
||||
|
||||
License: MIT (https://opensource.org/licenses/MIT)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following mixins and classes:
|
||||
* "carpetfixes/helpers/Utils.java"
|
||||
* "carpetfixes/mixins/optimizations/SheepEntity_childColorMixin.java"
|
||||
By: fxmorin <28154542+fxmorin@users.noreply.github.com>
|
||||
As part of: carpet-fixes (https://github.com/fxmorin/carpet-fixes)
|
||||
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||
|
||||
* carpet-fixes description *
|
||||
|
||||
The game determines the child sheep's color by getting a wool block from the parents, putting them in a crafting
|
||||
recipe, getting the output wool and getting the color from that.
|
||||
I don't know in what world we would consider a data-driven method with that much overhead as a smart idea. Instead,
|
||||
we used a prebaked list of all the possible colors and combinations, however this means that you can't use a
|
||||
datapack to change it.
|
||||
|
||||
* carpet-fixes copyright *
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Fx Morin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
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 efac4395fdb79a78fbb18a0f828b1a3c90b102fe..ef70179f71eb3f63f707d990bfc4d55101c28c4d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
@@ -391,7 +391,59 @@ public class Sheep extends Animal implements Shearable {
|
||||
return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
|
||||
}
|
||||
|
||||
+ // Gale start - carpet-fixes - optimize sheep offspring color
|
||||
+ private 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;
|
||||
+ }
|
||||
+ // Gale end - carpet-fixes - optimize sheep offspring color
|
||||
+
|
||||
private DyeColor getOffspringColor(Animal firstParent, Animal secondParent) {
|
||||
+ // Gale start - carpet-fixes - optimize sheep offspring color
|
||||
+ if (firstParent.level != null && firstParent.level.galeConfig().smallOptimizations.useOptimizedSheepOffspringColor) {
|
||||
+ DyeColor firstColor = ((Sheep)firstParent).getColor();
|
||||
+ DyeColor secondColor = ((Sheep)secondParent).getColor();
|
||||
+ DyeColor col = properDye(firstColor,secondColor);
|
||||
+ if (col == null) col = this.level.random.nextBoolean() ? firstColor : secondColor;
|
||||
+ return col;
|
||||
+ }
|
||||
+ // Gale end - carpet-fixes - optimize sheep offspring color
|
||||
DyeColor enumcolor = ((Sheep) firstParent).getColor();
|
||||
DyeColor enumcolor1 = ((Sheep) secondParent).getColor();
|
||||
CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1);
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index 24a6e2ef5472936f478b759e79197442490e3ada..b480d492d411d33393ac1b2f41bd4d62d232c568 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -33,6 +33,21 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public SmallOptimizations smallOptimizations;
|
||||
public class SmallOptimizations extends ConfigurationPart {
|
||||
|
||||
+ // Gale start - carpet-fixes - optimize sheep offspring color
|
||||
+ /**
|
||||
+ * Whether to use a (much) faster way to choose a color when a new baby sheep is born.
|
||||
+ * The color chosen is exactly the same as vanilla.
|
||||
+ * However, in vanilla, it is possible to change the new color by
|
||||
+ * changing the crafting recipe for combining dyes using a data pack.
|
||||
+ * If this is set to true, any such crafting recipe changes will be ignored.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: true</li>
|
||||
+ * <li><i>Vanilla</i>: false</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public boolean useOptimizedSheepOffspringColor = true;
|
||||
+ // Gale end - carpet-fixes - optimize sheep offspring color
|
||||
+
|
||||
// Gale start - Airplane - reduce projectile chunk loading
|
||||
public MaxProjectileChunkLoads maxProjectileChunkLoads;
|
||||
public class MaxProjectileChunkLoads extends ConfigurationPart {
|
||||
@@ -53,12 +53,12 @@ index 8fd080110ed4efaf6cb3a2561b32ed66ff8c78f0..b1a01ef0090718923aff4365d8e93c77
|
||||
return stack.is(otherStack.getItem()) && ItemStack.tagMatches(stack, otherStack);
|
||||
}
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index 24a6e2ef5472936f478b759e79197442490e3ada..6f6aa43685584517d3ea05fac1297c696eeea07d 100644
|
||||
index b480d492d411d33393ac1b2f41bd4d62d232c568..ce94f9a5bc826ce33ee63581ab864b04a8b4526e 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -33,6 +33,8 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public SmallOptimizations smallOptimizations;
|
||||
public class SmallOptimizations extends ConfigurationPart {
|
||||
@@ -48,6 +48,8 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public boolean useOptimizedSheepOffspringColor = true;
|
||||
// Gale end - carpet-fixes - optimize sheep offspring color
|
||||
|
||||
+ public boolean processFullEquipmentChangeIfOnlyDurabilityChanged = false; // Gale - Slice - ignore durability change equipment updates
|
||||
+
|
||||
@@ -31,10 +31,10 @@ index 92c9ccf9a05fe54b5c7e5a72da5498115a6d5bd9..d05e5b9b4dec0779489856dab5e50b53
|
||||
|
||||
this.firstTick = false;
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index 6f6aa43685584517d3ea05fac1297c696eeea07d..cf6f75c6c0c88cc0153e25980ba9bf8a915af3b5 100644
|
||||
index ce94f9a5bc826ce33ee63581ab864b04a8b4526e..3274742f667c9b0bec5f1bf8d03b2fd3165eb807 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -248,6 +248,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
@@ -263,6 +263,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
|
||||
public boolean entitiesCanEatBlocksInNonTickingChunks = false; // Gale - Purpur - prevent entities eating blocks in non-ticking chunks
|
||||
public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable
|
||||
@@ -36,10 +36,10 @@ index 216929c838446c3c14d9b9906ffa625ef35fcbc8..29c7f53a4fa88a77c4076a6294e689e4
|
||||
} else {
|
||||
this.wantedX = vec3.x;
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index cf6f75c6c0c88cc0153e25980ba9bf8a915af3b5..e2d6f0e479268e1fadfee4a73281360cf9406760 100644
|
||||
index 3274742f667c9b0bec5f1bf8d03b2fd3165eb807..c77ccc1e91756223bc8ced2d7648464dc33aa892 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -247,6 +247,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
@@ -262,6 +262,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public class GameplayMechanics extends ConfigurationPart {
|
||||
|
||||
public boolean entitiesCanEatBlocksInNonTickingChunks = false; // Gale - Purpur - prevent entities eating blocks in non-ticking chunks
|
||||
Reference in New Issue
Block a user