Several tweaks
This commit is contained in:
@@ -68,7 +68,6 @@ public class CommonEvents {
|
||||
|
||||
if (event.getEntity() instanceof FakePlayer) return;
|
||||
|
||||
//Cancel event if necessary
|
||||
ServerPlayer player = ((ServerPlayer) event.getEntity());
|
||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
@@ -77,15 +76,15 @@ public class CommonEvents {
|
||||
|
||||
//Only cancel if itemblock in hand
|
||||
//Fixed issue with e.g. Create Wrench shift-rightclick disassembling being cancelled.
|
||||
ItemStack currentItemStack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
if (currentItemStack.getItem() instanceof BlockItem ||
|
||||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown())) {
|
||||
if (isPlayerHoldingBlock(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
} else if (modifierSettings.doQuickReplace()) {
|
||||
//Cancel event and send message if QuickReplace
|
||||
event.setCanceled(true);
|
||||
if (isPlayerHoldingBlock(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new RequestLookAtMessage(true));
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new AddUndoMessage(event.getPos(), event.getBlockSnapshot().getReplacedBlock(), event.getState()));
|
||||
} else {
|
||||
@@ -96,11 +95,6 @@ public class CommonEvents {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new RequestLookAtMessage(false));
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new AddUndoMessage(event.getPos(), event.getBlockSnapshot().getReplacedBlock(), event.getState()));
|
||||
}
|
||||
|
||||
// Stat<ResourceLocation> blocksPlacedStat = StatList.CUSTOM.get(new ResourceLocation(EffortlessBuilding.MODID, "blocks_placed"));
|
||||
// player.getStats().increment(player, blocksPlacedStat, 1);
|
||||
//
|
||||
// System.out.println(player.getStats().getValue(blocksPlacedStat));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -129,6 +123,12 @@ public class CommonEvents {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPlayerHoldingBlock(Player player) {
|
||||
ItemStack currentItemStack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
return currentItemStack.getItem() instanceof BlockItem ||
|
||||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (event.getEntity() instanceof FakePlayer) return;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BuildModifiers {
|
||||
|
||||
} else {
|
||||
|
||||
int delay = CommonConfig.visuals.appearAnimationLength.get() * 3 - 3; //DelayedBlockPlacer is called 3 times per tick?
|
||||
int delay = CommonConfig.visuals.appearAnimationLength.get() * 3 - 3; //DelayedBlockPlacer is 3 times faster than client tick?
|
||||
|
||||
//place blocks after delay
|
||||
EffortlessBuilding.DELAYED_BLOCK_PLACER.placeBlocksDelayed(new DelayedBlockPlacer.Entry(world, player, coordinates,
|
||||
|
||||
Reference in New Issue
Block a user