mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-20 07:29:17 +00:00
添加on_shelf支持
This commit is contained in:
@@ -133,6 +133,7 @@ items:
|
|||||||
- gui
|
- gui
|
||||||
- ground
|
- ground
|
||||||
- fixed
|
- fixed
|
||||||
|
- on_shelf
|
||||||
model:
|
model:
|
||||||
type: minecraft:model
|
type: minecraft:model
|
||||||
path: minecraft:item/custom/topaz_trident
|
path: minecraft:item/custom/topaz_trident
|
||||||
|
|||||||
@@ -2132,7 +2132,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
boolean handAnimationOnSwap = originalItemModel.handAnimationOnSwap();
|
boolean handAnimationOnSwap = originalItemModel.handAnimationOnSwap();
|
||||||
boolean oversizedInGui = originalItemModel.oversizedInGui();
|
boolean oversizedInGui = originalItemModel.oversizedInGui();
|
||||||
|
|
||||||
Map<Float, ItemModel> entries = new HashMap<>();
|
Map<Float, ItemModel> entries = new TreeMap<>();
|
||||||
for (Map.Entry<Integer, ModernItemModel> modelWithDataEntry : entry.getValue().entrySet()) {
|
for (Map.Entry<Integer, ModernItemModel> modelWithDataEntry : entry.getValue().entrySet()) {
|
||||||
ModernItemModel modernItemModel = modelWithDataEntry.getValue();
|
ModernItemModel modernItemModel = modelWithDataEntry.getValue();
|
||||||
entries.put(modelWithDataEntry.getKey().floatValue(), modernItemModel.itemModel());
|
entries.put(modelWithDataEntry.getKey().floatValue(), modernItemModel.itemModel());
|
||||||
@@ -2166,6 +2166,11 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Revision> revisions = newItemModel.revisions();
|
List<Revision> revisions = newItemModel.revisions();
|
||||||
|
if (vanillaItemModel.value().equals("trident")) {
|
||||||
|
System.out.println(revisions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!revisions.isEmpty()) {
|
if (!revisions.isEmpty()) {
|
||||||
for (Revision revision : revisions) {
|
for (Revision revision : revisions) {
|
||||||
if (revision.matches(Config.packMinVersion(), Config.packMaxVersion())) {
|
if (revision.matches(Config.packMinVersion(), Config.packMaxVersion())) {
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class RangeDispatchItemModel implements ItemModel {
|
public class RangeDispatchItemModel implements ItemModel {
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
@@ -119,7 +116,7 @@ public class RangeDispatchItemModel implements ItemModel {
|
|||||||
if (entriesObj instanceof List<?> list) {
|
if (entriesObj instanceof List<?> list) {
|
||||||
List<Map<String, Object>> entries = (List<Map<String, Object>>) list;
|
List<Map<String, Object>> entries = (List<Map<String, Object>>) list;
|
||||||
if (!entries.isEmpty()) {
|
if (!entries.isEmpty()) {
|
||||||
Map<Float, ItemModel> entryMap = new HashMap<>();
|
Map<Float, ItemModel> entryMap = new TreeMap<>();
|
||||||
for (Map<String, Object> entry : entries) {
|
for (Map<String, Object> entry : entries) {
|
||||||
float threshold = ResourceConfigUtils.getAsFloat(entry.getOrDefault("threshold", 1), "threshold");
|
float threshold = ResourceConfigUtils.getAsFloat(entry.getOrDefault("threshold", 1), "threshold");
|
||||||
Object model = entry.getOrDefault("model", fallback);
|
Object model = entry.getOrDefault("model", fallback);
|
||||||
@@ -151,7 +148,7 @@ public class RangeDispatchItemModel implements ItemModel {
|
|||||||
if (entriesObj == null) {
|
if (entriesObj == null) {
|
||||||
throw new IllegalArgumentException("entries is expected to be a JsonArray");
|
throw new IllegalArgumentException("entries is expected to be a JsonArray");
|
||||||
}
|
}
|
||||||
Map<Float, ItemModel> entries = new HashMap<>();
|
Map<Float, ItemModel> entries = new TreeMap<>();
|
||||||
for (JsonElement entry : entriesObj) {
|
for (JsonElement entry : entriesObj) {
|
||||||
if (entry instanceof JsonObject entryObj) {
|
if (entry instanceof JsonObject entryObj) {
|
||||||
float threshold = entryObj.getAsJsonPrimitive("threshold").getAsFloat();
|
float threshold = entryObj.getAsJsonPrimitive("threshold").getAsFloat();
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class SelectItemModel implements ItemModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Revision> revisions() {
|
public List<Revision> revisions() {
|
||||||
List<Revision> versions = new ArrayList<>();
|
List<Revision> versions = new ArrayList<>(4);
|
||||||
for (Map.Entry<Either<JsonElement, List<JsonElement>>, ItemModel> entry : this.whenMap.entrySet()) {
|
for (Map.Entry<Either<JsonElement, List<JsonElement>>, ItemModel> entry : this.whenMap.entrySet()) {
|
||||||
Either<JsonElement, List<JsonElement>> when = entry.getKey();
|
Either<JsonElement, List<JsonElement>> when = entry.getKey();
|
||||||
if (when.primary().isPresent()) {
|
if (when.primary().isPresent()) {
|
||||||
@@ -107,13 +107,11 @@ public class SelectItemModel implements ItemModel {
|
|||||||
versions.addAll(this.property.revisions(e));
|
versions.addAll(this.property.revisions(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
versions.addAll(entry.getValue().revisions());
|
||||||
}
|
}
|
||||||
if (this.fallBack != null) {
|
if (this.fallBack != null) {
|
||||||
versions.addAll(this.fallBack.revisions());
|
versions.addAll(this.fallBack.revisions());
|
||||||
}
|
}
|
||||||
for (ItemModel itemModel : this.whenMap.values()) {
|
|
||||||
versions.addAll(itemModel.revisions());
|
|
||||||
}
|
|
||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import net.momirealms.craftengine.core.pack.revision.Revision;
|
import net.momirealms.craftengine.core.pack.revision.Revision;
|
||||||
|
import net.momirealms.craftengine.core.pack.revision.Revisions;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.MinecraftVersion;
|
import net.momirealms.craftengine.core.util.MinecraftVersion;
|
||||||
import net.momirealms.craftengine.core.util.MinecraftVersions;
|
import net.momirealms.craftengine.core.util.MinecraftVersions;
|
||||||
@@ -14,8 +15,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class DisplayContextSelectProperty implements SelectProperty {
|
public class DisplayContextSelectProperty implements SelectProperty {
|
||||||
public static final DisplayContextSelectProperty INSTANCE = new DisplayContextSelectProperty();
|
public static final DisplayContextSelectProperty INSTANCE = new DisplayContextSelectProperty();
|
||||||
public static final SimpleSelectProperty.Factory FACTORY = new SimpleSelectProperty.Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
public static final SimpleSelectProperty.Reader READER = new SimpleSelectProperty.Reader();
|
public static final Reader READER = new Reader();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Key type() {
|
public Key type() {
|
||||||
@@ -29,7 +30,10 @@ public class DisplayContextSelectProperty implements SelectProperty {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Revision> revisions(JsonElement element) {
|
public List<Revision> revisions(JsonElement element) {
|
||||||
return SelectProperty.super.revisions(element);
|
if (element instanceof JsonPrimitive primitive && primitive.isString() && primitive.getAsString().equals("on_shelf")) {
|
||||||
|
return List.of(Revisions.SINCE_1_21_9);
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ public interface Revision {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.minVersion.hashCode();
|
return this.minVersion.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Since{" + "minVersion=" + minVersion + '}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FromTo implements Revision {
|
class FromTo implements Revision {
|
||||||
@@ -135,5 +140,13 @@ public interface Revision {
|
|||||||
result = 31 * result + Objects.hashCode(maxVersion);
|
result = 31 * result + Objects.hashCode(maxVersion);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FromTo{" +
|
||||||
|
"minVersion=" + minVersion +
|
||||||
|
", maxVersion=" + maxVersion +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ public final class Revisions {
|
|||||||
|
|
||||||
public static final Revision SINCE_1_21_6 = Revision.since(MinecraftVersions.V1_21_6);
|
public static final Revision SINCE_1_21_6 = Revision.since(MinecraftVersions.V1_21_6);
|
||||||
public static final Revision SINCE_1_21_2 = Revision.since(MinecraftVersions.V1_21_2);
|
public static final Revision SINCE_1_21_2 = Revision.since(MinecraftVersions.V1_21_2);
|
||||||
|
public static final Revision SINCE_1_21_9 = Revision.since(MinecraftVersions.V1_21_9);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=0.0.64.18
|
project_version=0.0.64.19
|
||||||
config_version=49
|
config_version=49
|
||||||
lang_version=35
|
lang_version=35
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|||||||
Reference in New Issue
Block a user