-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutomataStartBlock.java
87 lines (77 loc) · 3.78 KB
/
AutomataStartBlock.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package br.com.isageek.automata.automata;
import br.com.isageek.automata.AutomataMod;
import br.com.isageek.automata.forge.WorldController;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.registries.RegistryObject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
public class AutomataStartBlock extends BaseEntityBlock {
public static final Property<AutomataStartState> state = EnumProperty.create("state", AutomataStartState.class);
private final AtomicReference<RegistryObject<BlockEntityType<?>>> blockEntityType;
private final Map<String, RegistryObject<Block>> registeredBlocks;
public AutomataStartBlock(
final AtomicReference<RegistryObject<BlockEntityType<?>>> blockEntityType,
final Map<String, RegistryObject<Block>> registeredBlocks
) {
super(BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
this.blockEntityType = blockEntityType;
this.registeredBlocks = registeredBlocks;
//this.registerDefaultState(this.getStateDefinition().any().setValue(state, AutomataStartState.LOAD_REPLACEABLES));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateBuilder) {
stateBuilder.add(state);
}
@Nullable
@Override
public BlockEntity newBlockEntity(
final @NotNull BlockPos blockPos,
final @NotNull BlockState blockState
) {
return new AutomataStartBlockEntity(blockEntityType, blockPos, blockState);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(
final @NotNull Level level,
final @NotNull BlockState blockState,
final @NotNull BlockEntityType<T> type
) {
if (type != blockEntityType.get().get()) return null;
return new Ticker(new WorldController(
new Block[]{Blocks.AIR, Blocks.CAVE_AIR},
registeredBlocks.get(AutomataMod.automata).get(),
registeredBlocks.get(AutomataMod.automata_termination).get(),
registeredBlocks.get(AutomataMod.automata_start).get(),
registeredBlocks.get(AutomataMod.automata_air_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_gravel_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_red_sand_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_sand_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_water_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_lava_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_tnt_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_bedrock_placeholder).get(),
registeredBlocks.get(AutomataMod.automata_y_rotation).get()
));
}
@Override
public RenderShape getRenderShape(BlockState p_49232_) {
return RenderShape.MODEL;
}
}