From cce5e2e28d2a90a65861222a706496344422ca8a Mon Sep 17 00:00:00 2001 From: Christian Knaapen Date: Wed, 18 Jan 2023 19:28:42 +0100 Subject: [PATCH] Several tweaks --- .../effortlessbuilding/CommonEvents.java | 20 +++++++++---------- .../buildmodifier/BuildModifiers.java | 2 +- .../textures/special/license.txt | 12 +++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/assets/effortlessbuilding/textures/special/license.txt diff --git a/src/main/java/nl/requios/effortlessbuilding/CommonEvents.java b/src/main/java/nl/requios/effortlessbuilding/CommonEvents.java index 541555e..b30c868 100644 --- a/src/main/java/nl/requios/effortlessbuilding/CommonEvents.java +++ b/src/main/java/nl/requios/effortlessbuilding/CommonEvents.java @@ -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 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; diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java index 1826f37..96c1fb6 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java @@ -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, diff --git a/src/main/resources/assets/effortlessbuilding/textures/special/license.txt b/src/main/resources/assets/effortlessbuilding/textures/special/license.txt new file mode 100644 index 0000000..86204cf --- /dev/null +++ b/src/main/resources/assets/effortlessbuilding/textures/special/license.txt @@ -0,0 +1,12 @@ +All files within this folder fall under the MIT license. + +The MIT License Copyright (c) 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. \ No newline at end of file