Skip to content

Commit ae0dd0b

Browse files
committed
fix: dupe when interaction is allowed but block editing is not
FTBTeam/FTB-Mods-Issues#1752
1 parent 539dcc4 commit ae0dd0b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import net.minecraft.world.entity.LivingEntity;
4545
import net.minecraft.world.entity.MobSpawnType;
4646
import net.minecraft.world.entity.player.Player;
47+
import net.minecraft.world.item.BlockItem;
4748
import net.minecraft.world.item.ItemStack;
4849
import net.minecraft.world.level.BaseSpawner;
4950
import net.minecraft.world.level.Explosion;
@@ -280,9 +281,17 @@ public EventResult blockLeftClick(Player player, InteractionHand hand, BlockPos
280281
public EventResult blockRightClick(Player player, InteractionHand hand, BlockPos pos, Direction face) {
281282
// calling architectury stub method
282283
//noinspection ConstantConditions
283-
if (player instanceof ServerPlayer sp && ClaimedChunkManagerImpl.getInstance().shouldPreventInteraction(player, hand, pos, FTBChunksExpected.getBlockInteractProtection(), null)) {
284-
FTBCUtils.forceHeldItemSync(sp, hand);
285-
return EventResult.interruptFalse();
284+
if (player instanceof ServerPlayer sp) {
285+
boolean blockItem = sp.getItemInHand(hand).getItem() instanceof BlockItem;
286+
ClaimedChunkManagerImpl mgr = ClaimedChunkManagerImpl.getInstance();
287+
// not ideal since it also prevents right-clicking *any* blocks if holding a block item when block placement is prevented
288+
// but necessary - https://github.com/FTBTeam/FTB-Mods-Issues/issues/1752
289+
if (mgr.shouldPreventInteraction(player, hand, pos, FTBChunksExpected.getBlockInteractProtection(), null)
290+
|| blockItem && mgr.shouldPreventInteraction(player, hand, pos, FTBChunksExpected.getBlockPlaceProtection(), null))
291+
{
292+
FTBCUtils.forceHeldItemSync(sp, hand);
293+
return EventResult.interruptFalse();
294+
}
286295
}
287296

288297
return EventResult.pass();
@@ -418,7 +427,7 @@ private void playerChangedDimension(ServerPlayer serverPlayer, ResourceKey<Level
418427
}
419428

420429
@SuppressWarnings("UnreachableCode")
421-
private void teamConfig(TeamCollectPropertiesEvent event) {
430+
private void teamConfig(TeamCollectPropertiesEvent event) {
422431
event.add(FTBChunksProperties.ALLOW_EXPLOSIONS);
423432
event.add(FTBChunksProperties.ALLOW_MOB_GRIEFING);
424433
event.add(FTBChunksProperties.ALLOW_ALL_FAKE_PLAYERS);
@@ -478,7 +487,7 @@ private void playerLeftParty(PlayerLeftPartyTeamEvent event) {
478487
}
479488

480489
@SuppressWarnings("UnreachableCode")
481-
private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl transferTo, Collection<ClaimedChunkImpl> chunksToTransfer) {
490+
private void transferClaims(ChunkTeamDataImpl transferFrom, ChunkTeamDataImpl transferTo, Collection<ClaimedChunkImpl> chunksToTransfer) {
482491
CommandSourceStack sourceStack = ClaimedChunkManagerImpl.getInstance().getMinecraftServer().createCommandSourceStack();
483492

484493
String fromName = transferFrom.getTeam().getShortName();

0 commit comments

Comments
 (0)