generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial implementation for BlockToolModificationEvent
- Loading branch information
Showing
5 changed files
with
157 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
portingLib.addModuleDependencies([ | ||
"lazy_registration", | ||
"tool_actions", | ||
"extensions", | ||
"gui_utils", | ||
"transfer", | ||
|
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
32 changes: 32 additions & 0 deletions
32
.../src/main/java/io/github/fabricators_of_create/porting_lib/mixin/common/AxeItemMixin.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,32 @@ | ||
package io.github.fabricators_of_create.porting_lib.mixin.common; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
|
||
import io.github.fabricators_of_create.porting_lib.tool.ToolActions; | ||
import io.github.fabricators_of_create.porting_lib.util.PortingHooks; | ||
import net.minecraft.world.item.AxeItem; | ||
|
||
import net.minecraft.world.item.context.UseOnContext; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import java.util.Optional; | ||
|
||
// This really should be in the tool actions modules fix this TODO: fix this on 1.21 | ||
@Mixin(AxeItem.class) | ||
public class AxeItemMixin { | ||
@WrapOperation(method = "useOn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/AxeItem;getStripped(Lnet/minecraft/world/level/block/state/BlockState;)Ljava/util/Optional;")) | ||
private Optional<BlockState> onStripToolAction(AxeItem instance, BlockState blockState, Operation<Optional<BlockState>> original, UseOnContext context) { | ||
BlockState eventState = PortingHooks.onToolUse(blockState, context, ToolActions.AXE_STRIP, false); | ||
return eventState != blockState ? Optional.ofNullable(eventState) : original.call(instance, blockState); | ||
} | ||
|
||
@WrapOperation(method = "useOn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/WeatheringCopper;getPrevious(Lnet/minecraft/world/level/block/state/BlockState;)Ljava/util/Optional;")) | ||
private Optional<BlockState> onScrapeToolAction(BlockState blockState, Operation<Optional<BlockState>> original, UseOnContext context) { | ||
BlockState eventState = PortingHooks.onToolUse(blockState, context, ToolActions.AXE_SCRAPE, false); | ||
return eventState != blockState ? Optional.ofNullable(eventState) : original.call(blockState); | ||
} | ||
} |
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