-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Triggers: Remove HitBlock and BreakBlock
- Loading branch information
1 parent
1b7861b
commit c78fea9
Showing
5 changed files
with
56 additions
and
78 deletions.
There are no files selected for viewing
22 changes: 10 additions & 12 deletions
22
src/main/java/com/chattriggers/ctjs/mixins/ClientPlayerInteractionManagerMixin.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 |
---|---|---|
@@ -1,25 +1,23 @@ | ||
package com.chattriggers.ctjs.mixins; | ||
|
||
import com.chattriggers.ctjs.minecraft.wrappers.World; | ||
import com.chattriggers.ctjs.minecraft.wrappers.world.block.BlockFace; | ||
import com.chattriggers.ctjs.triggers.TriggerType; | ||
import com.chattriggers.ctjs.minecraft.CTEvents; | ||
import net.minecraft.client.network.ClientPlayerInteractionManager; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(ClientPlayerInteractionManager.class) | ||
public class ClientPlayerInteractionManagerMixin { | ||
@Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true) | ||
void injectAttackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) { | ||
TriggerType.HIT_BLOCK.triggerAll(World.getBlockAt(pos.getX(), pos.getY(), pos.getZ()).withFace(BlockFace.fromMC(direction)), cir); | ||
} | ||
|
||
@Inject(method = "breakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V")) | ||
void injectBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) { | ||
TriggerType.BREAK_BLOCK.triggerAll(World.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); | ||
@Inject( | ||
method = "breakBlock", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V" | ||
) | ||
) | ||
private void injectBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) { | ||
CTEvents.BREAK_BLOCK.invoker().breakBlock(pos); | ||
} | ||
} |
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
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