mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Shulker change color with dye
This commit is contained in:
68
patches/server/0251-Shulker-change-color-with-dye.patch
Normal file
68
patches/server/0251-Shulker-change-color-with-dye.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
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/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
||||
index 03da91ee39851e8d066b8c63dce849e665c59479..fba13f838c7a427cf43ae9958d8815b170d64b46 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
|
||||
@@ -22,6 +22,8 @@ import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
+import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
@@ -48,6 +50,8 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.projectile.ShulkerBullet;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
+import net.minecraft.world.item.DyeItem;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -107,6 +111,19 @@ public class Shulker extends AbstractGolem implements Enemy {
|
||||
public void initAttributes() {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.shulkerMaxHealth);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ protected InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||
+ ItemStack itemstack = player.getItemInHand(hand);
|
||||
+ if (player.level.purpurConfig.shulkerChangeColorWithDye && itemstack.getItem() instanceof DyeItem dye && dye.getDyeColor() != this.getColor()) {
|
||||
+ this.setColor(dye.getDyeColor());
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ return super.mobInteract(player, hand);
|
||||
+ }
|
||||
// Purpur end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 57c5e7c77079a214ce7fde850fe198005b2297cd..91411bbd931bc26af5977ef8ab51dcc944521554 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1926,6 +1926,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);
|
||||
@@ -1940,6 +1941,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;
|
||||
Reference in New Issue
Block a user