Skip to content

Commit 2b79d33

Browse files
committed
hopefully no more weird protection issues remain.
1 parent 8d588ab commit 2b79d33

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/redart15/commandly/command/CommandProtect.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.mojang.brigadier.context.CommandContext;
88
import com.mojang.brigadier.exceptions.CommandSyntaxException;
99
import net.minecraft.core.block.Block;
10+
import net.minecraft.core.block.Blocks;
1011
import net.minecraft.core.entity.player.Player;
1112
import net.minecraft.core.net.command.CommandManager;
1213
import net.minecraft.core.net.command.CommandSource;
@@ -97,7 +98,8 @@ private static int chunks_protect(CommandSource source, World world, Predicate<B
9798
Block<?> block = world.getBlock(fx + x, y, fz + z);
9899
if (block == null) continue;
99100
if (treecapitator.test(block) || veinmining.test(block)) {
100-
world.setBlockMetadata(fx + x, y, fz + z, (1 << CommandlyMod.getMask()));
101+
int metadata = world.getBlockMetadata(fx + x, y, fz + z);
102+
world.setBlockMetadata(fx + x, y, fz + z, (1 << CommandlyMod.getMask()) | metadata);
101103
count_protected++;
102104
}
103105
}
@@ -157,7 +159,7 @@ private static int radius_protect(
157159
}
158160

159161
if ((int) Math.floor(1.25 * Math.PI * Math.pow(radius, 3)) > CommandlyMod.getMaxBlockCount()) {
160-
source.sendTranslatableMessage("commadly.protected.tolarge");
162+
source.sendTranslatableMessage("commadly.protected.toolarge");
161163
return code(CANNOT);
162164
}
163165
int count_protected = 0;
@@ -168,7 +170,8 @@ private static int radius_protect(
168170
Block<?> block = world.getBlock(fx + x, fy + y, fz + z);
169171
if (block == null) continue;
170172
if (treecapitator.test(block) || veinmining.test(block)) {
171-
world.setBlockMetadata(fx + x, fy + y, fz + z, (1 << CommandlyMod.getMask()));
173+
int metadata = world.getBlockMetadata(fx + x, y, fz + z);
174+
world.setBlockMetadata(fx + x, y, fz + z, (1 << CommandlyMod.getMask()) | metadata);
172175
count_protected++;
173176
}
174177
}
@@ -240,7 +243,8 @@ public static int point_protect(
240243
Block<?> block = world.getBlock(x, y, z);
241244
if (block == null) continue;
242245
if (treecapitator.test(block) || veinmining.test(block)) {
243-
world.setBlockMetadata(x, y, z, (1 << CommandlyMod.getMask()));
246+
int metadata = world.getBlockMetadata(fx + x, y, fz + z);
247+
world.setBlockMetadata(fx + x, y, fz + z, (1 << CommandlyMod.getMask()) | metadata);
244248
count_protected++;
245249
}
246250
}

0 commit comments

Comments
 (0)