mirror of
https://github.com/RoBaertschi/EnvironmentTech.git
synced 2025-04-19 23:03:28 +00:00
begin env distributor
This commit is contained in:
parent
336c9099ad
commit
c57cb36bd8
@ -48,7 +48,7 @@ public class EnvironmentTech
|
||||
ETCapabilities.init(modEventBus);
|
||||
ETMenus.init(modEventBus);
|
||||
ETParticles.init(modEventBus);
|
||||
ETComponents.DATA_COMPONENTS.register(modEventBus);
|
||||
ETComponents.init(modEventBus);
|
||||
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package robaertschi.environmenttech.data.components;
|
||||
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import robaertschi.environmenttech.EnvironmentTech;
|
||||
@ -11,4 +12,8 @@ public class ETComponents {
|
||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<FilledComponent>> FILLED_COMPONENT = DATA_COMPONENTS.registerComponentType("filled_component",
|
||||
filledComponentBuilder -> filledComponentBuilder.persistent(FilledComponent.CODEC).networkSynchronized(FilledComponent.STREAM_CODEC)
|
||||
);
|
||||
|
||||
public static void init(IEventBus modEventBus) {
|
||||
DATA_COMPONENTS.register(modEventBus);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package robaertschi.environmenttech.level.block;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EnvDistributor extends BaseEntityBlock {
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
public static final MapCodec<EnvDistributor> CODEC = simpleCodec(EnvDistributor::new);
|
||||
|
||||
|
||||
|
||||
public EnvDistributor(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RenderShape getRenderShape(BlockState pState) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, LevelAccessor level, BlockPos pos, Rotation direction) {
|
||||
return state.setValue(FACING, direction.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState mirror(BlockState pState, Mirror pMirror) {
|
||||
return pState.rotate(pMirror.getRotation(pState.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return this.defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) {
|
||||
pLevel.updateNeighborsAt(pPos, this);
|
||||
super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user