mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
准备工作
This commit is contained in:
@@ -49,6 +49,10 @@ public abstract class BlockBehavior {
|
||||
return (boolean) superMethod.call();
|
||||
}
|
||||
|
||||
public boolean isPathFindable(Object thisBlock, Object[] args, Callable<Object> superMethod) throws Exception {
|
||||
return (boolean) superMethod.call();
|
||||
}
|
||||
|
||||
public void onBrokenAfterFall(Object thisBlock, Object[] args) throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Properties {
|
||||
public static final Key AXIS = Key.of("craftengine:axis");
|
||||
public static final Key HORIZONTAL_DIRECTION = Key.of("craftengine:4-direction");
|
||||
public static final Key DIRECTION = Key.of("craftengine:6-direction");
|
||||
public static final Key HALF = Key.of("craftengine:half");
|
||||
|
||||
static {
|
||||
register(BOOLEAN, BooleanProperty.FACTORY);
|
||||
@@ -24,6 +25,7 @@ public class Properties {
|
||||
register(AXIS, new EnumProperty.Factory<>(Direction.Axis.class));
|
||||
register(DIRECTION, new EnumProperty.Factory<>(Direction.class));
|
||||
register(HORIZONTAL_DIRECTION, new EnumProperty.Factory<>(HorizontalDirection.class));
|
||||
register(HALF, new EnumProperty.Factory<>(Half.class));
|
||||
}
|
||||
|
||||
public static void register(Key key, PropertyFactory factory) {
|
||||
|
||||
@@ -9,11 +9,13 @@ import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DynamicLoreModifier<I> implements ItemDataModifier<I> {
|
||||
public static final String CONTEXT_TAG_KEY = "craftengine:display_context";
|
||||
private final Map<String, List<String>> displayContexts;
|
||||
private final String defaultContext;
|
||||
|
||||
@@ -22,6 +24,10 @@ public class DynamicLoreModifier<I> implements ItemDataModifier<I> {
|
||||
this.displayContexts = displayContexts;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> displayContexts() {
|
||||
return Collections.unmodifiableMap(this.displayContexts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "dynamic-lore";
|
||||
@@ -29,7 +35,7 @@ public class DynamicLoreModifier<I> implements ItemDataModifier<I> {
|
||||
|
||||
@Override
|
||||
public Item<I> apply(Item<I> item, ItemBuildContext context) {
|
||||
String displayContext = Optional.ofNullable(item.getJavaTag("craftengine:display_context")).orElse(this.defaultContext).toString();
|
||||
String displayContext = Optional.ofNullable(item.getJavaTag(CONTEXT_TAG_KEY)).orElse(this.defaultContext).toString();
|
||||
List<String> lore = this.displayContexts.get(displayContext);
|
||||
if (lore == null) {
|
||||
lore = this.displayContexts.get(this.defaultContext);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.momirealms.craftengine.core.util;
|
||||
|
||||
public enum Half {
|
||||
TOP, BOTTOM
|
||||
}
|
||||
Reference in New Issue
Block a user