mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
Merge remote-tracking branch 'refs/remotes/upstream/dev' into update-1.21.6
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) {
|
||||
|
||||
@@ -88,9 +88,16 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
||||
if (byId.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.furniture.duplicate");
|
||||
}
|
||||
|
||||
EnumMap<AnchorType, CustomFurniture.Placement> placements = new EnumMap<>(AnchorType.class);
|
||||
Map<String, Object> placementMap = MiscUtils.castToMap(ResourceConfigUtils.requireNonNullOrThrow(section.get("placement"), "warning.config.furniture.missing_placement"), false);
|
||||
Object placementObj = section.get("placement");
|
||||
if (placementObj == null) {
|
||||
// 防呆
|
||||
if (section.containsKey("material")) {
|
||||
plugin.itemManager().parser().parseSection(pack, path, id, section);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Map<String, Object> placementMap = MiscUtils.castToMap(ResourceConfigUtils.requireNonNullOrThrow(placementObj, "warning.config.furniture.missing_placement"), false);
|
||||
if (placementMap.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.furniture.missing_placement");
|
||||
}
|
||||
|
||||
@@ -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