mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@c1b4899 Fix dupe uuid check on entity add (#6735) PaperMC/Paper@3f043f7 Async catch modifications to critical entity state PaperMC/Paper@bc43f40 Update jline and TCA (#6829) PaperMC/Paper@d9e2817 Update paperweight to 1.1.13 (#6866) PaperMC/Paper@3e310e0 Remove redundant and unneeded repos, reorder repos (#6867) PaperMC/Paper@485d15f Update paperweight to 1.1.14 (#6868) PaperMC/Paper@09d50a9 Added missing mappings (#6810) PaperMC/Paper@0968cdd Move async catches back to where they were (#6869) PaperMC/Paper@6f71b7c Deduplicate strings in ObfHelper (#6841) PaperMC/Paper@ada930b Updated Upstream (Bukkit/CraftBukkit) (#6872) PaperMC/Paper@06d82e0 Cache palette array (#6767) PaperMC/Paper@70fe58d Expose the potential player cause of a lightning (#6782) PaperMC/Paper@c20c9d3 Fix CraftNamespacedKey shenanigans (#6825) PaperMC/Paper@29bb5a9 Add PlayerDeathEvent#getPlayer for clarity (#6859) PaperMC/Paper@124d079 Fix issues with mob conversion (#6831) PaperMC/Paper@22b0238 Add API for checking if a zombie has the option to break doors (#6855) PaperMC/Paper@5af80b0 Add isCollidable methods to various places (#6870) PaperMC/Paper@32ba088 Fix setPatternColor on tropical fish bucket meta (#6877) PaperMC/Paper@87121ce Move `getTrackedPlayers` up from Player to Entity (#6569) PaperMC/Paper@a923e33 Make despawn distance configs per-category, improve per category spawn limit config (#6717) PaperMC/Paper@3f17694 Goat ram API (#6336) PaperMC/Paper@cc2ecbc Add Raw Byte Entity Serialization (#6826) Airplane Changes: TECHNOVE/Airplane@e47949b Ty Penple <3 TECHNOVE/Airplane@86fee6b Update upstream
91 lines
5.6 KiB
Diff
91 lines
5.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 25 Jun 2021 19:48:21 -0500
|
|
Subject: [PATCH] Shulker spawn from bullet options
|
|
|
|
(0 - 1) / 5.0 = -0.2 (can never happen because self is included in count)
|
|
(1 - 1) / 5.0 = 0.0 1.0 - 0.0 = 1.0 100% (just self)
|
|
(2 - 1) / 5.0 = 0.2 1.0 - 0.2 = 0.8 80% (1 other shulker)
|
|
(3 - 1) / 5.0 = 0.4 1.0 - 0.4 = 0.6 60% (2 other shulkers)
|
|
(4 - 1) / 5.0 = 0.6 1.0 - 0.6 = 0.4 40% (3 other shulkers)
|
|
(5 - 1) / 5.0 = 0.8 1.0 - 0.8 = 0.2 20% (4 other shulkers)
|
|
(6 - 1) / 5.0 = 1.0 1.0 - 1.0 = 0.0 0% (5 other shulkers)
|
|
(7 - 1) / 5.0 = 1.2 1.0 - 1.2 = -0.2 0% (6 other shulkers)
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
|
index 23b038d4cca101313303299779ca50be7a596d27..06c6be23da8d1090aed33f48fc0bbbe442a974b4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
|
@@ -501,13 +501,22 @@ public class Shulker extends AbstractGolem implements Enemy {
|
|
Vec3 vec3d = this.position();
|
|
AABB axisalignedbb = this.getBoundingBox();
|
|
|
|
- if (!this.isClosed() && this.teleportSomewhere()) {
|
|
- int i = this.level.getEntities((EntityTypeTest) EntityType.SHULKER, axisalignedbb.inflate(8.0D), Entity::isAlive).size();
|
|
- float f = (float) (i - 1) / 5.0F;
|
|
-
|
|
- if (this.level.random.nextFloat() >= f) {
|
|
+ if ((!this.level.purpurConfig.shulkerSpawnFromBulletRequireOpenLid || !this.isClosed()) && this.teleportSomewhere()) {
|
|
+ // Purpur start
|
|
+ float chance = this.level.purpurConfig.shulkerSpawnFromBulletBaseChance;
|
|
+ if (!this.level.purpurConfig.shulkerSpawnFromBulletNearbyEquation.isBlank()) {
|
|
+ int nearby = this.level.getEntities((EntityTypeTest) EntityType.SHULKER, axisalignedbb.inflate(this.level.purpurConfig.shulkerSpawnFromBulletNearbyRange), Entity::isAlive).size();
|
|
+ try {
|
|
+ scriptEngine.eval("nearby = " + nearby);
|
|
+ chance -= (float) scriptEngine.eval(this.level.purpurConfig.shulkerSpawnFromBulletNearbyEquation);
|
|
+ } catch (Exception ignore) {
|
|
+ chance -= (float) (nearby - 1) / 5.0F;
|
|
+ }
|
|
+ }
|
|
+ if (this.level.random.nextFloat() <= chance) {
|
|
+ // Purpur end
|
|
Shulker entityshulker = (Shulker) EntityType.SHULKER.create(this.level);
|
|
- DyeColor enumcolor = this.getColor();
|
|
+ DyeColor enumcolor = this.level.purpurConfig.shulkerSpawnFromBulletRandomColor ? DyeColor.random(this.level.random) : this.getColor(); // Purpur
|
|
|
|
if (enumcolor != null) {
|
|
entityshulker.setColor(enumcolor);
|
|
diff --git a/src/main/java/net/minecraft/world/item/DyeColor.java b/src/main/java/net/minecraft/world/item/DyeColor.java
|
|
index f812a75985d26785639491c9a980387a3f261f2d..b11fb39b69f5225ca7da72ca1a2200c7eaf7e873 100644
|
|
--- a/src/main/java/net/minecraft/world/item/DyeColor.java
|
|
+++ b/src/main/java/net/minecraft/world/item/DyeColor.java
|
|
@@ -109,4 +109,10 @@ public enum DyeColor implements StringRepresentable {
|
|
public String getSerializedName() {
|
|
return this.name;
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ public static DyeColor random(java.util.Random random) {
|
|
+ return BY_ID[random.nextInt(BY_ID.length)];
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 87d4412a8cb4cac1d112436981d9df7c7314d6de..297f7c068e0af8c65f7cc33e8731bd595b95bacf 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1834,6 +1834,11 @@ public class PurpurWorldConfig {
|
|
public boolean shulkerRidableInWater = false;
|
|
public double shulkerMaxHealth = 30.0D;
|
|
public boolean shulkerTakeDamageFromWater = false;
|
|
+ public float shulkerSpawnFromBulletBaseChance = 1.0F;
|
|
+ public boolean shulkerSpawnFromBulletRequireOpenLid = true;
|
|
+ public double shulkerSpawnFromBulletNearbyRange = 8.0D;
|
|
+ public String shulkerSpawnFromBulletNearbyEquation = "(nearby - 1) / 5.0";
|
|
+ public boolean shulkerSpawnFromBulletRandomColor = false;
|
|
private void shulkerSettings() {
|
|
shulkerRidable = getBoolean("mobs.shulker.ridable", shulkerRidable);
|
|
shulkerRidableInWater = getBoolean("mobs.shulker.ridable-in-water", shulkerRidableInWater);
|
|
@@ -1844,6 +1849,11 @@ public class PurpurWorldConfig {
|
|
}
|
|
shulkerMaxHealth = getDouble("mobs.shulker.attributes.max_health", shulkerMaxHealth);
|
|
shulkerTakeDamageFromWater = getBoolean("mobs.shulker.takes-damage-from-water", shulkerTakeDamageFromWater);
|
|
+ shulkerSpawnFromBulletBaseChance = (float) getDouble("mobs.shulker.spawn-from-bullet.base-chance", shulkerSpawnFromBulletBaseChance);
|
|
+ shulkerSpawnFromBulletRequireOpenLid = getBoolean("mobs.shulker.spawn-from-bullet.require-open-lid", shulkerSpawnFromBulletRequireOpenLid);
|
|
+ shulkerSpawnFromBulletNearbyRange = getDouble("mobs.shulker.spawn-from-bullet.nearby-range", shulkerSpawnFromBulletNearbyRange);
|
|
+ shulkerSpawnFromBulletNearbyEquation = getString("mobs.shulker.spawn-from-bullet.nearby-equation", shulkerSpawnFromBulletNearbyEquation);
|
|
+ shulkerSpawnFromBulletRandomColor = getBoolean("mobs.shulker.spawn-from-bullet.random-color", shulkerSpawnFromBulletRandomColor);
|
|
}
|
|
|
|
public boolean silverfishRidable = false;
|