9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +00:00

恢复方块基础设置

This commit is contained in:
XiaoMoMi
2025-09-28 05:30:26 +08:00
parent bb997cf5ba
commit 7300f0e278
10 changed files with 113 additions and 22 deletions

View File

@@ -6,15 +6,9 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine; import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
import net.momirealms.craftengine.bukkit.plugin.injector.BlockGenerator; import net.momirealms.craftengine.bukkit.plugin.injector.BlockGenerator;
import net.momirealms.craftengine.bukkit.plugin.reflection.bukkit.CraftBukkitReflections; import net.momirealms.craftengine.bukkit.plugin.reflection.bukkit.CraftBukkitReflections;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections; import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.*;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBlocks;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBuiltInRegistries;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistries;
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer; import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
import net.momirealms.craftengine.bukkit.util.BlockStateUtils; import net.momirealms.craftengine.bukkit.util.*;
import net.momirealms.craftengine.bukkit.util.KeyUtils;
import net.momirealms.craftengine.bukkit.util.RegistryUtils;
import net.momirealms.craftengine.bukkit.util.TagUtils;
import net.momirealms.craftengine.core.block.*; import net.momirealms.craftengine.core.block.*;
import net.momirealms.craftengine.core.block.behavior.AbstractBlockBehavior; import net.momirealms.craftengine.core.block.behavior.AbstractBlockBehavior;
import net.momirealms.craftengine.core.block.behavior.BlockBehaviors; import net.momirealms.craftengine.core.block.behavior.BlockBehaviors;
@@ -59,6 +53,8 @@ public final class BukkitBlockManager extends AbstractBlockManager {
private final Set<Object> replacedBlockSounds = new HashSet<>(); private final Set<Object> replacedBlockSounds = new HashSet<>();
// 用于缓存string形式的方块状态到原版方块状态 // 用于缓存string形式的方块状态到原版方块状态
private final Map<String, Object> blockStateCache = new HashMap<>(1024); private final Map<String, Object> blockStateCache = new HashMap<>(1024);
// 用于临时存储可燃烧自定义方块的列表
private final List<DelegatingBlock> burnableBlocks = new ArrayList<>();
public BukkitBlockManager(BukkitCraftEngine plugin) { public BukkitBlockManager(BukkitCraftEngine plugin) {
super(plugin, RegistryUtils.currentBlockRegistrySize(), Config.serverSideBlocks()); super(plugin, RegistryUtils.currentBlockRegistrySize(), Config.serverSideBlocks());
@@ -95,6 +91,11 @@ public final class BukkitBlockManager extends AbstractBlockManager {
Arrays.fill(this.blockStateMappings, -1); Arrays.fill(this.blockStateMappings, -1);
this.previousClientBoundTags = this.clientBoundTags; this.previousClientBoundTags = this.clientBoundTags;
this.clientBoundTags = new HashMap<>(); this.clientBoundTags = new HashMap<>();
for (DelegatingBlock block : this.burnableBlocks) {
this.igniteOdds.remove(block);
this.burnOdds.remove(block);
}
this.burnableBlocks.clear();
if (EmptyBlock.STATE != null) if (EmptyBlock.STATE != null)
Arrays.fill(this.immutableBlockStates, EmptyBlock.STATE); Arrays.fill(this.immutableBlockStates, EmptyBlock.STATE);
for (DelegatingBlock block : this.customBlocks) { for (DelegatingBlock block : this.customBlocks) {
@@ -252,6 +253,82 @@ public final class BukkitBlockManager extends AbstractBlockManager {
} }
} }
@Override
protected void applyPlatformSettings(ImmutableBlockState state) {
DelegatingBlockState nmsState = (DelegatingBlockState) state.customBlockState().literalObject();
nmsState.setBlockState(state);
Object nmsVisualState = state.vanillaBlockState().literalObject();
BlockSettings settings = state.settings();
try {
CoreReflections.field$BlockStateBase$lightEmission.set(nmsState, settings.luminance());
CoreReflections.field$BlockStateBase$burnable.set(nmsState, settings.burnable());
CoreReflections.field$BlockStateBase$hardness.set(nmsState, settings.hardness());
CoreReflections.field$BlockStateBase$replaceable.set(nmsState, settings.replaceable());
Object mcMapColor = CoreReflections.method$MapColor$byId.invoke(null, settings.mapColor().id);
CoreReflections.field$BlockStateBase$mapColor.set(nmsState, mcMapColor);
CoreReflections.field$BlockStateBase$instrument.set(nmsState, CoreReflections.instance$NoteBlockInstrument$values[settings.instrument().ordinal()]);
CoreReflections.field$BlockStateBase$pushReaction.set(nmsState, CoreReflections.instance$PushReaction$values[settings.pushReaction().ordinal()]);
boolean canOcclude = settings.canOcclude() == Tristate.UNDEFINED ? BlockStateUtils.isOcclude(nmsVisualState) : settings.canOcclude().asBoolean();
CoreReflections.field$BlockStateBase$canOcclude.set(nmsState, canOcclude);
boolean useShapeForLightOcclusion = settings.useShapeForLightOcclusion() == Tristate.UNDEFINED ? CoreReflections.field$BlockStateBase$useShapeForLightOcclusion.getBoolean(nmsVisualState) : settings.useShapeForLightOcclusion().asBoolean();
CoreReflections.field$BlockStateBase$useShapeForLightOcclusion.set(nmsState, useShapeForLightOcclusion);
CoreReflections.field$BlockStateBase$isRedstoneConductor.set(nmsState, settings.isRedstoneConductor().asBoolean() ? ALWAYS_TRUE : ALWAYS_FALSE);
CoreReflections.field$BlockStateBase$isSuffocating.set(nmsState, settings.isSuffocating().asBoolean() ? ALWAYS_TRUE : ALWAYS_FALSE);
CoreReflections.field$BlockStateBase$isViewBlocking.set(nmsState, settings.isViewBlocking() == Tristate.UNDEFINED ? settings.isSuffocating().asBoolean() ? ALWAYS_TRUE : ALWAYS_FALSE : (settings.isViewBlocking().asBoolean() ? ALWAYS_TRUE : ALWAYS_FALSE));
DelegatingBlock nmsBlock = (DelegatingBlock) BlockStateUtils.getBlockOwner(nmsState);
ObjectHolder<BlockShape> shapeHolder = nmsBlock.shapeDelegate();
shapeHolder.bindValue(new BukkitBlockShape(nmsVisualState, Optional.ofNullable(state.settings().supportShapeBlockState()).map(it -> Objects.requireNonNull(createVanillaBlockState(it), "Illegal block state: " + it).literalObject()).orElse(null)));
ObjectHolder<BlockBehavior> behaviorHolder = nmsBlock.behaviorDelegate();
behaviorHolder.bindValue(state.behavior());
CoreReflections.field$BlockBehaviour$explosionResistance.set(nmsBlock, settings.resistance());
CoreReflections.field$BlockBehaviour$friction.set(nmsBlock, settings.friction());
CoreReflections.field$BlockBehaviour$speedFactor.set(nmsBlock, settings.speedFactor());
CoreReflections.field$BlockBehaviour$jumpFactor.set(nmsBlock, settings.jumpFactor());
CoreReflections.field$BlockBehaviour$soundType.set(nmsBlock, SoundUtils.toSoundType(settings.sounds()));
CoreReflections.method$BlockStateBase$initCache.invoke(nmsState);
boolean isConditionallyFullOpaque = canOcclude & useShapeForLightOcclusion;
if (!VersionHelper.isOrAbove1_21_2()) {
CoreReflections.field$BlockStateBase$isConditionallyFullOpaque.set(nmsState, isConditionallyFullOpaque);
}
if (VersionHelper.isOrAbove1_21_2()) {
int blockLight = settings.blockLight() != -1 ? settings.blockLight() : CoreReflections.field$BlockStateBase$lightBlock.getInt(nmsVisualState);
CoreReflections.field$BlockStateBase$lightBlock.set(nmsState, blockLight);
boolean propagatesSkylightDown = settings.propagatesSkylightDown() == Tristate.UNDEFINED ? CoreReflections.field$BlockStateBase$propagatesSkylightDown.getBoolean(nmsVisualState) : settings.propagatesSkylightDown().asBoolean();
CoreReflections.field$BlockStateBase$propagatesSkylightDown.set(nmsState, propagatesSkylightDown);
} else {
Object cache = CoreReflections.field$BlockStateBase$cache.get(nmsState);
int blockLight = settings.blockLight() != -1 ? settings.blockLight() : CoreReflections.field$BlockStateBase$Cache$lightBlock.getInt(CoreReflections.field$BlockStateBase$cache.get(nmsVisualState));
CoreReflections.field$BlockStateBase$Cache$lightBlock.set(cache, blockLight);
boolean propagatesSkylightDown = settings.propagatesSkylightDown() == Tristate.UNDEFINED ? CoreReflections.field$BlockStateBase$Cache$propagatesSkylightDown.getBoolean(CoreReflections.field$BlockStateBase$cache.get(nmsVisualState)) : settings.propagatesSkylightDown().asBoolean();
CoreReflections.field$BlockStateBase$Cache$propagatesSkylightDown.set(cache, propagatesSkylightDown);
if (!isConditionallyFullOpaque) {
CoreReflections.field$BlockStateBase$opacityIfCached.set(nmsState, blockLight);
}
}
CoreReflections.field$BlockStateBase$fluidState.set(nmsState, settings.fluidState() ? MFluids.WATER$defaultState : MFluids.EMPTY$defaultState);
CoreReflections.field$BlockStateBase$isRandomlyTicking.set(nmsState, settings.isRandomlyTicking());
Object holder = BukkitCraftEngine.instance().blockManager().getMinecraftBlockHolder(state.customBlockState().registryId());
Set<Object> tags = new HashSet<>();
for (Key tag : settings.tags()) {
tags.add(CoreReflections.method$TagKey$create.invoke(null, MRegistries.BLOCK, KeyUtils.toResourceLocation(tag)));
}
CoreReflections.field$Holder$Reference$tags.set(holder, tags);
if (settings.burnable()) {
this.igniteOdds.put(nmsBlock, settings.burnChance());
this.burnOdds.put(nmsBlock, settings.fireSpreadChance());
this.burnableBlocks.add(nmsBlock);
}
} catch (ReflectiveOperationException e) {
this.plugin.logger().warn("Failed to apply platform block settings for block state " + state, e);
}
}
private BlockSounds toBlockSounds(Object soundType) throws ReflectiveOperationException { private BlockSounds toBlockSounds(Object soundType) throws ReflectiveOperationException {
return new BlockSounds( return new BlockSounds(
toSoundData(CoreReflections.field$SoundType$breakSound.get(soundType), SoundData.SoundValue.FIXED_1, SoundData.SoundValue.FIXED_0_8), toSoundData(CoreReflections.field$SoundType$breakSound.get(soundType), SoundData.SoundValue.FIXED_1, SoundData.SoundValue.FIXED_0_8),

View File

@@ -1235,6 +1235,16 @@ public final class CoreReflections {
ReflectionUtils.getMethod(clazz$PushReaction, new String[] { "values" }) ReflectionUtils.getMethod(clazz$PushReaction, new String[] { "values" })
); );
public static final Object[] instance$PushReaction$values;
static {
try {
instance$PushReaction$values = (Object[]) method$PushReaction$values.invoke(null);
} catch (ReflectiveOperationException e) {
throw new ReflectionInitException("Failed to init PushReaction", e);
}
}
public static final Class<?> clazz$NoteBlockInstrument = requireNonNull( public static final Class<?> clazz$NoteBlockInstrument = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass( BukkitReflectionUtils.findReobfOrMojmapClass(
"world.level.block.state.properties.BlockPropertyInstrument", "world.level.block.state.properties.BlockPropertyInstrument",
@@ -1246,6 +1256,16 @@ public final class CoreReflections {
ReflectionUtils.getMethod(clazz$NoteBlockInstrument, new String[] { "values" }) ReflectionUtils.getMethod(clazz$NoteBlockInstrument, new String[] { "values" })
); );
public static final Object[] instance$NoteBlockInstrument$values;
static {
try {
instance$NoteBlockInstrument$values = (Object[]) method$NoteBlockInstrument$values.invoke(null);
} catch (ReflectiveOperationException e) {
throw new ReflectionInitException("Failed to init NoteBlockInstrument", e);
}
}
public static final Class<?> clazz$BlockStateBase = requireNonNull( public static final Class<?> clazz$BlockStateBase = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass( BukkitReflectionUtils.findReobfOrMojmapClass(
"world.level.block.state.BlockBase$BlockData", "world.level.block.state.BlockBase$BlockData",

View File

@@ -255,7 +255,6 @@ warning.config.block.state.property.invalid_format: "<yellow>Problem in Datei <a
warning.config.block.state.missing_state: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt das erforderliche 'state'-Argument für 'state'.</yellow>" warning.config.block.state.missing_state: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt das erforderliche 'state'-Argument für 'state'.</yellow>"
warning.config.block.state.missing_properties: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'properties'-Abschnitt für 'states'.</yellow>" warning.config.block.state.missing_properties: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'properties'-Abschnitt für 'states'.</yellow>"
warning.config.block.state.missing_appearances: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'appearances'-Abschnitt für 'states'.</yellow>" warning.config.block.state.missing_appearances: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'appearances'-Abschnitt für 'states'.</yellow>"
warning.config.block.state.missing_variants: "<yellow>Problem in Datei <arg:0> gefunden - Beim Block '<arg:1>' fehlt der erforderliche 'variants'-Abschnitt für 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' hat einen Fehler, dass die Variante '<arg:2>' eine nicht existierende Appearance '<arg:3>' verwendet.</yellow>" warning.config.block.state.variant.invalid_appearance: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' hat einen Fehler, dass die Variante '<arg:2>' eine nicht existierende Appearance '<arg:3>' verwendet.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen ungültigen Vanilla-Block-State '<arg:2>'.</yellow>" warning.config.block.state.invalid_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen ungültigen Vanilla-Block-State '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen nicht verfügbaren Vanilla-Block-State '<arg:2>'. Bitte gib diesen State in der mappings.yml frei.</yellow>" warning.config.block.state.unavailable_vanilla: "<yellow>Problem in Datei <arg:0> gefunden - Der Block '<arg:1>' verwendet einen nicht verfügbaren Vanilla-Block-State '<arg:2>'. Bitte gib diesen State in der mappings.yml frei.</yellow>"

View File

@@ -267,7 +267,6 @@ warning.config.block.state.property.invalid_format: "<yellow>Issue found in file
warning.config.block.state.missing_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument for 'state'.</yellow>" warning.config.block.state.missing_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument for 'state'.</yellow>"
warning.config.block.state.missing_properties: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'properties' section for 'states'.</yellow>" warning.config.block.state.missing_properties: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'properties' section for 'states'.</yellow>"
warning.config.block.state.missing_appearances: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'appearances' section for 'states'.</yellow>" warning.config.block.state.missing_appearances: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'appearances' section for 'states'.</yellow>"
warning.config.block.state.missing_variants: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'variants' section for 'states'.</yellow>"
warning.config.block.state.entity_renderer.invalid_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid entity renderer type '<arg:2>'.</yellow>" warning.config.block.state.entity_renderer.invalid_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid entity renderer type '<arg:2>'.</yellow>"
warning.config.block.state.entity_renderer.item_display.missing_item: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'item' argument for 'item_display' entity renderer.</yellow>" warning.config.block.state.entity_renderer.item_display.missing_item: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'item' argument for 'item_display' entity renderer.</yellow>"
warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'text' argument for 'text_display' entity renderer.</yellow>" warning.config.block.state.entity_renderer.text_display.missing_text: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'text' argument for 'text_display' entity renderer.</yellow>"

View File

@@ -178,7 +178,6 @@ warning.config.block.state.property.invalid_format: "<yellow>Problema encontrado
warning.config.block.state.missing_state: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece del argumento requerido 'state' para 'state'.</yellow>" warning.config.block.state.missing_state: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece del argumento requerido 'state' para 'state'.</yellow>"
warning.config.block.state.missing_properties: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'properties' para 'states'.</yellow>" warning.config.block.state.missing_properties: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'properties' para 'states'.</yellow>"
warning.config.block.state.missing_appearances: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'appearances' para 'states'.</yellow>" warning.config.block.state.missing_appearances: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'appearances' para 'states'.</yellow>"
warning.config.block.state.missing_variants: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' carece de la sección requerida 'variants' para 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Problema encontrado en el archivo <arg:0> - Hay un error en el bloque '<arg:1>' donde la variante '<arg:2>' está usando una apariencia inexistente '<arg:3>'.</yellow>" warning.config.block.state.variant.invalid_appearance: "<yellow>Problema encontrado en el archivo <arg:0> - Hay un error en el bloque '<arg:1>' donde la variante '<arg:2>' está usando una apariencia inexistente '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla inválido '<arg:2>'.</yellow>" warning.config.block.state.invalid_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla inválido '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla no disponible '<arg:2>'. Por favor libera este estado en el archivo mappings.yml.</yellow>" warning.config.block.state.unavailable_vanilla: "<yellow>Problema encontrado en el archivo <arg:0> - El bloque '<arg:1>' está usando un estado de bloque vanilla no disponible '<arg:2>'. Por favor libera este estado en el archivo mappings.yml.</yellow>"

View File

@@ -228,7 +228,6 @@ warning.config.block.state.property.invalid_format: "<yellow>Проблема н
warning.config.block.state.missing_state: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'state' аргумент для 'state'.</yellow>" warning.config.block.state.missing_state: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'state' аргумент для 'state'.</yellow>"
warning.config.block.state.missing_properties: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'properties' раздел для 'states'.</yellow>" warning.config.block.state.missing_properties: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'properties' раздел для 'states'.</yellow>"
warning.config.block.state.missing_appearances: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'appearances' раздел для 'states'.</yellow>" warning.config.block.state.missing_appearances: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'appearances' раздел для 'states'.</yellow>"
warning.config.block.state.missing_variants: "<yellow>Проблема найдена в файле <arg:0> - В блоке '<arg:1>' отсутствует необходимый 'variants' раздел для 'states'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет ошибку, что вариант '<arg:2>' использует несуществующий внешний вид '<arg:3>'.</yellow>" warning.config.block.state.variant.invalid_appearance: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет ошибку, что вариант '<arg:2>' использует несуществующий внешний вид '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет недействительное состояние ванильного блока '<arg:2>'.</yellow>" warning.config.block.state.invalid_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' имеет недействительное состояние ванильного блока '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' использует недоступное состояние ванильного блока '<arg:2>'. Пожалуйста, освободите это состояние в mappings.yml.</yellow>" warning.config.block.state.unavailable_vanilla: "<yellow>Проблема найдена в файле <arg:0> - Блок '<arg:1>' использует недоступное состояние ванильного блока '<arg:2>'. Пожалуйста, освободите это состояние в mappings.yml.</yellow>"

View File

@@ -176,7 +176,6 @@ warning.config.block.state.property.invalid_format: "<yellow><arg:0> dosyasında
warning.config.block.state.missing_state: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'state' için gerekli 'state' argümanı eksik.</yellow>" warning.config.block.state.missing_state: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'state' için gerekli 'state' argümanı eksik.</yellow>"
warning.config.block.state.missing_properties: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'properties' bölümü eksik.</yellow>" warning.config.block.state.missing_properties: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'properties' bölümü eksik.</yellow>"
warning.config.block.state.missing_appearances: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'appearances' bölümü eksik.</yellow>" warning.config.block.state.missing_appearances: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'appearances' bölümü eksik.</yellow>"
warning.config.block.state.missing_variants: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu, 'states' için gerekli 'variants' bölümü eksik.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğunda, '<arg:2>' varyantının var olmayan bir görünüm '<arg:3>' kullandığı bir hata var.</yellow>" warning.config.block.state.variant.invalid_appearance: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğunda, '<arg:2>' varyantının var olmayan bir görünüm '<arg:3>' kullandığı bir hata var.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu geçersiz bir vanilya blok durumu '<arg:2>' kullanıyor.</yellow>" warning.config.block.state.invalid_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu geçersiz bir vanilya blok durumu '<arg:2>' kullanıyor.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu kullanılamayan bir vanilya blok durumu '<arg:2>' kullanıyor. Lütfen bu durumu mappings.yml dosyasında serbest bırakın.</yellow>" warning.config.block.state.unavailable_vanilla: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' bloğu kullanılamayan bir vanilya blok durumu '<arg:2>' kullanıyor. Lütfen bu durumu mappings.yml dosyasında serbest bırakın.</yellow>"

View File

@@ -263,7 +263,6 @@ warning.config.block.state.property.invalid_format: "<yellow>在文件 <arg:0>
warning.config.block.state.missing_state: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'state' 缺少必需的 'state' 参数</yellow>" warning.config.block.state.missing_state: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'state' 缺少必需的 'state' 参数</yellow>"
warning.config.block.state.missing_properties: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'properties' 段落</yellow>" warning.config.block.state.missing_properties: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'properties' 段落</yellow>"
warning.config.block.state.missing_appearances: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'appearances' 段落</yellow>" warning.config.block.state.missing_appearances: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'appearances' 段落</yellow>"
warning.config.block.state.missing_variants: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'variants' 段落</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的变体 '<arg:2>' 使用了不存在的 appearance '<arg:3>'</yellow>" warning.config.block.state.variant.invalid_appearance: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的变体 '<arg:2>' 使用了不存在的 appearance '<arg:3>'</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的原版方块状态 '<arg:2>'</yellow>" warning.config.block.state.invalid_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的原版方块状态 '<arg:2>'</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了不可用的原版方块状态 '<arg:2>' 请在 mappings.yml 中释放该状态</yellow>" warning.config.block.state.unavailable_vanilla: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了不可用的原版方块状态 '<arg:2>' 请在 mappings.yml 中释放该状态</yellow>"

View File

@@ -6,7 +6,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior; import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElement; import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElement;
import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig; import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityElementConfig;
@@ -14,7 +13,6 @@ import net.momirealms.craftengine.core.block.entity.render.element.BlockEntityEl
import net.momirealms.craftengine.core.block.parser.BlockNbtParser; import net.momirealms.craftengine.core.block.parser.BlockNbtParser;
import net.momirealms.craftengine.core.block.properties.Properties; import net.momirealms.craftengine.core.block.properties.Properties;
import net.momirealms.craftengine.core.block.properties.Property; import net.momirealms.craftengine.core.block.properties.Property;
import net.momirealms.craftengine.core.item.AbstractItemManager;
import net.momirealms.craftengine.core.loot.LootTable; import net.momirealms.craftengine.core.loot.LootTable;
import net.momirealms.craftengine.core.pack.LoadingSequence; import net.momirealms.craftengine.core.pack.LoadingSequence;
import net.momirealms.craftengine.core.pack.Pack; import net.momirealms.craftengine.core.pack.Pack;
@@ -49,7 +47,6 @@ import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.function.Predicate;
public abstract class AbstractBlockManager extends AbstractModelGenerator implements BlockManager { public abstract class AbstractBlockManager extends AbstractModelGenerator implements BlockManager {
protected final BlockParser blockParser; protected final BlockParser blockParser;
@@ -150,7 +147,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
return Optional.ofNullable(this.byId.get(id)); return Optional.ofNullable(this.byId.get(id));
} }
protected void addBlockInternal(CustomBlock customBlock) { protected void addCustomBlock(CustomBlock customBlock) {
// 绑定外观状态等 // 绑定外观状态等
for (ImmutableBlockState state : customBlock.variantProvider().states()) { for (ImmutableBlockState state : customBlock.variantProvider().states()) {
int internalId = state.customBlockState().registryId(); int internalId = state.customBlockState().registryId();
@@ -159,6 +156,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
this.immutableBlockStates[index] = state; this.immutableBlockStates[index] = state;
this.blockStateMappings[internalId] = appearanceId; this.blockStateMappings[internalId] = appearanceId;
this.appearanceToRealState.computeIfAbsent(appearanceId, k -> new IntArrayList()).add(internalId); this.appearanceToRealState.computeIfAbsent(appearanceId, k -> new IntArrayList()).add(internalId);
this.applyPlatformSettings(state);
// generate mod assets // generate mod assets
if (Config.generateModAssets()) { if (Config.generateModAssets()) {
this.modBlockStateOverrides.put(getBlockOwnerId(state.customBlockState()), this.tempVanillaBlockStateModels.get(appearanceId)); this.modBlockStateOverrides.put(getBlockOwnerId(state.customBlockState()), this.tempVanillaBlockStateModels.get(appearanceId));
@@ -167,6 +165,8 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
this.byId.put(customBlock.id(), customBlock); this.byId.put(customBlock.id(), customBlock);
} }
protected abstract void applyPlatformSettings(ImmutableBlockState state);
@Override @Override
public ConfigParser[] parsers() { public ConfigParser[] parsers() {
return new ConfigParser[]{this.blockParser, this.blockStateMappingParser}; return new ConfigParser[]{this.blockParser, this.blockStateMappingParser};
@@ -546,7 +546,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
} }
// 添加方块 // 添加方块
addBlockInternal(customBlock); addCustomBlock(customBlock);
}, () -> GsonHelper.get().toJson(section))); }, () -> GsonHelper.get().toJson(section)));
} }

View File

@@ -8,9 +8,9 @@ public final class LoadingSequence {
public static final int GLOBAL_VAR = 10; public static final int GLOBAL_VAR = 10;
public static final int LANG = 20; public static final int LANG = 20;
public static final int TRANSLATION = 30; public static final int TRANSLATION = 30;
public static final int BLOCK = 40; public static final int EQUIPMENT = 40;
public static final int EQUIPMENT = 50; public static final int ITEM = 50;
public static final int ITEM = 60; public static final int BLOCK = 60;
public static final int FURNITURE = 70; public static final int FURNITURE = 70;
public static final int IMAGE = 80; public static final int IMAGE = 80;
public static final int RECIPE = 90; public static final int RECIPE = 90;