Shulker change color with dye

This commit is contained in:
William Blake Galbreath
2025-01-12 12:31:13 -08:00
committed by granny
parent 504c35afb7
commit c9760f34b3
6 changed files with 40 additions and 66 deletions

View File

@@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 21 Aug 2021 00:07:39 -0500
Subject: [PATCH] Shulker change color with dye
diff --git a/net/minecraft/world/entity/monster/Shulker.java b/net/minecraft/world/entity/monster/Shulker.java
index 1957e2be5087e7bf85be5dfba53de8385dbeadd6..2052549f2e6b23aff5491bb0cc1af00b7f560227 100644
--- a/net/minecraft/world/entity/monster/Shulker.java
+++ b/net/minecraft/world/entity/monster/Shulker.java
@@ -126,6 +126,19 @@ public class Shulker extends AbstractGolem implements VariantHolder<Optional<Dye
return this.level().purpurConfig.shulkerTakeDamageFromWater;
}
// Purpur end - Toggle for water sensitive mob damage
+ @Override
+ protected net.minecraft.world.InteractionResult mobInteract(Player player, net.minecraft.world.InteractionHand hand) {
+ net.minecraft.world.item.ItemStack itemstack = player.getItemInHand(hand);
+ if (player.level().purpurConfig.shulkerChangeColorWithDye && itemstack.getItem() instanceof net.minecraft.world.item.DyeItem dye && dye.getDyeColor() != this.getColor()) {
+ this.setVariant(Optional.of(dye.getDyeColor()));
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return net.minecraft.world.InteractionResult.SUCCESS;
+ }
+ return super.mobInteract(player, hand);
+ }
+
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index ff4d9ccbb9801649ad8ea9dac72b0f32f58e06c1..a47ddcb40340c19ce99a8befe8034240e0457acb 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -2327,6 +2327,7 @@ public class PurpurWorldConfig {
public double shulkerSpawnFromBulletNearbyRange = 8.0D;
public String shulkerSpawnFromBulletNearbyEquation = "(nearby - 1) / 5.0";
public boolean shulkerSpawnFromBulletRandomColor = false;
+ public boolean shulkerChangeColorWithDye = false;
private void shulkerSettings() {
shulkerRidable = getBoolean("mobs.shulker.ridable", shulkerRidable);
shulkerRidableInWater = getBoolean("mobs.shulker.ridable-in-water", shulkerRidableInWater);
@@ -2344,6 +2345,7 @@ public class PurpurWorldConfig {
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);
+ shulkerChangeColorWithDye = getBoolean("mobs.shulker.change-color-with-dye", shulkerChangeColorWithDye);
}
public boolean silverfishRidable = false;