From aca51393c7e715cb5263ba5468c9964aee81cb61 Mon Sep 17 00:00:00 2001 From: TheGlitch76 Date: Sun, 25 Oct 2020 15:41:08 -0500 Subject: [PATCH] Revert "Added LeftClickEmpty. (#197)" This reverts commit cf02fa10 --- .../entity/player/PlayerInteractEvent.java | 18 ++++---- .../entity/player/PlayerPickupXpEvent.java | 4 +- .../impl/event/entity/PlayerEvents.java | 5 --- .../event/entity/MixinMinecraftClient.java | 43 ------------------- .../patchwork-events-entity.mixins.json | 1 - .../net/minecraftforge/common/ForgeHooks.java | 5 --- 6 files changed, 11 insertions(+), 65 deletions(-) delete mode 100644 patchwork-events-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinMinecraftClient.java diff --git a/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index cb7bd1e5..91942c0b 100644 --- a/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -92,17 +92,17 @@ public Direction getFace() { } /** - * @return The effective, i.e. logical, side of this interaction. This will be {@link LogicalSide#CLIENT} on the client thread, and {@link LogicalSide#SERVER} on the server thread. + * @return Convenience method to get the world of this interaction. */ - public LogicalSide getSide() { - return getWorld().isClient ? LogicalSide.CLIENT : LogicalSide.SERVER; + public World getWorld() { + return getPlayer().getEntityWorld(); } /** - * @return Convenience method to get the world of this interaction. + * @return The effective, i.e. logical, side of this interaction. This will be {@link LogicalSide#CLIENT} on the client thread, and {@link LogicalSide#SERVER} on the server thread. */ - public World getWorld() { - return getPlayer().getEntityWorld(); + public LogicalSide getSide() { + return getWorld().isClient ? LogicalSide.CLIENT : LogicalSide.SERVER; } /** @@ -295,8 +295,10 @@ public RightClickEmpty(PlayerEntity player, Hand hand) { * This event is fired when a player left clicks while targeting a block. * *

This event controls which of {@link net.minecraft.block.Block#onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)} and/or the item harvesting methods will be called.

+ *

This event is cancellable. * Cancelling the event will cause none of the above noted methods to be called.

+ * There are various results to this event, see the getters below. * *

Note that if the event is canceled and the player holds down left mouse, the event will continue to fire. @@ -357,9 +359,9 @@ public void setCanceled(boolean canceled) { * *

This event is not cancellable.

*/ - public static class LeftClickEmpty extends PlayerInteractEvent { + /* TODO public static class LeftClickEmpty extends PlayerInteractEvent { public LeftClickEmpty(PlayerEntity player) { super(player, Hand.MAIN_HAND, new BlockPos(player), null); } - } + }*/ } diff --git a/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java b/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java index 3aef9c5a..fe2ae604 100644 --- a/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java +++ b/patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java @@ -23,10 +23,8 @@ import net.minecraft.entity.player.PlayerEntity; /** - * Legacy version of PlayerXpEvent.PickupXp.
+ * Legacy version of PlayerXpEvent.PickupXp. Mods should move to PickupXp, and * this class is removed in 1.15. - * - * @deprecated Mods should move to {@link net.minecraftforge.event.entity.player.PlayerXpEvent.PickupXp} */ @Deprecated public class PlayerPickupXpEvent extends PlayerXpEvent.PickupXp { diff --git a/patchwork-events-entity/src/main/java/net/patchworkmc/impl/event/entity/PlayerEvents.java b/patchwork-events-entity/src/main/java/net/patchworkmc/impl/event/entity/PlayerEvents.java index 4c9f3e25..9e908e1e 100644 --- a/patchwork-events-entity/src/main/java/net/patchworkmc/impl/event/entity/PlayerEvents.java +++ b/patchwork-events-entity/src/main/java/net/patchworkmc/impl/event/entity/PlayerEvents.java @@ -22,7 +22,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.ItemEntity; @@ -60,10 +59,6 @@ public static void firePlayerSmeltedEvent(PlayerEntity player, ItemStack smelted MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); } - public static void fireLeftClickEmptyEvent(PlayerEntity player) { - MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player)); - } - /** * * @return -1 if the event was canceled, 0 if the event was denied or had no result set, and 1 if the event was allowed diff --git a/patchwork-events-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinMinecraftClient.java b/patchwork-events-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinMinecraftClient.java deleted file mode 100644 index 63ed7705..00000000 --- a/patchwork-events-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinMinecraftClient.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Minecraft Forge, Patchwork Project - * Copyright (c) 2016-2020, 2019-2020 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.patchworkmc.mixin.event.entity; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import net.patchworkmc.impl.event.entity.PlayerEvents; - -@Mixin(MinecraftClient.class) -public abstract class MixinMinecraftClient { - @Shadow - public ClientPlayerEntity player; - - @Inject(method = "doAttack()V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;resetLastAttackedTicks()V", shift = At.Shift.AFTER)) - private void fireLeftClickEmpty(CallbackInfo ci) { - PlayerEvents.fireLeftClickEmptyEvent(player); - } -} diff --git a/patchwork-events-entity/src/main/resources/patchwork-events-entity.mixins.json b/patchwork-events-entity/src/main/resources/patchwork-events-entity.mixins.json index 09cea1a7..895bcd44 100644 --- a/patchwork-events-entity/src/main/resources/patchwork-events-entity.mixins.json +++ b/patchwork-events-entity/src/main/resources/patchwork-events-entity.mixins.json @@ -32,7 +32,6 @@ "MixinClientPlayerEntity", "MixinClientWorld", "MixinItemStack", - "MixinMinecraftClient", "MixinOtherClientPlayerEntity", "MixinPlayerEntityRenderer" ], diff --git a/patchwork-god-classes/src/main/java/net/minecraftforge/common/ForgeHooks.java b/patchwork-god-classes/src/main/java/net/minecraftforge/common/ForgeHooks.java index 2a504d5f..14d37442 100644 --- a/patchwork-god-classes/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/patchwork-god-classes/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -50,7 +50,6 @@ import net.minecraft.world.World; import net.patchworkmc.impl.event.entity.EntityEvents; -import net.patchworkmc.impl.event.entity.PlayerEvents; import net.patchworkmc.impl.extensions.block.BlockHarvestManager; import net.patchworkmc.impl.loot.LootHooks; @@ -66,10 +65,6 @@ public static int canEntitySpawn(MobEntity entity, IWorld world, double x, doubl // TODO: onInteractEntityAt - public static void onEmptyLeftClick(PlayerEntity player) { - PlayerEvents.fireLeftClickEmptyEvent(player); - } - public static ActionResult onInteractEntity(PlayerEntity player, Entity entity, Hand hand) { return EntityEvents.onInteractEntity(player, entity, hand); }