mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
temporarily remove pufferfish, closes #1625
This commit is contained in:
130
patches/server/0195-Conduit-behavior-configuration.patch
Normal file
130
patches/server/0195-Conduit-behavior-configuration.patch
Normal file
@@ -0,0 +1,130 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Encode42 <me@encode42.dev>
|
||||
Date: Sun, 8 Aug 2021 18:14:31 -0400
|
||||
Subject: [PATCH] Conduit behavior configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
index d354c2ad41533ec8d52f7c5f63f8f74a0b1ce235..a43c41a26c1e34a2f4eda1c498a562664a783c77 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
@@ -169,7 +169,7 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
if ((l > 1 || i1 > 1 || j1 > 1) && (i == 0 && (i1 == 2 || j1 == 2) || j == 0 && (l == 2 || j1 == 2) || k == 0 && (l == 2 || i1 == 2))) {
|
||||
BlockPos blockposition2 = pos.offset(i, j, k);
|
||||
BlockState iblockdata = world.getBlockState(blockposition2);
|
||||
- Block[] ablock = ConduitBlockEntity.VALID_BLOCKS;
|
||||
+ Block[] ablock = world.purpurConfig.conduitBlocks; // Purpur
|
||||
int k1 = ablock.length;
|
||||
|
||||
for (int l1 = 0; l1 < k1; ++l1) {
|
||||
@@ -189,13 +189,13 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
|
||||
private static void applyEffects(Level world, BlockPos pos, List<BlockPos> activatingBlocks) {
|
||||
// CraftBukkit start
|
||||
- ConduitBlockEntity.applyEffects(world, pos, ConduitBlockEntity.getRange(activatingBlocks));
|
||||
+ ConduitBlockEntity.applyEffects(world, pos, ConduitBlockEntity.getRange(activatingBlocks, world)); // Purpur
|
||||
}
|
||||
|
||||
- public static int getRange(List<BlockPos> list) {
|
||||
+ public static int getRange(List<BlockPos> list, Level world) { // Purpur
|
||||
// CraftBukkit end
|
||||
int i = list.size();
|
||||
- int j = i / 7 * 16;
|
||||
+ int j = i / 7 * world.purpurConfig.conduitDistance; // Purpur
|
||||
// CraftBukkit start
|
||||
return j;
|
||||
}
|
||||
@@ -238,20 +238,20 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
tileentityconduit.destroyTarget = ConduitBlockEntity.findDestroyTarget(world, blockposition, tileentityconduit.destroyTargetUUID);
|
||||
tileentityconduit.destroyTargetUUID = null;
|
||||
} else if (tileentityconduit.destroyTarget == null) {
|
||||
- List<LivingEntity> list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(blockposition), (entityliving1) -> {
|
||||
+ List<LivingEntity> list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(blockposition, world), (entityliving1) -> { // Purpur
|
||||
return entityliving1 instanceof Enemy && entityliving1.isInWaterOrRain();
|
||||
});
|
||||
|
||||
if (!list1.isEmpty()) {
|
||||
tileentityconduit.destroyTarget = (LivingEntity) list1.get(world.random.nextInt(list1.size()));
|
||||
}
|
||||
- } else if (!tileentityconduit.destroyTarget.isAlive() || !blockposition.closerThan(tileentityconduit.destroyTarget.blockPosition(), 8.0D)) {
|
||||
+ } else if (!tileentityconduit.destroyTarget.isAlive() || !blockposition.closerThan(tileentityconduit.destroyTarget.blockPosition(), world.purpurConfig.conduitDamageDistance)) { // Purpur
|
||||
tileentityconduit.destroyTarget = null;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
if (damageTarget && tileentityconduit.destroyTarget != null) {
|
||||
- if (tileentityconduit.destroyTarget.hurtServer((ServerLevel) world, world.damageSources().magic().directBlock(world, blockposition), 4.0F)) {
|
||||
+ if (tileentityconduit.destroyTarget.hurtServer((ServerLevel) world, world.damageSources().magic().directBlock(world, blockposition), world.purpurConfig.conduitDamageAmount)) { // Purpur
|
||||
world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -276,16 +276,22 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public static AABB getDestroyRangeAABB(BlockPos pos) {
|
||||
+ // Purpur start
|
||||
+ return getDestroyRangeAABB(pos, null);
|
||||
+ }
|
||||
+
|
||||
+ private static AABB getDestroyRangeAABB(BlockPos pos, Level level) {
|
||||
+ // Purpur end
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
|
||||
- return (new AABB((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1))).inflate(8.0D);
|
||||
+ return (new AABB((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1))).inflate(level == null ? 8.0D : level.purpurConfig.conduitDamageDistance); // Purpur
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LivingEntity findDestroyTarget(Level world, BlockPos pos, UUID uuid) {
|
||||
- List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving) -> {
|
||||
+ List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos, world), (entityliving) -> { // Purpur
|
||||
return entityliving.getUUID().equals(uuid);
|
||||
});
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java b/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java
|
||||
index c1759aeb3e6ad0e4eb66cba3da1b120dd1dce812..1a91bc2e422db0eba65694ac046f1b362c6b0cd6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java
|
||||
@@ -73,7 +73,7 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
public int getRange() {
|
||||
this.ensureNoWorldGeneration();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
- return (conduit != null) ? ConduitBlockEntity.getRange(conduit.effectBlocks) : 0;
|
||||
+ return (conduit != null) ? ConduitBlockEntity.getRange(conduit.effectBlocks, this.world.getHandle()) : 0; // Purpur
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 8f90dbc4395381f712befbbf09b6ae94887843e7..df054975a396856693eb6e70637a50b089836e37 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -3039,4 +3039,27 @@ public class PurpurWorldConfig {
|
||||
private void hungerSettings() {
|
||||
hungerStarvationDamage = (float) getDouble("hunger.starvation-damage", hungerStarvationDamage);
|
||||
}
|
||||
+
|
||||
+ public int conduitDistance = 16;
|
||||
+ public double conduitDamageDistance = 8;
|
||||
+ public float conduitDamageAmount = 4;
|
||||
+ public Block[] conduitBlocks;
|
||||
+ private void conduitSettings() {
|
||||
+ conduitDistance = getInt("blocks.conduit.effect-distance", conduitDistance);
|
||||
+ conduitDamageDistance = getDouble("blocks.conduit.mob-damage.distance", conduitDamageDistance);
|
||||
+ conduitDamageAmount = (float) getDouble("blocks.conduit.mob-damage.damage-amount", conduitDamageAmount);
|
||||
+ List<Block> conduitBlockList = new ArrayList<>();
|
||||
+ getList("blocks.conduit.valid-ring-blocks", new ArrayList<String>(){{
|
||||
+ add("minecraft:prismarine");
|
||||
+ add("minecraft:prismarine_bricks");
|
||||
+ add("minecraft:sea_lantern");
|
||||
+ add("minecraft:dark_prismarine");
|
||||
+ }}).forEach(key -> {
|
||||
+ Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(key.toString()));
|
||||
+ if (!block.defaultBlockState().isAir()) {
|
||||
+ conduitBlockList.add(block);
|
||||
+ }
|
||||
+ });
|
||||
+ conduitBlocks = conduitBlockList.toArray(Block[]::new);
|
||||
+ }
|
||||
}
|
||||
Reference in New Issue
Block a user