mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
0.0.48
This commit is contained in:
@@ -51,7 +51,9 @@ public abstract class Player extends Entity implements NetWorkUser {
|
||||
|
||||
public abstract boolean isAdventureMode();
|
||||
|
||||
public abstract boolean canBreak(BlockPos pos);
|
||||
public abstract boolean canBreak(BlockPos pos, Object state);
|
||||
|
||||
public abstract boolean canPlace(BlockPos pos, Object state);
|
||||
|
||||
public abstract void sendActionBar(Component text);
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ public class ComponentModifier<I> implements ItemDataModifier<I> {
|
||||
this.arguments = pairs;
|
||||
}
|
||||
|
||||
public List<Pair<Key, Object>> arguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private Object parseValue(Object value) {
|
||||
if (value instanceof String string) {
|
||||
if (string.startsWith("(json) ")) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.momirealms.craftengine.core.item.modifier;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import net.momirealms.craftengine.core.item.ComponentKeys;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
@@ -7,9 +10,20 @@ import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class IdModifier<I> implements ItemDataModifier<I> {
|
||||
public static final String CRAFT_ENGINE_ID = "craftengine:id";
|
||||
private static final BiConsumer<Item<?>, String> ID_SETTER = VersionHelper.isVersionNewerThan1_20_5() ?
|
||||
((item, id) -> {
|
||||
JsonElement element = item.getJsonTypeComponent(ComponentKeys.CUSTOM_DATA);
|
||||
if (element instanceof JsonObject jo) {
|
||||
jo.add(CRAFT_ENGINE_ID, new JsonPrimitive(id));
|
||||
item.setComponent(ComponentKeys.CUSTOM_DATA, jo);
|
||||
} else {
|
||||
item.setComponent(ComponentKeys.CUSTOM_DATA, Map.of(CRAFT_ENGINE_ID, id));
|
||||
}
|
||||
}) : ((item, id) -> item.setTag(id, CRAFT_ENGINE_ID));
|
||||
private final Key argument;
|
||||
|
||||
public IdModifier(Key argument) {
|
||||
@@ -23,11 +37,7 @@ public class IdModifier<I> implements ItemDataModifier<I> {
|
||||
|
||||
@Override
|
||||
public void apply(Item<I> item, ItemBuildContext context) {
|
||||
if (VersionHelper.isVersionNewerThan1_20_5()) {
|
||||
item.setComponent(ComponentKeys.CUSTOM_DATA, Map.of(CRAFT_ENGINE_ID, argument.toString()));
|
||||
} else {
|
||||
item.setTag(argument.toString(), CRAFT_ENGINE_ID);
|
||||
}
|
||||
ID_SETTER.accept(item, argument.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,10 @@ public class TagsModifier<I> implements ItemDataModifier<I> {
|
||||
this.arguments = mapToMap(arguments);
|
||||
}
|
||||
|
||||
public Map<String, Object> arguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "tags";
|
||||
|
||||
@@ -112,6 +112,7 @@ public class Config {
|
||||
|
||||
protected boolean block$sound_system$enable;
|
||||
protected boolean block$simplify_adventure_break_check;
|
||||
protected boolean block$simplify_adventure_place_check;
|
||||
protected boolean block$predict_breaking;
|
||||
protected int block$predict_breaking_interval;
|
||||
protected double block$extended_interaction_range;
|
||||
@@ -286,6 +287,7 @@ public class Config {
|
||||
// block
|
||||
block$sound_system$enable = config.getBoolean("block.sound-system.enable", true);
|
||||
block$simplify_adventure_break_check = config.getBoolean("block.simplify-adventure-break-check", false);
|
||||
block$simplify_adventure_place_check = config.getBoolean("block.simplify-adventure-place-check", false);
|
||||
block$predict_breaking = config.getBoolean("block.predict-breaking.enable", true);
|
||||
block$predict_breaking_interval = Math.max(config.getInt("block.predict-breaking.interval", 10), 1);
|
||||
block$extended_interaction_range = Math.max(config.getDouble("block.predict-breaking.extended-interaction-range", 0.5), 0.0);
|
||||
@@ -398,10 +400,14 @@ public class Config {
|
||||
return instance.block$sound_system$enable;
|
||||
}
|
||||
|
||||
public static boolean simplifyAdventureCheck() {
|
||||
public static boolean simplifyAdventureBreakCheck() {
|
||||
return instance.block$simplify_adventure_break_check;
|
||||
}
|
||||
|
||||
public static boolean simplifyAdventurePlaceCheck() {
|
||||
return instance.block$simplify_adventure_place_check;
|
||||
}
|
||||
|
||||
public static boolean enableRecipeSystem() {
|
||||
return instance.recipe$enable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user