minecraft-mod/20231021_Ver1.2/src/main/java/modchest/block/custom/steeringWheelBlock.java

44 lines
1.6 KiB
Java
Raw Normal View History

package modchest.block.custom;
import modchest.block.entity.steeringWheelEntity;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
//gibt dem Block steering_wheel eigenschaften, wie z.B. das Interaktionsmenü, oder Grafiken
public class steeringWheelBlock extends BlockWithEntity implements BlockEntityProvider {
public steeringWheelBlock(Settings settings) {
super(settings);
}
/* stuff benötigt um das Interaktionsmenü zu laden!*/
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.getBlock() != newState.getBlock()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof steeringWheelEntity) {
ItemScatterer.spawn(world, pos, (steeringWheelEntity)blockEntity);
world.updateComparators(pos,this);
}
super.onStateReplaced(state, world, pos, newState, moved);
}
}
@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return null;
}
}