-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More API improvements * Update RouterCompiledEvent.java * Publish sources * Set group and project name for includebuild * Return success when removing
- Loading branch information
1 parent
1f72de9
commit 49aa070
Showing
6 changed files
with
170 additions
and
25 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
61 changes: 61 additions & 0 deletions
61
src/main/java/me/desht/modularrouters/api/event/AddModuleTargetEvent.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,61 @@ | ||
package me.desht.modularrouters.api.event; | ||
|
||
import me.desht.modularrouters.item.module.TargetedModule; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
import net.neoforged.bus.api.Event; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Event fired when a player attempts to add a new target to a module. | ||
* <p> | ||
* This event can be used to allow a module to target blocks it otherwise couldn't in conjunction with {@link ExecuteModuleEvent}. | ||
*/ | ||
public final class AddModuleTargetEvent extends Event { | ||
private final TargetedModule item; | ||
private final UseOnContext context; | ||
private boolean valid; | ||
|
||
@ApiStatus.Internal | ||
public AddModuleTargetEvent(TargetedModule item, UseOnContext context, boolean valid) { | ||
this.item = item; | ||
this.context = context; | ||
this.valid = valid; | ||
} | ||
|
||
/** | ||
* {@return the module type} | ||
*/ | ||
public TargetedModule getModuleType() { | ||
return item; | ||
} | ||
|
||
/** | ||
* {@return the module stack} | ||
*/ | ||
public ItemStack getModule() { | ||
return context.getItemInHand(); | ||
} | ||
|
||
/** | ||
* {@return the context of the interaction} | ||
*/ | ||
public UseOnContext getContext() { | ||
return context; | ||
} | ||
|
||
/** | ||
* {@return whether the targeted block is valid and may be selected} | ||
*/ | ||
public boolean isValid() { | ||
return valid; | ||
} | ||
|
||
/** | ||
* Making the target {@code valid} allows the player to select the block and the router to process it. | ||
* @see ExecuteModuleEvent | ||
*/ | ||
public void setValid(boolean valid) { | ||
this.valid = valid; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/me/desht/modularrouters/api/event/RouterCompiledEvent.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,48 @@ | ||
package me.desht.modularrouters.api.event; | ||
|
||
import me.desht.modularrouters.block.tile.ModularRouterBlockEntity; | ||
import net.neoforged.bus.api.Event; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Called when a router is (re)compiled. Can be used to update state that's | ||
* independent of an upgrade or module and must be refreshed even when the upgrade isn't present. | ||
* | ||
* @see Upgrades | ||
* @see Modules | ||
*/ | ||
public abstract sealed class RouterCompiledEvent extends Event { | ||
private final ModularRouterBlockEntity router; | ||
|
||
@ApiStatus.Internal | ||
public RouterCompiledEvent(ModularRouterBlockEntity router) { | ||
this.router = router; | ||
} | ||
|
||
/** | ||
* {@return the router that is being compiled} | ||
*/ | ||
public ModularRouterBlockEntity getRouter() { | ||
return router; | ||
} | ||
|
||
/** | ||
* Called when a router (re)compiles its upgrades. This <strong>will</strong> be called on | ||
* the client-side too when the GUI is opened. | ||
*/ | ||
public final static class Upgrades extends RouterCompiledEvent { | ||
@ApiStatus.Internal | ||
public Upgrades(ModularRouterBlockEntity router) { | ||
super(router); | ||
} | ||
} | ||
|
||
/** | ||
* Called when a router (re)compiles its modules. | ||
*/ | ||
public final static class Modules extends RouterCompiledEvent { | ||
public Modules(ModularRouterBlockEntity router) { | ||
super(router); | ||
} | ||
} | ||
} |
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