I'm trying to make some custom walls for the game, which is working fine except for the bounding boxes that I have to change to make it look good. Here is the Wall class:
It may look a bit messy because not every variation is in it yet and because of too much testing. However, the Minecraft start fails with the error "Cannot set property BooleanProperty{name=up, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in Block{null}" at the line "super(properties);". I am not very experienced, where do I have to put a BooleanProperty here?
which seems to be mandatory. Unfortunately now the game crashes with
java.lang.NullPointerException: Rendering overlay
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.lambda$new$0(AbstractBlock.java:853) ~[?:?] {re:classloading}
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90) ~[?:1.8.0_252] {}
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) ~[?:1.8.0_252] {}
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_252] {}
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230) ~[?:1.8.0_252] {}
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_252] {}
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:516) ~[?:1.8.0_252] {}
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.<init>(AbstractBlock.java:852) ~[?:?] {re:classloading}
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.<init>(AbstractBlock.java:822) ~[?:?] {re:classloading}
at net.minecraft.block.AbstractBlock$AbstractBlockState.cacheState(AbstractBlock.java:471) ~[?:?] {re:classloading}
at net.minecraftforge.registries.GameData$BlockCallbacks.onBake(GameData.java:486) ~[?:?] {re:classloading}
at net.minecraftforge.registries.ForgeRegistry.bake(ForgeRegistry.java:531) ~[?:?] {re:classloading}
at net.minecraftforge.registries.GameData.lambda$freezeData$5(GameData.java:296) ~[?:?] {re:classloading}
at com.google.common.collect.HashBiMap.forEach(HashBiMap.java:528) ~[guava-21.0.jar:?] {}
at net.minecraftforge.registries.GameData.freezeData(GameData.java:294) ~[?:?] {re:classloading}
at net.minecraftforge.fml.ModLoader.finishMods(ModLoader.java:225) ~[?:?] {re:classloading}
at net.minecraftforge.fml.client.ClientModLoader.lambda$finishModLoading$8(ClientModLoader.java:146) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.finishModLoading(ClientModLoader.java:146) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.lambda$onResourceReload$3(ClientModLoader.java:116) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at java.util.concurrent.CompletableFuture.uniRun(CompletableFuture.java:719) ~[?:1.8.0_252] {}
at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:701) ~[?:1.8.0_252] {}
at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_252] {}
Hello together,
I'm trying to make some custom walls for the game, which is working fine except for the bounding boxes that I have to change to make it look good.
Here is the Wall class:
package com.raptor.customfence.blocks;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import java.util.Map;
public class Wall extends WallBlock {
VoxelShape bounding_box_values_classic = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 14.0F, 16.0F);
VoxelShape bounding_box_values_modern = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 16.0F, 16.0F);
VoxelShape bounding_box_values_castle = Block.makeCuboidShape(3.0F, 0.0F, 0.0F, 13.0F, 16.0F, 16.0F);
VoxelShape bounding_box_values_building = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 16.0F, 16.0F);
VoxelShape collision_box_values_classic = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 24.0F, 16.0F);
VoxelShape collision_box_values_modern = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 24.0F, 16.0F);
VoxelShape collision_box_values_castle = Block.makeCuboidShape(3.0F, 0.0F, 0.0F, 13.0F, 24.0F, 16.0F);
VoxelShape collision_box_values_building = Block.makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 24.0F, 16.0F);
VoxelShape voxel_shape = VoxelShapes.empty();
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public Wall(Properties properties) {
super(properties);
this.setDefaultState(stateContainer.getBaseState().with(BlockStateProperties.FACING,Direction.NORTH));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.FACING);
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(BlockStateProperties.FACING, Direction.UP);
}
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
if (getRegistryName().toString().contains("modern")) {
switch(state.get(BlockStateProperties.FACING)) {
case NORTH:
return makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 16.0F, 16.0F);
case EAST:
return makeCuboidShape(0.0F, 0.0F, 4.0F, 16.0F, 16.0F, 12.0F);
case SOUTH:
return makeCuboidShape(4.0F, 0.0F, 0.0F, 12.0F, 16.0F, 16.0F);
case WEST:
return makeCuboidShape(0.0F, 0.0F, 4.0F, 16.0F, 16.0F, 12.0F);
case UP:
return makeCuboidShape(0.0F, 0.0F, 4.0F, 16.0F, 16.0F, 12.0F);
case DOWN:
return makeCuboidShape(0.0F, 0.0F, 4.0F, 16.0F, 16.0F, 12.0F);
}
return VoxelShapes.fullCube();
}
else if (getRegistryName().toString().contains("castle")) {
return this.bounding_box_values_castle;
}
else if (getRegistryName().toString().contains("building")) {
return this.bounding_box_values_building;
}
else {
return this.bounding_box_values_classic;
}
}
//public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
// if (getRegistryName().toString().contains("modern")) {
// return this.collision_box_values_modern;
// }
// else if (getRegistryName().toString().contains("castle")) {
// return this.collision_box_values_castle;
// }
// else if (getRegistryName().toString().contains("building")) {
// return this.collision_box_values_building;
// }
// else {
// return this.collision_box_values_classic;
// }
//}
}
It may look a bit messy because not every variation is in it yet and because of too much testing. However, the Minecraft start fails with the error "Cannot set property BooleanProperty{name=up, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in Block{null}" at the line "super(properties);". I am not very experienced, where do I have to put a BooleanProperty here?
Try adding a call to the super method in getStateForPlacement().
I've changed the method getStateForPlacement()
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
super.getStateForPlacement(context);
return getDefaultState().with(BlockStateProperties.FACING, Direction.UP);
}[/pre]
and also added the direction and boolean properties method to fillStateContainer
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.field_235908_S_);
builder.add(BlockStateProperties.field_235909_T_);
builder.add(BlockStateProperties.field_235910_U_);
builder.add(BlockStateProperties.field_235911_V_);
builder.add(BlockStateProperties.UP);
builder.add(BlockStateProperties.WATERLOGGED);
builder.add(BlockStateProperties.FACING);
}[/pre]
which seems to be mandatory. Unfortunately now the game crashes with
java.lang.NullPointerException: Rendering overlay
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.lambda$new$0(AbstractBlock.java:853) ~[?:?] {re:classloading}
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90) ~[?:1.8.0_252] {}
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) ~[?:1.8.0_252] {}
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_252] {}
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230) ~[?:1.8.0_252] {}
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196) ~[?:1.8.0_252] {}
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_252] {}
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:516) ~[?:1.8.0_252] {}
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.<init>(AbstractBlock.java:852) ~[?:?] {re:classloading}
at net.minecraft.block.AbstractBlock$AbstractBlockState$Cache.<init>(AbstractBlock.java:822) ~[?:?] {re:classloading}
at net.minecraft.block.AbstractBlock$AbstractBlockState.cacheState(AbstractBlock.java:471) ~[?:?] {re:classloading}
at net.minecraftforge.registries.GameData$BlockCallbacks.onBake(GameData.java:486) ~[?:?] {re:classloading}
at net.minecraftforge.registries.ForgeRegistry.bake(ForgeRegistry.java:531) ~[?:?] {re:classloading}
at net.minecraftforge.registries.GameData.lambda$freezeData$5(GameData.java:296) ~[?:?] {re:classloading}
at com.google.common.collect.HashBiMap.forEach(HashBiMap.java:528) ~[guava-21.0.jar:?] {}
at net.minecraftforge.registries.GameData.freezeData(GameData.java:294) ~[?:?] {re:classloading}
at net.minecraftforge.fml.ModLoader.finishMods(ModLoader.java:225) ~[?:?] {re:classloading}
at net.minecraftforge.fml.client.ClientModLoader.lambda$finishModLoading$8(ClientModLoader.java:146) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.finishModLoading(ClientModLoader.java:146) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraftforge.fml.client.ClientModLoader.lambda$onResourceReload$3(ClientModLoader.java:116) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at java.util.concurrent.CompletableFuture.uniRun(CompletableFuture.java:719) ~[?:1.8.0_252] {}
at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:701) ~[?:1.8.0_252] {}
at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[?:1.8.0_252] {}
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_252] {}
Nevermind, I had to un-comment the getCollisionShape method.
Thank you very much for your help!
No problem, glad I could help!