You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Minecraft 1.19-41.1.0版本Backrooms风格模组中灯具方块纹理不加载问题排查求助

Minecraft 1.19-41.1.0版本Backrooms风格模组中灯具方块纹理不加载问题排查求助

大家好,我正在开发一款Backrooms风格的Minecraft模组(对应版本1.19-41.1.0),目前遇到了一个奇怪的问题:所有方块的纹理都能正常加载,唯独红色天花板灯方块的纹理显示不出来,但灯具的光照功能是完全正常的。我把相关的代码文件贴在下面,希望有经验的模组开发大佬能帮忙排查一下问题所在!

ModBlocks.java

package net.troy.floors.block;

import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.troy.floors.block.custom.ceiling_light_red;
import net.troy.floors.floors;
import net.troy.floors.item.ModItems;
import java.util.function.Supplier;

public class ModBlocks {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, floors.MOD_ID);

    public static final RegistryObject<Block> FLOOR_BLOCK = registerBlock("floor_block", () -> new Block(BlockBehaviour.Properties.of(Material.WOOD).strength(-1f)), CreativeModeTab.TAB_BUILDING_BLOCKS);
    public static final RegistryObject<Block> WALL_BLOCK = registerBlock("wall_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).strength(-1f)), CreativeModeTab.TAB_BUILDING_BLOCKS);
    public static final RegistryObject<Block> CEILING_BLOCK = registerBlock("ceiling_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).strength(-1f)), CreativeModeTab.TAB_BUILDING_BLOCKS);
    public static final RegistryObject<Block> CEILING_LIGHT_RED_BLOCK = registerBlock("ceiling_light_red", () -> new ceiling_light_red(BlockBehaviour.Properties.of(Material.STONE).strength(-1f).lightLevel(state -> state.getValue(ceiling_light_red.LIT) ? 5 : 0)), CreativeModeTab.TAB_DECORATIONS);

    private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block, CreativeModeTab tab) {
        RegistryObject<T> toReturn = BLOCKS.register(name, block);
        registerBlockItem(name, toReturn, tab);
        return toReturn;
    }

    private static <T extends Block> RegistryObject<Item> registerBlockItem(String name, RegistryObject<T> block, CreativeModeTab tab) {
        return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(tab)));
    }

    public static void register(IEventBus eventBus) {
        BLOCKS.register(eventBus);
    }
}

custom/ceiling_light_red.java

package net.troy.floors.block.custom;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;

public class ceiling_light_red extends Block {
    public static final BooleanProperty LIT = BooleanProperty.create("lit");

    public ceiling_light_red(Properties properties) {
        super(properties);
    }

    @Override
    public InteractionResult use(BlockState state, Level level, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult result) {
        if(!level.isClientSide() && hand == InteractionHand.MAIN_HAND) {
            level.setBlock(blockPos, state.cycle(LIT),3);
        }
        return super.use(state, level, blockPos, player, hand, result);
    }

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(LIT);
    }
}

floors.java

package net.troy.floors;

import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import net.troy.floors.block.ModBlocks;
import net.troy.floors.item.ModItems;
import org.slf4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(floors.MOD_ID)
public class floors {
    public static final String MOD_ID = "floors";
    private static final Logger LOGGER = LogUtils.getLogger();

    public floors() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        ModItems.register(modEventBus);
        ModBlocks.register(modEventBus);

        // Register the commonSetup method for modloading
        modEve

(注:floors.java的代码存在截断,我是按你提供的内容原样粘贴的)

内容来源于stack exchange

火山引擎 最新活动