forked from GregTechCEu/GregTech-Modern
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor DataStick item and associated interaction interface (GregTec…
- Loading branch information
1 parent
029f610
commit c0b5045
Showing
10 changed files
with
79 additions
and
74 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
33 changes: 5 additions & 28 deletions
33
src/main/java/com/gregtechceu/gtceu/api/machine/feature/IDataStickInteractable.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,39 +1,16 @@ | ||
package com.gregtechceu.gtceu.api.machine.feature; | ||
|
||
import com.gregtechceu.gtceu.common.data.GTItems; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
|
||
public interface IDataStickInteractable extends IInteractedMachine { | ||
public interface IDataStickInteractable { | ||
|
||
@Override | ||
default InteractionResult onUse(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, | ||
BlockHitResult hit) { | ||
var item = player.getItemInHand(hand); | ||
if (item.is(GTItems.TOOL_DATA_STICK.asItem())) { | ||
return onDataStickRightClick(player, item); | ||
} | ||
return IInteractedMachine.super.onUse(state, world, pos, player, hand, hit); | ||
default InteractionResult onDataStickUse(Player player, ItemStack dataStick) { | ||
return InteractionResult.PASS; | ||
} | ||
|
||
@Override | ||
default boolean onLeftClick(Player player, Level world, InteractionHand hand, BlockPos pos, Direction direction) { | ||
var item = player.getItemInHand(hand); | ||
if (item.is(GTItems.TOOL_DATA_STICK.asItem())) { | ||
return onDataStickLeftClick(player, item); | ||
} | ||
return IInteractedMachine.super.onLeftClick(player, world, hand, pos, direction); | ||
default InteractionResult onDataStickShiftUse(Player player, ItemStack dataStick) { | ||
return InteractionResult.PASS; | ||
} | ||
|
||
InteractionResult onDataStickRightClick(Player player, ItemStack dataStick); | ||
|
||
boolean onDataStickLeftClick(Player player, ItemStack dataStick); | ||
} |
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
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