mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 02:47:43 +01:00
Conduit behavior configuration
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
@@ -155,7 +_,7 @@
|
||||
BlockPos blockPos1 = pos.offset(i, i1, i2x);
|
||||
BlockState blockState = level.getBlockState(blockPos1);
|
||||
|
||||
- for (Block block : VALID_BLOCKS) {
|
||||
+ for (Block block : level.purpurConfig.conduitBlocks) { // Purpur - Conduit behavior configuration
|
||||
if (blockState.is(block)) {
|
||||
positions.add(blockPos1);
|
||||
}
|
||||
@@ -170,13 +_,13 @@
|
||||
|
||||
private static void applyEffects(Level level, BlockPos pos, List<BlockPos> positions) {
|
||||
// CraftBukkit start
|
||||
- ConduitBlockEntity.applyEffects(level, pos, ConduitBlockEntity.getRange(positions));
|
||||
+ ConduitBlockEntity.applyEffects(level, pos, ConduitBlockEntity.getRange(positions, level)); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
- public static int getRange(List<BlockPos> positions) {
|
||||
+ public static int getRange(List<BlockPos> positions, Level level) { // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit end
|
||||
int size = positions.size();
|
||||
- int i = size / 7 * 16;
|
||||
+ int i = size / 7 * level.purpurConfig.conduitDistance; // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit start
|
||||
return i;
|
||||
}
|
||||
@@ -213,17 +_,17 @@
|
||||
blockEntity.destroyTargetUUID = null;
|
||||
} else if (blockEntity.destroyTarget == null) {
|
||||
List<LivingEntity> entitiesOfClass = level.getEntitiesOfClass(
|
||||
- LivingEntity.class, getDestroyRangeAABB(pos), collidedEntity -> collidedEntity instanceof Enemy && collidedEntity.isInWaterOrRain()
|
||||
+ LivingEntity.class, getDestroyRangeAABB(pos, level), collidedEntity -> collidedEntity instanceof Enemy && collidedEntity.isInWaterOrRain() // Purpur - Conduit behavior configuration
|
||||
);
|
||||
if (!entitiesOfClass.isEmpty()) {
|
||||
blockEntity.destroyTarget = entitiesOfClass.get(level.random.nextInt(entitiesOfClass.size()));
|
||||
}
|
||||
- } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan(blockEntity.destroyTarget.blockPosition(), 8.0)) {
|
||||
+ } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan(blockEntity.destroyTarget.blockPosition(), level.purpurConfig.conduitDamageDistance)) { // Purpur - Conduit behavior configuration
|
||||
blockEntity.destroyTarget = null;
|
||||
}
|
||||
|
||||
if (damageTarget && blockEntity.destroyTarget != null) { // CraftBukkit
|
||||
- if (blockEntity.destroyTarget.hurtServer((net.minecraft.server.level.ServerLevel) level, level.damageSources().magic().directBlock(level, pos), 4.0F)) // CraftBukkit
|
||||
+ if (blockEntity.destroyTarget.hurtServer((net.minecraft.server.level.ServerLevel) level, level.damageSources().magic().directBlock(level, pos), level.purpurConfig.conduitDamageAmount)) // CraftBukkit // Purpur - Conduit behavior configuration
|
||||
level.playSound(
|
||||
null,
|
||||
blockEntity.destroyTarget.getX(),
|
||||
@@ -253,16 +_,22 @@
|
||||
}
|
||||
|
||||
public static AABB getDestroyRangeAABB(BlockPos pos) {
|
||||
+ // Purpur start - Conduit behavior configuration
|
||||
+ return getDestroyRangeAABB(pos, null);
|
||||
+ }
|
||||
+
|
||||
+ private static AABB getDestroyRangeAABB(BlockPos pos, Level level) {
|
||||
+ // Purpur end - Conduit behavior configuration
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
- return new AABB(x, y, z, x + 1, y + 1, z + 1).inflate(8.0);
|
||||
+ return new AABB(x, y, z, x + 1, y + 1, z + 1).inflate(level == null ? 8.0 : level.purpurConfig.conduitDamageDistance); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LivingEntity findDestroyTarget(Level level, BlockPos pos, UUID targetId) {
|
||||
List<LivingEntity> entitiesOfClass = level.getEntitiesOfClass(
|
||||
- LivingEntity.class, getDestroyRangeAABB(pos), collidedEntity -> collidedEntity.getUUID().equals(targetId)
|
||||
+ LivingEntity.class, getDestroyRangeAABB(pos, level), collidedEntity -> collidedEntity.getUUID().equals(targetId) // Purpur - Conduit behavior configuration
|
||||
);
|
||||
return entitiesOfClass.size() == 1 ? entitiesOfClass.get(0) : null;
|
||||
}
|
||||
Reference in New Issue
Block a user