-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
BlockEvents.picked
event, more repackages, added WIP web API …
…registry
- Loading branch information
1 parent
e69f722
commit 95200c3
Showing
184 changed files
with
571 additions
and
842 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
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
9 changes: 0 additions & 9 deletions
9
src/main/java/dev/latvian/mods/kubejs/bindings/event/KGUIEvents.java
This file was deleted.
Oops, something went wrong.
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
66 changes: 66 additions & 0 deletions
66
src/main/java/dev/latvian/mods/kubejs/block/BlockPickedKubeEvent.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,66 @@ | ||
package dev.latvian.mods.kubejs.block; | ||
|
||
import dev.latvian.mods.kubejs.entity.KubeRayTraceResult; | ||
import dev.latvian.mods.kubejs.level.LevelBlock; | ||
import dev.latvian.mods.kubejs.player.KubePlayerEvent; | ||
import dev.latvian.mods.kubejs.plugin.builtin.event.BlockEvents; | ||
import dev.latvian.mods.kubejs.typings.Info; | ||
import dev.latvian.mods.rhino.util.HideFromJS; | ||
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.LevelReader; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.HitResult; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Info(value = """ | ||
Invoked when player middle-clicks on a block. | ||
""") | ||
public class BlockPickedKubeEvent implements KubePlayerEvent { | ||
public final Level level; | ||
public final LevelBlock block; | ||
public final Player player; | ||
private final HitResult hitResult; | ||
private KubeRayTraceResult target; | ||
|
||
public BlockPickedKubeEvent(Level level, BlockPos pos, BlockState state, Player player, HitResult hitResult) { | ||
this.level = level; | ||
this.block = level.kjs$getBlock(pos).cache(state); | ||
this.player = player; | ||
this.hitResult = hitResult; | ||
} | ||
|
||
@Override | ||
public Level getLevel() { | ||
return block.getLevel(); | ||
} | ||
|
||
@Override | ||
public Player getEntity() { | ||
return player; | ||
} | ||
|
||
public KubeRayTraceResult getTarget() { | ||
if (target == null) { | ||
target = new KubeRayTraceResult(player, hitResult); | ||
} | ||
|
||
return target; | ||
} | ||
|
||
@Nullable | ||
@HideFromJS | ||
public static ItemStack handle(BlockState state, HitResult target, LevelReader levelReader, BlockPos pos, Player player) { | ||
if (levelReader instanceof Level level) { | ||
var key = state.kjs$getKey(); | ||
|
||
if (BlockEvents.PICKED.hasListeners(key) && BlockEvents.PICKED.post(level, key, new BlockPickedKubeEvent(level, pos, state, player, target)).value() instanceof ItemStack stack) { | ||
return stack; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/dev/latvian/mods/kubejs/block/BlockTintFunction.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
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
25 changes: 0 additions & 25 deletions
25
src/main/java/dev/latvian/mods/kubejs/block/EntityBlockKJS.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/java/dev/latvian/mods/kubejs/block/KubeJSBlockEventHandler.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
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
6 changes: 3 additions & 3 deletions
6
...ds/kubejs/block/RandomTickCallbackJS.java → ...js/block/callback/RandomTickCallback.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
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
Oops, something went wrong.