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
|
||||
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,
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
All files within this folder fall under the MIT license.
|
||||
|
||||
The MIT License Copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions: The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Reference in New Issue
Block a user