mirror of
https://github.com/RoBaertschi/EnvironmentTech.git
synced 2025-04-20 07:03:30 +00:00
create block entity
This commit is contained in:
parent
50e36869ce
commit
29ce7ddc77
@ -14,6 +14,7 @@ public class ETBlocks {
|
|||||||
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
|
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
|
||||||
// Creates a new Block with the id "environmenttech:example_block", combining the namespace and path
|
// Creates a new Block with the id "environmenttech:example_block", combining the namespace and path
|
||||||
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
|
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
|
||||||
|
public static final DeferredBlock<EnvCollectorBlock> ENV_COLLECTOR_BLOCK = BLOCKS.registerBlock("env_collector", EnvCollectorBlock::new, BlockBehaviour.Properties.of());
|
||||||
|
|
||||||
|
|
||||||
public static void init(IEventBus iEventBus) {
|
public static void init(IEventBus iEventBus) {
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import robaertschi.environmenttech.level.block.entity.EnvCollectorBlockEntity;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@ -36,6 +37,6 @@ public class EnvCollectorBlock extends BaseEntityBlock {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
||||||
return null;
|
return new EnvCollectorBlockEntity(pPos, pState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package robaertschi.environmenttech.level.block.entity;
|
||||||
|
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
import robaertschi.environmenttech.level.block.ETBlocks;
|
||||||
|
|
||||||
|
import static robaertschi.environmenttech.EnvironmentTech.MODID;
|
||||||
|
|
||||||
|
public class ETBlockEntities {
|
||||||
|
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, MODID);
|
||||||
|
|
||||||
|
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<EnvCollectorBlockEntity>> ENV_COLLECTOR_BLOCK_ENTITY =
|
||||||
|
BLOCK_ENTITIES.register("env_collector",
|
||||||
|
() -> BlockEntityType.Builder.of(EnvCollectorBlockEntity::new,
|
||||||
|
ETBlocks.ENV_COLLECTOR_BLOCK.get()).build(null));
|
||||||
|
|
||||||
|
public static void init(IEventBus iEventBus) {
|
||||||
|
BLOCK_ENTITIES.register(iEventBus);
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,14 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||||
|
|
||||||
public class EnvCollectorBlockEntity extends BlockEntity {
|
public class EnvCollectorBlockEntity extends BlockEntity {
|
||||||
public EnvCollectorBlockEntity(BlockEntityType<?> pType, BlockPos pPos, BlockState pBlockState) {
|
public EnvCollectorBlockEntity(BlockEntityType<EnvCollectorBlockEntity> pType, BlockPos pPos, BlockState pBlockState) {
|
||||||
super(pType, pPos, pBlockState);
|
super(pType, pPos, pBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnvCollectorBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
this(ETBlockEntities.ENV_COLLECTOR_BLOCK_ENTITY.get(), pos, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user