MCPcopy Create free account
hub / github.com/McJty/TutorialV3 / GeneratorBE

Class GeneratorBE

src/main/java/com/example/tutorialv3/blocks/GeneratorBE.java:39–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37import java.util.Objects;
38
39public class GeneratorBE extends BlockEntity {
40
41 public static final int INPUT_SLOTS = 5;
42 public static final int OUTPUT_SLOTS = 1;
43
44 // The properties that are used to communicate data to the baked model (GeneratorBakedModel)
45 public static final ModelProperty<BlockState> GENERATING_BLOCK = new ModelProperty<>();
46 public static final ModelProperty<Boolean> GENERATING = new ModelProperty<>();
47 public static final ModelProperty<Boolean> COLLECTING = new ModelProperty<>();
48 public static final ModelProperty<Boolean> ACTUALLY_GENERATING = new ModelProperty<>();
49
50 // The actual values for these properties
51 private boolean generating = false;
52 private boolean collecting = false;
53 private BlockState generatingBlock;
54 private boolean actuallyGenerating = false;
55
56 // For collecting
57 private int collectingTicker = 0;
58 private AABB collectingBox = null;
59
60 // For generating our ores
61 private int generatingCounter = 0;
62
63 // A direct reference to our items and energy for easy access inside our block entity
64 // LazyOptionals to return with getCapability()
65 private final ItemStackHandler inputItems = createInputItemHandler();
66 private final LazyOptional<IItemHandler> inputItemHandler = LazyOptional.of(() -> inputItems);
67 private final ItemStackHandler outputItems = createOutputItemHandler();
68 private final LazyOptional<IItemHandler> outputItemHandler = LazyOptional.of(() -> outputItems);
69 private final LazyOptional<IItemHandler> combinedItemHandler = LazyOptional.of(this::createCombinedItemHandler);
70
71 private final CustomEnergyStorage energy = createEnergyStorage();
72 private final LazyOptional<IEnergyStorage> energyHandler = LazyOptional.of(() -> energy);
73
74 public GeneratorBE(BlockPos pos, BlockState state) {
75 super(Registration.GENERATOR_BE.get(), pos, state);
76 }
77
78 public boolean isGenerating() {
79 return generating;
80 }
81
82 public void setGenerating(boolean generating) {
83 this.generating = generating;
84 setChanged();
85 level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_ALL);
86 }
87
88 public boolean isCollecting() {
89 return collecting;
90 }
91
92 public void setCollecting(boolean collecting) {
93 this.collecting = collecting;
94 setChanged();
95 level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_ALL);
96 }

Callers

nothing calls this directly

Calls 3

createEnergyStorageMethod · 0.95

Tested by

no test coverage detected