MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a machine that learn and visualize what learn on the gui"
-- First, create a custom block entity class that extends BlockEntity and implements ITickableBlockEntity for updating the learning process public class LearningMachineBlockEntity extends BlockEntity implements ITickableBlockEntity { private int learningProgress; public LearningMachineBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityInit.LEARNING_MACHINE.get(), pos, state); this.learningProgress = 0; } @Override public void tick() { -- Update the learning progress here learningProgress++; } public int getLearningProgress() { return learningProgress; } } -- Next, create a custom block class that implements EntityBlock public class LearningMachineBlock extends Block implements EntityBlock { public LearningMachineBlock(AbstractBlock.Properties props) { super(props); } @Nullable @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return BlockEntityInit.LEARNING_MACHINE.get().create(pos, state); } } -- Finally, create a custom container screen class to visualize the learning progress on the GUI public class LearningMachineScreen extends ContainerScreen<LearningMachineContainer> { public LearningMachineScreen(LearningMachineContainer container, PlayerInventory inv, ITextComponent title) { super(container, inv, title); } @Override protected void renderLabels(MatrixStack matrixStack, int mouseX, int mouseY) { super.renderLabels(matrixStack, mouseX, mouseY); int learningProgress = this.menu.getLearningProgress(); this.font.draw(matrixStack, "Learning Progress: " + learningProgress, 10, 10, 0xFFFFFF); } @Override protected void renderBg(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) { -- Render the background of the GUI here } }