-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04a39d3
commit 0c71ea8
Showing
15 changed files
with
399 additions
and
131 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
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
26 changes: 26 additions & 0 deletions
26
common/src/main/java/dev/wuffs/squatgrow/actions/Action.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,26 @@ | ||
package dev.wuffs.squatgrow.actions; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
public interface Action { | ||
BooleanSupplier TRUE = () -> true; | ||
BooleanSupplier FALSE = () -> false; | ||
|
||
/** | ||
* Only called once upon initial creation of the available actions list. | ||
* This is loaded after game setup and thus is safe to use mod loaded checking. | ||
* <p> | ||
* Running modded code here is not recommended unless you register your action only | ||
* when your mod is present. | ||
*/ | ||
BooleanSupplier isAvailable(); | ||
|
||
/** | ||
* Called upon the action being available and the block is about to be actioned upon. | ||
* | ||
* @return if we should continue to apply the action. | ||
*/ | ||
boolean canApply(ActionContext context); | ||
|
||
boolean execute(ActionContext context); | ||
} |
16 changes: 16 additions & 0 deletions
16
common/src/main/java/dev/wuffs/squatgrow/actions/ActionContext.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,16 @@ | ||
package dev.wuffs.squatgrow.actions; | ||
|
||
import net.minecraft.core.BlockPos; | ||
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; | ||
|
||
public record ActionContext( | ||
Level level, | ||
BlockPos pos, | ||
BlockState state, | ||
ItemStack mainHand, | ||
ItemStack offhand, | ||
Player player | ||
) {} |
Oops, something went wrong.