Copy-Paste Templates
Just looking for some template code to copy-paste?
See below for some existing code you can use to get you started.
Block Class
- Fabric
- Forge
- NeoForge
public class ExampleBlock extends Block implements EntityBlock {
public ExampleBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.create(pos, state);
}
}
public class ExampleBlock extends Block implements EntityBlock {
public ExampleBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get().create(pos, state);
}
}
public class ExampleBlock extends Block implements EntityBlock {
public ExampleBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get().create(pos, state);
}
}
BlockEntity Class
- Fabric
- Forge
- NeoForge
public class ExampleBlockEntity extends BlockEntity {
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
public ExampleBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY, pos, state);
}
@Override
public void registerControllers(final AnimatableManager.ControllerRegistrar controllers) {
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.geoCache;
}
}
public class ExampleBlockEntity extends BlockEntity {
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
public ExampleBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get(), pos, state);
}
@Override
public void registerControllers(final AnimatableManager.ControllerRegistrar controllers) {
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.geoCache;
}
}
public class ExampleBlockEntity extends BlockEntity {
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
public ExampleBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get(), pos, state);
}
@Override
public void registerControllers(final AnimatableManager.ControllerRegistrar controllers) {
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.geoCache;
}
}
BlockEntity Renderer
- Simple
- Advanced
- Fabric
- Forge
- NeoForge
// Registering the renderer
context -> new GeoBlockRenderer<>(context, BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY);
// Registering the renderer
context -> new GeoBlockRenderer<>(context, BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get());
// Registering the renderer
context -> new GeoBlockRenderer<>(context, BlockEntityRegistry.EXAMPLE_BLOCK_ENTITY.get());
public class ExampleBlockRenderer<R extends BlockEntityRenderState & GeoRenderState> extends GeoBlockRenderer<ExampleBlockEntity, R> {
public ExampleBlockRenderer(BlockEntityType<ExampleBlockEntity> blockEntityType) {
super(blockEntityType);
}
}
Blockstate JSON
{
"variants": {
"": {
"model": "examplemod:block/example_block"
}
}
}
Block Model JSON
{
"textures": {
"particle": "examplemod:block/example_block"
}
}