mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
I'll make some changes now, so skipping build Changelog: * add CarpetFixes optimizations * fix optimizations config * lithium optimizations * add Carpet Fixes Sheep Optimization * add Async Pathfinding; add C2ME opts math * add 2 vmp patches * New performance patches; update README and wiki README * update configuration on wiki * update wiki main page * Updated Upstream (Purpur) * fix conflicts * make "Don't save Fireworks" patch configurable * Disable memory reserve allocating * Fix MC-172801 * resolve conflicts * add bstats to readme * dd custom list of forks * update logo link
123 lines
6.7 KiB
Diff
123 lines
6.7 KiB
Diff
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/gq/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
|
|
index 9f50b2a3c8a576074d75719e6e2abbd984814d7f..da28482bb10cdeb23a54338354e9c54b661846d7 100644
|
|
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
|
|
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
|
|
@@ -176,8 +176,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/gq/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java b/src/main/java/gq/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..87d5a82c5dc3ef4bcbeaf9ef837230269a1670df
|
|
--- /dev/null
|
|
+++ b/src/main/java/gq/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java
|
|
@@ -0,0 +1,46 @@
|
|
+package gq.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;
|
|
+ }
|
|
+}
|
|
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..768c9fc58af7204c79cb1ea2430a58482045bf6c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
|
@@ -457,21 +457,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 (gq.bxteam.divinemc.configuration.DivineConfig.sheepOptimization) {
|
|
+ DyeColor col = gq.bxteam.divinemc.util.carpetfixes.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) {
|