Skip to content

Commit

Permalink
Conduit behavior configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
encode42 committed Aug 8, 2021
1 parent 947158f commit bd98fb5
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Config to remove curse of binding with weakness


diff --git a/src/main/java/net/minecraft/world/inventory/InventoryMenu.java b/src/main/java/net/minecraft/world/inventory/InventoryMenu.java
index 777c21d8f3d5a7e9c156d25263f4b50ad67bd7c7..75cda19edb86af7b1806ff647426cf4a2c166e6b 100644
index 777c21d8f3d5a7e9c156d25263f4b50ad67bd7c7..98cc31b2f318c468d1d2a26b24441bfe03055562 100644
--- a/src/main/java/net/minecraft/world/inventory/InventoryMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/InventoryMenu.java
@@ -4,6 +4,7 @@ import com.mojang.datafixers.util.Pair;
Expand All @@ -21,7 +21,7 @@ index 777c21d8f3d5a7e9c156d25263f4b50ad67bd7c7..75cda19edb86af7b1806ff647426cf4a
ItemStack itemstack = this.getItem();

- return !itemstack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.mayPickup(playerEntity);
+ return !itemstack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? playerEntity.level.purpurConfig.playerRemoveBindingWithWeakness && playerEntity.hasEffect(MobEffects.WEAKNESS) : super.mayPickup(playerEntity);
+ return !itemstack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? playerEntity.level.purpurConfig.playerRemoveBindingWithWeakness && playerEntity.hasEffect(MobEffects.WEAKNESS) : super.mayPickup(playerEntity); // Purpur
}

@Override
Expand Down
86 changes: 86 additions & 0 deletions patches/server/0246-Conduit-behavior-configuration.patch
@@ -0,0 +1,86 @@
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 fc996199616156d04d6ae06ddc3da8d2c159c771..b5b202645c0e9adb2173f8d99381a16f4d409819 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
@@ -55,6 +55,8 @@ public class ConduitBlockEntity extends BlockEntity {

public ConduitBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.CONDUIT, pos, state);
+
+
}

@Override
@@ -175,7 +177,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) {
@@ -195,7 +197,7 @@ public class ConduitBlockEntity extends BlockEntity {

private static void applyEffects(Level world, BlockPos pos, List<BlockPos> activatingBlocks) {
int i = activatingBlocks.size();
- int j = i / 7 * 16;
+ int j = i / 7 * world.purpurConfig.conduitDistance; // Purpur
int k = pos.getX();
int l = pos.getY();
int i1 = pos.getZ();
@@ -233,14 +235,14 @@ public class ConduitBlockEntity extends BlockEntity {
if (!list1.isEmpty()) {
blockEntity.destroyTarget = (LivingEntity) list1.get(world.random.nextInt(list1.size()));
}
- } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan((Vec3i) blockEntity.destroyTarget.blockPosition(), 8.0D)) {
+ } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan((Vec3i) blockEntity.destroyTarget.blockPosition(), world.purpurConfig.conduitDamageDistance)) { // Purpur
blockEntity.destroyTarget = null;
}

if (blockEntity.destroyTarget != null) {
// CraftBukkit start
CraftEventFactory.blockDamage = CraftBlock.at(world, pos);
- if (blockEntity.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) {
+ if (blockEntity.destroyTarget.hurt(DamageSource.MAGIC, world.purpurConfig.conduitDamageAmount)) { // Purpur
world.playSound((Player) null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F);
}
CraftEventFactory.blockDamage = null;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 0ccb7328ee0d348300a0947241d732b897a91f60..627bebded409d93530b7ffb8db7b83e59d163f5c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -2486,4 +2486,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 = Registry.BLOCK.get(new ResourceLocation(key.toString()));
+ if (!block.defaultBlockState().isAir()) {
+ conduitBlockList.add(block);
+ }
+ });
+ conduitBlocks = conduitBlockList.toArray(Block[]::new);
+ }
}

0 comments on commit bd98fb5

Please sign in to comment.