mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
添加堆肥物品
This commit is contained in:
@@ -64,7 +64,7 @@ public abstract class AbstractCustomFurniture implements CustomFurniture {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnchorType getAnyPlacement() {
|
||||
public AnchorType getAnyAnchorType() {
|
||||
return this.anyType;
|
||||
}
|
||||
|
||||
@@ -77,4 +77,13 @@ public abstract class AbstractCustomFurniture implements CustomFurniture {
|
||||
public Placement getPlacement(AnchorType anchorType) {
|
||||
return this.placements.get(anchorType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Placement getValidPlacement(AnchorType anchorType) {
|
||||
Placement placement = this.placements.get(anchorType);
|
||||
if (placement == null) {
|
||||
return this.placements.get(getAnyAnchorType());
|
||||
}
|
||||
return placement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,11 +86,14 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (byId.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.furniture.duplicate", path, 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);
|
||||
if (placementMap.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.furniture.missing_placement");
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : placementMap.entrySet()) {
|
||||
// anchor type
|
||||
AnchorType anchorType = AnchorType.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
|
||||
@@ -133,6 +136,7 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
||||
Map<String, Object> ruleSection = MiscUtils.castToMap(placementArguments.get("rules"), true);
|
||||
if (ruleSection != null) {
|
||||
placements.put(anchorType, new CustomFurniture.Placement(
|
||||
anchorType,
|
||||
elements.toArray(new FurnitureElement[0]),
|
||||
hitboxes.toArray(new HitBox[0]),
|
||||
ResourceConfigUtils.getOrDefault(ruleSection.get("rotation"), o -> RotationRule.valueOf(o.toString().toUpperCase(Locale.ENGLISH)), RotationRule.ANY),
|
||||
@@ -142,6 +146,7 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
||||
));
|
||||
} else {
|
||||
placements.put(anchorType, new CustomFurniture.Placement(
|
||||
anchorType,
|
||||
elements.toArray(new FurnitureElement[0]),
|
||||
hitboxes.toArray(new HitBox[0]),
|
||||
RotationRule.ANY,
|
||||
|
||||
@@ -26,12 +26,14 @@ public interface CustomFurniture {
|
||||
@Nullable
|
||||
LootTable<?> lootTable();
|
||||
|
||||
AnchorType getAnyPlacement();
|
||||
AnchorType getAnyAnchorType();
|
||||
|
||||
boolean isAllowedPlacement(AnchorType anchorType);
|
||||
|
||||
Placement getPlacement(AnchorType anchorType);
|
||||
|
||||
Placement getValidPlacement(AnchorType anchorType);
|
||||
|
||||
interface Builder {
|
||||
|
||||
Builder id(Key id);
|
||||
@@ -47,7 +49,8 @@ public interface CustomFurniture {
|
||||
CustomFurniture build();
|
||||
}
|
||||
|
||||
record Placement(FurnitureElement[] elements,
|
||||
record Placement(AnchorType anchorType,
|
||||
FurnitureElement[] elements,
|
||||
HitBox[] hitBoxes,
|
||||
RotationRule rotationRule,
|
||||
AlignmentRule alignmentRule,
|
||||
|
||||
@@ -439,4 +439,9 @@ public class AbstractItem<W extends ItemWrapper<I>, I> implements Item<I> {
|
||||
public byte[] toByteArray() {
|
||||
return this.factory.toByteArray(this.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shrink(int amount) {
|
||||
this.item.shrink(amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +181,8 @@ public interface Item<I> {
|
||||
|
||||
Item<I> transmuteCopy(Key another, int count);
|
||||
|
||||
void shrink(int amount);
|
||||
|
||||
default Item<I> transmuteCopy(Key another) {
|
||||
return transmuteCopy(another, this.count());
|
||||
}
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface ItemWrapper<I> {
|
||||
void count(int amount);
|
||||
|
||||
ItemWrapper<I> copyWithCount(int count);
|
||||
|
||||
void shrink(int amount);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public interface World {
|
||||
playBlockSound(location, data.id(), data.volume(), data.pitch());
|
||||
}
|
||||
|
||||
void levelEvent(int id, BlockPos pos, int data);
|
||||
|
||||
void spawnParticle(Position location, Key particle, int count, double xOffset, double yOffset, double zOffset, double speed, @Nullable ParticleData extraData, @NotNull Context context);
|
||||
|
||||
long time();
|
||||
|
||||
Reference in New Issue
Block a user