mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 11:59:11 +00:00
重构特殊配方
This commit is contained in:
@@ -60,6 +60,7 @@ public final class ItemKeys {
|
||||
public static final Key GREEN_DYE = Key.of("minecraft:green_dye");
|
||||
public static final Key RED_DYE = Key.of("minecraft:red_dye");
|
||||
public static final Key BLACK_DYE = Key.of("minecraft:black_dye");
|
||||
public static final Key FIREWORK_STAR = Key.of("minecraft:firework_star");
|
||||
|
||||
public static final Key[] AXES = new Key[] {
|
||||
WOODEN_AXE, STONE_AXE, IRON_AXE, GOLDEN_AXE, DIAMOND_AXE, NETHERITE_AXE
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||
public class ItemSettings {
|
||||
int fuelTime;
|
||||
Set<Key> tags = Set.of();
|
||||
boolean canRepair = true;
|
||||
Tristate canRepair = Tristate.UNDEFINED;
|
||||
List<AnvilRepairItem> anvilRepairItems = List.of();
|
||||
boolean renameable = true;
|
||||
boolean canPlaceRelatedVanillaBlock = false;
|
||||
@@ -43,6 +43,8 @@ public class ItemSettings {
|
||||
ItemEquipment equipment;
|
||||
@Nullable
|
||||
Color dyeColor;
|
||||
@Nullable
|
||||
Color fireworkColor;
|
||||
|
||||
private ItemSettings() {}
|
||||
|
||||
@@ -102,6 +104,7 @@ public class ItemSettings {
|
||||
newSettings.compostProbability = settings.compostProbability;
|
||||
newSettings.respectRepairableComponent = settings.respectRepairableComponent;
|
||||
newSettings.dyeColor = settings.dyeColor;
|
||||
newSettings.fireworkColor = settings.fireworkColor;
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@@ -125,7 +128,7 @@ public class ItemSettings {
|
||||
return canPlaceRelatedVanillaBlock;
|
||||
}
|
||||
|
||||
public boolean canRepair() {
|
||||
public Tristate canRepair() {
|
||||
return canRepair;
|
||||
}
|
||||
|
||||
@@ -184,7 +187,12 @@ public class ItemSettings {
|
||||
|
||||
@Nullable
|
||||
public Color dyeColor() {
|
||||
return dyeColor;
|
||||
return this.dyeColor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Color fireworkColor() {
|
||||
return this.fireworkColor;
|
||||
}
|
||||
|
||||
public List<DamageSource> invulnerable() {
|
||||
@@ -195,6 +203,11 @@ public class ItemSettings {
|
||||
return compostProbability;
|
||||
}
|
||||
|
||||
public ItemSettings fireworkColor(Color color) {
|
||||
this.fireworkColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings dyeColor(Color color) {
|
||||
this.dyeColor = color;
|
||||
return this;
|
||||
@@ -220,7 +233,7 @@ public class ItemSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings canRepair(boolean canRepair) {
|
||||
public ItemSettings canRepair(Tristate canRepair) {
|
||||
this.canRepair = canRepair;
|
||||
return this;
|
||||
}
|
||||
@@ -303,7 +316,7 @@ public class ItemSettings {
|
||||
static {
|
||||
registerFactory("repairable", (value -> {
|
||||
boolean bool = ResourceConfigUtils.getAsBoolean(value, "repairable");
|
||||
return settings -> settings.canRepair(bool);
|
||||
return settings -> settings.canRepair(bool ? Tristate.TRUE : Tristate.FALSE);
|
||||
}));
|
||||
registerFactory("enchantable", (value -> {
|
||||
boolean bool = ResourceConfigUtils.getAsBoolean(value, "enchantable");
|
||||
@@ -416,6 +429,13 @@ public class ItemSettings {
|
||||
return settings -> settings.dyeColor(Color.fromVector3f(MiscUtils.getAsVector3f(value, "dye-color")));
|
||||
}
|
||||
}));
|
||||
registerFactory("firework-color", (value -> {
|
||||
if (value instanceof Integer i) {
|
||||
return settings -> settings.fireworkColor(Color.fromDecimal(i));
|
||||
} else {
|
||||
return settings -> settings.fireworkColor(Color.fromVector3f(MiscUtils.getAsVector3f(value, "firework-color")));
|
||||
}
|
||||
}));
|
||||
registerFactory("food", (value -> {
|
||||
Map<String, Object> args = MiscUtils.castToMap(value, false);
|
||||
FoodData data = new FoodData(
|
||||
|
||||
@@ -8,6 +8,12 @@ import java.util.Map;
|
||||
|
||||
public record FireworkExplosion(Shape shape, IntList colors, IntList fadeColors, boolean hasTrail, boolean hasTwinkle) {
|
||||
|
||||
public static final FireworkExplosion DEFAULT = new FireworkExplosion(Shape.SMALL_BALL, IntList.of(), IntList.of(), false, false);
|
||||
|
||||
public FireworkExplosion withFadeColors(@NotNull final IntList fadeColors) {
|
||||
return new FireworkExplosion(this.shape, this.colors, fadeColors, this.hasTrail, this.hasTwinkle);
|
||||
}
|
||||
|
||||
public enum Shape {
|
||||
SMALL_BALL(0, "small_ball"),
|
||||
LARGE_BALL(1, "large_ball"),
|
||||
|
||||
Reference in New Issue
Block a user