Move the grinder back to code.
This commit is contained in:
parent
a162a5ab40
commit
d0bdf744cf
13 changed files with 82 additions and 384 deletions
|
@ -28,9 +28,9 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreens;
|
||||
import net.minecraft.util.Identifier;
|
||||
import techreborn.blockentity.GuiType;
|
||||
import techreborn.blockentity.data.DataDrivenBEProvider;
|
||||
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
|
||||
import techreborn.blockentity.generator.SolarPanelBlockEntity;
|
||||
import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity;
|
||||
|
@ -82,6 +82,7 @@ public class ClientGuiType<T extends BlockEntity> {
|
|||
public static final ClientGuiType<DistillationTowerBlockEntity> DISTILLATION_TOWER = register(GuiType.DISTILLATION_TOWER, GuiDistillationTower::new);
|
||||
public static final ClientGuiType<ElectricFurnaceBlockEntity> ELECTRIC_FURNACE = register(GuiType.ELECTRIC_FURNACE, GuiElectricFurnace::new);
|
||||
public static final ClientGuiType<ExtractorBlockEntity> EXTRACTOR = register(GuiType.EXTRACTOR, GuiExtractor::new);
|
||||
public static final ClientGuiType<GrinderBlockEntity> GRINDER = register(GuiType.GRINDER, GuiGrinder::new);
|
||||
public static final ClientGuiType<FusionControlComputerBlockEntity> FUSION_CONTROLLER = register(GuiType.FUSION_CONTROLLER, GuiFusionReactor::new);
|
||||
public static final ClientGuiType<GasTurbineBlockEntity> GAS_TURBINE = register(GuiType.GAS_TURBINE, GuiGasTurbine::new);
|
||||
public static final ClientGuiType<SolidFuelGeneratorBlockEntity> GENERATOR = register(GuiType.GENERATOR, GuiGenerator::new);
|
||||
|
@ -110,7 +111,6 @@ public class ClientGuiType<T extends BlockEntity> {
|
|||
public static final ClientGuiType<GreenhouseControllerBlockEntity> GREENHOUSE_CONTROLLER = register(GuiType.GREENHOUSE_CONTROLLER, GuiGreenhouseController::new);
|
||||
public static final ClientGuiType<FluidReplicatorBlockEntity> FLUID_REPLICATOR = register(GuiType.FLUID_REPLICATOR, GuiFluidReplicator::new);
|
||||
public static final ClientGuiType<PlayerDetectorBlockEntity> PLAYER_DETECTOR = register(GuiType.PLAYER_DETECTOR, GuiPlayerDetector::new);
|
||||
public static final ClientGuiType<DataDrivenBEProvider.DataDrivenBlockEntity> DATA_DRIVEN = register(GuiType.DATA_DRIVEN, DataDrivenGui::new);
|
||||
public static final ClientGuiType<BlockBreakerBlockEntity> BLOCK_BREAKER = register(GuiType.BLOCK_BREAKER, GuiBlockBreaker::new);
|
||||
public static final ClientGuiType<BlockPlacerBlockEntity> BLOCK_PLACER = register(GuiType.BLOCK_PLACER, GuiBlockPlacer::new);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class ClientGuiType<T extends BlockEntity> {
|
|||
this.guiType = Objects.requireNonNull(guiType);
|
||||
this.guiFactory = Objects.requireNonNull(guiFactory);
|
||||
|
||||
ScreenRegistry.register(guiType.getScreenHandlerType(), getGuiFactory());
|
||||
HandledScreens.register(guiType.getScreenHandlerType(), getGuiFactory());
|
||||
|
||||
TYPES.put(guiType.getIdentifier(), this);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,14 @@ import net.fabricmc.api.Environment;
|
|||
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreens;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.common.screen.BuiltScreenHandler;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public interface GuiFactory<T extends BlockEntity> extends ScreenRegistry.Factory<BuiltScreenHandler, HandledScreen<BuiltScreenHandler>> {
|
||||
public interface GuiFactory<T extends BlockEntity> extends HandledScreens.Provider<BuiltScreenHandler, HandledScreen<BuiltScreenHandler>> {
|
||||
HandledScreen<?> create(int syncId, PlayerEntity playerEntity, T blockEntity);
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2020 TechReborn
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -29,38 +29,29 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.client.gui.guibuilder.GuiBuilder;
|
||||
import reborncore.common.screen.BuiltScreenHandler;
|
||||
import techreborn.blockentity.data.DataDrivenBEProvider;
|
||||
import techreborn.blockentity.data.DataDrivenSlot;
|
||||
import techreborn.blockentity.data.SlotType;
|
||||
import techreborn.blockentity.machine.tier1.GrinderBlockEntity;
|
||||
|
||||
public class DataDrivenGui extends GuiBase<BuiltScreenHandler> {
|
||||
public class GuiGrinder extends GuiBase<BuiltScreenHandler> {
|
||||
GrinderBlockEntity blockEntity;
|
||||
|
||||
private final DataDrivenBEProvider provider;
|
||||
private final DataDrivenBEProvider.DataDrivenBlockEntity blockEntity;
|
||||
|
||||
public DataDrivenGui(int syncID, final PlayerEntity player, final DataDrivenBEProvider.DataDrivenBlockEntity blockEntity) {
|
||||
public GuiGrinder(int syncID, final PlayerEntity player, final GrinderBlockEntity blockEntity) {
|
||||
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
|
||||
this.blockEntity = blockEntity;
|
||||
this.provider = blockEntity.getProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(MatrixStack matrixStack, final float f, final int mouseX, final int mouseY) {
|
||||
super.drawBackground(matrixStack, f, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
final DataDrivenGui gui = this;
|
||||
|
||||
provider.getSlots().forEach(slot -> draw(matrixStack, gui, layer, slot));
|
||||
drawSlot(matrixStack, 8, 72, layer);
|
||||
|
||||
drawSlot(matrixStack, 55, 45, layer);
|
||||
drawOutputSlot(matrixStack, 101, 45, layer);
|
||||
|
||||
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
|
||||
}
|
||||
|
||||
|
||||
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer, DataDrivenSlot slot) {
|
||||
if (slot.type() == SlotType.OUTPUT) {
|
||||
guiBase.drawOutputSlot(matrixStack, slot.x(), slot.y(), layer);
|
||||
} else {
|
||||
guiBase.drawSlot(matrixStack, slot.x(), slot.y(), layer);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
|
||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
Loading…
Add table
Add a link
Reference in a new issue