修复json错误,添加codec

This commit is contained in:
17146 2025-04-09 02:48:45 +08:00
parent 52b723c77b
commit 42c242dfe8
3 changed files with 11 additions and 8 deletions

View file

@ -28,6 +28,7 @@ import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
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;
@ -48,10 +49,13 @@ public class ContainerBlock extends BaseEntityBlock {
public static final BooleanProperty OPENED = BooleanProperty.create("opened");
public ContainerBlock() {
super(Properties.of().sound(SoundType.METAL).strength(3.0f).noOcclusion().requiresCorrectToolForDrops());
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPENED, false));
this(Properties.of().sound(SoundType.METAL).strength(3.0f).noOcclusion().requiresCorrectToolForDrops());
}
public ContainerBlock(BlockBehaviour.Properties properties) {
super(properties);
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPENED, false));
}
@Override
@ParametersAreNonnullByDefault
@ -188,10 +192,9 @@ public class ContainerBlock extends BaseEntityBlock {
return state.getValue(OPENED) ? box(1, 0, 1, 15, 14, 15) : box(0, 0, 0, 16, 15, 16);
}
// TODO codec
@Override
protected @NotNull MapCodec<? extends BaseEntityBlock> codec() {
return null;
protected MapCodec<? extends BaseEntityBlock> codec() {
return simpleCodec(ContainerBlock::new);
}
@Override

View file

@ -43,7 +43,7 @@ public class ModBlocks {
() -> new Block(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.METAL).strength(5f, 6f).requiresCorrectToolForDrops()));
public static final DeferredHolder<Block, Block> CEMENTED_CARBIDE_BLOCK = REGISTRY.register("cemented_carbide_block",
() -> new Block(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.METAL).strength(5f, 6f).requiresCorrectToolForDrops()));
public static final DeferredHolder<Block, Block> CONTAINER = REGISTRY.register("container", ContainerBlock::new);
public static final DeferredHolder<Block, Block> CONTAINER = REGISTRY.register("container", () -> new ContainerBlock());
public static final DeferredHolder<Block, Block> SMALL_CONTAINER = REGISTRY.register("small_container", () -> new SmallContainerBlock());
public static final DeferredHolder<Block, Block> CHARGING_STATION = REGISTRY.register("charging_station", ChargingStationBlock::new);
public static final DeferredHolder<Block, Block> CREATIVE_CHARGING_STATION = REGISTRY.register("creative_charging_station", () -> new CreativeChargingStationBlock());

View file

@ -5,7 +5,7 @@
"name": "SUPERBWARFARE_LEGENDARY",
"constructor": "(ILjava/lang/String;Lnet/minecraft/ChatFormatting;)V",
"parameters": {
"class": "com/atsuishio/superbwarfare/init/ModEnumExtends",
"class": "com/atsuishio/superbwarfare/init/ModEnumExtensions",
"field": "SUPERBWARFARE_LEGENDARY"
}
},
@ -14,7 +14,7 @@
"name": "SUPERBWARFARE_LUNGE_MINE_POSE",
"constructor": "(ZLnet/neoforged/neoforge/client/IArmPoseTransformer;)V",
"parameters": {
"class": "com/atsuishio/superbwarfare/init/ModEnumExtends",
"class": "com/atsuishio/superbwarfare/init/ModEnumExtensions",
"field": "SUPERBWARFARE_LUNGE_MINE_POSE"
}
}