mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 12:56:28 +00:00
strippable
This commit is contained in:
@@ -23,6 +23,9 @@ blocks:
|
||||
from: 0
|
||||
to: 27
|
||||
default:palm_log:
|
||||
behavior:
|
||||
type: strippable_block
|
||||
stripped: default:stripped_palm_log
|
||||
loot:
|
||||
template: loot_table:normal
|
||||
arguments:
|
||||
@@ -73,6 +76,9 @@ blocks:
|
||||
from: 3
|
||||
to: 5
|
||||
default:palm_wood:
|
||||
behavior:
|
||||
type: strippable_block
|
||||
stripped: default:stripped_palm_wood
|
||||
loot:
|
||||
template: loot_table:normal
|
||||
arguments:
|
||||
|
||||
@@ -9,11 +9,13 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
|
||||
public static final Key BUSH_BLOCK = Key.from("craftengine:bush_block");
|
||||
public static final Key FALLING_BLOCK = Key.from("craftengine:falling_block");
|
||||
public static final Key LEAVES_BLOCK = Key.from("craftengine:leaves_block");
|
||||
public static final Key STRIPPABLE_BLOCK = Key.from("craftengine:strippable_block");
|
||||
|
||||
public static void init() {
|
||||
register(EMPTY, (block, args) -> EmptyBlockBehavior.INSTANCE);
|
||||
register(FALLING_BLOCK, FallingBlockBehavior.FACTORY);
|
||||
register(BUSH_BLOCK, BushBlockBehavior.FACTORY);
|
||||
register(LEAVES_BLOCK, LeavesBlockBehavior.FACTORY);
|
||||
register(STRIPPABLE_BLOCK, StrippableBlockBehavior.FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.momirealms.craftengine.bukkit.block.behavior;
|
||||
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.shared.block.BlockBehavior;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class StrippableBlockBehavior extends BlockBehavior {
|
||||
public static final Factory FACTORY = new Factory();
|
||||
private final Key stripped;
|
||||
|
||||
public StrippableBlockBehavior(Key stripped) {
|
||||
this.stripped = stripped;
|
||||
}
|
||||
|
||||
public Key stripped() {
|
||||
return stripped;
|
||||
}
|
||||
|
||||
public static class Factory implements BlockBehaviorFactory {
|
||||
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
String stripped = (String) arguments.get("stripped");
|
||||
if (stripped == null) {
|
||||
throw new IllegalArgumentException("stripped is null");
|
||||
}
|
||||
return new StrippableBlockBehavior(Key.of(stripped));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user