mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
implement PaletteBlockShortcutAddon
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.dfsek.terra.addons.palette.shortcut.block;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
|
||||
public class PaletteBlockShortcutAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.registerShortcut(Palette.class, "BLOCK",
|
||||
(configLoader, input) -> new SingletonPalette(configLoader.loadType(BlockState.class, input))))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.dfsek.terra.addons.palette.shortcut.block;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
|
||||
public class SingletonPalette implements Palette {
|
||||
private final BlockState blockState;
|
||||
|
||||
public SingletonPalette(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState get(int layer, double x, double y, double z, long seed) {
|
||||
return blockState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: palette-block-shortcut
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.palette.shortcut.block.PaletteBlockShortcutAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: MIT License
|
||||
Reference in New Issue
Block a user