9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-26 10:29:20 +00:00

添加api方法

This commit is contained in:
XiaoMoMi
2025-09-11 01:54:41 +08:00
parent dcc45c7327
commit e1fdc17fd2
11 changed files with 79 additions and 6 deletions

View File

@@ -86,7 +86,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
}
@Override
public Map<Key, CustomBlock> blocks() {
public Map<Key, CustomBlock> loadedBlocks() {
return Collections.unmodifiableMap(this.byId);
}

View File

@@ -24,7 +24,12 @@ public interface BlockManager extends Manageable, ModelGenerator {
Map<Key, JsonElement> modBlockStates();
Map<Key, CustomBlock> blocks();
Map<Key, CustomBlock> loadedBlocks();
@Deprecated(forRemoval = true)
default Map<Key, CustomBlock> blocks() {
return loadedBlocks();
}
Optional<CustomBlock> blockById(Key key);

View File

@@ -58,6 +58,11 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
return Optional.ofNullable(this.byId.get(id));
}
@Override
public Map<Key, CustomFurniture> loadedFurniture() {
return Collections.unmodifiableMap(this.byId);
}
@Override
public void unload() {
this.byId.clear();

View File

@@ -9,6 +9,7 @@ import org.incendo.cloud.suggestion.Suggestion;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
public interface FurnitureManager extends Manageable {
@@ -30,6 +31,8 @@ public interface FurnitureManager extends Manageable {
Optional<CustomFurniture> furnitureById(Key id);
Map<Key, CustomFurniture> loadedFurniture();
boolean isFurnitureRealEntity(int entityId);
@Nullable

View File

@@ -229,8 +229,8 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
}
@Override
public Collection<Key> items() {
return Collections.unmodifiableCollection(this.customItemsById.keySet());
public Map<Key, CustomItem<I>> loadedItems() {
return Collections.unmodifiableMap(this.customItemsById);
}
@Override

View File

@@ -16,6 +16,10 @@ import java.util.Optional;
public interface CustomItem<I> extends BuildableItem<I> {
/**
* Since CraftEngine allows users to add certain functionalities to vanilla items, this custom item might actually be a vanilla item.
* This will be refactored before the 1.0 release, but no changes will be made for now to ensure compatibility.
*/
boolean isVanillaItem();
Key id();

View File

@@ -54,7 +54,12 @@ public interface ItemManager<T> extends Manageable, ModelGenerator {
Item<T> fromByteArray(byte[] bytes);
Collection<Key> items();
Map<Key, CustomItem<T>> loadedItems();
@Deprecated(forRemoval = true)
default Collection<Key> items() {
return loadedItems().keySet();
}
ExternalItemSource<T> getExternalItemSource(String name);

View File

@@ -1,6 +1,5 @@
package net.momirealms.craftengine.core.world;
import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue;
import ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.momirealms.craftengine.core.block.ImmutableBlockState;