This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement PlayerInteractEvent Subclasses (#213)
* Implement EntityInteractSpecific * Implement RightClickEmpty * Implement LeftClickBlock * Implement LeftClickEmpty * Unstub interaction hooks in ForgeHooks * Clean up PlayerInteractEvent javadocs
- Loading branch information
1 parent
6638a9b
commit 1e97382
Showing
5 changed files
with
174 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...-events-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinMinecraftClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.HitResult; | ||
|
||
import net.patchworkmc.impl.event.entity.EntityEvents; | ||
|
||
@Mixin(MinecraftClient.class) | ||
public class MixinMinecraftClient { | ||
@Shadow | ||
public HitResult crosshairTarget; | ||
|
||
@Shadow | ||
public ClientPlayerEntity player; | ||
|
||
@Inject(method = "doItemUse", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isEmpty()Z", ordinal = 1), | ||
locals = LocalCapture.CAPTURE_FAILHARD) | ||
public void onItemUse(CallbackInfo ci, Hand[] hands, int handCount, int handIndex, Hand hand, ItemStack itemStack) { | ||
if (itemStack.isEmpty() && (this.crosshairTarget == null || this.crosshairTarget.getType() == HitResult.Type.MISS)) { | ||
EntityEvents.onEmptyRightClick(this.player, hand); | ||
} | ||
} | ||
|
||
@Inject(method = "doAttack", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;resetLastAttackedTicks()V", shift = At.Shift.AFTER)) | ||
public void onAttackMiss(CallbackInfo ci) { | ||
EntityEvents.onEmptyLeftClick(this.player); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.