diff --git a/src/main/java/gregtech/api/capability/GregtechCapabilities.java b/src/main/java/gregtech/api/capability/GregtechCapabilities.java index 985d6c5a7fe..df163402aeb 100644 --- a/src/main/java/gregtech/api/capability/GregtechCapabilities.java +++ b/src/main/java/gregtech/api/capability/GregtechCapabilities.java @@ -2,7 +2,6 @@ import gregtech.api.GTValues; import gregtech.api.capability.impl.EUToFEProvider; -import gregtech.api.terminal.hardware.HardwareProvider; import gregtech.api.util.GTUtility; import gregtech.common.metatileentities.converter.ConverterTrait; @@ -26,9 +25,6 @@ public class GregtechCapabilities { @CapabilityInject(IMultiblockController.class) public static Capability CAPABILITY_MULTIBLOCK_CONTROLLER = null; - @CapabilityInject(HardwareProvider.class) - public static Capability CAPABILITY_HARDWARE_PROVIDER = null; - @CapabilityInject(ConverterTrait.class) public static Capability CAPABILITY_CONVERTER = null; diff --git a/src/main/java/gregtech/api/capability/SimpleCapabilityManager.java b/src/main/java/gregtech/api/capability/SimpleCapabilityManager.java index 8aad39dc29c..f517b473bab 100644 --- a/src/main/java/gregtech/api/capability/SimpleCapabilityManager.java +++ b/src/main/java/gregtech/api/capability/SimpleCapabilityManager.java @@ -3,7 +3,6 @@ import gregtech.api.capability.impl.AbstractRecipeLogic; import gregtech.api.cover.CoverHolder; import gregtech.api.metatileentity.multiblock.IMaintenance; -import gregtech.api.terminal.hardware.HardwareProvider; import gregtech.api.worldgen.generator.GTWorldGenCapability; import gregtech.common.metatileentities.converter.ConverterTrait; @@ -48,7 +47,6 @@ public static void init() { registerCapabilityWithNoDefault(AbstractRecipeLogic.class); registerCapabilityWithNoDefault(IDataAccessHatch.class); registerCapabilityWithNoDefault(IOpticalComputationProvider.class); - registerCapabilityWithNoDefault(HardwareProvider.class); registerCapabilityWithNoDefault(ConverterTrait.class); registerCapabilityWithNoDefault(ILaserContainer.class); diff --git a/src/main/java/gregtech/api/gui/GuiTextures.java b/src/main/java/gregtech/api/gui/GuiTextures.java index e2b7afa929a..8c984b5d4ed 100644 --- a/src/main/java/gregtech/api/gui/GuiTextures.java +++ b/src/main/java/gregtech/api/gui/GuiTextures.java @@ -474,9 +474,6 @@ public class GuiTextures { .fullImage("textures/gui/terminal/icon/appearance_hover.png"); public final static TextureArea ICON_CALCULATOR = TextureArea .fullImage("textures/gui/terminal/icon/calculator_hover.png"); - public final static TextureArea UI_FRAME_SIDE_UP = TextureArea.fullImage("textures/gui/terminal/frame_side_up.png"); - public final static TextureArea UI_FRAME_SIDE_DOWN = TextureArea - .fullImage("textures/gui/terminal/frame_side_down.png"); // Texture Areas public static final TextureArea BUTTON_FLUID = TextureArea diff --git a/src/main/java/gregtech/api/terminal/TerminalRegistry.java b/src/main/java/gregtech/api/terminal/TerminalRegistry.java deleted file mode 100644 index e842eb0c7a9..00000000000 --- a/src/main/java/gregtech/api/terminal/TerminalRegistry.java +++ /dev/null @@ -1,347 +0,0 @@ -package gregtech.api.terminal; - -import gregtech.api.GTValues; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.util.FileUtility; -import gregtech.api.util.GTLog; -import gregtech.api.util.Mods; -import gregtech.common.ConfigHolder; -import gregtech.common.items.MetaItems; -import gregtech.common.terminal.app.VirtualTankApp; -import gregtech.common.terminal.app.appstore.AppStoreApp; -import gregtech.common.terminal.app.batterymanager.BatteryManagerApp; -import gregtech.common.terminal.app.capeselector.CapeSelectorApp; -import gregtech.common.terminal.app.console.ConsoleApp; -import gregtech.common.terminal.app.game.maze.MazeApp; -import gregtech.common.terminal.app.game.minesweeper.MinesweeperApp; -import gregtech.common.terminal.app.game.pong.PongApp; -import gregtech.common.terminal.app.guide.ItemGuideApp; -import gregtech.common.terminal.app.guide.MultiBlockGuideApp; -import gregtech.common.terminal.app.guide.SimpleMachineGuideApp; -import gregtech.common.terminal.app.guide.TutorialGuideApp; -import gregtech.common.terminal.app.guideeditor.GuideEditorApp; -import gregtech.common.terminal.app.hardwaremanager.HardwareManagerApp; -import gregtech.common.terminal.app.multiblockhelper.MultiBlockPreviewARApp; -import gregtech.common.terminal.app.prospector.ProspectorApp; -import gregtech.common.terminal.app.prospector.ProspectorMode; -import gregtech.common.terminal.app.recipechart.RecipeChartApp; -import gregtech.common.terminal.app.settings.SettingsApp; -import gregtech.common.terminal.app.teleport.TeleportApp; -import gregtech.common.terminal.app.worldprospector.WorldProspectorARApp; -import gregtech.common.terminal.hardware.BatteryHardware; -import gregtech.common.terminal.hardware.DeviceHardware; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.SimpleReloadableResourceManager; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.*; -import java.util.stream.Collectors; - -public class TerminalRegistry { - - public static final Map APP_REGISTER = new LinkedHashMap<>(); - public static final Map HW_REGISTER = new LinkedHashMap<>(); - public static final Map[]> APP_HW_DEMAND = new HashMap<>(); - public static final Map[]> APP_UPGRADE_CONDITIONS = new HashMap<>(); - public static final List DEFAULT_APPS = new ArrayList<>(); - @SideOnly(Side.CLIENT) - public static File TERMINAL_PATH; - - static { - if (FMLCommonHandler.instance().getSide().isClient()) { - TERMINAL_PATH = new File(Loader.instance().getConfigDir(), ConfigHolder.client.terminalRootPath); - } - } - - public static void init() { - // register hardware - registerHardware(new BatteryHardware()); - int deviceSize = DeviceHardware.DEVICE.values().length; - for (int i = 1; i < deviceSize; i++) { - registerHardware(new DeviceHardware(i)); - } - // register applications - AppRegistryBuilder.create(new SimpleMachineGuideApp()).defaultApp().build(); - AppRegistryBuilder.create(new MultiBlockGuideApp()).defaultApp().build(); - AppRegistryBuilder.create(new ItemGuideApp()).defaultApp().build(); - AppRegistryBuilder.create(new TutorialGuideApp()).defaultApp().build(); - AppRegistryBuilder.create(new GuideEditorApp()).defaultApp().build(); - AppRegistryBuilder.create(new SettingsApp()).defaultApp().build(); - AppRegistryBuilder.create(new CapeSelectorApp()).defaultApp().build(); - - AppRegistryBuilder.create(new TeleportApp()) - .battery(GTValues.ZPM, 10000) - .device(DeviceHardware.DEVICE.FIELD_GENERATOR_UV) - .build(); - - AppRegistryBuilder.create(new PongApp()) - .battery(GTValues.LV, 75) - .build(); - AppRegistryBuilder.create(new MazeApp()) - .battery(GTValues.LV, 150) - .build(); - AppRegistryBuilder.create(new MinesweeperApp()) - .battery(GTValues.LV, 150) - .build(); - - AppRegistryBuilder.create(new ProspectorApp(ProspectorMode.ORE)) - .battery(0, GTValues.LV, 640) - .battery(1, GTValues.LV, 640) - .battery(2, GTValues.MV, 1000) - .battery(3, GTValues.HV, 1500) - .battery(4, GTValues.HV, 1500) - .upgrade(0, MetaItems.SENSOR_LV.getStackForm(1)) - .upgrade(1, MetaItems.SENSOR_HV.getStackForm(1)) - .upgrade(2, MetaItems.SENSOR_EV.getStackForm(1)) - .upgrade(3, MetaItems.SENSOR_IV.getStackForm(1)) - .upgrade(4, MetaItems.SENSOR_LuV.getStackForm(1)) - .device(0, DeviceHardware.DEVICE.PROSPECTOR_LV) - .device(1, DeviceHardware.DEVICE.PROSPECTOR_LV) - .device(2, DeviceHardware.DEVICE.PROSPECTOR_LV) - .device(3, DeviceHardware.DEVICE.PROSPECTOR_HV) - .device(4, DeviceHardware.DEVICE.PROSPECTOR_HV) - .build(); - - AppRegistryBuilder.create(new ProspectorApp(ProspectorMode.FLUID)) - .battery(0, GTValues.MV, 1000) - .battery(1, GTValues.MV, 1000) - .battery(2, GTValues.HV, 1500) - .battery(3, GTValues.HV, 1500) - .battery(4, GTValues.HV, 1500) - .upgrade(0, MetaItems.SENSOR_HV.getStackForm(1)) - .upgrade(1, MetaItems.SENSOR_HV.getStackForm(3)) - .upgrade(2, MetaItems.SENSOR_EV.getStackForm(1)) - .upgrade(3, MetaItems.SENSOR_IV.getStackForm(1)) - .upgrade(4, MetaItems.SENSOR_LuV.getStackForm(1)) - .device(DeviceHardware.DEVICE.PROSPECTOR_HV) - .build(); - AppRegistryBuilder.create(new MultiBlockPreviewARApp()) - .battery(GTValues.LV, 128) - .device(DeviceHardware.DEVICE.CAMERA) - .upgrade(1, MetaItems.EMITTER_HV.getStackForm(4), MetaItems.WORKSTATION_EV.getStackForm(2)) - .defaultApp() - .build(); - if (Mods.JustEnoughItems.isModLoaded()) { - AppRegistryBuilder.create(new RecipeChartApp()) - .battery(GTValues.LV, 160) - .upgrade(0, new ItemStack(Items.PAPER, 32)) - .upgrade(1, new ItemStack(Items.PAPER, 64)) - .upgrade(2, MetaItems.RANDOM_ACCESS_MEMORY.getStackForm(16)) - .upgrade(3, MetaItems.RANDOM_ACCESS_MEMORY.getStackForm(32)) - .build(); - } - AppRegistryBuilder.create(new ConsoleApp()) - .battery(GTValues.LV, 500) - .device(DeviceHardware.DEVICE.WIRELESS) - .build(); - AppRegistryBuilder.create(new BatteryManagerApp()).defaultApp() - .battery(GTValues.ULV, 0) - .build(); - AppRegistryBuilder.create(new HardwareManagerApp()).defaultApp().build(); - AppRegistryBuilder.create(new AppStoreApp()).defaultApp().build(); - AppRegistryBuilder.create(new WorldProspectorARApp()) - .battery(GTValues.LV, 320) - .upgrade(0, MetaItems.EMITTER_LV.getStackForm(2)) - .upgrade(1, MetaItems.EMITTER_MV.getStackForm(2)) - .upgrade(2, MetaItems.EMITTER_HV.getStackForm(2)) - .device(DeviceHardware.DEVICE.CAMERA) - .build(); - AppRegistryBuilder.create(new VirtualTankApp()) - .battery(GTValues.MV, 500) - .device(DeviceHardware.DEVICE.WIRELESS) - .build(); - } - - @SideOnly(Side.CLIENT) - public static void initTerminalFiles() { - ((SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()) - .registerReloadListener(TerminalRegistry::onResourceManagerReload); - } - - @SideOnly(Side.CLIENT) - public static void onResourceManagerReload(IResourceManager resourceManager) { - FileUtility.extractJarFiles(String.format("/assets/%s/%s", GTValues.MODID, "terminal"), TERMINAL_PATH, false); - } - - public static void registerApp(AbstractApplication application) { - String name = application.getRegistryName(); - if (APP_REGISTER.containsKey(name)) { - GTLog.logger.warn("Duplicate APP registry names exist: {}", name); - return; - } - APP_REGISTER.put(name, application); - } - - public static void registerHardware(Hardware hardware) { - String name = hardware.getRegistryName(); - if (APP_REGISTER.containsKey(name)) { - GTLog.logger.warn("Duplicate APP registry names exist: {}", name); - return; - } - HW_REGISTER.put(name, hardware); - } - - public static void registerHardwareDemand(String name, boolean isDefaultApp, @NotNull List[] hardware, - @NotNull List[] upgrade) { - if (name != null && APP_REGISTER.containsKey(name)) { - if (isDefaultApp) { - DEFAULT_APPS.add(name); - } - APP_HW_DEMAND.put(name, hardware); - APP_UPGRADE_CONDITIONS.put(name, upgrade); - } else { - GTLog.logger.error("Not found the app {}", name); - } - } - - public static List getDefaultApps() { - return DEFAULT_APPS.stream().map(APP_REGISTER::get).collect(Collectors.toList()); - } - - public static Collection getAllApps() { - return APP_REGISTER.values(); - } - - public static AbstractApplication getApplication(String name) { - return APP_REGISTER.get(name); - } - - public static Collection getAllHardware() { - return HW_REGISTER.values(); - } - - public static Hardware getHardware(String name) { - return HW_REGISTER.get(name); - } - - public static List getAppHardwareDemand(String name, int tier) { - return APP_HW_DEMAND.get(name)[tier] != null ? APP_HW_DEMAND.get(name)[tier] : Collections.emptyList(); - } - - public static List getAppHardwareUpgradeConditions(String name, int tier) { - return APP_UPGRADE_CONDITIONS.get(name)[tier] != null ? APP_UPGRADE_CONDITIONS.get(name)[tier] : - Collections.emptyList(); - } - - private static class AppRegistryBuilder { - - AbstractApplication app; - boolean isDefaultApp; - BatteryHardware[] battery; - List[] hardware; - List[] upgrade; - - public static AppRegistryBuilder create(AbstractApplication app) { - AppRegistryBuilder builder = new AppRegistryBuilder(); - builder.app = app; - builder.battery = new BatteryHardware[app.getMaxTier() + 1]; - builder.hardware = new List[app.getMaxTier() + 1]; - builder.upgrade = new List[app.getMaxTier() + 1]; - return builder; - } - - public AppRegistryBuilder defaultApp() { - this.isDefaultApp = true; - return this; - } - - public AppRegistryBuilder battery(int batteryTier, long cost) { - BatteryHardware hw = new BatteryHardware.BatteryDemand(batteryTier, cost); - for (int i = 0; i <= app.getMaxTier(); i++) { - battery[i] = hw; - } - return this; - } - - public AppRegistryBuilder battery(int tier, int batteryTier, long cost) { - if (tier < battery.length) { - battery[tier] = new BatteryHardware.BatteryDemand(batteryTier, cost); - } - return this; - } - - public AppRegistryBuilder device(DeviceHardware.DEVICE... device) { - Hardware[] hw = Arrays.stream(device).map(DeviceHardware.DeviceDemand::new).toArray(Hardware[]::new); - for (int i = 0; i <= app.getMaxTier(); i++) { - this.hardware(i, hw); - } - return this; - } - - public AppRegistryBuilder device(int tier, DeviceHardware.DEVICE... device) { - this.hardware(tier, Arrays.stream(device).map(DeviceHardware.DeviceDemand::new).toArray(Hardware[]::new)); - return this; - } - - public AppRegistryBuilder hardware(Hardware... hardware) { - for (int i = 0; i <= app.getMaxTier(); i++) { - this.hardware(i, hardware); - } - return this; - } - - public AppRegistryBuilder hardware(int tier, Hardware... hardware) { - if (tier < this.hardware.length) { - this.hardware[tier] = new LinkedList<>(); - for (Hardware hw : hardware) { - this.hardware[tier].add(hw); - } - } - return this; - } - - public AppRegistryBuilder appendHardware(int tier, Hardware... hardware) { - if (tier < this.hardware.length) { - if (this.hardware[tier] == null) { - this.hardware[tier] = new LinkedList<>(); - } - for (Hardware hw : hardware) { - this.hardware[tier].add(hw); - } - } - return this; - } - - public AppRegistryBuilder upgrade(ItemStack... upgrade) { - ItemStack[] up = Arrays.stream(upgrade).toArray(ItemStack[]::new); - for (int i = 0; i <= app.getMaxTier(); i++) { - this.upgrade(i, up); - } - return this; - } - - public AppRegistryBuilder upgrade(int tier, ItemStack... upgrade) { - if (tier < this.upgrade.length) { - this.upgrade[tier] = new LinkedList<>(); - for (ItemStack up : upgrade) { - this.upgrade[tier].add(up); - } - } - return this; - } - - public void build() { - TerminalRegistry.registerApp(app); - for (int i = 0; i < hardware.length; i++) { - if (battery[i] != null) { - if (hardware[i] == null) { - hardware[i] = new LinkedList<>(); - } - hardware[i].add(battery[i]); - } - } - TerminalRegistry.registerHardwareDemand(app.getRegistryName(), isDefaultApp, hardware, upgrade); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/app/ARApplication.java b/src/main/java/gregtech/api/terminal/app/ARApplication.java deleted file mode 100644 index c5bd9a4e564..00000000000 --- a/src/main/java/gregtech/api/terminal/app/ARApplication.java +++ /dev/null @@ -1,104 +0,0 @@ -package gregtech.api.terminal.app; - -import gregtech.api.terminal.os.SystemCall; -import gregtech.common.items.behaviors.TerminalBehaviour; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/09/13 - * @Description: Application for AR. - * When AR is running, {@link #tickAR(EntityPlayer)} and {@link #drawARScreen(RenderWorldLastEvent)} will - * be called when you hold the terminal in one of your hands. - * Therefore, at most one AR app is active on the terminal at any one time. And when you open the terminal - * GUI it automatically closes the currently running AR. - * You have access to the app's NBT of the handheld terminal when the AR is active, to load configs, init - * and so on. - * Don't try to write NBT, you should always be aware that the AR is running on the client side. - * if you really want to do something on the server side when AR is running, plz send packets. Because - * it's always running on the client side!!!!!!!!!! - * (If you need data from NBT, dont forget to write nbt when closeApp {@link #closeApp()}) - */ -public abstract class ARApplication extends AbstractApplication { - - protected ItemStack heldStack; - - public ARApplication(String name) { - super(name); - } - - @Override - public int getAppTier() { - if (nbt != null) { - if (os != null) { - return super.getAppTier(); - } else if (TerminalBehaviour.isCreative(heldStack)) { - return getMaxTier(); - } - return Math.min(nbt.getInteger("_tier"), getMaxTier()); - } - return 0; - } - - @SideOnly(Side.CLIENT) - public final void setAROpened(ItemStack heldStack) { - this.heldStack = heldStack; - this.nbt = heldStack.getOrCreateSubCompound("terminal").getCompoundTag(getRegistryName()); - } - - @Override - public AbstractApplication initApp() { - openAR(); - return this; - } - - /** - * open Camera for this AR and shutdown. - * then, this AR will be in active and running on the client side. - * It is best to call it on both sides. - */ - protected final void openAR() { - os.tabletNBT.setString("_ar", getRegistryName()); - if (isClient) { - SystemCall.SHUT_DOWN.call(getOs(), true); - } - } - - /** - * this will be fired every time you first switch selected slot to the held terminal. - */ - @SideOnly(Side.CLIENT) - public void onAROpened() {} - - /** - * this will be fired when switch the current slot (terminal) to other slots or open this terminal. - */ - @SideOnly(Side.CLIENT) - public void onARClosed() { - nbt = null; - heldStack = null; - } - - /** - * Be careful! do not try to use non-static field or call a non-static function here. - * This method is called with the registered instance. - * {@link gregtech.api.terminal.TerminalRegistry#registerApp(AbstractApplication)} - */ - @SideOnly(Side.CLIENT) - public void tickAR(EntityPlayer player) {} - - /** - * Be careful! do not try to use non-static field or call a non-static function here. - * This method is called with the registered instance. - * {@link gregtech.api.terminal.TerminalRegistry#registerApp(AbstractApplication)} - */ - @SideOnly(Side.CLIENT) - public abstract void drawARScreen(RenderWorldLastEvent event); -} diff --git a/src/main/java/gregtech/api/terminal/app/AbstractApplication.java b/src/main/java/gregtech/api/terminal/app/AbstractApplication.java deleted file mode 100644 index 30f5878f829..00000000000 --- a/src/main/java/gregtech/api/terminal/app/AbstractApplication.java +++ /dev/null @@ -1,268 +0,0 @@ -package gregtech.api.terminal.app; - -import gregtech.api.gui.INativeWidget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ResourceHelper; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.gui.widgets.AnimaWidgetGroup; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.util.GTLog; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.items.behaviors.TerminalBehaviour; - -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; -import java.util.regex.Pattern; - -public abstract class AbstractApplication extends AnimaWidgetGroup { - - private static final Pattern NEW_LINE_PATTERN = Pattern.compile("\\\\n"); - - protected final String name; - protected TerminalOSWidget os; - protected boolean isClient; - protected NBTTagCompound nbt; - - public AbstractApplication(String name) { - super(Position.ORIGIN, new Size(TerminalOSWidget.DEFAULT_WIDTH, TerminalOSWidget.DEFAULT_HEIGHT)); - this.name = name; - } - - public AbstractApplication setOs(TerminalOSWidget os) { - this.os = os; - return this; - } - - public boolean canOpenMenuOnEdge() { - return true; - } - - /** - * App theme color - */ - public int getThemeColor() { - return name.hashCode() | 0xff000000; - } - - /** - * App Name - */ - public String getRegistryName() { - return name; - } - - public String getUnlocalizedName() { - return "gregtech.terminal.app_name." + name; - } - - /** - * App Icon - */ - public IGuiTexture getIcon() { - return TextureArea.fullImage("textures/gui/terminal/" + name + "/icon.png"); - } - - /** - * App Description - */ - @SideOnly(Side.CLIENT) - public String getDescription() { - if (I18n.hasKey("terminal." + getRegistryName() + ".description")) { - return NEW_LINE_PATTERN.matcher(I18n.format("terminal." + getRegistryName() + ".description")) - .replaceAll("\n"); - } - return I18n.format("terminal.app_name.description"); - } - - /** - * App Profile - */ - @SideOnly(Side.CLIENT) - public IGuiTexture getProfile() { - if (ResourceHelper.isResourceExist("textures/gui/terminal/" + name + "/profile.png")) { - return TextureArea.fullImage("textures/gui/terminal/" + name + "/profile.png"); - } - return getIcon(); - } - - /** - * App Banner - */ - @SideOnly(Side.CLIENT) - public IGuiTexture getBanner() { - if (ResourceHelper.isResourceExist("textures/gui/terminal/" + name + "/banner.png")) { - return TextureArea.fullImage("textures/gui/terminal/" + name + "/banner.png"); - } - return null; - } - - /** - * App Information for each tier - */ - @SideOnly(Side.CLIENT) - public String getTierInformation(int tier) { - if (I18n.hasKey("terminal." + name + ".tier." + tier)) { - return I18n.format("terminal." + name + ".tier." + tier); - } - return I18n.format("terminal.app_name.tier", tier); - } - - /** - * Will be called when try to open this app. you should return an instance here. - * Due to INative's poor synchronization, do not add the INativeWidget {@link INativeWidget} here. - * Instead, It's probably best not to initialize your app here. initialize should in initApp {@link #initApp()} - */ - public AbstractApplication createAppInstance(TerminalOSWidget os, boolean isClient, NBTTagCompound nbt) { - try { - AbstractApplication app = this.getClass().newInstance(); - app.isClient = isClient; - app.nbt = nbt; - return app; - } catch (InstantiationException | IllegalAccessException e) { - GTLog.logger.error("Error while create default app. {}", this.getClass(), e); - } - return null; - } - - /** - * init app here. you have access to os, isClient, nbt. - */ - public AbstractApplication initApp() { - return this; - } - - /** - * you should store the persistent data for both side here. - * - * @return nbt data. if its a clientSideApp and the nbt not null, this nbt should be synced to the server side. - */ - public NBTTagCompound closeApp() { - return null; - } - - /** - * Whether the app can run in the background when minimized. - */ - public boolean isBackgroundApp() { - return false; - } - - /** - * If it is a client side app, will block all action packets sent from client. - * If the app doesn't require server execution, it better be a client side app. - * For details about data synchronization, see {@link #closeApp()} - */ - public boolean isClientSideApp() { - return false; - } - - public TerminalOSWidget getOs() { - return os; - } - - /** - * Add components to menu bar. - * - * @see IMenuComponent - */ - public List getMenuComponents() { - return Collections.emptyList(); - } - - /** - * Whether the player can open this app. - */ - public boolean canPlayerUse(EntityPlayer player) { - return true; - } - - /** - * App Current Tier. Creative Terminal(return max tier) - */ - public int getAppTier() { - if (nbt != null) { - if (TerminalBehaviour.isCreative(getOs().itemStack)) { - return getMaxTier(); - } - return Math.min(nbt.getInteger("_tier"), getMaxTier()); - } - return 0; - } - - /** - * App Max Tier - */ - public int getMaxTier() { - return 0; - } - - @Override - protected void writeClientAction(int id, Consumer packetBufferWriter) { - if (!isClientSideApp()) { - super.writeClientAction(id, packetBufferWriter); - } - } - - /** - * read NBT from the local config folder. - */ - protected void loadLocalConfig(Consumer reader) { - if (isClient && reader != null) { - NBTTagCompound nbt = null; - try { - nbt = CompressedStreamTools.read( - new File(TerminalRegistry.TERMINAL_PATH, String.format("config/%S.nbt", getRegistryName()))); - } catch (IOException e) { - GTLog.logger.error("error while loading local nbt for {}", getRegistryName(), e); - } - if (nbt == null) { - nbt = new NBTTagCompound(); - } - reader.accept(nbt); - } - } - - /** - * Write NBT to the local config folder. - */ - protected void saveLocalConfig(Consumer writer) { - if (isClient && writer != null) { - NBTTagCompound nbt = new NBTTagCompound(); - try { - writer.accept(nbt); - if (!nbt.isEmpty()) { - CompressedStreamTools.safeWrite(nbt, new File(TerminalRegistry.TERMINAL_PATH, - String.format("config/%S.nbt", getRegistryName()))); - } - } catch (IOException e) { - GTLog.logger.error("error while saving local nbt for {}", getRegistryName(), e); - } - } - } - - /** - * Fired when you open this app or terminal's size updated. (maximize) - */ - public void onOSSizeUpdate(int width, int height) { - setSelfPosition( - Position.ORIGIN.add(new Position((width - getSize().width) / 2, (height - getSize().height) / 2))); - } - - public boolean canLaunchConcurrently(AbstractApplication application) { - return true; - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/CustomTabListRenderer.java b/src/main/java/gregtech/api/terminal/gui/CustomTabListRenderer.java deleted file mode 100644 index c3cf0733e93..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/CustomTabListRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -package gregtech.api.terminal.gui; - -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.tab.ITabInfo; -import gregtech.api.gui.widgets.tab.TabListRenderer; -import gregtech.api.util.Position; - -import net.minecraft.client.renderer.GlStateManager; - -import java.util.List; - -public class CustomTabListRenderer extends TabListRenderer { - - private final IGuiTexture unSelected; - private final IGuiTexture selected; - private final int width; - private final int height; - - public CustomTabListRenderer(IGuiTexture unSelected, IGuiTexture selected, int width, int height) { - this.unSelected = unSelected; - this.selected = selected; - this.width = width; - this.height = height; - } - - @Override - public void renderTabs(ModularUI gui, Position offset, List tabInfos, int guiWidth, int guiHeight, - int selectedTabIndex) { - int y = offset.y - height; - GlStateManager.color(gui.getRColorForOverlay(), gui.getGColorForOverlay(), gui.getBColorForOverlay(), 1.0F); - for (int i = 0; i < tabInfos.size(); i++) { - int x = offset.x + i * width; - if (selectedTabIndex == i && selected != null) { - tabInfos.get(i).renderTab(selected, x, y, width, height, true); - GlStateManager.color(gui.getRColorForOverlay(), gui.getGColorForOverlay(), gui.getBColorForOverlay(), - 1.0F); - } - if (selectedTabIndex != i && unSelected != null) { - tabInfos.get(i).renderTab(unSelected, x, y, width, height, false); - GlStateManager.color(gui.getRColorForOverlay(), gui.getGColorForOverlay(), gui.getBColorForOverlay(), - 1.0F); - } - } - } - - @Override - public int[] getTabPos(int guiWidth, int guiHeight, int tabIndex) { - return new int[] { width * guiWidth, -height, width, height }; - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/AnimaWidgetGroup.java b/src/main/java/gregtech/api/terminal/gui/widgets/AnimaWidgetGroup.java deleted file mode 100644 index acd2a58bed4..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/AnimaWidgetGroup.java +++ /dev/null @@ -1,111 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.function.Consumer; - -public abstract class AnimaWidgetGroup extends WidgetGroup { - - @SideOnly(Side.CLIENT) - protected Interpolator interpolator; - protected float scale = 1; - - public AnimaWidgetGroup(Position position, Size size) { - super(position, size); - } - - public AnimaWidgetGroup(int x, int y, int width, int height) { - super(new Position(x, y), new Size(width, height)); - } - - @Override - public void updateScreenOnFrame() { - if (interpolator != null) { - interpolator.update(); - } - super.updateScreenOnFrame(); - } - - @SideOnly(Side.CLIENT) - public final void maximizeWidget(Consumer callback) { - this.scale = 0; - setVisible(true); - interpolator = new Interpolator(0, 1, 10, Eases.LINEAR, - value -> scale = value.floatValue(), - value -> { - interpolator = null; - if (callback != null) { - callback.accept(this); - } - }); - interpolator.start(); - } - - @SideOnly(Side.CLIENT) - public final void minimizeWidget(Consumer callback) { - this.scale = 1; - interpolator = new Interpolator(1, 0, 10, Eases.LINEAR, - value -> scale = value.floatValue(), - value -> { - setVisible(false); - interpolator = null; - if (callback != null) { - callback.accept(this); - } - }); - interpolator.start(); - } - - @SideOnly(Side.CLIENT) - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @SideOnly(Side.CLIENT) - protected void hookDrawInForeground(int mouseX, int mouseY) { - super.drawInForeground(mouseX, mouseY); - } - - @Override - public final void drawInForeground(int mouseX, int mouseY) { - if (scale == 0) { - return; - } - if (scale != 1) { - GlStateManager.pushMatrix(); - GlStateManager.translate((this.gui.getScreenWidth() - this.gui.getScreenWidth() * scale) / 2, - (this.gui.getScreenHeight() - this.gui.getScreenHeight() * scale) / 2, 0); - GlStateManager.scale(scale, scale, 1); - hookDrawInForeground(0, 0); - GlStateManager.popMatrix(); - } else { - hookDrawInForeground(mouseX, mouseY); - } - } - - @Override - public final void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (scale == 0) { - return; - } - if (scale != 1) { - GlStateManager.pushMatrix(); - GlStateManager.translate((this.gui.getScreenWidth() - this.gui.getScreenWidth() * scale) / 2, - (this.gui.getScreenHeight() - this.gui.getScreenHeight() * scale) / 2, 0); - GlStateManager.scale(scale, scale, 1); - hookDrawInBackground(0, 0, partialTicks, context); - GlStateManager.popMatrix(); - } else { - hookDrawInBackground(mouseX, mouseY, partialTicks, context); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/ColorWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/ColorWidget.java deleted file mode 100644 index 673c049b5f6..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/ColorWidget.java +++ /dev/null @@ -1,305 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.TextFieldWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.MathHelper; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -public class ColorWidget extends WidgetGroup { - - private int red = 255; - private int green = 255; - private int blue = 255; - private int alpha = 255; - private Consumer onColorChanged; - private final int barWidth; - private final int barHeight; - private final CircleButtonWidget redButton; - private final CircleButtonWidget greenButton; - private final CircleButtonWidget blueButton; - private final CircleButtonWidget alphaButton; - private int lastMouseX; - private CircleButtonWidget dragged; - private Supplier colorSupplier; - private boolean isClient; - - public ColorWidget(int x, int y, int barWidth, int barHeight) { - super(new Position(x, y), new Size(barWidth + 35, 3 * (barHeight + 5) + 10)); - this.barWidth = barWidth; - this.barHeight = barHeight; - IGuiTexture textFieldBackground = new ColorRectTexture(0x9f000000); - TextFieldWidget redField = new TextFieldWidget(barWidth + 5, 0, 30, barHeight, textFieldBackground, null, null) - .setTextResponder((t) -> { - setRed(t.isEmpty() ? 0 : Integer.parseInt(t)); - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - writeClientAction(2, buffer -> buffer.writeInt(getColor())); - }, true) - .setTextSupplier(() -> Integer.toString(red), true) - .setValidator(ColorWidget::checkValid); - TextFieldWidget greenField = new TextFieldWidget(barWidth + 5, barHeight + 5, 30, barHeight, - textFieldBackground, null, null) - .setTextResponder((t) -> { - setGreen(t.isEmpty() ? 0 : Integer.parseInt(t)); - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - writeClientAction(2, buffer -> buffer.writeInt(getColor())); - }, true) - .setTextSupplier(() -> Integer.toString(green), true) - .setValidator(ColorWidget::checkValid); - TextFieldWidget blueField = new TextFieldWidget(barWidth + 5, (barHeight + 5) * 2, 30, barHeight, - textFieldBackground, null, null) - .setTextResponder((t) -> { - setBlue(t.isEmpty() ? 0 : Integer.parseInt(t)); - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - writeClientAction(2, buffer -> buffer.writeInt(getColor())); - }, true) - .setTextSupplier(() -> Integer.toString(blue), true) - .setValidator(ColorWidget::checkValid); - TextFieldWidget alphaField = new TextFieldWidget(barWidth + 5, (barHeight + 5) * 3, 30, barHeight, - textFieldBackground, null, null) - .setTextResponder((t) -> { - setAlpha(t.isEmpty() ? 0 : Integer.parseInt(t)); - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - writeClientAction(2, buffer -> buffer.writeInt(getColor())); - }, true) - .setTextSupplier(() -> Integer.toString(alpha), true) - .setValidator(ColorWidget::checkValid); - this.addWidget(redField); - this.addWidget(greenField); - this.addWidget(blueField); - this.addWidget(alphaField); - redButton = new CircleButtonWidget(barWidth, barHeight / 2, 4, 1, 0).setFill(0xffff0000).setStrokeAnima(-1); - greenButton = new CircleButtonWidget(barWidth, barHeight / 2 + barHeight + 5, 4, 1, 0).setFill(0xff00ff00) - .setStrokeAnima(-1); - blueButton = new CircleButtonWidget(barWidth, barHeight / 2 + 2 * (barHeight + 5), 4, 1, 0).setFill(0xff0000ff) - .setStrokeAnima(-1); - alphaButton = new CircleButtonWidget(barWidth, barHeight / 2 + 3 * (barHeight + 5), 4, 1, 0).setFill(-1) - .setStrokeAnima(-1); - this.addWidget(redButton); - this.addWidget(greenButton); - this.addWidget(blueButton); - this.addWidget(alphaButton); - } - - public ColorWidget setOnColorChanged(Consumer onColorChanged) { - this.onColorChanged = onColorChanged; - return this; - } - - public ColorWidget setColorSupplier(Supplier colorSupplier, boolean isClient) { - this.colorSupplier = colorSupplier; - this.isClient = isClient; - return this; - } - - public ColorWidget setStartColor(int color) { - setRed((color >> 16) & 0xFF); - setGreen((color >> 8) & 0xFF); - setBlue(color & 0xFF); - setAlpha((color >> 24) & 0xFF); - return this; - } - - public int getColor() { - return (alpha << 24) | (red << 16) | (green << 8) | (blue); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (!isClient && colorSupplier != null) { - int c = colorSupplier.get(); - int r = (c & 0x00ff0000) >>> 16; - int g = (c & 0x0000ff00) >>> 8; - int b = (c & 0x000000ff); - int a = (c & 0xff000000) >>> 24; - if (r != red || g != green || b != blue || a != alpha) { - setRed(r); - setGreen(g); - setBlue(b); - setAlpha(a); - writeUpdateInfo(2, buffer -> buffer.writeInt(c)); - } - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - if (isClient && colorSupplier != null) { - int c = colorSupplier.get(); - int r = (c & 0x00ff0000) >>> 16; - int g = (c & 0x0000ff00) >>> 8; - int b = (c & 0x000000ff); - int a = (c & 0xff000000) >>> 24; - if (r != red || g != green || b != blue || a != alpha) { - setRed(r); - setGreen(g); - setBlue(b); - setAlpha(a); - writeClientAction(2, buffer -> buffer.writeInt(c)); - } - } - } - - @Override - public void readUpdateInfo(int id, PacketBuffer buffer) { - handleColor(id, buffer); - } - - private void handleColor(int id, PacketBuffer buffer) { - if (id == 2) { - int c = buffer.readInt(); - int r = (c & 0x00ff0000) >>> 16; - int g = (c & 0x0000ff00) >>> 8; - int b = (c & 0x000000ff); - int a = (c & 0xff000000) >>> 24; - if (r != red || g != green || b != blue || a != alpha) { - setRed(r); - setGreen(g); - setBlue(b); - setAlpha(a); - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - } - } - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - handleColor(id, buffer); - } - - private void setRed(int red) { - if (this.red != red) { - this.red = red; - redButton.setSelfPosition(new Position(red * barWidth / 255 - 4, redButton.getSelfPosition().y)); - } - } - - private void setGreen(int green) { - if (this.green != green) { - this.green = green; - greenButton.setSelfPosition(new Position(green * barWidth / 255 - 4, greenButton.getSelfPosition().y)); - } - } - - private void setBlue(int blue) { - if (this.blue != blue) { - this.blue = blue; - blueButton.setSelfPosition(new Position(blue * barWidth / 255 - 4, blueButton.getSelfPosition().y)); - } - } - - private void setAlpha(int alpha) { - if (this.alpha != alpha) { - this.alpha = alpha; - alphaButton.setSelfPosition(new Position(alpha * barWidth / 255 - 4, alphaButton.getSelfPosition().y)); - } - } - - private static boolean checkValid(String input) { - if (input.length() > 3) return false; - if (input.isEmpty()) return true; - try { - int value = Integer.parseInt(input); - if (value >= 0 && value <= 255) { - return true; - } - } catch (Exception e) { - return false; - } - return false; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - drawGradientRect(x, y + 2, barWidth, 5, (255 << 24) | (0) | (green << 8) | (blue), - (255 << 24) | (255 << 16) | (green << 8) | (blue), true); - drawGradientRect(x, y + barHeight + 5 + 2, barWidth, 5, (255 << 24) | (red << 16) | (0) | (blue), - (255 << 24) | (red << 16) | (255 << 8) | (blue), true); - drawGradientRect(x, y + 2 * (barHeight + 5) + 2, barWidth, 5, (255 << 24) | (red << 16) | (green << 8) | (0), - (255 << 24) | (red << 16) | (green << 8) | (255), true); - drawGradientRect(x, y + 3 * (barHeight + 5) + 2, barWidth, 5, (0) | (red << 16) | (green << 8) | (blue), - (255 << 24) | (red << 16) | (green << 8) | (blue), true); - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - lastMouseX = mouseX; - dragged = null; - if (redButton.isMouseOverElement(mouseX, mouseY)) { - dragged = redButton; - return true; - } else if (greenButton.isMouseOverElement(mouseX, mouseY)) { - dragged = greenButton; - return true; - } else if (blueButton.isMouseOverElement(mouseX, mouseY)) { - dragged = blueButton; - return true; - } else if (alphaButton.isMouseOverElement(mouseX, mouseY)) { - dragged = alphaButton; - return true; - } - boolean flag = false; - for (int i = widgets.size() - 1; i >= 0; i--) { - Widget widget = widgets.get(i); - if (widget.isVisible() && widget.mouseClicked(mouseX, mouseY, button)) { - flag = true; - } - } - return flag; - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - int xDelta = mouseX - lastMouseX; - lastMouseX = mouseX; - if (dragged != null) { - int newX = MathHelper.clamp(dragged.getSelfPosition().x + 4 + xDelta, 0, barWidth); - if (dragged == redButton) { - setRed(newX * 255 / barWidth); - } else if (dragged == greenButton) { - setGreen(newX * 255 / barWidth); - } else if (dragged == blueButton) { - setBlue(newX * 255 / barWidth); - } else if (dragged == alphaButton) { - setAlpha(newX * 255 / barWidth); - } - if (onColorChanged != null) { - onColorChanged.accept(getColor()); - } - writeClientAction(2, buffer -> buffer.writeInt(getColor())); - dragged.setSelfPosition(new Position(newX - 4, dragged.getSelfPosition().y)); - return true; - } - return super.mouseDragged(mouseX, mouseY, button, timeDragged); - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - dragged = null; - return super.mouseReleased(mouseX, mouseY, button); - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/CustomPositionSizeWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/CustomPositionSizeWidget.java deleted file mode 100644 index a499d12ebb0..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/CustomPositionSizeWidget.java +++ /dev/null @@ -1,217 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.IDraggable; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import java.util.function.BiConsumer; - -public class CustomPositionSizeWidget extends Widget implements IDraggable { - - private Widget controlled; - private final int borderColor; - private final int hoverColor; - private final int border; - private boolean dragUp; - private boolean dragDown; - private boolean dragLeft; - private boolean dragRight; - private boolean dragPos; - - private BiConsumer onUpdated; - - public CustomPositionSizeWidget(Widget controlled, int borderColor, int hoverColor, int border) { - super(controlled.getSelfPosition(), controlled.getSize()); - this.controlled = controlled; - this.borderColor = borderColor; - this.hoverColor = hoverColor; - this.border = border; - } - - public CustomPositionSizeWidget(int borderColor, int hoverColor, int border) { - super(Position.ORIGIN, Size.ZERO); - this.borderColor = borderColor; - this.hoverColor = hoverColor; - this.border = border; - } - - public CustomPositionSizeWidget setControlled(Widget controlled) { - this.controlled = controlled; - if (controlled != null) { - this.setSelfPosition(controlled.getSelfPosition()); - this.setSize(controlled.getSize()); - } - return this; - } - - public Widget getControlled() { - return controlled; - } - - public CustomPositionSizeWidget setOnUpdated(BiConsumer onUpdated) { - this.onUpdated = onUpdated; - return this; - } - - @Override - public void updateScreen() { - if (controlled != null) { - Position pos = controlled.getSelfPosition(); - Size size = controlled.getSize(); - if (!this.getSelfPosition().equals(pos)) { - this.setSelfPosition(pos); - } - if (this.getSize().equals(size)) { - this.setSize(size); - } - } - } - - private boolean hoverUp(int x, int y, int width, int height, int mouseX, int mouseY) { - return isMouseOver(x, y, width / 5, border, mouseX, mouseY) || - isMouseOver(x + width * 2 / 5, y, width / 5, border, mouseX, mouseY) || - isMouseOver(x + width * 4 / 5, y, width / 5, border, mouseX, mouseY) || - isMouseOver(x, y, border, height / 5, mouseX, mouseY) || - isMouseOver(x + width - border, y, border, height / 5, mouseX, mouseY); - } - - private boolean hoverDown(int x, int y, int width, int height, int mouseX, int mouseY) { - return isMouseOver(x, y + height - border, width / 5, border, mouseX, mouseY) || - isMouseOver(x + width * 2 / 5, y + height - border, width / 5, border, mouseX, mouseY) || - isMouseOver(x + width * 4 / 5, y + height - border, width / 5, border, mouseX, mouseY) || - isMouseOver(x, y + height * 4 / 5, border, height / 5, mouseX, mouseY) || - isMouseOver(x + width - border, y + height * 4 / 5, border, height / 5, mouseX, mouseY); - } - - private boolean hoverLeft(int x, int y, int width, int height, int mouseX, int mouseY) { - return isMouseOver(x, y, border, height / 5, mouseX, mouseY) || - isMouseOver(x, y + height * 2 / 5, border, height / 5, mouseX, mouseY) || - isMouseOver(x, y + height * 4 / 5, border, height / 5, mouseX, mouseY) || - isMouseOver(x, y, width / 5, border, mouseX, mouseY) || - isMouseOver(x, y + height - border, width / 5, border, mouseX, mouseY); - } - - private boolean hoverRight(int x, int y, int width, int height, int mouseX, int mouseY) { - return isMouseOver(x + width - border, y, border, height / 5, mouseX, mouseY) || - isMouseOver(x + width - border, y + height * 2 / 5, border, height / 5, mouseX, mouseY) || - isMouseOver(x + width - border, y + height * 4 / 5, border, height / 5, mouseX, mouseY) || - isMouseOver(x + width * 4 / 5, y, width / 5, border, mouseX, mouseY) || - isMouseOver(x + width * 4 / 5, y + height - border, width / 5, border, mouseX, mouseY); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (controlled == null) return; - int x = controlled.getPosition().x; - int y = controlled.getPosition().y; - int width = controlled.getSize().width; - int height = controlled.getSize().height; - - boolean hoverUp = false; - boolean hoverDown = false; - boolean hoverLeft = false; - boolean hoverRight = false; - // UP - if (dragUp || hoverUp(x, y, width, height, mouseX, mouseY)) { - hoverUp = true; - } - if (dragDown || hoverDown(x, y, width, height, mouseX, mouseY)) { - hoverDown = true; - } - if (dragLeft || hoverLeft(x, y, width, height, mouseX, mouseY)) { - hoverLeft = true; - } - if (dragRight || hoverRight(x, y, width, height, mouseX, mouseY)) { - hoverRight = true; - } - // UP - drawSolidRect(x, y, width / 5, border, hoverUp && !hoverRight ? hoverColor : borderColor); - drawSolidRect(x + width * 2 / 5, y, width / 5, border, - hoverUp && !hoverLeft && !hoverRight ? hoverColor : borderColor); - drawSolidRect(x + width * 4 / 5, y, width / 5, border, hoverUp && !hoverLeft ? hoverColor : borderColor); - // DOWN - drawSolidRect(x, y + height - border, width / 5, border, hoverDown && !hoverRight ? hoverColor : borderColor); - drawSolidRect(x + width * 2 / 5, y + height - border, width / 5, border, - hoverDown && !hoverLeft && !hoverRight ? hoverColor : borderColor); - drawSolidRect(x + width * 4 / 5, y + height - border, width / 5, border, - hoverDown && !hoverLeft ? hoverColor : borderColor); - // LEFT - drawSolidRect(x, y, border, height / 5, hoverLeft && !hoverDown ? hoverColor : borderColor); - drawSolidRect(x, y + height * 2 / 5, border, height / 5, - hoverLeft && !hoverDown && !hoverUp ? hoverColor : borderColor); - drawSolidRect(x, y + height * 4 / 5, border, height / 5, hoverLeft && !hoverUp ? hoverColor : borderColor); - // RIGHT - drawSolidRect(x + width - border, y, border, height / 5, hoverRight && !hoverDown ? hoverColor : borderColor); - drawSolidRect(x + width - border, y + height * 2 / 5, border, height / 5, - hoverRight && !hoverDown && !hoverUp ? hoverColor : borderColor); - drawSolidRect(x + width - border, y + height * 4 / 5, border, height / 5, - hoverRight && !hoverUp ? hoverColor : borderColor); - } - - @Override - public boolean allowDrag(int mouseX, int mouseY, int button) { - if (controlled == null || !isActive()) return false; - int x = controlled.getPosition().x; - int y = controlled.getPosition().y; - int width = controlled.getSize().width; - int height = controlled.getSize().height; - if (isMouseOver(x, y, width, height, mouseX, mouseY)) { - // UP - dragUp = hoverUp(x, y, width, height, mouseX, mouseY); - // DOWN - dragDown = hoverDown(x, y, width, height, mouseX, mouseY); - // LEFT - dragLeft = hoverLeft(x, y, width, height, mouseX, mouseY); - // RIGHT - dragRight = hoverRight(x, y, width, height, mouseX, mouseY); - dragPos = !dragUp && !dragDown && !dragLeft && !dragRight; - return true; - } - return false; - } - - @Override - public boolean dragging(int mouseX, int mouseY, int deltaX, int deltaY) { - if (controlled == null || !isActive()) return false; - int width = controlled.getSize().width; - int height = controlled.getSize().height; - int addX = 0, addY = 0; - if (!dragPos) { - if (dragUp) { - addY = deltaY; - height = Math.max(1, height - deltaY); - } - if (dragDown) { - height = Math.max(1, height + deltaY); - } - if (dragLeft) { - addX = deltaX; - width = Math.max(1, width - deltaX); - } - if (dragRight) { - width = Math.max(1, width + deltaX); - } - controlled.addSelfPosition(addX, addY); - controlled.setSize(new Size(width, height)); - } else { - controlled.addSelfPosition(deltaX, deltaY); - } - if (onUpdated != null) { - onUpdated.accept(controlled.getSelfPosition(), controlled.getSize()); - } - this.setSelfPosition(controlled.getSelfPosition()); - this.setSize(controlled.getSize()); - return false; - } - - @Override - public void endDrag(int mouseX, int mouseY) { - dragDown = false; - dragUp = false; - dragLeft = false; - dragRight = false; - dragPos = false; - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/MachineSceneWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/MachineSceneWidget.java deleted file mode 100644 index 43fceb358f9..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/MachineSceneWidget.java +++ /dev/null @@ -1,345 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.metatileentity.multiblock.IMultiblockPart; -import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; -import gregtech.api.pattern.PatternMatchContext; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.FacingPos; -import gregtech.client.renderer.scene.FBOWorldSceneRenderer; -import gregtech.client.renderer.scene.WorldSceneRenderer; -import gregtech.client.utils.RenderUtil; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - -import javax.vecmath.Vector3f; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/08/23/19:21 - * @Description: - */ -public class MachineSceneWidget extends WidgetGroup { - - private static FBOWorldSceneRenderer worldSceneRenderer; - private boolean dragging; - private int lastMouseX; - private int lastMouseY; - private int currentMouseX; - private int currentMouseY; - private Vector3f center; - private float rotationYaw = 45; - private float rotationPitch; - private float zoom = 5; - private float alpha = 1f; - private boolean blendColor = true; - private Set cores; - private Set around; - private FacingPos hoveredFacingPos; - private FacingPos selectedFacingPos; - private BiConsumer onSelected; - - protected MetaTileEntity mte; - protected final BlockPos pos; - - public MachineSceneWidget(int x, int y, int width, int height, MetaTileEntity mte) { - this(x, y, width, height, mte.getPos()); - this.mte = mte; - updateScene(); - } - - public MachineSceneWidget(int x, int y, int width, int height, BlockPos pos) { - super(x, y, width, height); - this.pos = pos; - this.addWidget(new ScrollBarWidget(5, height - 13, width - 50, 8, 0, 1, 0.05f) - .setOnChanged(value -> alpha = value, true).setInitValue(1f)); - this.addWidget(new RectButtonWidget(width - 40, height - 15, 35, 12, 1) - .setToggleButton(new TextTexture("COLOR", -1), (c, b) -> blendColor = b) - .setValueSupplier(true, () -> blendColor) - .setColors(TerminalTheme.COLOR_7.getColor(), TerminalTheme.COLOR_F_1.getColor(), 0) - .setIcon(new TextTexture("ALPHA", -1))); - if (worldSceneRenderer != null) { - worldSceneRenderer.releaseFBO(); - worldSceneRenderer = null; - } - } - - public Set getCores() { - return cores; - } - - public Set getAround() { - return around; - } - - public static FBOWorldSceneRenderer getWorldSceneRenderer() { - return worldSceneRenderer; - } - - public MachineSceneWidget setOnSelected(BiConsumer onSelected) { - this.onSelected = onSelected; - return this; - } - - @SideOnly(Side.CLIENT) - private void renderBlockOverLay(WorldSceneRenderer renderer) { - hoveredFacingPos = null; - if (isMouseOverElement(currentMouseX, currentMouseY)) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - int resolutionWidth = worldSceneRenderer.getResolutionWidth(); - int resolutionHeight = worldSceneRenderer.getResolutionHeight(); - int mouseX = resolutionWidth * (currentMouseX - x) / width; - int mouseY = (int) (resolutionHeight * (1 - (currentMouseY - y) / (float) height)); - Vector3f hitPos = WorldSceneRenderer.unProject(mouseX, mouseY); - World world = renderer.world; - Vec3d eyePos = new Vec3d(renderer.getEyePos().x, renderer.getEyePos().y, renderer.getEyePos().z); - hitPos.scale(2); // Double view range to ensure pos can be seen. - Vec3d endPos = new Vec3d((hitPos.x - eyePos.x), (hitPos.y - eyePos.y), (hitPos.z - eyePos.z)); - double min = Float.MAX_VALUE; - for (BlockPos core : cores) { - IBlockState blockState = world.getBlockState(core); - if (blockState.getBlock() == Blocks.AIR) { - continue; - } - RayTraceResult hit = blockState.collisionRayTrace(world, core, eyePos, endPos); - if (hit != null && hit.typeOfHit != RayTraceResult.Type.MISS) { - double dist = eyePos.distanceTo(new Vec3d(hit.getBlockPos())); - if (dist < min) { - min = dist; - hoveredFacingPos = new FacingPos(hit.getBlockPos(), hit.sideHit); - } - } - } - } - if (selectedFacingPos != null || hoveredFacingPos != null) { - GlStateManager.pushMatrix(); - RenderUtil.useLightMap(240, 240, () -> { - GlStateManager.disableDepth(); - if (selectedFacingPos != null) { - drawFacingBorder(selectedFacingPos, 0xff00ff00); - } - if (hoveredFacingPos != null && !hoveredFacingPos.equals(selectedFacingPos)) { - drawFacingBorder(hoveredFacingPos, 0xffffffff); - } - GlStateManager.enableDepth(); - }); - GlStateManager.popMatrix(); - } - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, - GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, - GlStateManager.DestFactor.ZERO); - } - - private static void drawFacingBorder(FacingPos posFace, int color) { - GlStateManager.pushMatrix(); - RenderUtil.moveToFace(posFace.getPos().getX(), posFace.getPos().getY(), posFace.getPos().getZ(), - posFace.getFacing()); - RenderUtil.rotateToFace(posFace.getFacing(), null); - GlStateManager.scale(1f / 16, 1f / 16, 0); - GlStateManager.translate(-8, -8, 0); - Widget.drawBorder(1, 1, 14, 14, color, 1); - GlStateManager.popMatrix(); - } - - @Override - public void updateScreen() { - super.updateScreen(); - if (mte == null) { - World world = this.gui.entityPlayer.world; - TileEntity tileEntity = world.getTileEntity(pos); - if (tileEntity instanceof IGregTechTileEntity && - ((IGregTechTileEntity) tileEntity).getMetaTileEntity() != null) { - mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); - updateScene(); - } - } else if (!mte.isValid()) { - worldSceneRenderer.releaseFBO(); - worldSceneRenderer = null; - mte = null; - } - } - - private void updateScene() { - if (!mte.isValid()) return; - World world = mte.getWorld(); - if (worldSceneRenderer != null) { - worldSceneRenderer.releaseFBO(); - } - worldSceneRenderer = new FBOWorldSceneRenderer(world, 1080, 1080); - worldSceneRenderer.setAfterWorldRender(this::renderBlockOverLay); - cores = new HashSet<>(); - around = new HashSet<>(); - cores.add(pos); - if (mte instanceof MultiblockControllerBase multi && multi.isStructureFormed()) { - PatternMatchContext context = multi.structurePattern.checkPatternFastAt( - world, pos, mte.getFrontFacing().getOpposite(), multi.getUpwardsFacing(), multi.allowsFlip()); - if (context != null) { - List validPos = multi.structurePattern.cache.keySet().stream().map(BlockPos::fromLong) - .collect(Collectors.toList()); - Set parts = context.getOrCreate("MultiblockParts", HashSet::new); - for (IMultiblockPart part : parts) { - if (part instanceof MetaTileEntity) { - cores.add(((MetaTileEntity) part).getPos()); - } - } - for (EnumFacing facing : EnumFacing.VALUES) { - cores.forEach(pos -> around.add(pos.offset(facing))); - } - int minX = Integer.MAX_VALUE; - int minY = Integer.MAX_VALUE; - int minZ = Integer.MAX_VALUE; - int maxX = Integer.MIN_VALUE; - int maxY = Integer.MIN_VALUE; - int maxZ = Integer.MIN_VALUE; - for (BlockPos vPos : validPos) { - around.add(vPos); - minX = Math.min(minX, vPos.getX()); - minY = Math.min(minY, vPos.getY()); - minZ = Math.min(minZ, vPos.getZ()); - maxX = Math.max(maxX, vPos.getX()); - maxY = Math.max(maxY, vPos.getY()); - maxZ = Math.max(maxZ, vPos.getZ()); - } - around.removeAll(cores); - center = new Vector3f((minX + maxX) / 2f, (minY + maxY) / 2f, (minZ + maxZ) / 2f); - } else { - for (EnumFacing facing : EnumFacing.VALUES) { - around.add(pos.offset(facing)); - } - center = new Vector3f(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f); - } - } else { - for (EnumFacing facing : EnumFacing.VALUES) { - around.add(pos.offset(facing)); - } - center = new Vector3f(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f); - } - worldSceneRenderer.addRenderedBlocks(cores, null); - worldSceneRenderer.addRenderedBlocks(around, this::aroundBlocksRenderHook); - worldSceneRenderer.setCameraLookAt(center, zoom, Math.toRadians(rotationPitch), Math.toRadians(rotationYaw)); - } - - private void aroundBlocksRenderHook(boolean isTESR, int pass, BlockRenderLayer layer) { - GlStateManager.color(1, 1, 1, 1); - GlStateManager.enableDepth(); - GlStateManager.enableBlend(); - if (blendColor) { - GlStateManager.tryBlendFuncSeparate( - GlStateManager.SourceFactor.CONSTANT_ALPHA, GlStateManager.DestFactor.CONSTANT_COLOR, - GlStateManager.SourceFactor.CONSTANT_ALPHA, GlStateManager.DestFactor.DST_ALPHA); - } else { - GlStateManager.blendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA); - } - GL14.glBlendColor(1, 1, 1, alpha); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (super.mouseClicked(mouseX, mouseY, button)) { - return true; - } - if (isMouseOverElement(mouseX, mouseY)) { - dragging = true; - lastMouseX = mouseX; - lastMouseY = mouseY; - if (hoveredFacingPos != null && !hoveredFacingPos.equals(selectedFacingPos)) { - selectedFacingPos = hoveredFacingPos; - if (onSelected != null) { - onSelected.accept(selectedFacingPos.getPos(), selectedFacingPos.getFacing()); - } - } - return true; - } - dragging = false; - return false; - } - - @Override - public boolean mouseWheelMove(int mouseX, int mouseY, int wheelDelta) { - if (isMouseOverElement(mouseX, mouseY)) { - zoom = (float) MathHelper.clamp(zoom + (wheelDelta < 0 ? 0.5 : -0.5), 3, 999); - if (worldSceneRenderer != null) { - worldSceneRenderer.setCameraLookAt(center, zoom, Math.toRadians(rotationPitch), - Math.toRadians(rotationYaw)); - } - } - return super.mouseWheelMove(mouseX, mouseY, wheelDelta); - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - if (dragging) { - rotationPitch += mouseX - lastMouseX + 360; - rotationPitch = rotationPitch % 360; - rotationYaw = (float) MathHelper.clamp(rotationYaw + (mouseY - lastMouseY), -89.9, 89.9); - lastMouseY = mouseY; - lastMouseX = mouseX; - if (worldSceneRenderer != null) { - worldSceneRenderer.setCameraLookAt(center, zoom, Math.toRadians(rotationPitch), - Math.toRadians(rotationYaw)); - } - return true; - } - return super.mouseDragged(mouseX, mouseY, button, timeDragged); - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - dragging = false; - return super.mouseReleased(mouseX, mouseY, button); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - drawSolidRect(x, y, width, height, 0xaf000000); - if (worldSceneRenderer != null) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - worldSceneRenderer.render(x, y, width, height, mouseX - x, mouseY - y); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } - drawBorder(x + 1, y + 1, width - 2, height - 2, 0xff000000, 1); - if (mte != null) { - drawStringSized(I18n.format(mte.getMetaFullName()), x + width / 2f, y + 10, -1, true, 1, true); - } - super.drawInBackground(mouseX, mouseY, partialTicks, context); - currentMouseX = mouseX; - currentMouseY = mouseY; - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/ScrollBarWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/ScrollBarWidget.java deleted file mode 100644 index 619fd1cbd6d..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/ScrollBarWidget.java +++ /dev/null @@ -1,137 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.MathHelper; - -import java.util.function.Consumer; - -public class ScrollBarWidget extends Widget { - - protected final float min; - protected final float max; - protected final float dur; - protected int xOffset; - protected boolean draggedOnScrollBar; - protected IGuiTexture background; - protected IGuiTexture buttonTexture; - protected int buttonWidth; - protected int buttonHeight; - protected Consumer onChanged; - protected boolean isClient; - - public ScrollBarWidget(int x, int y, int width, int height, float min, float max, float dur) { - super(new Position(x, y), new Size(width, height)); - this.max = max; - this.min = min; - this.dur = dur; - this.xOffset = width / 2; - this.buttonTexture = new ColorRectTexture(-1); - this.buttonWidth = Math.max((int) (width / ((max - min) / dur)), 5); - this.buttonHeight = height; - } - - public ScrollBarWidget setOnChanged(Consumer onChanged, boolean isClient) { - this.onChanged = onChanged; - this.isClient = isClient; - return this; - } - - public ScrollBarWidget setBackground(IGuiTexture background) { - this.background = background; - return this; - } - - public ScrollBarWidget setInitValue(float value) { - if (value >= min && value <= max) { - this.xOffset = (int) ((value - min) / (max - min) * (this.getSize().width - buttonWidth)); - } - return this; - } - - public ScrollBarWidget setButtonTexture(TextureArea buttonTexture, int buttonWidth, int buttonHeight) { - this.buttonTexture = buttonTexture; - this.buttonWidth = buttonWidth; - this.buttonHeight = buttonHeight; - return this; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - if (this.background != null) { - this.background.draw(x, y, width, height); - } else { - drawBorder(x - 1, y - 1, width + 2, height + 2, -1, 1); - } - if (this.buttonTexture != null) { - this.buttonTexture.draw(x + xOffset, y + (height - buttonHeight) / 2f, buttonWidth, buttonHeight); - } - } - - private boolean isOnScrollPane(int mouseX, int mouseY) { - Position position = this.getPosition(); - Size size = this.getSize(); - return isMouseOver(position.x, position.y, size.width, buttonHeight, mouseX, mouseY); - } - - private float getValue() { - return (float) (min + - Math.floor((max - min) * xOffset * 1.0f / (this.getSize().width - buttonWidth) / dur) * dur); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (this.isOnScrollPane(mouseX, mouseY)) { - this.xOffset = MathHelper.clamp(mouseX - this.getPosition().x - buttonWidth / 2, 0, - this.getSize().width - buttonWidth); - this.draggedOnScrollBar = true; - } - return this.isMouseOverElement(mouseX, mouseY); - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - if (draggedOnScrollBar) { - this.xOffset = MathHelper.clamp(mouseX - this.getPosition().x - buttonWidth / 2, 0, - this.getSize().width - buttonWidth); - if (onChanged != null) { - onChanged.accept(getValue()); - } - return true; - } - return false; - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - if (this.draggedOnScrollBar) { - if (!isClient) { - this.writeClientAction(2, packetBuffer -> packetBuffer.writeFloat(getValue())); - } - } - this.draggedOnScrollBar = false; - return this.isMouseOverElement(mouseX, mouseY); - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - super.handleClientAction(id, buffer); - if (id == 2) { - float value = buffer.readFloat(); - if (this.onChanged != null) { - onChanged.accept(value); - } - } - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/TextEditorWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/TextEditorWidget.java deleted file mode 100644 index 4837420bcc5..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/TextEditorWidget.java +++ /dev/null @@ -1,463 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.ChatAllowedCharacters; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class TextEditorWidget extends WidgetGroup { - - private static final TextureArea PALETTE = TextureArea.fullImage("textures/gui/widget/palette.png"); - private static final TextureArea STYLE = TextureArea.fullImage("textures/gui/widget/formatting.png"); - private final TextPanelWidget textPanelWidget; - - private static final Pattern COMMENT = Pattern.compile("(//.*|/\\*[\\s\\S]*?\\*/)|(#.*)"); - private static final Pattern STRING = Pattern - .compile("(\"(?:[^\"\\\\]|\\\\[\\s\\S])*\"|'(?:[^'\\\\]|\\\\[\\s\\S])*')"); - private static final Pattern BOOL = Pattern.compile("\\b(true|false|null|undefined|NaN)\\b"); - private static final Pattern KEYWORD = Pattern.compile( - "\\b(import|var|for|if|else|return|this|while|new|function|switch|case|typeof|do|in|throw|try|catch|finally|with|instance|delete|void|break|continue)\\b"); - private static final Pattern KEYWORD_2 = Pattern.compile( - "\\b(String|int|long|boolean|float|double|byte|short|document|Date|Math|window|Object|location|navigator|Array|Number|Boolean|Function|RegExp)\\b"); - private static final Pattern VARIABLE = Pattern.compile("(?:[^\\W\\d]|\\$)[\\$\\w]*"); - private static final Pattern NUMBER = Pattern - .compile("(0[xX][0-9a-fA-F]+|\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|\\.\\d+(?:[eE][+-]?\\d+)?)"); - private static final Pattern ANY = Pattern.compile("[\\s\\S]"); - - public TextEditorWidget(int x, int y, int width, int height, Consumer stringUpdate, boolean allowToolBox) { - super(new Position(x, y), - new Size(Math.max(width, allowToolBox ? 80 : width), Math.max(height, allowToolBox ? 32 : height))); - textPanelWidget = new TextPanelWidget(0, 32, Math.max(width, allowToolBox ? 80 : width), - Math.max(height, allowToolBox ? 32 : height) - 32, stringUpdate); - this.addWidget(textPanelWidget); - if (allowToolBox) { - initToolBox(); - } - } - - public TextEditorWidget setBackground(IGuiTexture background) { - textPanelWidget.setBackground(background); - return this; - } - - public TextEditorWidget setContent(String content) { - textPanelWidget.pageSetCurrent(content); - return this; - } - - @Override - public void setActive(boolean active) { - super.setActive(active); - textPanelWidget.setActive(active); - } - - private void initToolBox() { - TextFormatting[] formatting = TextFormatting.values(); - // palette - for (int y = 0; y < 4; y++) { - for (int x = 0; x < 4; x++) { - TextFormatting colorFormatting = formatting[y * 4 + x]; - this.addWidget(new RectButtonWidget(x * 8, y * 8, 8, 8, 1) - .setToggleButton(PALETTE.getSubArea(0.5 + x * 0.125, y * 0.25, 0.125, 0.25), - (cd, pressed) -> { - if (pressed) { - textPanelWidget.addFormatting(colorFormatting); - } else { - textPanelWidget.removeFormatting(colorFormatting); - } - }) - .setValueSupplier(true, () -> colorFormatting == textPanelWidget.getFrontColorFormatting()) - .setIcon(PALETTE.getSubArea(x * 0.125, y * 0.25, 0.125, 0.25)) - .setColors(0, -1, 0) - .setHoverText(colorFormatting.getFriendlyName())); - } - } - // style - for (int y = 0; y < 2; y++) { - for (int x = 0; x < 3; x++) { - TextFormatting styleFormatting = formatting[16 + y * 3 + x]; - if (styleFormatting == TextFormatting.RESET) break; - this.addWidget(new RectButtonWidget(x * 16 + 32, y * 16, 16, 16, 1) - .setToggleButton(STYLE.getSubArea(0.5 + x * 1.0 / 6, y * 0.5, 1.0 / 6, 0.5), - (cd, pressed) -> { - if (pressed) { - textPanelWidget.addFormatting(styleFormatting); - } else { - textPanelWidget.removeFormatting(styleFormatting); - } - }) - .setValueSupplier(true, - () -> textPanelWidget.getFrontStyleFormatting().contains(styleFormatting)) - .setIcon(STYLE.getSubArea(x * 1.0 / 6, y * 0.5, 1.0 / 6, 0.5)) - .setColors(0, -1, 0) - .setHoverText(styleFormatting.getFriendlyName())); - } - } - this.addWidget(new RectButtonWidget(3 * 16 + 32, 0, 16, 16, 3) - .setToggleButton(new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()), - (c, p) -> textPanelWidget.allowMarkdown = !p) - .setValueSupplier(true, () -> !textPanelWidget.allowMarkdown) - .setColors(TerminalTheme.COLOR_B_3.getColor(), TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_3.getColor()) - .setIcon(new ColorRectTexture(TerminalTheme.COLOR_7.getColor())) - .setHoverText("Check Markdown when Ctrl+V")); - this.addWidget(new RectButtonWidget(3 * 16 + 32, 16, 16, 16, 3) - .setClickListener(clickData -> textPanelWidget.pageSetCurrent("")) - .setColors(TerminalTheme.COLOR_B_3.getColor(), TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_3.getColor()) - .setIcon(new ColorRectTexture(TerminalTheme.COLOR_7.getColor())) - .setHoverText("Clean Up")); - } - - private static class TextPanelWidget extends DraggableScrollableWidgetGroup { - - public final static int SPACE = 0; - public int updateCount; - public String content; - public int textHeight; - public final Consumer stringUpdate; - public TextFormatting frontColor; - public List frontStyle; - public boolean allowMarkdown; - - private static final char SECTION_SIGN = '\u00A7'; - - @SideOnly(Side.CLIENT) - public FontRenderer fontRenderer; - @SideOnly(Side.CLIENT) - private static final Pattern R_CODE_PATTERN = Pattern.compile("(?i)" + SECTION_SIGN + "[R]"); - @SideOnly(Side.CLIENT) - private static final Pattern COLOR_CODE_PATTERN = Pattern.compile("(?i)" + SECTION_SIGN + "[0-9A-F]"); - - public TextPanelWidget(int x, int y, int width, int height, Consumer stringUpdate) { - super(x, y, width, height); - this.stringUpdate = stringUpdate; - this.content = ""; - this.allowMarkdown = true; - if (isClientSide()) { - fontRenderer = Minecraft.getMinecraft().fontRenderer; - textHeight = fontRenderer.getWordWrappedHeight(content, width - yBarWidth); - frontColor = null; - frontStyle = new ArrayList<>(); - } - } - - @Override - public int getMaxHeight() { - return textHeight + SPACE + xBarHeight; - } - - public void updateScreen() { - super.updateScreen(); - ++this.updateCount; - } - - @Override - public boolean keyTyped(char typedChar, int keyCode) { - if (!focus || !isActive()) return false; - if (GuiScreen.isKeyComboCtrlV(keyCode)) { - this.pageInsertIntoCurrent(allowMarkdown ? formatFromMarkdown(GuiScreen.getClipboardString()) : - GuiScreen.getClipboardString()); - findFrontFormatting(); - } else { - switch (keyCode) { - case 14: - if (!content.isEmpty()) { - this.pageSetCurrent(content.substring(0, content.length() - 1)); - } - break; - case 28: - case 156: - this.pageInsertIntoCurrent("\n"); - break; - default: - if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) { - this.pageInsertIntoCurrent(Character.toString(typedChar)); - } - } - } - if (getMaxHeight() > getSize().height) { - setScrollYOffset(getMaxHeight() - getSize().height); - } else { - setScrollYOffset(0); - } - return true; - } - - private static String formatFromMarkdown(String markdown) { - StringBuilder builder = new StringBuilder(); - Deque stack = new ArrayDeque<>(); - int[] chars = markdown.chars().toArray(); - for (int i = 0; i < chars.length; i++) { - if (chars[i] == '\\' && i + 1 < chars.length) { - if (chars[i + 1] == '*' || chars[i + 1] == '_' || chars[i + 1] == '~' || chars[i + 1] == '`') { - builder.append(chars[i + 1]); - i++; - } else { - builder.append('\\'); - } - } else if (chars[i] == '*' && i + 1 < chars.length && chars[i + 1] == ' ') { // SUBLINE - builder.append(' ').append(TextFormatting.BOLD).append('*').append(TextFormatting.RESET) - .append(' '); - i++; - } else if (chars[i] == '*' && i + 1 < chars.length && chars[i + 1] == '*') { // BOLD - checkTextFormatting(builder, TextFormatting.BOLD, stack); - i++; - } else if (chars[i] == '_') { - if (i - 1 == -1 || !Character.isLetterOrDigit(chars[i - 1])) { // ITALIC - checkTextFormatting(builder, TextFormatting.ITALIC, stack); - } else if (i + 1 == chars.length || !Character.isLetterOrDigit(chars[i + 1])) { - checkTextFormatting(builder, TextFormatting.ITALIC, stack); - } else { - builder.append('_'); - } - } else if (chars[i] == '~') { // STRIKETHROUGH - checkTextFormatting(builder, TextFormatting.STRIKETHROUGH, stack); - } else if (chars[i] == '`' && i + 1 < chars.length && chars[i + 1] == '`' && i + 2 < chars.length && - chars[i + 2] == '`') { // code - boolean find = false; - for (int j = i + 3; j < chars.length - 2; j++) { - if (chars[j] == '`' && chars[j + 1] == '`' && chars[j + 2] == '`') { - find = true; - builder.append(checkCode(markdown.substring(i + 3, j))); - i += j - i; - } - } - if (!find) { - builder.append("```"); - } - i += 2; - } else - if (chars[i] == '`') { - checkTextFormatting(builder, TextFormatting.UNDERLINE, stack); - } else { - builder.append((char) chars[i]); - } - } - return builder.toString(); - } - - private static String checkCode(String code) { - Pattern[] patterns = new Pattern[] { COMMENT, STRING, BOOL, KEYWORD, KEYWORD_2, VARIABLE, NUMBER, ANY }; - TextFormatting[] colors = new TextFormatting[] { - TextFormatting.DARK_GRAY, // comment - TextFormatting.DARK_GREEN, // string - TextFormatting.RED, // value - TextFormatting.BLUE, // keyword - TextFormatting.LIGHT_PURPLE, // keyword2 - TextFormatting.BLACK, // variable - TextFormatting.RED, // variable - TextFormatting.DARK_PURPLE }; // else - StringBuilder builder = new StringBuilder(); - while (code.length() > 0) { - boolean find = false; - for (int i = 0; i < patterns.length; i++) { - Matcher matcher = patterns[i].matcher(code); - if (matcher.find() && matcher.start() == 0) { - builder.append(colors[i]).append(code, 0, matcher.end()).append(TextFormatting.RESET); - find = true; - code = code.substring(matcher.end()); - break; - } - } - if (!find) { - builder.append(code.charAt(0)); - code = code.substring(1); - } - } - return builder.toString(); - } - - private static void checkTextFormatting(StringBuilder builder, TextFormatting formatting, - Deque stack) { - if (!stack.isEmpty() && stack.peek() == formatting) { - builder.append(TextFormatting.RESET); - stack.pop(); - for (TextFormatting pre : stack) { - builder.append(pre.toString()); - } - } else { - stack.push(formatting); - builder.append(formatting.toString()); - } - } - - private static TextFormatting lookAheadChars(final String content, int index) { - if (index > 1 && content.charAt(index - 2) == SECTION_SIGN) { - int t = content.charAt(index - 1); - if ('0' <= t && t <= '9') { - return TextFormatting.values()[t - '0']; - } else if ('a' <= t && t <= 'f') { - return TextFormatting.values()[t - 'a' + 10]; - } else if ('k' <= t && t <= 'o') { - return TextFormatting.values()[t - 'k' + 16]; - } else if (t == 'r') { - return TextFormatting.values()[21]; - } - } - return null; - } - - public static String cleanUpFormatting(final String content) { - Set removed = new HashSet<>(); - Matcher marcher = R_CODE_PATTERN.matcher(content); - while (marcher.find()) { - int index = marcher.start(); - while (index > 1) { - TextFormatting ahead = lookAheadChars(content, index); - if (ahead != null) { - removed.add(index - 2); - } else { - break; - } - index -= 2; - } - } - marcher = COLOR_CODE_PATTERN.matcher(content); - while (marcher.find()) { - int index = marcher.start(); - while (index > 1) { - TextFormatting ahead = lookAheadChars(content, index); - if (ahead == null) { - break; - } else if (TextFormatting.RESET != ahead) { - if (!removed.add(index - 2)) { - break; - } - } else { - break; - } - index -= 2; - } - } - StringBuilder builder = new StringBuilder(); - AtomicInteger start = new AtomicInteger(); - removed.stream().sorted().forEach(remove -> { - builder.append(content, start.get(), remove); - start.set(remove + 2); - }); - builder.append(content, start.get(), content.length()); - return builder.toString(); - } - - private void findFrontFormatting() { - int lastReset = content.lastIndexOf(SECTION_SIGN + "r"); - int lastColor = -1; - frontColor = null; - frontStyle.clear(); - for (TextFormatting value : TextFormatting.values()) { - int index = content.lastIndexOf(value.toString()); - if (index > lastReset) { - if (value.isColor()) { - if (index > lastColor) { - lastColor = index; - frontColor = value; - } - } else if (value.isFancyStyling() && index > lastColor) { - frontStyle.add(value); - } - } - } - } - - public void addFormatting(TextFormatting formatting) { - if (formatting.isColor()) { - frontColor = formatting; - pageInsertIntoCurrent(formatting.toString()); - for (TextFormatting style : frontStyle) { - pageInsertIntoCurrent(style.toString()); - } - } else if (formatting.isFancyStyling()) { - if (frontStyle.contains(formatting)) { - return; - } - frontStyle.add(formatting); - pageInsertIntoCurrent(formatting.toString()); - } - } - - public void removeFormatting(TextFormatting formatting) { - if (formatting.isColor()) { - frontColor = null; - pageInsertIntoCurrent(TextFormatting.RESET.toString()); - frontStyle.forEach(style -> pageInsertIntoCurrent(style.toString())); - } else if (formatting.isFancyStyling()) { - pageInsertIntoCurrent(TextFormatting.RESET.toString()); - if (frontColor != null) { - pageInsertIntoCurrent(frontColor.toString()); - } - frontStyle.remove(formatting); - frontStyle.forEach(style -> pageInsertIntoCurrent(style.toString())); - } - } - - public TextFormatting getFrontColorFormatting() { - return frontColor; - } - - public List getFrontStyleFormatting() { - return frontStyle; - } - - public void pageSetCurrent(String string) { - if (!content.equals(string)) { - content = cleanUpFormatting(string); - findFrontFormatting(); - if (stringUpdate != null) { - stringUpdate.accept(content); - } - textHeight = this.fontRenderer.getWordWrappedHeight(content + TextFormatting.BLACK + "_", - this.getSize().width - yBarWidth); - } - } - - public void pageInsertIntoCurrent(String string) { - content = cleanUpFormatting(content + string); - if (stringUpdate != null) { - stringUpdate.accept(content); - } - textHeight = this.fontRenderer.getWordWrappedHeight(content + TextFormatting.BLACK + "_", - this.getSize().width - yBarWidth); - } - - @Override - public boolean hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - String contentString = content; - if (focus && isActive()) { - if (this.fontRenderer.getBidiFlag()) { - contentString += "_"; - } else if (this.updateCount / 6 % 2 == 0) { - contentString += TextFormatting.BLACK + "_"; - } else { - contentString += TextFormatting.GRAY + "_"; - } - } - int x = getPosition().x - scrollXOffset; - int y = getPosition().y + SPACE - scrollYOffset; - for (String textLine : this.fontRenderer.listFormattedStringToWidth(contentString, - getSize().width - yBarWidth)) { - fontRenderer.drawString(textLine, x, y, 0xff000000, false); - y += fontRenderer.FONT_HEIGHT; - } - return true; - } - } -} diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/TreeListWidget.java b/src/main/java/gregtech/api/terminal/gui/widgets/TreeListWidget.java deleted file mode 100644 index 45e5c12d55e..00000000000 --- a/src/main/java/gregtech/api/terminal/gui/widgets/TreeListWidget.java +++ /dev/null @@ -1,247 +0,0 @@ -package gregtech.api.terminal.gui.widgets; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.terminal.util.TreeNode; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.client.utils.RenderUtil; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.math.MathHelper; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; - -public class TreeListWidget extends Widget { - - private static final int ITEM_HEIGHT = 11; - protected int scrollOffset; - protected List> list; - protected TreeNode selected; - protected IGuiTexture background; - protected IGuiTexture nodeTexture; - protected IGuiTexture leafTexture; - protected Consumer> onSelected; - protected Function keyIconSupplier; - protected Function keyNameSupplier; - protected Function contentIconSupplier; - protected Function contentNameSupplier; - protected boolean canSelectNode; - private int tick; - - public TreeListWidget(int xPosition, int yPosition, int width, int height, - TreeNode root, - Consumer> onSelected) { - super(new Position(xPosition, yPosition), new Size(width, height)); - list = new ArrayList<>(); - if (root.getChildren() != null) { - list.addAll(root.getChildren()); - } - this.onSelected = onSelected; - } - - public TreeListWidget canSelectNode(boolean canSelectNode) { - this.canSelectNode = canSelectNode; - return this; - } - - public TreeListWidget setBackground(IGuiTexture background) { - this.background = background; - return this; - } - - public TreeListWidget setNodeTexture(IGuiTexture nodeTexture) { - this.nodeTexture = nodeTexture; - return this; - } - - public TreeListWidget setLeafTexture(IGuiTexture leafTexture) { - this.leafTexture = leafTexture; - return this; - } - - public TreeListWidget setContentIconSupplier(Function iconSupplier) { - contentIconSupplier = iconSupplier; - return this; - } - - public TreeListWidget setKeyIconSupplier(Function iconSupplier) { - keyIconSupplier = iconSupplier; - return this; - } - - public TreeListWidget setContentNameSupplier(Function nameSupplier) { - contentNameSupplier = nameSupplier; - return this; - } - - public TreeListWidget setKeyNameSupplier(Function nameSupplier) { - keyNameSupplier = nameSupplier; - return this; - } - - @Override - public void updateScreen() { - tick++; - } - - @Override - public boolean mouseWheelMove(int mouseX, int mouseY, int wheelDelta) { - if (this.isMouseOverElement(mouseX, mouseY)) { - int moveDelta = -MathHelper.clamp(wheelDelta, -1, 1) * 5; - this.scrollOffset = MathHelper.clamp(scrollOffset + moveDelta, 0, - Math.max(list.size() * ITEM_HEIGHT - getSize().height, 0)); - return true; - } - return false; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - if (background != null) { - background.draw(x, y, width, height); - } else { - drawGradientRect(x, y, width, height, 0x8f000000, 0x8f000000); - } - RenderUtil.useScissor(x, y, width, height, () -> { - FontRenderer fr = Minecraft.getMinecraft().fontRenderer; - int minToRender = scrollOffset / ITEM_HEIGHT; - int maxToRender = Math.min(list.size(), height / ITEM_HEIGHT + 2 + minToRender); - for (int i = minToRender; i < maxToRender; i++) { - GlStateManager.color(1, 1, 1, 1); - TreeNode node = list.get(i); - int sX = x + 10 * node.dimension; - int sY = y - scrollOffset + i * ITEM_HEIGHT; - String name = node.toString(); - if (node.isLeaf()) { - if (leafTexture != null) { - leafTexture.draw(x, sY, width, ITEM_HEIGHT); - } else { - drawSolidRect(x, sY, width, ITEM_HEIGHT, 0xffff0000); - } - if (node.getContent() != null) { - String nameS = contentNameSupplier == null ? null : - contentNameSupplier.apply(node.getContent()); - name = nameS == null ? name : nameS; - IGuiTexture icon = contentIconSupplier == null ? null : - contentIconSupplier.apply(node.getContent()); - if (icon != null) { - icon.draw(sX - 9, sY + 1, 8, 8); - } - } - } else { - if (nodeTexture != null) { - nodeTexture.draw(x, sY, width, ITEM_HEIGHT); - } else { - drawSolidRect(x, sY, width, ITEM_HEIGHT, 0xffffff00); - } - String nameS = keyNameSupplier == null ? null : keyNameSupplier.apply(node.getKey()); - name = nameS == null ? name : nameS; - IGuiTexture icon = keyIconSupplier == null ? null : keyIconSupplier.apply(node.getKey()); - if (icon != null) { - icon.draw(sX - 9, sY + 1, 8, 8); - } - } - if (node == selected) { - drawSolidRect(x, sY, width, ITEM_HEIGHT, 0x7f000000); - } - int textW = Math.max(width - 10 * node.dimension, 10); - List list = fr.listFormattedStringToWidth(I18n.format(name), textW); - fr.drawString(list.get(Math.abs((tick / 20) % list.size())), sX, sY + 2, 0xff000000); - } - }); - GlStateManager.enableBlend(); - GlStateManager.color(1, 1, 1, 1); - } - - public TreeNode jumpTo(List path) { - list.removeIf(node -> node.dimension != 1); - this.selected = null; - int dim = 1; - int index = 0; - boolean flag = false; - TreeNode node = null; - for (K key : path) { - flag = false; - for (int i = index; i < list.size(); i++) { - node = list.get(i); - if (node.dimension != dim) { - return null; - } else if (node.getKey().equals(key)) { // expand - if (!node.isLeaf() && path.size() > dim) { - for (int j = 0; j < node.getChildren().size(); j++) { - list.add(index + 1 + j, node.getChildren().get(j)); - } - } - index++; - dim++; - flag = true; - break; - } else { - index++; - } - } - if (!flag) return null; - } - if (flag) { - this.selected = node; - this.scrollOffset = MathHelper.clamp(ITEM_HEIGHT * (index - 1), 0, - Math.max(list.size() * ITEM_HEIGHT - getSize().height, 0)); - return this.selected; - } - return null; - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (this.isMouseOverElement(mouseX, mouseY)) { - int index = ((mouseY - getPosition().y) + scrollOffset) / ITEM_HEIGHT; - if (index < list.size()) { - TreeNode node = list.get(index); - if (node.isLeaf()) { - if (node != this.selected) { - this.selected = node; - if (onSelected != null) { - onSelected.accept(node); - } - } - } else { - if (canSelectNode && this.selected != node) { - this.selected = node; - if (onSelected != null) { - onSelected.accept(node); - } - } else if (node.getChildren().size() > 0 && list.contains(node.getChildren().get(0))) { - removeNode(node); - } else { - for (int i = 0; i < node.getChildren().size(); i++) { - list.add(index + 1 + i, node.getChildren().get(i)); - } - } - } - playButtonClickSound(); - } - return true; - } - return false; - } - - private void removeNode(TreeNode node) { - if (node.isLeaf()) return; - for (TreeNode child : node.getChildren()) { - list.remove(child); - removeNode(child); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/hardware/Hardware.java b/src/main/java/gregtech/api/terminal/hardware/Hardware.java deleted file mode 100644 index 6a34ff4de48..00000000000 --- a/src/main/java/gregtech/api/terminal/hardware/Hardware.java +++ /dev/null @@ -1,101 +0,0 @@ -package gregtech.api.terminal.hardware; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.resources.IGuiTexture; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/08/27 - * @Description: Hardware - */ -public abstract class Hardware { - - protected HardwareProvider provider; - - public abstract String getRegistryName(); - - @SideOnly(Side.CLIENT) - public String getLocalizedName() { - return I18n.format("terminal.hw." + getRegistryName()); - } - - @SideOnly(Side.CLIENT) - public IGuiTexture getIcon() { - return GuiTextures.ICON_REMOVE; - } - - /** - * Check whether the current hardware (this) meets requirement (demand); - */ - public boolean isHardwareAdequate(Hardware demand) { - return this.getClass() == demand.getClass() || this.getRegistryName().equals(demand.getRegistryName()); - } - - /** - * Check whether the terminal has this hardware. - */ - public final boolean hasHW() { - return provider != null && provider.hasHardware(getRegistryName()); - } - - public final ItemStack getItem() { - return provider.getHardwareItem(getRegistryName()); - } - - /** - * Returns the NBT of the this hardware. - */ - public final NBTTagCompound getNBT() { - return provider.getHardwareNBT(getRegistryName()); - } - - /** - * Check whether the terminal is in creative mode. - */ - public final boolean isCreative() { - return provider != null && provider.isCreative(); - } - - /** - * information added to tooltips - * - * @return null->nothing added. - */ - @SideOnly(Side.CLIENT) - public String addInformation() { - return null; - } - - /** - * Create the hardware instance, NOTE!!! do not check nbt or anything here. Terminal has not been initialized here. - * - * @param itemStack terminal - * @return instance - */ - protected abstract Hardware createHardware(ItemStack itemStack); - - /** - * Use the item to install this hardware. - * - * @return The NBT of the hardware is returned if the item is valid, otherwise NULL is returned - */ - public abstract NBTTagCompound acceptItemStack(ItemStack itemStack); - - /** - * Called when the hardware is removed and back to the player inventory. - * - * @param itemStack (original one) - * @return result - */ - public ItemStack onHardwareRemoved(ItemStack itemStack) { - return itemStack; - } -} diff --git a/src/main/java/gregtech/api/terminal/hardware/HardwareProvider.java b/src/main/java/gregtech/api/terminal/hardware/HardwareProvider.java deleted file mode 100644 index 1df64c9efc0..00000000000 --- a/src/main/java/gregtech/api/terminal/hardware/HardwareProvider.java +++ /dev/null @@ -1,143 +0,0 @@ -package gregtech.api.terminal.hardware; - -import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.items.metaitem.stats.IItemCapabilityProvider; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.common.items.behaviors.TerminalBehaviour; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/08/28 - * @Description: - */ -public class HardwareProvider implements ICapabilityProvider, IItemCapabilityProvider { - - private Map providers; - private Map itemCache; - private Boolean isCreative; - private ItemStack itemStack; - private NBTTagCompound tag; - - public HardwareProvider() {} - - public void cleanCache(String name) { - itemCache.remove(name); - } - - public boolean isCreative() { - if (isCreative == null) { - isCreative = TerminalBehaviour.isCreative(getItemStack()); - } - return isCreative; - } - - public Map getProviders() { - return providers; - } - - public ItemStack getItemStack() { - return itemStack; - } - - public NBTTagCompound getOrCreateHardwareCompound() { - if (tag == null) { - NBTTagCompound terminal = itemStack.getOrCreateSubCompound("terminal"); - if (!terminal.hasKey("_hw")) { - terminal.setTag("_hw", new NBTTagCompound()); - } - tag = terminal.getCompoundTag("_hw"); - } - return tag; - } - - public List getHardware() { - if (TerminalBehaviour.isCreative(itemStack)) { - return new ArrayList<>(providers.values()); - } - return getOrCreateHardwareCompound().getKeySet().stream().map(providers::get).filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - public boolean hasHardware(String name) { - return itemStack != null && - (TerminalBehaviour.isCreative(getItemStack()) || getOrCreateHardwareCompound().hasKey(name)); - } - - public NBTTagCompound getHardwareNBT(String name) { - return getOrCreateHardwareCompound().getCompoundTag(name); - } - - public ItemStack getHardwareItem(String name) { - if (!itemCache.containsKey(name)) { - NBTTagCompound tag = getHardwareNBT(name); - if (tag.hasKey("item")) { - itemCache.put(name, new ItemStack(tag.getCompoundTag("item"))); - } else { - itemCache.put(name, ItemStack.EMPTY); - } - } - return itemCache.get(name); - } - - @Override - public ICapabilityProvider createProvider(ItemStack itemStack) { - HardwareProvider provider = new HardwareProvider(); - provider.providers = new LinkedHashMap<>(); - provider.itemCache = new HashMap<>(); - provider.itemStack = itemStack; - for (Hardware hardware : TerminalRegistry.getAllHardware()) { - Hardware instance = hardware.createHardware(itemStack); - if (instance != null) { - instance.provider = provider; - provider.providers.put(hardware.getRegistryName(), instance); - } - } - return provider; - } - - @Override - public boolean hasCapability(@NotNull Capability capability, @Nullable EnumFacing facing) { - if (providers != null) { - for (Map.Entry entry : providers.entrySet()) { - Hardware provider = entry.getValue(); - if (provider instanceof IHardwareCapability && - hasHardware(entry.getKey()) && - ((IHardwareCapability) provider).hasCapability(capability)) { - return true; - } - } - } - return capability == GregtechCapabilities.CAPABILITY_HARDWARE_PROVIDER; - } - - @Nullable - @Override - public T getCapability(@NotNull Capability capability, @Nullable EnumFacing facing) { - if (providers != null) { - for (Map.Entry entry : providers.entrySet()) { - Hardware provider = entry.getValue(); - if (provider instanceof IHardwareCapability && - hasHardware(entry.getKey()) && - ((IHardwareCapability) provider).hasCapability(capability)) { - return ((IHardwareCapability) provider).getCapability(capability); - } - } - } - return capability == GregtechCapabilities.CAPABILITY_HARDWARE_PROVIDER ? - GregtechCapabilities.CAPABILITY_HARDWARE_PROVIDER.cast(this) : null; - } -} diff --git a/src/main/java/gregtech/api/terminal/hardware/IHardwareCapability.java b/src/main/java/gregtech/api/terminal/hardware/IHardwareCapability.java deleted file mode 100644 index a02caa5b76f..00000000000 --- a/src/main/java/gregtech/api/terminal/hardware/IHardwareCapability.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.api.terminal.hardware; - -import net.minecraftforge.common.capabilities.Capability; - -import org.jetbrains.annotations.NotNull; - -public interface IHardwareCapability { - - default boolean hasCapability(@NotNull Capability capability) { - return getCapability(capability) != null; - } - - T getCapability(@NotNull Capability capability); -} diff --git a/src/main/java/gregtech/api/terminal/os/SystemCall.java b/src/main/java/gregtech/api/terminal/os/SystemCall.java deleted file mode 100644 index 2110775b5db..00000000000 --- a/src/main/java/gregtech/api/terminal/os/SystemCall.java +++ /dev/null @@ -1,60 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.util.function.TriConsumer; - -public enum SystemCall { - - CALL_MENU("call_menu", 0, (os, side, args) -> os.callMenu(side)), - FULL_SCREEN("full_screen", 1, (os, side, args) -> os.maximize(side)), - MINIMIZE_FOCUS_APP("minimize_focus_app", 2, (os, side, args) -> os.minimizeApplication(os.getFocusApp(), side)), - CLOSE_FOCUS_APP("close_focus_app", 3, (os, side, args) -> os.closeApplication(os.getFocusApp(), side)), - SHUT_DOWN("shutdown", 4, (os, side, args) -> os.shutdown(side)), - OPEN_APP("open_app", 5, (os, side, args) -> { - if (args.length > 0 && args[0] != null) { - AbstractApplication app = TerminalRegistry.getApplication(args[0]); - if (app != null) { - os.openApplication(app, side); - } - } - }); - - TriConsumer action; - String name; - int index; - - SystemCall(String name, int index, TriConsumer action) { - this.action = action; - this.name = name; - this.index = index; - } - - public void call(TerminalOSWidget os, boolean isClient, String... args) { - action.accept(os, isClient, args); - } - - public String getTranslateKey() { - return "terminal.system_call." + name; - } - - public static SystemCall getFromName(String name) { - for (SystemCall value : SystemCall.values()) { - if (value.name.equalsIgnoreCase(name)) { - return value; - } else if (value.getTranslateKey().equals(name)) { - return value; - } - } - return null; - } - - public static SystemCall getFromIndex(int index) { - for (SystemCall value : SystemCall.values()) { - if (value.index == index) { - return value; - } - } - return null; - } -} diff --git a/src/main/java/gregtech/api/terminal/os/TerminalDesktopWidget.java b/src/main/java/gregtech/api/terminal/os/TerminalDesktopWidget.java deleted file mode 100644 index 19ad7f969b2..00000000000 --- a/src/main/java/gregtech/api/terminal/os/TerminalDesktopWidget.java +++ /dev/null @@ -1,117 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.LinkedList; -import java.util.List; - -public class TerminalDesktopWidget extends WidgetGroup { - - private final TerminalOSWidget os; - private final WidgetGroup appDiv; - private final List topWidgets; - private int rowCount = 7; - - public TerminalDesktopWidget(Position position, Size size, TerminalOSWidget os) { - super(position, size); - this.os = os; - this.appDiv = new WidgetGroup(); - this.addWidget(appDiv); - this.topWidgets = new LinkedList<>(); - } - - public void installApplication(AbstractApplication application) { - int r = 12; - int index = appDiv.widgets.size(); - int x = this.getSize().width / 2 + (3 * r) * (index % rowCount - rowCount / 2); - int y = (index / rowCount) * (3 * r) + 40; - CircleButtonWidget button = new CircleButtonWidget(x, y) - .setColors(TerminalTheme.COLOR_B_2.getColor(), - application.getThemeColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(application.getIcon()) - .setHoverText(application.getUnlocalizedName()); - button.setClickListener(clickData -> os.openApplication(application, clickData.isClient)); - appDiv.addWidget(button); - } - - @SideOnly(Side.CLIENT) - public void addTopWidget(Widget widget) { - topWidgets.add(widget); - } - - @SideOnly(Side.CLIENT) - public void removeTopWidget(Widget widget) { - topWidgets.remove(widget); - } - - @SideOnly(Side.CLIENT) - private static boolean topWidgetsMouseOver(Widget widget, int mouseX, int mouseY) { - if (widget.isMouseOverElement(mouseX, mouseY)) { - return true; - } - if (widget instanceof WidgetGroup) { - for (Widget child : ((WidgetGroup) widget).widgets) { - if (child.isVisible() && topWidgetsMouseOver(child, mouseX, mouseY)) { - return true; - } - } - } - return false; - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - boolean isBlocked = false; - for (Widget topWidget : topWidgets) { - if (topWidgetsMouseOver(topWidget, mouseX, mouseY)) { - isBlocked = true; - break; - } - } - for (Widget widget : widgets) { - if (widget.isVisible() && !(isBlocked && widget instanceof AbstractApplication)) { - widget.drawInForeground(mouseX, mouseY); - } - } - } - - public void showDesktop() { - appDiv.setActive(true); - appDiv.setVisible(true); - } - - public void hideDesktop() { - appDiv.setActive(false); - appDiv.setVisible(false); - } - - public void removeAllDialogs() { - for (Widget widget : widgets) { - if (widget instanceof TerminalDialogWidget) { - ((TerminalDialogWidget) widget).close(); - } - } - } - - @Override - public void setSize(Size size) { - super.setSize(size); - this.rowCount = (size.width - 81) / 36; - int r = 12; - for (int i = appDiv.widgets.size() - 1; i >= 0; i--) { - Widget widget = appDiv.widgets.get(i); - int x = this.getSize().width / 2 + (3 * r) * (i % rowCount - rowCount / 2); - int y = (i / rowCount) * (3 * r) + 40; - widget.setSelfPosition(new Position(x - r, y - r)); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/os/TerminalDialogWidget.java b/src/main/java/gregtech/api/terminal/os/TerminalDialogWidget.java deleted file mode 100644 index 30cd7ee1150..00000000000 --- a/src/main/java/gregtech/api/terminal/os/TerminalDialogWidget.java +++ /dev/null @@ -1,421 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.*; -import gregtech.api.terminal.gui.widgets.AnimaWidgetGroup; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.gui.widgets.ColorWidget; -import gregtech.api.terminal.gui.widgets.TreeListWidget; -import gregtech.api.terminal.util.FileTree; -import gregtech.api.util.GTLog; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; - -import java.awt.*; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class TerminalDialogWidget extends AnimaWidgetGroup { - - private static final IGuiTexture DIALOG_BACKGROUND = TextureArea - .fullImage("textures/gui/terminal/terminal_dialog.png"); - private static final IGuiTexture OK_NORMAL = TextureArea.fullImage("textures/gui/terminal/icon/ok_normal.png"); - private static final IGuiTexture OK_HOVER = TextureArea.fullImage("textures/gui/terminal/icon/ok_hover.png"); - // private static final IGuiTexture OK_DISABLE = TextureArea.fullImage("textures/gui/terminal/icon/ok_disable.png"); - private static final IGuiTexture CANCEL_NORMAL = TextureArea - .fullImage("textures/gui/terminal/icon/cancel_normal.png"); - private static final IGuiTexture CANCEL_HOVER = TextureArea - .fullImage("textures/gui/terminal/icon/cancel_hover.png"); - // private static final IGuiTexture CANCEL_DISABLE = - // TextureArea.fullImage("textures/gui/terminal/icon/cancel_disable.png"); - private static final int HEIGHT = 128; - private static final int WIDTH = 184; - - private final TerminalOSWidget os; - private IGuiTexture background; - private boolean isClient; - private List iNativeWidgets; - boolean isClosed; - - public TerminalDialogWidget(TerminalOSWidget os, int x, int y, int width, int height) { - super(x, y, width, height); - this.os = os; - } - - public boolean isClient() { - return isClient; - } - - public TerminalDialogWidget open() { - os.openDialog(this); - if (iNativeWidgets != null) { - iNativeWidgets.forEach(this::addWidget); - } - if (isRemote()) { - os.desktop.addTopWidget(this); - } - return this; - } - - public void close() { - if (isClosed) return; - isClosed = true; - os.closeDialog(this); - if (isRemote()) { - os.desktop.removeTopWidget(this); - } - } - - /** - * Should be a client side dialog. - * This is very important, please make sure the right side. - */ - public TerminalDialogWidget setClientSide() { - this.isClient = true; - return this; - } - - public TerminalDialogWidget setBackground(IGuiTexture background) { - this.background = background; - return this; - } - - public TerminalDialogWidget addOkButton(Runnable callback) { - addWidget(new CircleButtonWidget(WIDTH / 2, HEIGHT - 22, 12, 0, 24) - .setClickListener(cd -> { - close(); - if (callback != null) - callback.run(); - }) - .setColors(0, 0, 0) - .setIcon(OK_NORMAL) - .setHoverIcon(OK_HOVER)); - return this; - } - - public TerminalDialogWidget addConfirmButton(Consumer result) { - addWidget(new CircleButtonWidget(WIDTH / 2 - 30, HEIGHT - 22, 12, 0, 24) - .setClickListener(cd -> { - close(); - if (result != null) - result.accept(true); - }) - .setColors(0, 0, 0) - .setIcon(OK_NORMAL) - .setHoverIcon(OK_HOVER)); - addWidget(new CircleButtonWidget(WIDTH / 2 + 30, HEIGHT - 22, 12, 0, 24) - .setClickListener(cd -> { - close(); - if (result != null) - result.accept(false); - }) - .setColors(0, 0, 0) - .setIcon(CANCEL_NORMAL) - .setHoverIcon(CANCEL_HOVER)); - return this; - } - - public TerminalDialogWidget addTitle(String title) { - this.addWidget(new LabelWidget(WIDTH / 2, 11, title, -1).setXCentered(true)); - return this; - } - - public TerminalDialogWidget addInfo(String info) { - this.addWidget(new LabelWidget(WIDTH / 2, HEIGHT / 2, info, -1).setWidth(WIDTH - 16).setYCentered(true) - .setXCentered(true)); - return this; - } - - public static TerminalDialogWidget createEmptyTemplate(TerminalOSWidget os) { - Size size = os.getSize(); - return new TerminalDialogWidget(os, (size.width - WIDTH) / 2, (size.height - HEIGHT) / 2, WIDTH, HEIGHT) - .setBackground(DIALOG_BACKGROUND); - } - - public static TerminalDialogWidget showInfoDialog(TerminalOSWidget os, String title, String info, - Runnable callback) { - return createEmptyTemplate(os).addTitle(title).addInfo(info).addOkButton(callback); - } - - public static TerminalDialogWidget showInfoDialog(TerminalOSWidget os, String title, String info) { - return createEmptyTemplate(os).addTitle(title).addInfo(info).addOkButton(null); - } - - public static TerminalDialogWidget showConfirmDialog(TerminalOSWidget os, String title, String info, - Consumer result) { - return createEmptyTemplate(os).addConfirmButton(result).addTitle(title).addInfo(info); - } - - public static TerminalDialogWidget showTextFieldDialog(TerminalOSWidget os, String title, - Predicate validator, Consumer result) { - TextFieldWidget textFieldWidget = new TextFieldWidget(WIDTH / 2 - 50, HEIGHT / 2 - 15, 100, 20, - new ColorRectTexture(0x2fffffff), null, null).setValidator(validator); - TerminalDialogWidget dialog = createEmptyTemplate(os).addTitle(title).addConfirmButton(b -> { - if (b) { - if (result != null) - result.accept(textFieldWidget.getCurrentString()); - } else { - if (result != null) - result.accept(null); - } - }); - dialog.addWidget(textFieldWidget); - return dialog; - } - - /** - * Show Color Dialog - * - * @return color (rgba) - */ - public static TerminalDialogWidget showColorDialog(TerminalOSWidget os, String title, Consumer result, - int startColor) { - TerminalDialogWidget dialog = createEmptyTemplate(os).addTitle(title); - ColorWidget colorWidget = new ColorWidget(WIDTH / 2 - 60, HEIGHT / 2 - 35, 80, 10); - colorWidget.setStartColor(startColor); - dialog.addWidget(colorWidget); - dialog.addConfirmButton(b -> { - if (b) { - if (result != null) - result.accept(colorWidget.getColor()); - } else { - if (result != null) - result.accept(null); - } - }); - return dialog; - } - - /** - * Show FileDialog - * - * @param dir root directory - * @param isSelector select a file or save a file - * @param result selected file or (saved) - */ - public static TerminalDialogWidget showFileDialog(TerminalOSWidget os, String title, File dir, boolean isSelector, - Consumer result) { - Size size = os.getSize(); - TerminalDialogWidget dialog = new TerminalDialogWidget(os, 0, 0, size.width, size.height) - .setBackground(new ColorRectTexture(0x4f000000)); - if (!dir.isDirectory()) { - if (!dir.mkdirs()) { - return dialog.addInfo(I18n.format("terminal.dialog.error_path") + dir.getPath()).addOkButton(null); - } - } - AtomicReference selected = new AtomicReference<>(); - selected.set(dir); - dialog.addWidget( - new TreeListWidget<>(0, 0, 130, size.height, new FileTree(dir), node -> selected.set(node.getKey())) - .setNodeTexture(GuiTextures.BORDERED_BACKGROUND) - .canSelectNode(true) - .setLeafTexture(GuiTextures.SLOT_DARKENED)); - int x = 130 + (size.width - 133 - WIDTH) / 2; - int y = (size.height - HEIGHT) / 2; - dialog.addWidget(new ImageWidget(x, y, WIDTH, HEIGHT, DIALOG_BACKGROUND)); - dialog.addWidget(new CircleButtonWidget(x + WIDTH / 2 - 30, y + HEIGHT - 22, 12, 0, 24) - .setClickListener(cd -> { - dialog.close(); - if (result != null) - result.accept(selected.get()); - }) - .setColors(0, 0, 0) - .setIcon(OK_NORMAL) - .setHoverIcon(OK_HOVER)); - dialog.addWidget(new CircleButtonWidget(x + WIDTH / 2 + 30, y + HEIGHT - 22, 12, 0, 24) - .setClickListener(cd -> { - dialog.close(); - if (result != null) - result.accept(null); - }) - .setColors(0, 0, 0) - .setIcon(CANCEL_NORMAL) - .setHoverIcon(CANCEL_HOVER)); - if (isSelector) { - dialog.addWidget(new SimpleTextWidget(x + WIDTH / 2, y + HEIGHT / 2 - 5, "", -1, () -> { - if (selected.get() != null) { - return selected.get().toString(); - } - return "terminal.dialog.no_file_selected"; - }, true).setWidth(WIDTH - 16)); - } else { - dialog.addWidget(new TextFieldWidget(x + WIDTH / 2 - 38, y + HEIGHT / 2 - 10, 76, 20, - new ColorRectTexture(0x4f000000), null, null) - .setTextResponder(res -> { - File file = selected.get(); - if (file == null) return; - if (file.isDirectory()) { - selected.set(new File(file, res)); - } else { - selected.set(new File(file.getParent(), res)); - } - }, true) - .setTextSupplier(() -> { - File file = selected.get(); - if (file != null && !file.isDirectory()) { - return selected.get().getName(); - } - return ""; - }, true) - .setMaxStringLength(Integer.MAX_VALUE) - .setValidator(s -> true)); - } - dialog.addWidget(new CircleButtonWidget(x + 17, y + 15, 10, 1, 16) - .setClickListener(cd -> { - File file = selected.get(); - if (file != null && Desktop.isDesktopSupported()) { - try { - Desktop.getDesktop().open(file.isDirectory() ? file : file.getParentFile()); - } catch (IOException e) { - GTLog.logger.error("Error reading opening file " + file.getPath(), e); - } - } - }) - .setColors(0, 0xFFFFFFFF, 0) - .setHoverText("terminal.dialog.folder") - .setIcon(GuiTextures.ICON_LOAD)); - dialog.addWidget(new LabelWidget(x + WIDTH / 2, y + 11, title, -1).setXCentered(true)); - if (os.isRemote()) { - os.menu.hideMenu(); - } - return dialog.setClientSide(); - } - - public static TerminalDialogWidget showItemSelector(TerminalOSWidget os, String title, boolean cost, - Predicate filter, Consumer result) { - TerminalDialogWidget dialog = createEmptyTemplate(os); - dialog.addWidget(new LabelWidget(WIDTH / 2, -7, title, -1).setShadow(true).setXCentered(true)); - IInventory inventoryPlayer = os.getModularUI().entityPlayer.inventory; - if (dialog.iNativeWidgets == null) { - dialog.iNativeWidgets = new ArrayList<>(); - } - int x = 11; - int y = 30; - final SlotWidget[] selected = { null }; - for (int row = 0; row < 4; row++) { - for (int col = 0; col < 9; col++) { - boolean pass = filter == null || filter.test(inventoryPlayer.getStackInSlot(col + row * 9)); - SlotWidget slotWidget = new SlotWidget(inventoryPlayer, col + row * 9, x + col * 18, - (int) (y + (row == 0 ? -1.2 : (row - 1)) * 18), false, false) { - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - if (selected[0] == this) { - drawBorder(getPosition().x, getPosition().y, getSize().width, getSize().height, -1, 1); - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (pass && isMouseOverElement(mouseX, mouseY)) { - if (selected[0] == this) { - selected[0] = null; - } else { - selected[0] = this; - } - writeClientAction(7, buffer -> buffer.writeBoolean(selected[0] == this)); - } - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == 7) { - if (buffer.readBoolean()) { - selected[0] = this; - } else { - selected[0] = null; - } - } - super.readUpdateInfo(id, buffer); - } - }.setBackgroundTexture(TerminalTheme.COLOR_B_1).setLocationInfo(true, false); - slotWidget.setActive(pass); - dialog.iNativeWidgets.add(slotWidget); - } - } - dialog.addConfirmButton(confirm -> { - if (result != null && confirm && selected[0] != null && !selected[0].getHandle().getStack().isEmpty()) { - ItemStack stack = selected[0].getHandle().getStack().copy(); - if (cost) { - selected[0].getHandle().getStack().setCount(stack.getCount() - 1); - } - stack.setCount(1); - result.accept(stack); - } - }); - return dialog; - } - - @Override - public void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - GlStateManager.disableDepth(); - if (background != null) { - background.draw(getPosition().x, getPosition().y, getSize().width, getSize().height); - } - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - GlStateManager.enableDepth(); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - for (int i = widgets.size() - 1; i >= 0; i--) { - Widget widget = widgets.get(i); - if (widget.isVisible()) { - if (widget.mouseClicked(mouseX, mouseY, button)) { - return true; - } - } - } - return true; - } - - @Override - protected void writeClientAction(int id, Consumer packetBufferWriter) { - if (isClient || isClosed) return; - super.writeClientAction(id, packetBufferWriter); - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == -1) { // esc close - if (buffer.readBoolean()) { - close(); - } - } else { - super.handleClientAction(id, buffer); - } - } - - @Override - public boolean keyTyped(char charTyped, int keyCode) { - if (keyCode == 1 && super.interpolator == null) { - writeClientAction(-1, buffer -> buffer.writeBoolean(true)); - close(); - return true; - } - return super.keyTyped(charTyped, keyCode); - } - - public void onOSSizeUpdate(int width, int height) { - setSelfPosition( - Position.ORIGIN.add(new Position((width - getSize().width) / 2, (height - getSize().height) / 2))); - } -} diff --git a/src/main/java/gregtech/api/terminal/os/TerminalHomeButtonWidget.java b/src/main/java/gregtech/api/terminal/os/TerminalHomeButtonWidget.java deleted file mode 100644 index 0b9c7683e4c..00000000000 --- a/src/main/java/gregtech/api/terminal/os/TerminalHomeButtonWidget.java +++ /dev/null @@ -1,145 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.util.GTLog; - -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.common.FMLCommonHandler; - -import org.apache.commons.lang3.tuple.MutablePair; -import org.apache.commons.lang3.tuple.Pair; - -import java.io.File; -import java.io.IOException; - -public class TerminalHomeButtonWidget extends CircleButtonWidget { - - private final TerminalOSWidget os; - private int mouseClickTime = -1; - private final Pair[] actions; - - public TerminalHomeButtonWidget(TerminalOSWidget os) { - super(351, 115, 11, 2, 18); - this.os = os; - this.setColors(0, TerminalTheme.COLOR_F_1.getColor(), 0); - this.actions = new Pair[8]; - if (FMLCommonHandler.instance().getSide().isClient()) { - NBTTagCompound nbt = null; - try { - nbt = CompressedStreamTools.read(new File(TerminalRegistry.TERMINAL_PATH, "config/home_button.nbt")); - } catch (IOException e) { - GTLog.logger.error("error while loading local nbt for the home button", e); - } - if (nbt == null) { - actions[actionMap(false, false, false)] = new MutablePair<>(SystemCall.CALL_MENU, null); - actions[actionMap(true, false, false)] = new MutablePair<>(SystemCall.MINIMIZE_FOCUS_APP, null); - } else { - for (int i = 0; i < actions.length; i++) { - if (nbt.hasKey(String.valueOf(i))) { - NBTTagCompound tag = nbt.getCompoundTag(String.valueOf(i)); - actions[i] = new MutablePair<>(SystemCall.getFromIndex(tag.getInteger("action")), - tag.hasKey("arg") ? tag.getString("arg") : null); - } - } - } - } - } - - public Pair[] getActions() { - return actions; - } - - public static int actionMap(boolean doubleClick, boolean isCtrl, boolean isShift) { - return (doubleClick ? 1 : 0) + (isCtrl ? 2 : 0) + (isShift ? 4 : 0); - } - - public void saveConfig() { - if (FMLCommonHandler.instance().getSide().isClient()) { - NBTTagCompound nbt = new NBTTagCompound(); - for (int i = 0; i < actions.length; i++) { - if (actions[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("action", actions[i].getKey().index); - if (actions[i].getValue() != null) { - tag.setString("arg", actions[i].getValue()); - } - nbt.setTag(String.valueOf(i), tag); - } - } - try { - if (!nbt.isEmpty()) { - CompressedStreamTools.safeWrite(nbt, - new File(TerminalRegistry.TERMINAL_PATH, "config/home_button.nbt")); - } - } catch (IOException e) { - GTLog.logger.error("error while saving local nbt for the home button", e); - } - } - } - - private void click(int index, boolean isClient, String... args) { - SystemCall action = SystemCall.getFromIndex(index); - if (action != null) { - action.call(os, isClient, args); - } - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == 1) { - int index = buffer.readVarInt(); - int length = buffer.readVarInt(); - String[] args = new String[length]; - for (int i = 0; i < length; i++) { - args[i] = buffer.readString(32767); - } - click(index, false, args); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - if (mouseClickTime > 3) { // click - Pair pair = actions[actionMap(false, isCtrlDown(), isShiftDown())]; - sendToServer(pair); - playButtonClickSound(); - mouseClickTime = -1; - } else if (mouseClickTime > -1) { - mouseClickTime++; - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - if (mouseClickTime == -1) { - mouseClickTime = 0; - } else if (mouseClickTime <= 3) { // double click - Pair pair = actions[actionMap(true, isCtrlDown(), isShiftDown())]; - sendToServer(pair); - playButtonClickSound(); - mouseClickTime = -1; - } - return true; - } - return false; - } - - private void sendToServer(Pair pair) { - if (pair != null) { - String[] args = pair.getValue() == null ? new String[0] : pair.getValue().split(" "); - writeClientAction(1, buffer -> { - buffer.writeVarInt(pair.getKey().index); - buffer.writeVarInt(args.length); - for (String arg : args) { - buffer.writeString(arg); - } - }); - click(pair.getKey().index, true, args); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/os/TerminalOSWidget.java b/src/main/java/gregtech/api/terminal/os/TerminalOSWidget.java deleted file mode 100644 index 518609c585a..00000000000 --- a/src/main/java/gregtech/api/terminal/os/TerminalOSWidget.java +++ /dev/null @@ -1,543 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.capability.IElectricItem; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.AbstractWidgetGroup; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.terminal.hardware.HardwareProvider; -import gregtech.api.terminal.os.menu.TerminalMenuWidget; -import gregtech.api.util.GTLog; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.client.utils.RenderUtil; -import gregtech.common.items.behaviors.TerminalBehaviour; -import gregtech.common.terminal.app.settings.widgets.OsSettings; -import gregtech.common.terminal.hardware.BatteryHardware; -import gregtech.common.terminal.hardware.DeviceHardware; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.util.Constants; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - -public class TerminalOSWidget extends AbstractWidgetGroup { - - public static final TextureArea TERMINAL_FRAME = TextureArea.fullImage("textures/gui/terminal/terminal_frame.png"); - public static final TextureArea TERMINAL_HOME = TextureArea.fullImage("textures/gui/terminal/terminal_home.png"); - public static final int DEFAULT_WIDTH = 333; - public static final int DEFAULT_HEIGHT = 232; - - private IGuiTexture background; - private AbstractApplication focusApp; - public final NBTTagCompound tabletNBT; - public final List openedApps; - public final List installedApps; - public final TerminalMenuWidget menu; - public final TerminalDesktopWidget desktop; - public final TerminalHomeButtonWidget home; - public final BlockPos clickPos; - public final ItemStack itemStack; - public final HardwareProvider hardwareProvider; - private int tickCounter; - private long lastCharge; - private boolean maximize; - private boolean showMenuHover = false; - - public TerminalOSWidget(int xPosition, int yPosition, ItemStack itemStack) { - super(new Position(xPosition, yPosition), new Size(DEFAULT_WIDTH, DEFAULT_HEIGHT)); - this.background = TerminalTheme.WALL_PAPER; - this.openedApps = new ArrayList<>(); - this.installedApps = new ArrayList<>(); - this.desktop = new TerminalDesktopWidget(Position.ORIGIN, new Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), this); - this.menu = new TerminalMenuWidget(Position.ORIGIN, new Size(31, DEFAULT_HEIGHT), this) - .setBackground(TerminalTheme.COLOR_B_2); - this.home = new TerminalHomeButtonWidget(this); - this.addWidget(desktop); - this.addWidget(menu); - this.addWidget(home); - this.itemStack = itemStack; - this.tabletNBT = itemStack.getOrCreateSubCompound("terminal"); - this.tabletNBT.removeTag("_ar"); - this.hardwareProvider = itemStack.getCapability(GregtechCapabilities.CAPABILITY_HARDWARE_PROVIDER, null); - if (TerminalBehaviour.isCreative(itemStack)) { - TerminalRegistry.getAllApps().forEach(this::installApplication); - } else { - TerminalRegistry.getDefaultApps().forEach(this::installApplication); - NBTTagList installed = tabletNBT.getTagList("_installed", Constants.NBT.TAG_STRING); - for (NBTBase nbtBase : installed) { - if (nbtBase instanceof NBTTagString) { - AbstractApplication app = TerminalRegistry.getApplication(((NBTTagString) nbtBase).getString()); - if (app != null) { - installApplication(app); - } - } - } - } - if (tabletNBT.hasKey("_click")) { - clickPos = NBTUtil.getPosFromTag(tabletNBT.getCompoundTag("_click")); - } else { - clickPos = null; - } - } - - public ModularUI getModularUI() { - return this.gui; - } - - public TerminalOSWidget setBackground(IGuiTexture background) { - this.background = background; - return this; - } - - public AbstractApplication getFocusApp() { - return focusApp; - } - - public List getHardware() { - if (hardwareProvider == null) { - return Collections.emptyList(); - } - return hardwareProvider.getHardware(); - } - - public List getHardware(Class clazz) { - return getHardware().stream().filter(hw -> hw.getClass() == clazz).map(hw -> (T) hw) - .collect(Collectors.toList()); - } - - public void installApplication(AbstractApplication application) { - desktop.installApplication(application); - installedApps.add(application); - } - - public void openApplication(AbstractApplication application, boolean isClient) { - desktop.removeAllDialogs(); - NBTTagCompound nbt = tabletNBT.getCompoundTag(application.getRegistryName()); - if (!TerminalBehaviour.isCreative(itemStack)) { - List hwDemand = TerminalRegistry.getAppHardwareDemand(application.getRegistryName(), - Math.min(nbt.getInteger("_tier"), application.getMaxTier())); - List unMatch = hwDemand.stream() - .filter(demand -> getHardware().stream().noneMatch(hw -> hw.isHardwareAdequate(demand))) - .collect(Collectors.toList()); - if (unMatch.size() > 0) { - if (isClient) { - StringBuilder tooltips = new StringBuilder("\n"); - for (Hardware match : unMatch) { - String info = match.addInformation(); - String name = match.getLocalizedName(); - if (info == null) { - tooltips.append(name); - } else if (match instanceof BatteryHardware) { - IElectricItem energyItem = itemStack - .getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); - if (energyItem != null && energyItem.getCharge() <= 0) { - tooltips.append(I18n.format("terminal.battery.low_energy")); - } else { - tooltips.append(String.format("%s (%s+)", name, info)); - } - } else { - tooltips.append(String.format("%s (%s)", name, info)); - } - tooltips.append(" "); - } - TerminalDialogWidget.showInfoDialog(this, - "terminal.component.error", - I18n.format("terminal.os.hw_demand") + tooltips).setClientSide().open(); - } - return; - } - } - if (!application.canPlayerUse(gui.entityPlayer)) { - return; - } - if (focusApp != null) { - closeApplication(focusApp, isClient); - } - for (AbstractApplication app : openedApps) { - if (app.getRegistryName().equals(application.getRegistryName()) && application.canLaunchConcurrently(app)) { - app.onOSSizeUpdate(this.getSize().width, this.getSize().height); - maximizeApplication(app, isClient); - return; - } - } - AbstractApplication app = application.createAppInstance(this, isClient, nbt); - if (app != null) { - desktop.addWidget(app); - app.setOs(this).initApp(); - app.onOSSizeUpdate(this.getSize().width, this.getSize().height); - openedApps.add(app); - maximizeApplication(app, isClient); - } - } - - public void maximizeApplication(AbstractApplication application, boolean isClient) { - application.setActive(true); - if (isClient) { - application.maximizeWidget(app -> desktop.hideDesktop()); - if (!menu.isHide) { - menu.hideMenu(); - } - } - focusApp = application; - menu.loadComponents(focusApp); - desktop.hideDesktop(); - } - - public void minimizeApplication(AbstractApplication application, boolean isClient) { - desktop.removeAllDialogs(); - if (application != null) { - if (focusApp == application) { - if (isClient) { - application.minimizeWidget(app -> { - if (!application.isBackgroundApp()) { - application.setActive(false); - } - }); - } else if (!application.isBackgroundApp()) { - application.setActive(false); - } - focusApp = null; - } - menu.removeComponents(); - desktop.showDesktop(); - } - } - - public void closeApplication(AbstractApplication application, boolean isClient) { - desktop.removeAllDialogs(); - if (application != null) { - String appName = application.getRegistryName(); - NBTTagCompound synced = application.closeApp(); - - if (synced != null && !synced.isEmpty()) { - tabletNBT.setTag(appName, synced); - if (application.isClientSideApp() && isClient) { - writeClientAction(-2, buffer -> { - buffer.writeString(appName); - buffer.writeCompoundTag(synced); - }); - } - } - - if (isClient && focusApp == application) { - application.minimizeWidget(desktop::waitToRemoved); - } else { - desktop.waitToRemoved(application); - } - openedApps.remove(application); - if (focusApp == application) { - focusApp = null; - } - menu.removeComponents(); - desktop.showDesktop(); - } - } - - public void callMenu(boolean isClient) { - if (isClient) { - if (menu.isHide) { - menu.showMenu(); - } else { - menu.hideMenu(); - } - } - } - - public void shutdown(boolean isClient) { - if (isClient) { - NBTTagCompound nbt = new NBTTagCompound(); - for (AbstractApplication openedApp : openedApps) { - String appName = openedApp.getRegistryName(); - NBTTagCompound synced = openedApp.closeApp(); - if (synced != null && !synced.isEmpty()) { - tabletNBT.setTag(appName, synced); - if (openedApp.isClientSideApp()) {// if its a clientSideApp and the nbt not null, meaning this nbt - // should be synced to the server side. - nbt.setTag(appName, synced); - } - } - } - writeClientAction(-1, buffer -> buffer.writeCompoundTag(nbt)); - } else { // request shutdown from the server side - writeUpdateInfo(-2, packetBuffer -> {}); - } - } - - protected void openDialog(TerminalDialogWidget widget) { - if (isRemote()) { - widget.onOSSizeUpdate(getSize().width, getSize().height); - widget.maximizeWidget(null); - } else if (widget.isClient()) { - return; - } - desktop.addWidget(widget); - } - - protected void closeDialog(TerminalDialogWidget widget) { - if (isRemote()) { - widget.minimizeWidget(desktop::waitToRemoved); - } else if (!widget.isClient()) { - desktop.waitToRemoved(widget); - } - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == -1) { // shutdown - NBTTagCompound nbt = null; - try { - nbt = buffer.readCompoundTag(); - } catch (IOException e) { - GTLog.logger.error("TerminalOSWidget Shutdown could not read NBT tag from buffer", e); - } - for (AbstractApplication openedApp : openedApps) { - String appName = openedApp.getRegistryName(); - NBTTagCompound data = openedApp.closeApp(); - if (data != null && !data.isEmpty()) { - tabletNBT.setTag(appName, data); - } else if (nbt != null && openedApp.isClientSideApp() && nbt.hasKey(appName)) { - tabletNBT.setTag(appName, nbt.getCompoundTag(appName)); - } - } - this.getModularUI().entityPlayer.closeScreen(); // must close tablet from server side. - } else if (id == -2) { // closeApp sync - String appName = buffer.readString(32767); - NBTTagCompound nbt = null; - try { - nbt = buffer.readCompoundTag(); - } catch (IOException e) { - GTLog.logger.error("TerminalOSWidget CloseApp could not read NBT tag from buffer", e); - } - if (nbt != null) { - tabletNBT.setTag(appName, nbt); - } - } else { - super.handleClientAction(id, buffer); - } - } - - @Override - public void readUpdateInfo(int id, PacketBuffer buffer) { - if (id == -1) { // disCharge - long charge = buffer.readLong(); - IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); - if (electricItem instanceof BatteryHardware) { - ((BatteryHardware) electricItem).setCharge(charge); - } - if (charge <= 0) { - List toClosed = new LinkedList<>(); - for (AbstractApplication openedApp : openedApps) { - TerminalRegistry.getAppHardwareDemand(openedApp.getRegistryName(), openedApp.getAppTier()).stream() - .filter(i -> i instanceof BatteryHardware).findFirst() - .ifPresent(x -> toClosed.add(openedApp)); - } - for (AbstractApplication close : toClosed) { - this.closeApplication(close, true); - } - TerminalDialogWidget.showInfoDialog(this, "terminal.component.warning", "terminal.battery.low_energy") - .setClientSide().open(); - } - } else if (id == -2) { // shutdown - shutdown(true); - } else { - super.readUpdateInfo(id, buffer); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - tickCounter++; - if (background != null) { - background.updateTick(); - } - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - tickCounter++; - if (tickCounter % 20 == 0) { - long energyStore = disCharge(); - if (lastCharge != energyStore) { - lastCharge = energyStore; - writeUpdateInfo(-1, packetBuffer -> packetBuffer.writeLong(lastCharge)); - } - } - } - - private long disCharge() { - IElectricItem electricItem = hardwareProvider.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, - null); - if (electricItem != null && !TerminalBehaviour.isCreative(itemStack)) { - AtomicLong costs = new AtomicLong(0); - List charged = new ArrayList<>(); - for (AbstractApplication openedApp : openedApps) { - TerminalRegistry.getAppHardwareDemand(openedApp.getRegistryName(), openedApp.getAppTier()).stream() - .filter(i -> i instanceof BatteryHardware).findFirst() - .ifPresent(battery -> { - costs.addAndGet(((BatteryHardware) battery).getCharge()); - charged.add(openedApp); - }); - } - for (DeviceHardware hardware : getHardware(DeviceHardware.class)) { - if (hardware.getDevice() == DeviceHardware.DEVICE.SOLAR_LV) { - costs.addAndGet(-200); - } - } - if (costs.get() > 0 && electricItem.discharge(costs.get(), 999, true, false, false) != costs.get()) { - charged.forEach(app -> closeApplication(app, false)); - } else if (costs.get() < 0) { - electricItem.charge(-costs.get(), 999, true, false); - } - return electricItem.getCharge(); - } - return lastCharge; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - Position position = getPosition(); - Size size = getSize(); - - // show menu when mouse near the left edge - if ((focusApp == null || focusApp.canOpenMenuOnEdge()) && - isMouseOver(position.x, position.y, 7, size.height, mouseX, mouseY)) { - if (menu.isHide && !showMenuHover) { - menu.showMenu(); - showMenuHover = true; - } - } else if (!menu.isHide && showMenuHover && - !isMouseOver(position.x - 10, position.y, 41, size.height, mouseX, mouseY)) { - menu.hideMenu(); - showMenuHover = false; - } - - if (background != null) { - background.draw(position.x, position.y, size.width, size.height); - } else { - drawGradientRect(position.x, position.y, size.width, size.height, -1, -1); - } - if (maximize) { - desktop.drawInBackground(mouseX, mouseY, partialTicks, context); - if (menu.isVisible()) { - menu.drawInBackground(mouseX, mouseY, partialTicks, context); - } - } else { - RenderUtil.useScissor(position.x, position.y, size.width, size.height, () -> { - desktop.drawInBackground(mouseX, mouseY, partialTicks, context); - if (menu.isVisible()) { - menu.drawInBackground(mouseX, mouseY, partialTicks, context); - } - }); - TERMINAL_FRAME.draw(position.x - 12, position.y - 11, 380, 256); - } - home.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - boolean waitShutdown; - - @Override - public boolean keyTyped(char charTyped, int keyCode) { - if (waitShutdown && - (keyCode == 1 || Minecraft.getMinecraft().gameSettings.keyBindInventory.isActiveAndMatches(keyCode))) { - shutdown(true); - return true; - } - if (super.keyTyped(charTyped, keyCode)) { - return true; - } - if (keyCode == 1 || Minecraft.getMinecraft().gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) { // hook - // esc - // and - // e - waitShutdown = true; - if (!OsSettings.DOUBLE_CHECK) { - shutdown(true); - return true; - } - TerminalDialogWidget - .showConfirmDialog(this, "terminal.component.warning", "terminal.os.shutdown_confirm", result -> { - if (result) { - shutdown(true); - } else { - waitShutdown = false; - } - }).setClientSide().open(); - return true; - } - waitShutdown = false; - return false; - } - - public boolean isMaximize() { - return maximize; - } - - private void updateOSSize() { - int osWidth = getSize().width; - int osHeight = getSize().height; - if (this.maximize && (osWidth != gui.getScreenWidth() || osHeight != gui.getScreenHeight())) { - osWidth = gui.getScreenWidth(); - osHeight = gui.getScreenHeight(); - } else if (!this.maximize && (osWidth != DEFAULT_WIDTH || osHeight != DEFAULT_HEIGHT)) { - osWidth = DEFAULT_WIDTH; - osHeight = DEFAULT_HEIGHT; - } else { - return; - } - this.setSize(new Size(osWidth, osHeight)); - this.desktop.setSize(new Size(osWidth, osHeight)); - this.menu.setSize(new Size(31, osHeight)); - this.home.setSelfPosition(this.maximize ? - new Position((osWidth - this.home.getSize().width) / 2, osHeight - this.home.getSize().height - 10) : - new Position(340, 104)); - this.home.setIcon(this.maximize ? TERMINAL_HOME : null); - gui.setSize(this.maximize ? osWidth : 380, this.maximize ? osHeight : 256); - if (this.focusApp != null) { - this.focusApp.onOSSizeUpdate(osWidth, osHeight); - } - for (Widget widget : desktop.widgets) { - if (widget instanceof TerminalDialogWidget) { - ((TerminalDialogWidget) widget).onOSSizeUpdate(osWidth, osHeight); - } - } - } - - public void maximize(boolean isClient) { - if (isClient) { - this.maximize = !this.maximize; - updateOSSize(); - } - } - - @Override - public void setParentPosition(Position parentPosition) { - if (this.maximize) { - super.setParentPosition(parentPosition.subtract(this.getSelfPosition())); - if (isRemote()) { - updateOSSize(); - } - } else { - super.setParentPosition(parentPosition); - } - } -} diff --git a/src/main/java/gregtech/api/terminal/os/TerminalTheme.java b/src/main/java/gregtech/api/terminal/os/TerminalTheme.java deleted file mode 100644 index 66bf68c5bfd..00000000000 --- a/src/main/java/gregtech/api/terminal/os/TerminalTheme.java +++ /dev/null @@ -1,106 +0,0 @@ -package gregtech.api.terminal.os; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.ModifyGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.util.FileUtility; - -import net.minecraftforge.fml.common.FMLCommonHandler; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.awt.*; -import java.io.File; - -import static gregtech.api.terminal.TerminalRegistry.TERMINAL_PATH; - -public class TerminalTheme { - - private static final String FILE_PATH = "config/theme.json"; - public static final ColorRectTexture COLOR_1 = new ColorRectTexture(new Color(144, 243, 116)); - public static final ColorRectTexture COLOR_2 = new ColorRectTexture(new Color(243, 208, 116)); - public static final ColorRectTexture COLOR_3 = new ColorRectTexture(new Color(231, 95, 95)); - public static final ColorRectTexture COLOR_4 = new ColorRectTexture(new Color(0, 115, 255)); - public static final ColorRectTexture COLOR_5 = new ColorRectTexture(new Color(113, 27, 217)); - public static final ColorRectTexture COLOR_6 = new ColorRectTexture(new Color(30, 30, 30, 255)); - public static final ColorRectTexture COLOR_7 = new ColorRectTexture(new Color(230, 230, 230, 255)); - - public static final ColorRectTexture COLOR_F_1 = new ColorRectTexture(new Color(148, 226, 193)); - public static final ColorRectTexture COLOR_F_2 = new ColorRectTexture(new Color(175, 0, 0, 131)); - - public static final ColorRectTexture COLOR_B_1 = new ColorRectTexture(new Color(0, 0, 0, 80)); - public static final ColorRectTexture COLOR_B_2 = new ColorRectTexture(new Color(0, 0, 0, 160)); - public static final ColorRectTexture COLOR_B_3 = new ColorRectTexture(new Color(246, 120, 120, 160)); - - public static final ModifyGuiTexture WALL_PAPER = new ModifyGuiTexture( - TextureArea.fullImage("textures/gui/terminal/terminal_background.png")); - - static { - if (FMLCommonHandler.instance().getSide().isClient()) { - JsonElement element = FileUtility.loadJson(new File(TERMINAL_PATH, FILE_PATH)); - if (element == null || !element.isJsonObject()) { - saveConfig(); - } else { - JsonObject config = element.getAsJsonObject(); - if (config.has("COLOR_1")) { - COLOR_1.setColor(config.get("COLOR_1").getAsInt()); - } - if (config.has("COLOR_2")) { - COLOR_2.setColor(config.get("COLOR_2").getAsInt()); - } - if (config.has("COLOR_3")) { - COLOR_3.setColor(config.get("COLOR_3").getAsInt()); - } - if (config.has("COLOR_4")) { - COLOR_4.setColor(config.get("COLOR_4").getAsInt()); - } - if (config.has("COLOR_5")) { - COLOR_5.setColor(config.get("COLOR_5").getAsInt()); - } - if (config.has("COLOR_6")) { - COLOR_6.setColor(config.get("COLOR_6").getAsInt()); - } - if (config.has("COLOR_7")) { - COLOR_7.setColor(config.get("COLOR_7").getAsInt()); - } - if (config.has("COLOR_F_1")) { - COLOR_F_1.setColor(config.get("COLOR_F_1").getAsInt()); - } - if (config.has("COLOR_F_2")) { - COLOR_F_2.setColor(config.get("COLOR_F_2").getAsInt()); - } - if (config.has("COLOR_B_1")) { - COLOR_B_1.setColor(config.get("COLOR_B_1").getAsInt()); - } - if (config.has("COLOR_B_2")) { - COLOR_B_2.setColor(config.get("COLOR_B_2").getAsInt()); - } - if (config.has("COLOR_B_3")) { - COLOR_B_3.setColor(config.get("COLOR_B_3").getAsInt()); - } - if (config.has("WALL_PAPER")) { - WALL_PAPER.loadConfig(config.get("WALL_PAPER").getAsJsonObject()); - } - } - } - } - - public static boolean saveConfig() { - JsonObject config = new JsonObject(); - config.addProperty("COLOR_1", COLOR_1.getColor()); - config.addProperty("COLOR_2", COLOR_2.getColor()); - config.addProperty("COLOR_3", COLOR_3.getColor()); - config.addProperty("COLOR_4", COLOR_4.getColor()); - config.addProperty("COLOR_5", COLOR_5.getColor()); - config.addProperty("COLOR_6", COLOR_6.getColor()); - config.addProperty("COLOR_7", COLOR_7.getColor()); - config.addProperty("COLOR_F_1", COLOR_F_1.getColor()); - config.addProperty("COLOR_F_2", COLOR_F_2.getColor()); - config.addProperty("COLOR_B_1", COLOR_B_1.getColor()); - config.addProperty("COLOR_B_2", COLOR_B_2.getColor()); - config.addProperty("COLOR_B_3", COLOR_B_3.getColor()); - config.add("WALL_PAPER", WALL_PAPER.saveConfig()); - return FileUtility.saveJson(new File(TERMINAL_PATH, FILE_PATH), config); - } -} diff --git a/src/main/java/gregtech/api/terminal/os/menu/TerminalMenuWidget.java b/src/main/java/gregtech/api/terminal/os/menu/TerminalMenuWidget.java deleted file mode 100644 index daeaf572d4e..00000000000 --- a/src/main/java/gregtech/api/terminal/os/menu/TerminalMenuWidget.java +++ /dev/null @@ -1,189 +0,0 @@ -package gregtech.api.terminal.os.menu; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.os.SystemCall; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.Tuple; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.ArrayList; -import java.util.List; - -public class TerminalMenuWidget extends WidgetGroup { - - @SideOnly(Side.CLIENT) - private Interpolator interpolator; - private IGuiTexture background; - private final TerminalOSWidget os; - private final List> components; - public boolean isHide; - - public TerminalMenuWidget(Position position, Size size, TerminalOSWidget os) { - super(position, size); - addSelfPosition(-size.width, 0); - setVisible(false); - isHide = true; - this.os = os; - components = new ArrayList<>(); - this.addWidget(new CircleButtonWidget(5, 10, 4, 1, 0) - .setColors(0, - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_3.getColor()) - .setHoverText("terminal.menu.close") - .setClickListener(this::close)); - this.addWidget(new CircleButtonWidget(15, 10, 4, 1, 0) - .setColors(0, - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_2.getColor()) - .setHoverText("terminal.menu.minimize") - .setClickListener(this::minimize)); - this.addWidget(new CircleButtonWidget(25, 10, 4, 1, 0) - .setColors(0, - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_1.getColor()) - .setHoverText("terminal.menu.maximize") - .setClickListener(this::maximize)); - } - - public TerminalMenuWidget setBackground(IGuiTexture background) { - this.background = background; - return this; - } - - public void close(ClickData clickData) { - SystemCall.CLOSE_FOCUS_APP.call(os, clickData.isClient); - } - - public void minimize(ClickData clickData) { - SystemCall.MINIMIZE_FOCUS_APP.call(os, clickData.isClient); - } - - public void maximize(ClickData clickData) { - SystemCall.FULL_SCREEN.call(os, clickData.isClient); - } - - public void addComponent(IMenuComponent component) { - WidgetGroup group = new WidgetGroup(); - int x = 15; - int y = 40 + components.size() * 25; - CircleButtonWidget button = new CircleButtonWidget(x, y, 10, 1, 16) - .setColors(0, 0xFFFFFFFF, 0) - .setHoverText(component.hoverText()) - .setIcon(component.buttonIcon()); - button.setClickListener(c -> { - components.forEach(tuple -> { - if (tuple.getFirst() instanceof Widget && tuple.getFirst() != component) { - ((Widget) tuple.getFirst()).setActive(false); - ((Widget) tuple.getFirst()).setVisible(false); - ((CircleButtonWidget) tuple.getSecond().widgets.get(0)).setFill(0); - } - }); - if (component instanceof Widget) { - Widget widget = (Widget) component; - widget.setVisible(!widget.isVisible()); - widget.setActive(!widget.isActive()); - button.setFill(widget.isVisible() ? 0xFF94E2C1 : 0); - } - component.click(c); - }); - group.addWidget(button); - if (component instanceof Widget) { - Widget widget = (Widget) component; - widget.setSelfPosition(new Position(x + 20, 0)); - widget.setVisible(false); - widget.setActive(false); - group.addWidget(widget); - } - this.addWidget(group); - components.add(new Tuple<>(component, group)); - } - - public void loadComponents(AbstractApplication app) { - removeComponents(); - if (app != null) { - app.getMenuComponents().forEach(this::addComponent); - } - } - - public void removeComponents() { - components.forEach(component -> this.removeWidget(component.getSecond())); - components.clear(); - } - - @SideOnly(Side.CLIENT) - public void hideMenu() { - if (!isHide && interpolator == null) { - int y = getSelfPosition().y; - interpolator = new Interpolator(getSelfPosition().x, getSelfPosition().x - getSize().width, 6, Eases.LINEAR, - value -> setSelfPosition(new Position(value.intValue(), y)), - value -> { - setVisible(false); - interpolator = null; - isHide = true; - }); - interpolator.start(); - os.desktop.removeTopWidget(this); - } - } - - @SideOnly(Side.CLIENT) - public void showMenu() { - if (isHide && interpolator == null) { - setVisible(true); - int y = getSelfPosition().y; - interpolator = new Interpolator(getSelfPosition().x, getSelfPosition().x + getSize().width, 6, Eases.LINEAR, - value -> setSelfPosition(new Position(value.intValue(), y)), - value -> { - interpolator = null; - isHide = false; - }); - interpolator.start(); - os.desktop.addTopWidget(this); - } - } - - @Override - public void updateScreenOnFrame() { - if (interpolator != null) interpolator.update(); - super.updateScreenOnFrame(); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - GlStateManager.color(1, 1, 1, 0.5f); - if (background != null) { - background.draw(this.getPosition().x, this.getPosition().y, this.getSize().width, this.getSize().height); - } else { - drawGradientRect(this.getPosition().x, this.getPosition().y, this.getSize().width, this.getSize().height, - 0xff000000, 0xff000000); - } - GlStateManager.color(1, 1, 1, 1); - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (!super.mouseClicked(mouseX, mouseY, button)) { - if (isMouseOverElement(mouseX, mouseY)) { - return true; - } else if (!isHide) { - hideMenu(); - } - return false; - } - return true; - } -} diff --git a/src/main/java/gregtech/api/terminal/util/FileTree.java b/src/main/java/gregtech/api/terminal/util/FileTree.java deleted file mode 100644 index 5097c478aff..00000000000 --- a/src/main/java/gregtech/api/terminal/util/FileTree.java +++ /dev/null @@ -1,53 +0,0 @@ -package gregtech.api.terminal.util; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FileTree extends TreeNode { - - public FileTree(File dir) { - this(0, dir); - } - - private FileTree(int dimension, File key) { - super(dimension, key); - } - - @Override - public boolean isLeaf() { - return getKey().isFile(); - } - - @Override - public File getContent() { - return isLeaf() ? getKey() : null; - } - - @Override - public List> getChildren() { - if (children == null && !isLeaf()) { - children = new ArrayList<>(); - File[] listFiles = key.listFiles(); - if (listFiles != null) { - Arrays.stream(listFiles).sorted((a, b) -> { - if (a.isFile() && b.isFile()) { - return a.compareTo(b); - } else if (a.isDirectory() && b.isDirectory()) { - return a.compareTo(b); - } else if (a.isDirectory()) { - return -1; - } - return 1; - }).forEach(file -> children.add(new FileTree(dimension + 1, file))); - } - } - return super.getChildren(); - } - - @Override - public String toString() { - return getKey().getName(); - } -} diff --git a/src/main/java/gregtech/api/terminal/util/TreeNode.java b/src/main/java/gregtech/api/terminal/util/TreeNode.java deleted file mode 100644 index 7f99ac830ae..00000000000 --- a/src/main/java/gregtech/api/terminal/util/TreeNode.java +++ /dev/null @@ -1,75 +0,0 @@ -package gregtech.api.terminal.util; - -import java.util.ArrayList; -import java.util.List; - -/*** - * Tree - * - * @param key - * @param leaf - */ -public class TreeNode { - - public final int dimension; - protected final T key; - protected K content; - protected List> children; - - public TreeNode(int dimension, T key) { - this.dimension = dimension; - this.key = key; - } - - public boolean isLeaf() { - return getChildren() == null || getChildren().isEmpty(); - } - - public TreeNode getOrCreateChild(T childKey) { - TreeNode result; - if (getChildren() != null) { - result = getChildren().stream().filter(child -> child.key.equals(childKey)).findFirst().orElseGet(() -> { - TreeNode newNode = new TreeNode<>(dimension + 1, childKey); - getChildren().add(newNode); - return newNode; - }); - } else { - children = new ArrayList<>(); - result = new TreeNode<>(dimension + 1, childKey); - getChildren().add(result); - } - return result; - } - - public TreeNode getChild(T key) { - if (getChildren() != null) { - for (TreeNode child : getChildren()) { - if (child.key.equals(key)) { - return child; - } - } - } - return null; - } - - public void addContent(T key, K content) { - getOrCreateChild(key).content = content; - } - - public T getKey() { - return key; - } - - public K getContent() { - return content; - } - - public List> getChildren() { - return children; - } - - @Override - public String toString() { - return key.toString(); - } -} diff --git a/src/main/java/gregtech/client/ClientProxy.java b/src/main/java/gregtech/client/ClientProxy.java index 7fb4773d478..b0581389bcf 100644 --- a/src/main/java/gregtech/client/ClientProxy.java +++ b/src/main/java/gregtech/client/ClientProxy.java @@ -4,7 +4,6 @@ import gregtech.api.fluids.GTFluidRegistration; import gregtech.api.items.metaitem.MetaOreDictItem; import gregtech.api.items.toolitem.IGTTool; -import gregtech.api.terminal.TerminalRegistry; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Materials; import gregtech.api.unification.stack.UnificationEntry; @@ -105,7 +104,6 @@ public void onLoad() { @Override public void onPostLoad() { super.onPostLoad(); - TerminalRegistry.initTerminalFiles(); ItemRenderCompat.init(); FacadeRenderer.init(); } diff --git a/src/main/java/gregtech/client/event/ClientEventHandler.java b/src/main/java/gregtech/client/event/ClientEventHandler.java index f4ac14d8bfd..57c79a3afb7 100644 --- a/src/main/java/gregtech/client/event/ClientEventHandler.java +++ b/src/main/java/gregtech/client/event/ClientEventHandler.java @@ -10,7 +10,6 @@ import gregtech.client.particle.GTParticleManager; import gregtech.client.renderer.handler.BlockPosHighlightRenderer; import gregtech.client.renderer.handler.MultiblockPreviewRenderer; -import gregtech.client.renderer.handler.TerminalARRenderer; import gregtech.client.utils.BloomEffectUtil; import gregtech.client.utils.DepthTextureUtil; import gregtech.client.utils.TooltipHelper; @@ -69,7 +68,6 @@ public static void onPreWorldRender(TickEvent.RenderTickEvent event) { @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { GTParticleManager.clientTick(event); - TerminalARRenderer.onClientTick(event); TooltipHelper.onClientTick(event); if (event.phase == TickEvent.Phase.END) { CLIENT_TIME++; @@ -81,23 +79,16 @@ public static void onRenderWorldLast(RenderWorldLastEvent event) { DepthTextureUtil.renderWorld(event); MultiblockPreviewRenderer.renderWorldLastEvent(event); BlockPosHighlightRenderer.renderWorldLastEvent(event); - TerminalARRenderer.renderWorldLastEvent(event); GTParticleManager.renderWorld(event); } @SubscribeEvent public static void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) { - TerminalARRenderer.renderGameOverlayEvent(event); if (ConfigHolder.misc.debug && event instanceof RenderGameOverlayEvent.Text text) { GTParticleManager.debugOverlay(text); } } - @SubscribeEvent - public static void onRenderSpecificHand(RenderSpecificHandEvent event) { - TerminalARRenderer.renderHandEvent(event); - } - private static final Map DEFAULT_CAPES = new Object2ObjectOpenHashMap<>(); @SubscribeEvent diff --git a/src/main/java/gregtech/client/renderer/handler/TerminalARRenderer.java b/src/main/java/gregtech/client/renderer/handler/TerminalARRenderer.java deleted file mode 100644 index 1bc5e61a13e..00000000000 --- a/src/main/java/gregtech/client/renderer/handler/TerminalARRenderer.java +++ /dev/null @@ -1,99 +0,0 @@ -package gregtech.client.renderer.handler; - -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.ARApplication; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.client.utils.RenderUtil; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumHand; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderSpecificHandEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/09/13 - * @Description: Renderer for AR applications. - * Please don't render your stuff here, it's just a handler - */ -@SideOnly(Side.CLIENT) -public class TerminalARRenderer { - - public static ARApplication APP; - public static int x, y, width, height; - public static EnumHand HELD_HAND; - - public static void renderHandEvent(RenderSpecificHandEvent event) { - if (APP != null && event.getHand() == HELD_HAND) { - event.setCanceled(true); - } - } - - public static void renderGameOverlayEvent(RenderGameOverlayEvent.Pre event) { - if (APP != null && event.getType() == RenderGameOverlayEvent.ElementType.ALL) { - int sWidth = event.getResolution().getScaledWidth(); - int sHeight = event.getResolution().getScaledHeight(); - width = (int) (380 * 0.8 * sHeight / 256); - height = (int) (0.8 * sHeight); - x = (sWidth - width) / 2; - y = (sHeight - height) / 2; - GlStateManager.enableBlend(); - TerminalOSWidget.TERMINAL_FRAME.draw(x, y, width, height); - GlStateManager.disableBlend(); - } - } - - public static void renderWorldLastEvent(RenderWorldLastEvent event) { - if (APP != null) { - RenderUtil.useScissor(x, y, width, height, () -> APP.drawARScreen(event)); - } - } - - public static void onClientTick(TickEvent.ClientTickEvent event) { - if (event.phase == TickEvent.Phase.END) { - EntityPlayer player = Minecraft.getMinecraft().player; - if (player == null) { - if (APP != null) { - APP.onARClosed(); - APP = null; - } - return; - } - HELD_HAND = EnumHand.MAIN_HAND; - NBTTagCompound tag = player.getHeldItem(EnumHand.MAIN_HAND).getSubCompound("terminal"); - if (tag == null) { - tag = player.getHeldItem(EnumHand.OFF_HAND).getSubCompound("terminal"); - HELD_HAND = EnumHand.OFF_HAND; - } - if (tag != null && tag.hasKey("_ar")) { - AbstractApplication app = TerminalRegistry.getApplication(tag.getString("_ar")); - if (app instanceof ARApplication) { - if (APP != app) { - if (APP != null) { - APP.onARClosed(); - } - APP = (ARApplication) app; - APP.setAROpened(player.getHeldItem(HELD_HAND)); - APP.onAROpened(); - } - APP.tickAR(player); - return; - } - } - if (APP != null) { - APP.onARClosed(); - APP = null; - } - } - } -} diff --git a/src/main/java/gregtech/common/CommonProxy.java b/src/main/java/gregtech/common/CommonProxy.java index 1a43a28aa62..59055bb74e1 100644 --- a/src/main/java/gregtech/common/CommonProxy.java +++ b/src/main/java/gregtech/common/CommonProxy.java @@ -11,7 +11,6 @@ import gregtech.api.recipes.ModHandler; import gregtech.api.recipes.ingredients.GTRecipeOreInput; import gregtech.api.recipes.properties.impl.FusionEUToStartProperty; -import gregtech.api.terminal.TerminalRegistry; import gregtech.api.unification.material.Material; import gregtech.api.unification.material.info.MaterialFlags; import gregtech.api.unification.material.properties.DustProperty; @@ -410,8 +409,6 @@ public void onLoad() { } public void onPostLoad() { - TerminalRegistry.init(); - if (ConfigHolder.compat.removeSmeltingForEBFMetals) { ModHandler.removeSmeltingEBFMetals(); } diff --git a/src/main/java/gregtech/common/covers/CoverDigitalInterface.java b/src/main/java/gregtech/common/covers/CoverDigitalInterface.java index d4950ca4ac7..0063a113faa 100644 --- a/src/main/java/gregtech/common/covers/CoverDigitalInterface.java +++ b/src/main/java/gregtech/common/covers/CoverDigitalInterface.java @@ -19,8 +19,8 @@ import gregtech.api.util.TextFormattingUtil; import gregtech.client.renderer.texture.Textures; import gregtech.client.utils.RenderUtil; +import gregtech.common.gui.widget.prospector.widget.WidgetOreList; import gregtech.common.metatileentities.multi.electric.MetaTileEntityPowerSubstation; -import gregtech.common.terminal.app.prospector.widget.WidgetOreList; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; diff --git a/src/main/java/gregtech/common/terminal/app/prospector/ProspectingTexture.java b/src/main/java/gregtech/common/gui/widget/prospector/ProspectingTexture.java similarity index 99% rename from src/main/java/gregtech/common/terminal/app/prospector/ProspectingTexture.java rename to src/main/java/gregtech/common/gui/widget/prospector/ProspectingTexture.java index 4f0070524ec..d0313daf95b 100644 --- a/src/main/java/gregtech/common/terminal/app/prospector/ProspectingTexture.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/ProspectingTexture.java @@ -1,4 +1,4 @@ -package gregtech.common.terminal.app.prospector; +package gregtech.common.gui.widget.prospector; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.stack.MaterialStack; diff --git a/src/main/java/gregtech/common/terminal/app/prospector/ProspectorMode.java b/src/main/java/gregtech/common/gui/widget/prospector/ProspectorMode.java similarity index 93% rename from src/main/java/gregtech/common/terminal/app/prospector/ProspectorMode.java rename to src/main/java/gregtech/common/gui/widget/prospector/ProspectorMode.java index 5de3b24ec9b..0867c6d2a3f 100644 --- a/src/main/java/gregtech/common/terminal/app/prospector/ProspectorMode.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/ProspectorMode.java @@ -1,4 +1,4 @@ -package gregtech.common.terminal.app.prospector; +package gregtech.common.gui.widget.prospector; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetOreList.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetOreList.java similarity index 91% rename from src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetOreList.java rename to src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetOreList.java index 40435e51b5e..2e774351517 100644 --- a/src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetOreList.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetOreList.java @@ -1,15 +1,19 @@ -package gregtech.common.terminal.app.prospector.widget; +package gregtech.common.gui.widget.prospector.widget; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.*; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.os.TerminalTheme; +import gregtech.api.gui.resources.ColorRectTexture; +import gregtech.api.gui.widgets.ImageWidget; +import gregtech.api.gui.widgets.LabelWidget; +import gregtech.api.gui.widgets.SlotWidget; +import gregtech.api.gui.widgets.TankWidget; +import gregtech.api.gui.widgets.WidgetGroup; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.stack.MaterialStack; import gregtech.api.util.Position; -import gregtech.common.terminal.app.prospector.ProspectorMode; +import gregtech.common.gui.widget.prospector.ProspectorMode; +import gregtech.common.gui.widget.terminal.gui.widgets.DraggableScrollableWidgetGroup; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; @@ -23,7 +27,12 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -import java.util.*; +import java.awt.*; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Consumer; public class WidgetOreList extends DraggableScrollableWidgetGroup { @@ -39,7 +48,7 @@ public WidgetOreList(int xPosition, int yPosition, int width, int slotSize) { widgetMap = HashBiMap.create(); ores = new HashMap<>(); this.setYScrollBarWidth(5); - this.setYBarStyle(null, TerminalTheme.COLOR_F_1); + this.setYBarStyle(null, new ColorRectTexture(new Color(148, 226, 193))); clear(); } diff --git a/src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java similarity index 99% rename from src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetProspectingMap.java rename to src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index ba42b1a29cc..f203e1af020 100644 --- a/src/main/java/gregtech/common/terminal/app/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -1,4 +1,4 @@ -package gregtech.common.terminal.app.prospector.widget; +package gregtech.common.gui.widget.prospector.widget; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.Widget; @@ -11,8 +11,8 @@ import gregtech.api.worldgen.config.OreDepositDefinition; import gregtech.api.worldgen.config.WorldGenRegistry; import gregtech.api.worldgen.filler.FillerEntry; -import gregtech.common.terminal.app.prospector.ProspectingTexture; -import gregtech.common.terminal.app.prospector.ProspectorMode; +import gregtech.common.gui.widget.prospector.ProspectingTexture; +import gregtech.common.gui.widget.prospector.ProspectorMode; import gregtech.core.network.packets.PacketProspecting; import gregtech.integration.xaero.ColorUtility; diff --git a/src/main/java/gregtech/common/terminal/component/SearchComponent.java b/src/main/java/gregtech/common/gui/widget/terminal/SearchComponent.java similarity index 94% rename from src/main/java/gregtech/common/terminal/component/SearchComponent.java rename to src/main/java/gregtech/common/gui/widget/terminal/SearchComponent.java index b0b99d8f154..b06bb1ce2f8 100644 --- a/src/main/java/gregtech/common/terminal/component/SearchComponent.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/SearchComponent.java @@ -1,4 +1,4 @@ -package gregtech.common.terminal.component; +package gregtech.common.gui.widget.terminal; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.resources.ColorRectTexture; @@ -6,9 +6,9 @@ import gregtech.api.gui.resources.TextureArea; import gregtech.api.gui.widgets.TextFieldWidget; import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.terminal.util.ISearch; -import gregtech.api.terminal.util.SearchEngine; +import gregtech.common.gui.widget.terminal.menu.IMenuComponent; +import gregtech.common.gui.widget.terminal.util.ISearch; +import gregtech.common.gui.widget.terminal.util.SearchEngine; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/gregtech/api/terminal/gui/IDraggable.java b/src/main/java/gregtech/common/gui/widget/terminal/gui/IDraggable.java similarity index 86% rename from src/main/java/gregtech/api/terminal/gui/IDraggable.java rename to src/main/java/gregtech/common/gui/widget/terminal/gui/IDraggable.java index 33b6cf41719..c93e7491f2c 100644 --- a/src/main/java/gregtech/api/terminal/gui/IDraggable.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/gui/IDraggable.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.gui; +package gregtech.common.gui.widget.terminal.gui; public interface IDraggable { diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/CircleButtonWidget.java b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/CircleButtonWidget.java similarity index 98% rename from src/main/java/gregtech/api/terminal/gui/widgets/CircleButtonWidget.java rename to src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/CircleButtonWidget.java index 98d6b27b5ab..953bf457f1b 100644 --- a/src/main/java/gregtech/api/terminal/gui/widgets/CircleButtonWidget.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/CircleButtonWidget.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.gui.widgets; +package gregtech.common.gui.widget.terminal.gui.widgets; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.Widget; diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/DraggableScrollableWidgetGroup.java b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/DraggableScrollableWidgetGroup.java similarity index 99% rename from src/main/java/gregtech/api/terminal/gui/widgets/DraggableScrollableWidgetGroup.java rename to src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/DraggableScrollableWidgetGroup.java index 7adb35a9e56..339a7f7cdfa 100644 --- a/src/main/java/gregtech/api/terminal/gui/widgets/DraggableScrollableWidgetGroup.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/DraggableScrollableWidgetGroup.java @@ -1,14 +1,14 @@ -package gregtech.api.terminal.gui.widgets; +package gregtech.common.gui.widget.terminal.gui.widgets; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.Widget; import gregtech.api.gui.resources.IGuiTexture; import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.IDraggable; import gregtech.api.util.Position; import gregtech.api.util.Size; import gregtech.client.utils.RenderUtil; import gregtech.common.ConfigHolder; +import gregtech.common.gui.widget.terminal.gui.IDraggable; import net.minecraft.util.math.MathHelper; diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/RectButtonWidget.java b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/RectButtonWidget.java similarity index 98% rename from src/main/java/gregtech/api/terminal/gui/widgets/RectButtonWidget.java rename to src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/RectButtonWidget.java index d49b5a3c25d..e4f134ff851 100644 --- a/src/main/java/gregtech/api/terminal/gui/widgets/RectButtonWidget.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/RectButtonWidget.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.gui.widgets; +package gregtech.common.gui.widget.terminal.gui.widgets; import gregtech.api.gui.IRenderContext; import gregtech.api.gui.resources.IGuiTexture; diff --git a/src/main/java/gregtech/api/terminal/gui/widgets/SelectorWidget.java b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/SelectorWidget.java similarity index 98% rename from src/main/java/gregtech/api/terminal/gui/widgets/SelectorWidget.java rename to src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/SelectorWidget.java index c5f35429f01..20e0bf030b5 100644 --- a/src/main/java/gregtech/api/terminal/gui/widgets/SelectorWidget.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/gui/widgets/SelectorWidget.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.gui.widgets; +package gregtech.common.gui.widget.terminal.gui.widgets; import gregtech.api.gui.resources.IGuiTexture; import gregtech.api.gui.widgets.SimpleTextWidget; diff --git a/src/main/java/gregtech/api/terminal/os/menu/IMenuComponent.java b/src/main/java/gregtech/common/gui/widget/terminal/menu/IMenuComponent.java similarity index 91% rename from src/main/java/gregtech/api/terminal/os/menu/IMenuComponent.java rename to src/main/java/gregtech/common/gui/widget/terminal/menu/IMenuComponent.java index 519d09b2231..6996f8888d5 100644 --- a/src/main/java/gregtech/api/terminal/os/menu/IMenuComponent.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/menu/IMenuComponent.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.os.menu; +package gregtech.common.gui.widget.terminal.menu; import gregtech.api.gui.Widget; import gregtech.api.gui.resources.ColorRectTexture; diff --git a/src/main/java/gregtech/api/terminal/util/ISearch.java b/src/main/java/gregtech/common/gui/widget/terminal/util/ISearch.java similarity index 79% rename from src/main/java/gregtech/api/terminal/util/ISearch.java rename to src/main/java/gregtech/common/gui/widget/terminal/util/ISearch.java index 2ae8c26569b..0f256ab62c0 100644 --- a/src/main/java/gregtech/api/terminal/util/ISearch.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/util/ISearch.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.util; +package gregtech.common.gui.widget.terminal.util; import java.util.function.Consumer; diff --git a/src/main/java/gregtech/api/terminal/util/SearchEngine.java b/src/main/java/gregtech/common/gui/widget/terminal/util/SearchEngine.java similarity index 94% rename from src/main/java/gregtech/api/terminal/util/SearchEngine.java rename to src/main/java/gregtech/common/gui/widget/terminal/util/SearchEngine.java index deaff75d2fd..e810dfaca34 100644 --- a/src/main/java/gregtech/api/terminal/util/SearchEngine.java +++ b/src/main/java/gregtech/common/gui/widget/terminal/util/SearchEngine.java @@ -1,4 +1,4 @@ -package gregtech.api.terminal.util; +package gregtech.common.gui.widget.terminal.util; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/gregtech/common/items/MetaItem1.java b/src/main/java/gregtech/common/items/MetaItem1.java index 378b7c12849..cdf8d42deda 100644 --- a/src/main/java/gregtech/common/items/MetaItem1.java +++ b/src/main/java/gregtech/common/items/MetaItem1.java @@ -11,7 +11,6 @@ import gregtech.api.items.metaitem.stats.IItemComponent; import gregtech.api.items.metaitem.stats.IItemContainerItemProvider; import gregtech.api.items.metaitem.stats.ItemFluidContainer; -import gregtech.api.terminal.hardware.HardwareProvider; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.MarkerMaterial; import gregtech.api.unification.material.MarkerMaterials; @@ -48,7 +47,6 @@ import gregtech.common.items.behaviors.MultiblockBuilderBehavior; import gregtech.common.items.behaviors.NanoSaberBehavior; import gregtech.common.items.behaviors.ProspectorScannerBehavior; -import gregtech.common.items.behaviors.TerminalBehaviour; import gregtech.common.items.behaviors.TooltipBehavior; import gregtech.common.items.behaviors.TricorderBehavior; import gregtech.common.items.behaviors.TurbineRotorBehavior; @@ -792,7 +790,6 @@ public void registerSubItems() { .setMaxStackSize(1) .setCreativeTabs(GTCreativeTabs.TAB_GREGTECH_TOOLS); TERMINAL = addItem(465, "terminal") - .addComponents(new HardwareProvider(), new TerminalBehaviour()) .setMaxStackSize(1) .setCreativeTabs(GTCreativeTabs.TAB_GREGTECH_TOOLS); PROSPECTOR_LV = addItem(466, "prospector.lv") diff --git a/src/main/java/gregtech/common/items/behaviors/ProspectorScannerBehavior.java b/src/main/java/gregtech/common/items/behaviors/ProspectorScannerBehavior.java index ac1e91f3615..eaad7dd7bc2 100644 --- a/src/main/java/gregtech/common/items/behaviors/ProspectorScannerBehavior.java +++ b/src/main/java/gregtech/common/items/behaviors/ProspectorScannerBehavior.java @@ -11,10 +11,10 @@ import gregtech.api.items.gui.PlayerInventoryHolder; import gregtech.api.items.metaitem.stats.IItemBehaviour; import gregtech.api.util.GTUtility; -import gregtech.common.terminal.app.prospector.ProspectorMode; -import gregtech.common.terminal.app.prospector.widget.WidgetOreList; -import gregtech.common.terminal.app.prospector.widget.WidgetProspectingMap; -import gregtech.common.terminal.component.SearchComponent; +import gregtech.common.gui.widget.prospector.ProspectorMode; +import gregtech.common.gui.widget.prospector.widget.WidgetOreList; +import gregtech.common.gui.widget.prospector.widget.WidgetProspectingMap; +import gregtech.common.gui.widget.terminal.SearchComponent; import net.minecraft.client.resources.I18n; import net.minecraft.entity.Entity; diff --git a/src/main/java/gregtech/common/items/behaviors/TerminalBehaviour.java b/src/main/java/gregtech/common/items/behaviors/TerminalBehaviour.java deleted file mode 100644 index 6ffc8919a40..00000000000 --- a/src/main/java/gregtech/common/items/behaviors/TerminalBehaviour.java +++ /dev/null @@ -1,144 +0,0 @@ -package gregtech.common.items.behaviors; - -import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.capability.IElectricItem; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.items.gui.ItemUIFactory; -import gregtech.api.items.gui.PlayerInventoryHolder; -import gregtech.api.items.metaitem.stats.IItemBehaviour; -import gregtech.api.items.metaitem.stats.ISubItemHandler; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.terminal.hardware.HardwareProvider; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.common.terminal.hardware.BatteryHardware; - -import net.minecraft.client.resources.I18n; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import java.util.List; - -public class TerminalBehaviour implements IItemBehaviour, ItemUIFactory, ISubItemHandler { - - @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, - float hitY, float hitZ, EnumHand hand) { - if (player.isSneaking()) { - ItemStack itemStack = player.getHeldItem(hand); - itemStack.getOrCreateSubCompound("terminal").removeTag("_click"); - if (pos != null) { - itemStack.getOrCreateSubCompound("terminal").setTag("_click", NBTUtil.createPosTag(pos)); - if (!world.isRemote) { - PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand); - holder.openUI(); - } - return EnumActionResult.SUCCESS; - } - } - return EnumActionResult.PASS; - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack itemStack = player.getHeldItem(hand); - itemStack.getOrCreateSubCompound("terminal").removeTag("_click"); - if (!world.isRemote) { - PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand); - holder.openUI(); - } - return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack); - } - - @Override - public void onUpdate(ItemStack itemStack, Entity entity) { - NBTTagCompound tabletNBT = itemStack.getOrCreateSubCompound("terminal"); - if (entity.ticksExisted % 20 == 0 && tabletNBT.hasKey("_ar")) { - if (entity instanceof EntityLivingBase) { - EntityLivingBase livingBase = (EntityLivingBase) entity; - if (!livingBase.getHeldItemMainhand().isItemEqual(itemStack) && - !livingBase.getHeldItemOffhand().isItemEqual(itemStack)) { - return; - } - } - - String appName = tabletNBT.getString("_ar"); - int tier = TerminalRegistry.getApplication(appName).getMaxTier(); - if (!TerminalBehaviour.isCreative(itemStack)) { - tier = Math.min(tabletNBT.getCompoundTag(appName).getInteger("_tier"), tier); - } - long cost = 0; - for (Hardware hardware : TerminalRegistry.getAppHardwareDemand(appName, tier)) { - if (hardware instanceof BatteryHardware) { - cost = ((BatteryHardware) hardware).getCharge(); - break; - } - } - if (cost > 0) { - IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, - null); - if (electricItem != null) { - long back = electricItem.discharge(cost, 999, true, false, false); - if (back != cost) { - tabletNBT.removeTag("_ar"); - } - } else { - tabletNBT.removeTag("_ar"); - } - } - } - } - - @Override - public void addInformation(ItemStack itemStack, List lines) { - HardwareProvider provider = itemStack.getCapability(GregtechCapabilities.CAPABILITY_HARDWARE_PROVIDER, null); - if (isCreative(itemStack)) { - lines.add(I18n.format("metaitem.terminal.tooltip.creative")); - } - if (provider != null) { - List hardware = provider.getHardware(); - lines.add(I18n.format("metaitem.terminal.tooltip.hardware", hardware.size())); - for (Hardware hw : hardware) { - String info = hw.addInformation(); - if (info == null) { - lines.add(hw.getLocalizedName()); - } else { - lines.add(String.format("%s (%s)", hw.getLocalizedName(), info)); - } - } - } - } - - @Override - public ModularUI createUI(PlayerInventoryHolder holder, EntityPlayer entityPlayer) { - return ModularUI.builder(IGuiTexture.EMPTY, 380, 256) - .widget(new TerminalOSWidget(12, 11, holder.getCurrentItem())) - .shouldColor(false) - .build(holder, entityPlayer); - } - - public static boolean isCreative(ItemStack itemStack) { - return itemStack != null && itemStack.getOrCreateSubCompound("terminal").getBoolean("_creative"); - } - - @Override - public String getItemSubType(ItemStack itemStack) { - return ""; - } - - @Override - public void getSubItems(ItemStack itemStack, CreativeTabs creativeTab, NonNullList subItems) { - ItemStack copy = itemStack.copy(); - copy.getOrCreateSubCompound("terminal").setBoolean("_creative", true); - subItems.add(copy); - } -} diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAlarm.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAlarm.java index 67751f893e9..8e0518fb935 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAlarm.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAlarm.java @@ -11,9 +11,9 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.TieredMetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.terminal.gui.widgets.SelectorWidget; import gregtech.client.renderer.texture.Textures; import gregtech.common.ConfigHolder; +import gregtech.common.gui.widget.terminal.gui.widgets.SelectorWidget; import gregtech.core.sound.GTSoundEvents; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/gregtech/common/terminal/app/VirtualTankApp.java b/src/main/java/gregtech/common/terminal/app/VirtualTankApp.java deleted file mode 100644 index ed0e63eefac..00000000000 --- a/src/main/java/gregtech/common/terminal/app/VirtualTankApp.java +++ /dev/null @@ -1,261 +0,0 @@ -package gregtech.common.terminal.app; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.TankWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.util.GTLog; -import gregtech.api.util.virtualregistry.VirtualEnderRegistry; -import gregtech.common.terminal.component.SearchComponent; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -public class VirtualTankApp extends AbstractApplication implements SearchComponent.IWidgetSearch> { - - private WidgetGroup widgetGroup; - private Map, FluidStack> cacheServer; - @SideOnly(Side.CLIENT) - private Map, IFluidTank> cacheClient; - - public VirtualTankApp() { - super("vtank_viewer"); - } - - @Override - public AbstractApplication initApp() { - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2)); - this.addWidget(new LabelWidget(10, 10, "terminal.vtank_viewer.title", -1)); - this.addWidget(new RectButtonWidget(216, 7, 110, 18) - .setClickListener(cd -> { - if (cd.isClient) { - reloadWidgets(cacheClient); - } - }) - .setIcon(new TextTexture("terminal.vtank_viewer.refresh", -1)) - .setFill(TerminalTheme.COLOR_B_2.getColor())); - widgetGroup = new DraggableScrollableWidgetGroup(10, 30, 313, 195) - .setDraggable(true) - .setYScrollBarWidth(3) - .setYBarStyle(null, TerminalTheme.COLOR_F_1); - if (isClient) { - cacheClient = new HashMap<>(); - } else { - cacheServer = new HashMap<>(); - } - this.addWidget(widgetGroup); - if (!isRemote()) { - refresh(); - } - return this; - } - - private List> findVirtualTanks(Map> tankMap) { - List> result = new LinkedList<>(); - for (UUID uuid : tankMap.keySet().stream().sorted(Comparator.nullsLast(UUID::compareTo)) - .collect(Collectors.toList())) { - if (uuid == null || uuid.equals(gui.entityPlayer.getUniqueID())) { - for (String key : tankMap.get(uuid).keySet().stream().sorted().collect(Collectors.toList())) { - result.add(new ImmutablePair<>(uuid, key)); - } - } - } - return result; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (gui.entityPlayer.ticksExisted % 20 == 0) { - refresh(); - } - } - - private void refresh() { - Map> tankMap = VirtualEnderRegistry.createTankMap(); - Map, FluidStack> access = new HashMap<>(); - for (Pair virtualTankEntry : findVirtualTanks(tankMap)) { - UUID uuid = virtualTankEntry.getKey(); - String key = virtualTankEntry.getValue(); - FluidStack fluidStack = tankMap.get(uuid).get(key).getFluid(); - access.put(new ImmutablePair<>(uuid, key), fluidStack == null ? null : fluidStack.copy()); - } - if (access.keySet().containsAll(cacheServer.keySet()) && access.size() == cacheServer.size()) { - List> toUpdated = new LinkedList<>(); - for (Map.Entry, FluidStack> entry : access.entrySet()) { - Pair pair = entry.getKey(); - FluidStack fluidStackNew = entry.getValue(); - FluidStack fluidStackOld = cacheServer.get(pair); - if (fluidStackNew == null && fluidStackOld == null) { - continue; - } - if (fluidStackNew != null && fluidStackOld == null) { - toUpdated.add(pair); - } else if (fluidStackNew == null) { - toUpdated.add(pair); - } else if (fluidStackOld.amount != fluidStackNew.amount || !fluidStackNew.isFluidEqual(fluidStackOld)) { - toUpdated.add(pair); - } - } - if (!toUpdated.isEmpty()) { - writeUpdateInfo(-2, buffer -> { // update specific info - buffer.writeVarInt(toUpdated.size()); - for (Pair update : toUpdated) { - buffer.writeBoolean(update.getKey() != null); - if (update.getKey() != null) { - buffer.writeString(update.getKey().toString()); - } - buffer.writeString(update.getValue()); - FluidStack value = access.get(update); - buffer.writeBoolean(value != null); - if (value != null) { - buffer.writeCompoundTag(value.writeToNBT(new NBTTagCompound())); - } - } - }); - } - return; - } - cacheServer = access; - writeUpdateInfo(-1, buffer -> { // update all info - buffer.writeVarInt(cacheServer.size()); - cacheServer.forEach((key, value) -> { - buffer.writeBoolean(key.getKey() != null); - if (key.getKey() != null) { - buffer.writeString(key.getKey().toString()); - } - buffer.writeString(key.getValue()); - buffer.writeBoolean(value != null); - if (value != null) { - buffer.writeCompoundTag(value.writeToNBT(new NBTTagCompound())); - } - }); - }); - } - - @Override - public void readUpdateInfo(int id, PacketBuffer buffer) { - if (id == -1) { // update all info - int size = buffer.readVarInt(); - cacheClient.clear(); - try { - for (int i = 0; i < size; i++) { - UUID uuid = null; - if (buffer.readBoolean()) { - uuid = UUID.fromString(buffer.readString(32767)); - } - String key = buffer.readString(32767); - IFluidTank fluidTank = new FluidTank(64000); - if (buffer.readBoolean()) { - fluidTank.fill(FluidStack.loadFluidStackFromNBT(buffer.readCompoundTag()), true); - } - cacheClient.put(new ImmutablePair<>(uuid, key), fluidTank); - } - } catch (Exception e) { - GTLog.logger.error("error sync fluid", e); - } - reloadWidgets(cacheClient); - } else if (id == -2) { - int size = buffer.readVarInt(); - try { - for (int i = 0; i < size; i++) { - UUID uuid = null; - if (buffer.readBoolean()) { - uuid = UUID.fromString(buffer.readString(32767)); - } - String key = buffer.readString(32767); - FluidStack fluidStack = null; - if (buffer.readBoolean()) { - fluidStack = FluidStack.loadFluidStackFromNBT(buffer.readCompoundTag()); - } - - IFluidTank fluidTank = cacheClient.get(new ImmutablePair<>(uuid, key)); - if (fluidTank != null) { - fluidTank.drain(64000, true); - if (fluidStack != null) { - fluidTank.fill(fluidStack, true); - } - } - } - } catch (Exception e) { - GTLog.logger.error("error sync fluid", e); - } - } else { - super.readUpdateInfo(id, buffer); - } - } - - private void reloadWidgets(Map, IFluidTank> map) { - widgetGroup.clearAllWidgets(); - AtomicInteger cy = new AtomicInteger(); - map.forEach((key, fluidTank) -> { - if (key.getKey() != null) { - widgetGroup.addWidget(new ImageWidget(0, cy.get() + 4, 8, 8, GuiTextures.LOCK_WHITE)); - } - widgetGroup.addWidget(new TankWidget(fluidTank, 8, cy.get(), 18, 18) - .setAlwaysShowFull(true) - .setBackgroundTexture(GuiTextures.FLUID_SLOT).setClient()); - widgetGroup.addWidget(new LabelWidget(36, cy.get() + 5, key.getValue(), -1) - .setWidth(180)); - cy.addAndGet(23); - }); - } - - @Override - public List getMenuComponents() { - return Collections.singletonList(new SearchComponent<>(this)); - } - - @Override - public String resultDisplay(Pair result) { - FluidStack fluidStack = VirtualEnderRegistry.createTankMap().get(result.getKey()).get(result.getValue()) - .getFluid(); - return String.format("Lock: %b, ID: %s, Fluid: %s", result.getKey() != null, result.getValue(), - fluidStack == null ? "-" : fluidStack.getLocalizedName()); - } - - @Override - public void selectResult(Pair result) { - Map, IFluidTank> map = new HashMap<>(); - map.put(result, cacheClient.get(result)); - reloadWidgets(map); - } - - @Override - public void search(String word, Consumer> find) { - if (!isClient) - return; - for (Map.Entry, IFluidTank> access : cacheClient.entrySet()) { - Pair accessingCover = access.getKey(); - if (accessingCover.getValue() != null && - accessingCover.getValue().toLowerCase().contains(word.toLowerCase())) { - find.accept(accessingCover); - } else { - FluidStack fluidStack = access.getValue().getFluid(); - if (fluidStack != null && fluidStack.getLocalizedName().toLowerCase().contains(word.toLowerCase())) { - find.accept(accessingCover); - } - } - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/appstore/AppCardWidget.java b/src/main/java/gregtech/common/terminal/app/appstore/AppCardWidget.java deleted file mode 100644 index f06ec173db3..00000000000 --- a/src/main/java/gregtech/common/terminal/app/appstore/AppCardWidget.java +++ /dev/null @@ -1,201 +0,0 @@ -package gregtech.common.terminal.app.appstore; - -import gregtech.api.GTValues; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.*; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.AnimaWidgetGroup; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; -import gregtech.client.shader.Shaders; -import gregtech.client.utils.RenderUtil; -import gregtech.common.items.behaviors.TerminalBehaviour; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.awt.*; -import java.util.List; - -public class AppCardWidget extends AnimaWidgetGroup { - - private final AbstractApplication application; - private final AppStoreApp store; - @SideOnly(Side.CLIENT) - private ImageWidget stateWidget; - @SideOnly(Side.CLIENT) - private ImageWidget bgWidget; - @SideOnly(Side.CLIENT) - private IGuiTexture banner; - @SideOnly(Side.CLIENT) - private int offset; - @SideOnly(Side.CLIENT) - private int alpha; - - public AppCardWidget(int x, int y, AbstractApplication application, AppStoreApp store) { - super(x, y, 100, 100); - this.application = application; - this.store = store; - TerminalOSWidget os = store.getOs(); - if (os.isRemote()) { - this.addWidget(new CircleButtonWidget(15, 17) - .setColors(TerminalTheme.COLOR_B_2.getColor(), - application.getThemeColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setHoverText(application.getUnlocalizedName()) - .setIcon(application.getIcon())); - this.addWidget(new ImageWidget(30, 0, 65, 34, - new TextTexture(application.getUnlocalizedName(), -1).setDropShadow(true) - .setWidth(65))); - offset = Math.abs(GTValues.RNG.nextInt()) % 200; - banner = application.getBanner(); - if (os.installedApps.contains(application)) { - if (TerminalBehaviour.isCreative(os.itemStack) || application.getMaxTier() == - Math.min(os.tabletNBT.getCompoundTag(application.getRegistryName()).getInteger("_tier"), - application.getMaxTier())) { - updateState(0); - } else { - updateState(1); - } - } else { - updateState(2); - } - } - } - - @SideOnly(Side.CLIENT) - public void updateState(int state) { - String text = "Latest"; - int bg = 0xff4B4C4C; - if (state == 1) { - text = "Upgrade"; - bg = 0xffF7911F; - } else if (state == 2) { - text = "Install"; - bg = 0xff67F74B; - } - if (stateWidget != null) { - removeWidget(stateWidget); - removeWidget(bgWidget); - } - stateWidget = new ImageWidget(15, 85, 70, 15, - new TextTexture(text, -1).setWidth(70).setDropShadow(true).setType(TextTexture.TextType.HIDE)); - bgWidget = new ImageWidget(15, 85, 70, 13, new ColorRectTexture(bg)); - this.addWidget(bgWidget); - this.addWidget(stateWidget); - } - - private void openDialog() { - new AppPageWidget(application, store, this).open(); - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == -1) { // open page - if (buffer.readBoolean()) { - openDialog(); - } - } else { - super.handleClientAction(id, buffer); - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - writeClientAction(-1, buffer -> buffer.writeBoolean(true)); - openDialog(); - } - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public void hookDrawInForeground(int mouseX, int mouseY) { - // hover - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - if (isMouseOverElement(mouseX, mouseY) && - store.getOs().desktop.widgets.stream().noneMatch(app -> app instanceof TerminalDialogWidget)) { - int dur = 7; - int maxAlpha = 100; // 0-255!!!!! - float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks(); - if (alpha != maxAlpha && interpolator == null) { - interpolator = new Interpolator(0, maxAlpha, dur, Eases.LINEAR, - value -> alpha = value.intValue(), - value -> interpolator = null); - interpolator.start(); - } - // smooth - int color; - if (alpha == maxAlpha) { - color = TerminalTheme.COLOR_B_2.getColor() & 0x00ffffff | ((alpha) << 24); - } else { - color = TerminalTheme.COLOR_B_2.getColor() & 0x00ffffff | - ((alpha + (int) (maxAlpha * partialTicks / dur)) << 24); - } - int finalColor = color; - RenderUtil.useScissor(store.getPosition().x, store.getPosition().y, store.getSize().width, - store.getSize().height, () -> { - drawSolidRect(0, 0, gui.getScreenWidth(), y, finalColor); - drawSolidRect(0, y + height, gui.getScreenWidth(), gui.getScreenHeight(), finalColor); - drawSolidRect(0, y, x, height, finalColor); - drawSolidRect(x + width, y, gui.getScreenWidth(), height, finalColor); - - drawBorder(x, y, width, height, application.getThemeColor(), -1); - }); - } else { - alpha = 0; - } - super.hookDrawInForeground(mouseX, mouseY); - } - - @Override - public void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - Color color = new Color(application.getThemeColor()); - drawSolidRect(x, y, width, height, color.getRGB() & 0x00ffffff | 0x4f000000); - if (banner != null) { - banner.draw(x, y, width, 34); - } else { - if (Shaders.allowedShader()) { - float time = offset + (gui.entityPlayer.ticksExisted + partialTicks) / 20f; - ShaderTexture.createShader("banner.frag").draw(x, y, width, 34, uniformCache -> { - uniformCache.glUniform1F("u_time", time); - uniformCache.glUniform3F("b_color", color.getRed() / 255f, color.getGreen() / 255f, - color.getBlue() / 255f); - }); - } else { - drawSolidRect(x, y, width, 34, color.getRGB()); - } - } - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - - // description - FontRenderer fr = Minecraft.getMinecraft().fontRenderer; - List description = fr.listFormattedStringToWidth(application.getDescription(), 90); - int fColor = store.darkMode ? -1 : 0xff333333; - for (int i = 0; i < Math.min(description.size(), 4); i++) { - fr.drawString(description.get(i), x + 5, y + 40 + i * fr.FONT_HEIGHT, fColor, store.darkMode); - } - if (description.size() > 4) { - fr.drawString("...", x + 5, y + 40 + 4 * fr.FONT_HEIGHT, fColor, store.darkMode); - } - - // shadow - drawGradientRect(x, y + 34, width, 3, 0x6f000000, 0, false); - drawRectShadow(x, y, width, height, 5); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/appstore/AppPageWidget.java b/src/main/java/gregtech/common/terminal/app/appstore/AppPageWidget.java deleted file mode 100644 index dc02aac2078..00000000000 --- a/src/main/java/gregtech/common/terminal/app/appstore/AppPageWidget.java +++ /dev/null @@ -1,305 +0,0 @@ -package gregtech.common.terminal.app.appstore; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; -import gregtech.common.inventory.handlers.SingleItemStackHandler; -import gregtech.common.items.behaviors.TerminalBehaviour; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraftforge.common.util.Constants; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -public class AppPageWidget extends TerminalDialogWidget { - - private final AbstractApplication application; - private final AppCardWidget appCardWidget; - private final AppStoreApp store; - private final CircleButtonWidget[] buttons; - private int lineWidth; - private boolean back; - - public AppPageWidget(AbstractApplication application, AppStoreApp store, AppCardWidget appCardWidget) { // 323 222 - super(store.getOs(), 5, 5, 333 - 10, 232 - 10); - this.appCardWidget = appCardWidget; - this.application = application; - this.store = store; - String name = this.application.getRegistryName(); - int stage = application.getMaxTier() + 1; - - int dur = 323 / (stage + 1); - buttons = new CircleButtonWidget[stage]; - for (int i = 0; i < stage; i++) { - int tier = i; - // upgrade button - buttons[i] = new CircleButtonWidget(dur + dur * i, 110, 6, 2, 0) - .setClickListener(cd -> buttonClicked(tier)); - this.addWidget(buttons[i]); - } - this.addWidget(new CircleButtonWidget(310, 10, 6, 1, 8) - .setColors(0, - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_3.getColor()) - .setIcon(GuiTextures.ICON_REMOVE) - .setHoverText("terminal.store.close") - .setClickListener(cd -> close())); - if (store.getOs().isRemote()) { - // profile - int color = application.getThemeColor(); - int lightColor = color & 0x00ffffff | ((0x6f) << 24); - IGuiTexture profile = application.getProfile(); - this.addWidget(new ImageWidget(10, 15, 80, 80, profile)); - - for (int i = 0; i < stage; i++) { - List demand = TerminalRegistry.getAppHardwareDemand(name, i) - .stream() - .map(hw -> hw.getLocalizedName() + "(" + hw.addInformation() + ")") - .collect(Collectors.toList()); - demand.add(0, application.getTierInformation(i)); - buttons[i].setColors(0, lightColor, color).setHoverText(demand.toArray(new String[0])); - List conditions = TerminalRegistry.getAppHardwareUpgradeConditions(name, i); - // line - if (conditions.size() > 0) { - this.addWidget(new ImageWidget(dur + dur * i, 115, 1, - -18 + (conditions.size() >= 4 ? 4 * 25 : conditions.size() * 25), - new ColorRectTexture(0xafffffff))); - } - // conditions - for (int j = 0; j < conditions.size(); j++) { - this.addWidget(new SlotWidget(new SingleItemStackHandler(conditions.get(j)), 0, - dur + dur * i + 25 * (j / 4) - 9, 120 + 25 * (j % 4), false, false)); - } - } - } - } - - private void buttonClicked(int tier) { - int lastTier; - TerminalOSWidget os = store.getOs(); - if (!os.installedApps.contains(application)) { - lastTier = -1; - } else if (TerminalBehaviour.isCreative(os.itemStack)) { - lastTier = application.getMaxTier(); - } else { - lastTier = Math.min(os.tabletNBT.getCompoundTag(application.getRegistryName()).getInteger("_tier"), - application.getMaxTier()); - } - String name = application.getRegistryName(); - if (tier > lastTier) { - boolean match = true; // inventory match - List requirements = new ArrayList<>(); - ItemStack missStack = null; - if (!gui.entityPlayer.isCreative()) { - for (int i = lastTier + 1; i <= tier; i++) { - for (ItemStack condition : TerminalRegistry.getAppHardwareUpgradeConditions(name, i)) { - boolean miss = true; - for (ItemStack requirement : requirements) { - if (requirement.isItemEqual(condition)) { - requirement.setCount(requirement.getCount() + condition.getCount()); - miss = false; - break; - } - } - if (miss) { - requirements.add(condition.copy()); - } - } - } - for (ItemStack requirement : requirements) { - int left = requirement.getCount(); - for (ItemStack hold : gui.entityPlayer.inventory.mainInventory) { - if (requirement.isItemEqual(hold)) { - if (hold.getCount() < left) { - left -= hold.getCount(); - } else { - left = 0; - } - if (left == 0) { - break; - } - } - } - if (left > 0) { - missStack = requirement.copy(); - missStack.setCount(left); - match = false; - break; - } - } - } - - if (match) { - if (os.isRemote()) { - appCardWidget.updateState(tier == application.getMaxTier() ? 0 : 1); - } - if (!gui.entityPlayer.isCreative()) { // cost - TerminalDialogWidget - .showConfirmDialog(store.getOs(), "terminal.dialog.notice", "terminal.store.match", res -> { - if (res) { - for (ItemStack requirement : requirements) { - int left = requirement.getCount(); - for (ItemStack hold : gui.entityPlayer.inventory.mainInventory) { - if (requirement.isItemEqual(hold)) { - if (hold.getCount() <= left) { - hold.setCount(0); - left -= hold.getCount(); - } else { - hold.setCount(hold.getCount() - left); - left = 0; - } - if (left == 0) { - break; - } - } - } - } - updateTerminalAppTier(tier, lastTier); - } - }).open(); - } else { - updateTerminalAppTier(tier, lastTier); - } - } else { - if (isRemote()) { - TerminalDialogWidget.showInfoDialog(store.getOs(), - "terminal.dialog.notice", - I18n.format("terminal.store.miss", missStack.getDisplayName(), missStack.getCount())) - .setClientSide().open(); - } - } - } - } - - private void updateTerminalAppTier(int tier, int lastTier) { - TerminalOSWidget os = store.getOs(); - os.openedApps.stream() - .filter(app -> app.getRegistryName().equals(this.application.getRegistryName())) - .findFirst() - .ifPresent(app -> os.closeApplication(app, os.isRemote())); - if (lastTier == -1) { // update terminal - NBTTagList installed = os.tabletNBT.getTagList("_installed", Constants.NBT.TAG_STRING); - installed.appendTag(new NBTTagString(application.getRegistryName())); - os.tabletNBT.setTag("_installed", installed); - os.installApplication(application); - } - NBTTagCompound tag = os.tabletNBT.getCompoundTag(application.getRegistryName()); - tag.setInteger("_tier", tier); - os.tabletNBT.setTag(application.getRegistryName(), tag); - lineWidth = 0; - } - - @Override - public void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - - GlStateManager.disableDepth(); - - drawSolidRect(x, y, width, height, store.darkMode ? 0xcf000000 : 0xdfdddddd); - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - int stage; - TerminalOSWidget os = store.getOs(); - if (!os.installedApps.contains(application)) { - stage = 0; - } else if (TerminalBehaviour.isCreative(os.itemStack)) { - stage = application.getMaxTier() + 1; - } else { - stage = Math.min(os.tabletNBT.getCompoundTag(application.getRegistryName()).getInteger("_tier"), - application.getMaxTier()) + 1; - } - int maxStage = application.getMaxTier() + 1; - int color = application.getThemeColor(); - int lightColor = color & 0x00ffffff | ((0x6f) << 24); - int dur = 323 / (maxStage + 1); - - int hover = -1; - for (int i = 0; i < buttons.length; i++) { - if (buttons[i].isMouseOverElement(mouseX, mouseY)) { - hover = i; - } - } - - // draw current tier - drawSolidRect(x, y + 110 - 2, dur * stage, 4, color); - if (stage == maxStage) { - drawSolidRect(x + stage * dur, y + 110 - 2, dur, 4, color); - } else { - drawSolidRect(x + stage * dur, y + 110 - 2, dur, 4, lightColor); - } - - int end = dur * (hover + 1 - stage); - - if (hover + 1 > stage) { - if (lineWidth != end && (interpolator == null || back)) { - back = false; - interpolator = new Interpolator(lineWidth, end, (end - lineWidth) / 15, Eases.LINEAR, - value -> lineWidth = value.intValue(), - value -> interpolator = null); - interpolator.start(); - } - } else { - if (lineWidth != 0 && (interpolator == null || !back)) { - back = true; - interpolator = new Interpolator(lineWidth, 0, lineWidth / 15, Eases.LINEAR, - value -> lineWidth = value.intValue(), - value -> interpolator = null); - interpolator.start(); - } - } - - if (lineWidth != 0) { - int smoothWidth = lineWidth; - if (hover + 1 > stage) { - if (lineWidth != end) { - smoothWidth += partialTicks * end / 10; - } - } else { - smoothWidth -= partialTicks * end / 10; - } - - drawSolidRect(x + stage * dur, y + 110 - 2, smoothWidth, 4, color); - } - - // description - FontRenderer fr = Minecraft.getMinecraft().fontRenderer; - List description = fr.listFormattedStringToWidth(application.getDescription(), 210); - int fColor = store.darkMode ? -1 : 0xff333333; - String localizedName = I18n.format(application.getUnlocalizedName()); - drawStringSized(localizedName, x + 100, y + 14, fColor, store.darkMode, 2, false); - if (isMouseOver(x + 100, y + 14, fr.getStringWidth(localizedName) * 2, fr.FONT_HEIGHT * 2, mouseX, mouseY)) { - drawHoveringText(ItemStack.EMPTY, Collections.singletonList("(" + application.getRegistryName() + ")"), 200, - mouseX, mouseY); - } - for (int i = 0; i < description.size(); i++) { - fr.drawString(description.get(i), x + 100, y + 35 + i * fr.FONT_HEIGHT, fColor, store.darkMode); - } - - drawBorder(x + 10, y + 15, 80, 80, store.darkMode ? -1 : 0xff333333, 2); - - GlStateManager.enableDepth(); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/appstore/AppStoreApp.java b/src/main/java/gregtech/common/terminal/app/appstore/AppStoreApp.java deleted file mode 100644 index 6e1ffea4e6e..00000000000 --- a/src/main/java/gregtech/common/terminal/app/appstore/AppStoreApp.java +++ /dev/null @@ -1,114 +0,0 @@ -package gregtech.common.terminal.app.appstore; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.util.Size; -import gregtech.common.items.MetaItems; -import gregtech.common.terminal.component.ClickComponent; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.Collections; -import java.util.List; - -public class AppStoreApp extends AbstractApplication { - - @SideOnly(Side.CLIENT) - protected boolean darkMode; - - public AppStoreApp() { - super("store"); - } - - @Override - public IGuiTexture getIcon() { - return new ItemStackTexture(MetaItems.COIN_GOLD_ANCIENT.getStackForm()); - } - - @Override - public AbstractApplication initApp() { - DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, 333, 232); - this.addWidget(group); - int index = 0; - int yOffset = 50; - group.addWidget(new ImageWidget(0, 0, 333, 30, GuiTextures.UI_FRAME_SIDE_UP)); - group.addWidget(new LabelWidget(333 / 2, 10, getUnlocalizedName(), -1).setShadow(true).setYCentered(true) - .setXCentered(true)); - for (AbstractApplication app : TerminalRegistry.getAllApps()) { - group.addWidget(new AppCardWidget(5 + 110 * (index % 3), yOffset + 110 * (index / 3), app, this)); - index++; - } - int y = yOffset + 110 * ((index + 2) / 3); - group.addWidget(new ImageWidget(0, y, 333, 30, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()))); - group.addWidget( - new ImageWidget(0, y, 333, 30, new TextTexture("Copyright @2021-xxxx Gregicality Team XD", -1))); - loadLocalConfig(nbt -> this.darkMode = nbt.getBoolean("dark")); - return this; - } - - @Override - public NBTTagCompound closeApp() { - for (Widget widget : getOs().desktop.widgets) { - if (widget instanceof AppPageWidget) { - ((AppPageWidget) widget).close(); - } - } - saveLocalConfig(nbt -> nbt.setBoolean("dark", this.darkMode)); - return super.closeApp(); - } - - @Override - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - drawSolidRect(x, y, width, height, darkMode ? TerminalTheme.COLOR_B_2.getColor() : 0x9fffffff); - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public List getMenuComponents() { - ClickComponent darkMode = new ClickComponent().setIcon(GuiTextures.ICON_VISIBLE) - .setHoverText("terminal.prospector.vis_mode").setClickConsumer(cd -> { - if (cd.isClient) { - this.darkMode = !this.darkMode; - } - }); - return Collections.singletonList(darkMode); - } - - @Override - public void onOSSizeUpdate(int width, int height) { - this.setSize(new Size(width, height)); - for (Widget dragWidget : this.widgets) { - if (dragWidget instanceof DraggableScrollableWidgetGroup) { - int lastWidth = dragWidget.getSize().width; - for (Widget widget : ((DraggableScrollableWidgetGroup) dragWidget).widgets) { - if (widget instanceof AppCardWidget) { - widget.addSelfPosition((width - lastWidth) / 2, 0); - } else if (widget instanceof ImageWidget) { - widget.setSize(new Size(width, 30)); - } else { - widget.addSelfPosition((width - lastWidth) / 2, 0); - } - } - dragWidget.setSize(new Size(width, height)); - } - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryManagerApp.java b/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryManagerApp.java deleted file mode 100644 index 25fae6eee53..00000000000 --- a/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryManagerApp.java +++ /dev/null @@ -1,65 +0,0 @@ -package gregtech.common.terminal.app.batterymanager; - -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.items.MetaItems; -import gregtech.common.terminal.hardware.BatteryHardware; - -import net.minecraft.client.resources.I18n; - -import java.util.concurrent.atomic.AtomicInteger; - -public class BatteryManagerApp extends AbstractApplication { - - public BatteryManagerApp() { - super("battery"); - } - - @Override - public IGuiTexture getIcon() { - return new ItemStackTexture(MetaItems.BATTERY_HV_SODIUM.getStackForm()); - } - - @Override - public boolean isClientSideApp() { - return true; - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2)); - this.addWidget(new ImageWidget(170, 15, 1, 232 - 30, TerminalTheme.COLOR_7)); - this.addWidget(new BatteryWidget(10, 10 + (212 - 150) / 2, 150, 150, getOs())); - addBatteryApps(); - } - return this; - } - - private void addBatteryApps() { - AtomicInteger index = new AtomicInteger(); - for (AbstractApplication installed : getOs().installedApps) { - TerminalRegistry - .getAppHardwareDemand(installed.getRegistryName(), - getOs().tabletNBT.getCompoundTag(installed.getRegistryName()).getInteger("_tier")) - .stream() - .filter(i -> i instanceof BatteryHardware).findFirst() - .ifPresent(battery -> { - long charge = ((BatteryHardware) battery).getCharge(); - this.addWidget(new RectButtonWidget(180 + (index.get() % 5) * 30, 15 + (index.get() / 5) * 30, - 20, 20, 2) - .setIcon(installed.getIcon()) - // warn unsafe call the I18n here. - .setHoverText(I18n.format("terminal.battery.hover", - I18n.format(installed.getUnlocalizedName()), charge)) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0)); - index.getAndIncrement(); - }); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryWidget.java b/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryWidget.java deleted file mode 100644 index 50dc490e3dd..00000000000 --- a/src/main/java/gregtech/common/terminal/app/batterymanager/BatteryWidget.java +++ /dev/null @@ -1,62 +0,0 @@ -package gregtech.common.terminal.app.batterymanager; - -import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.capability.IElectricItem; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ShaderTexture; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.client.shader.Shaders; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BatteryWidget extends Widget { - - @SideOnly(Side.CLIENT) - private ShaderTexture battery; - private final TerminalOSWidget os; - - public BatteryWidget(int x, int y, int width, int height, TerminalOSWidget os) { - super(x, y, width, height); - this.os = os; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - float left = 0; - IElectricItem electricItem = os.hardwareProvider.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, - null); - if (electricItem != null) { - left = electricItem.getCharge() / (float) electricItem.getMaxCharge(); - } - if (Shaders.allowedShader()) { - float progress = left; - float time = (gui.entityPlayer.ticksExisted + partialTicks) / 20f; - int color = TerminalTheme.COLOR_F_1.getColor(); - if (battery == null) { - battery = ShaderTexture.createShader("battery.frag"); - } - battery.draw(x, y, width, height, uniformCache -> { - uniformCache.glUniform1F("u_time", time); - uniformCache.glUniform1F("progress", progress); - uniformCache.glUniform3F("c_ring", .55f, .7f, .7f); - uniformCache.glUniform3F("c_sector", (color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, - (color & 255) / 255.0F); - uniformCache.glUniform3F("c_water", (1 - progress), progress, 0f); - }); - } else { - int b_color = (int) (255 * (1 - left)) << 16 | (int) (255 * left) << 8 | 255 << 24; - drawBorder(x, y, width, height, TerminalTheme.COLOR_1.getColor(), 2); - drawSolidRect(x, y + height - (int) (height * left), width, (int) (height * left), b_color); - } - drawStringSized(String.format("%.2f%%", left * 100), x + width / 2f + 3, y + height / 2f - 7, -1, true, 2, - true); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/capeselector/CapeSelectorApp.java b/src/main/java/gregtech/common/terminal/app/capeselector/CapeSelectorApp.java deleted file mode 100644 index 2105e3ed11e..00000000000 --- a/src/main/java/gregtech/common/terminal/app/capeselector/CapeSelectorApp.java +++ /dev/null @@ -1,62 +0,0 @@ -package gregtech.common.terminal.app.capeselector; - -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.client.renderer.texture.Textures; -import gregtech.common.terminal.app.capeselector.widget.CapeListWidget; - -public class CapeSelectorApp extends AbstractApplication { - - protected CapeListWidget capeListWidget; - - public CapeSelectorApp() { - super("cape_selector"); - } - - @Override - public IGuiTexture getIcon() { - return new TextureArea(Textures.GREGTECH_CAPE_TEXTURE, 28f / 64, 0, 22f / 64, 22f / 32); - } - - @Override - public AbstractApplication initApp() { - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2)); - - this.setCapeList(new CapeListWidget(27, 43, 4, 3, this.gui.entityPlayer.getPersistentID())); - this.getCapeList().setYScrollBarWidth(3).setYBarStyle(null, TerminalTheme.COLOR_F_1); - - this.addWidget(new SimpleTextWidget(166, 33, "", 0xFFFFFF, () -> { - if (this.getCapeList().getCapes() == null || this.getCapeList().getCapes().isEmpty()) { - return "terminal.cape_selector.empty"; - } - return "terminal.cape_selector.select"; - })); - - this.addWidget(new SimpleTextWidget(166, 45, "", 0xFFFFFF, () -> { - if (this.getCapeList().getCapes() == null || this.getCapeList().getCapes().isEmpty()) { - return "terminal.cape_selector.tip"; - } - return ""; - })); - - return super.initApp(); - } - - protected void setCapeList(CapeListWidget widget) { - this.capeListWidget = widget; - this.addWidget(capeListWidget); - } - - public CapeListWidget getCapeList() { - return this.capeListWidget; - } - - @Override - public boolean isClientSideApp() { - return false; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/capeselector/widget/CapeListWidget.java b/src/main/java/gregtech/common/terminal/app/capeselector/widget/CapeListWidget.java deleted file mode 100644 index 98f7bd57e35..00000000000 --- a/src/main/java/gregtech/common/terminal/app/capeselector/widget/CapeListWidget.java +++ /dev/null @@ -1,126 +0,0 @@ -package gregtech.common.terminal.app.capeselector.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.SizedTextureArea; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ClickButtonWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.CapesRegistry; -import gregtech.client.utils.RenderUtil; - -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class CapeListWidget extends DraggableScrollableWidgetGroup { - - private final UUID uuid; - private List capes; - private int selectedX, selectedY = -1; - - public CapeListWidget(int xPosition, int yPosition, int width, int height, UUID uuid) { - super(xPosition, yPosition, width * 70, height * 56); // Cape banners are 28x44, expanded to 70x56 - this.uuid = uuid; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (capes == null) { - updateCapeCandidates(CapesRegistry.getUnlockedCapes(uuid)); - writeUpdateInfo(-1, buf -> { - buf.writeVarInt(capes.size()); - capes.stream().map(ResourceLocation::toString).forEach(buf::writeString); - }); - } - } - - @Override - public void readUpdateInfo(int id, PacketBuffer buffer) { - if (id == -1) { - capes = new ArrayList<>(); - int count = buffer.readVarInt(); - for (int i = 0; i < count; i++) { - capes.add(new ResourceLocation(buffer.readString(Short.MAX_VALUE))); - } - updateCapeCandidates(capes); - } else { - super.readUpdateInfo(id, buffer); - } - } - - private void updateCapeCandidates(List capes) { - this.capes = capes; - int width = (getSize().width) / 70; - int rowNumber = 0; - if (capes == null || capes.isEmpty()) return; - int i = 0; - while (true) { - WidgetGroup row = new WidgetGroup(); - for (int rowPosition = 0; rowPosition < width; rowPosition++) { - TextureArea capeImage = new SizedTextureArea(capes.get(i), 0.5, 0, 14f / 64, 22f / 32, 28, 44); - - int finalRowPosition = rowPosition; - int finalRowNumber = rowNumber; - int finalI = i; - ClickButtonWidget capeButton = new ClickButtonWidget(rowPosition * 70 + 21, rowNumber * 56, 28, 44, "", - (data) -> this.setCape(finalRowPosition, finalRowNumber, capes.get(finalI))) - .setButtonTexture(capeImage) - .setShouldClientCallback(true); - row.addWidget(capeButton); - - if (capes.get(i).equals(CapesRegistry.getPlayerCape(uuid))) { // If this is the cape that the player is - // wearing right now, select it. - selectedX = finalRowPosition; - selectedY = finalRowNumber; - } - i++; - if (i == capes.size()) { - this.addWidget(row); - return; - } - } - this.addWidget(row); - rowNumber++; - } - } - - private void setCape(int x, int y, ResourceLocation cape) { - if (selectedX == x && selectedY == y) { - selectedX = -1; // Sets a "not in use" flag. - cape = null; - } else { - selectedX = x; - selectedY = y; - } - if (!isRemote()) { - CapesRegistry.giveCape(uuid, cape); - } - } - - public List getCapes() { - return capes; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - - if (selectedX == -1 || selectedY == -1) - return; - - // Get selected cape button - Widget button = ((WidgetGroup) this.widgets.get(this.selectedY)).widgets.get(this.selectedX); - - RenderUtil.useScissor(getPosition().x, getPosition().y, getSize().width - yBarWidth, - getSize().height - xBarHeight, () -> { - drawSelectionOverlay(button.getPosition().x - 6, button.getPosition().y - 6, - button.getSize().width + 12, button.getSize().height + 12); // Add a bit of margin - }); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/console/ConsoleApp.java b/src/main/java/gregtech/common/terminal/app/console/ConsoleApp.java deleted file mode 100644 index 6147c219ad4..00000000000 --- a/src/main/java/gregtech/common/terminal/app/console/ConsoleApp.java +++ /dev/null @@ -1,55 +0,0 @@ -package gregtech.common.terminal.app.console; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.MachineSceneWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.common.metatileentities.storage.MetaTileEntityWorkbench; - -import net.minecraft.tileentity.TileEntity; - -public class ConsoleApp extends AbstractApplication { - - public ConsoleApp() { - super("console"); - } - - private IGregTechTileEntity getMTE() { - if (os.clickPos != null) { - TileEntity te = os.getModularUI().entityPlayer.world.getTileEntity(os.clickPos); - if (te instanceof IGregTechTileEntity && ((IGregTechTileEntity) te).isValid()) { - return (IGregTechTileEntity) te; - } - } - return null; - } - - @Override - public AbstractApplication initApp() { - IGregTechTileEntity mteResult = getMTE(); - - if (mteResult == null || - mteResult.getMetaTileEntity() instanceof MetaTileEntityWorkbench) // Remove Crafting Station compat - { // 333 232 - TerminalDialogWidget.showInfoDialog(os, - "terminal.dialog.notice", - "terminal.console.notice", - () -> os.closeApplication(this, isClient)).open(); - return this; - } - MachineConsoleWidget consoleWidget = new MachineConsoleWidget(200, 16, 133, 200); - this.addWidget(consoleWidget); - if (isClient) { - this.addWidget(0, - new MachineSceneWidget(0, 16, 200, 200, os.clickPos).setOnSelected(consoleWidget::setFocus)); - this.addWidget(new ImageWidget(0, 0, 333, 16, GuiTextures.UI_FRAME_SIDE_UP)); - this.addWidget(new ImageWidget(0, 216, 333, 16, GuiTextures.UI_FRAME_SIDE_DOWN)); - } else { - this.addWidget(0, new WidgetGroup()); // placeholder - } - return this; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/console/MachineConsoleWidget.java b/src/main/java/gregtech/common/terminal/app/console/MachineConsoleWidget.java deleted file mode 100644 index a3272fa06c3..00000000000 --- a/src/main/java/gregtech/common/terminal/app/console/MachineConsoleWidget.java +++ /dev/null @@ -1,466 +0,0 @@ -package gregtech.common.terminal.app.console; - -import gregtech.api.capability.GregtechTileCapabilities; -import gregtech.api.capability.IControllable; -import gregtech.api.capability.impl.AbstractRecipeLogic; -import gregtech.api.capability.impl.RecipeLogicSteam; -import gregtech.api.cover.Cover; -import gregtech.api.cover.CoverWithUI; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.*; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; -import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Size; -import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMaintenanceHatch; -import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart; -import gregtech.common.metatileentities.storage.MetaTileEntityQuantumChest; -import gregtech.common.metatileentities.storage.MetaTileEntityQuantumTank; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Items; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.items.ItemStackHandler; - -import org.lwjgl.opengl.GL11; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/08/25 - * @Description: - */ -public class MachineConsoleWidget extends WidgetGroup { - - private BlockPos pos; - private EnumFacing facing; - private MetaTileEntity mte; - private UIWidgetGroup uiWidgetGroup; - - public MachineConsoleWidget(int x, int y, int width, int height) { - super(x, y, width, height); - } - - public void setFocus(BlockPos pos, EnumFacing facing) { - this.pos = new BlockPos(pos); - this.facing = facing; - this.mte = null; - checkMachine(); - } - - @Override - public void updateScreen() { - super.updateScreen(); - checkMachine(); - } - - private void checkMachine() { - if (mte != null && mte.isValid()) { - return; - } - if (pos != null && facing != null) { - TileEntity te = gui.entityPlayer.world.getTileEntity(pos); - clearAllWidgets(); - if (te instanceof IGregTechTileEntity && ((IGregTechTileEntity) te).isValid()) { - mte = ((IGregTechTileEntity) te).getMetaTileEntity(); - initWidgets(); - if (isRemote()) { - writeClientAction(5, buf -> { - buf.writeBlockPos(pos); - buf.writeByte(facing.getIndex()); - }); - } - } - } - } - - private void initWidgets() { - if (mte != null) { - uiWidgetGroup = new UIWidgetGroup(); - uiWidgetGroup.setActive(false); - uiWidgetGroup.setVisible(false); - Size size = getSize(); - addWidget(new ImageWidget(0, 0, size.width, size.height, GuiTextures.BACKGROUND)); - addWidget(new SimpleTextWidget(size.width / 2, 12, "", -1, () -> facing.toString().toUpperCase()) - .setShadow(true)); - int y = 20; - if (mte.hasFrontFacing()) { - addWidget(new RectButtonWidget(10, y, size.width - 20, 20, 1) - .setClickListener(clickData -> { - if (!isRemote() && mte.isValidFrontFacing(facing)) { - mte.setFrontFacing(facing); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.console.front", -1))); - y += 25; - } - - // IControllable - IControllable controllable = mte.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, facing); - if (controllable != null) { - addWidget(new RectButtonWidget(10, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_WORKING_ENABLE.getSubArea(0, 0, 1, 0.5), (c, p) -> { - if (!isRemote()) { - controllable.setWorkingEnabled(p); - } - }) - .setValueSupplier(false, controllable::isWorkingEnabled) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.controllable") - .setIcon(GuiTextures.BUTTON_WORKING_ENABLE.getSubArea(0, 0.5, 1, 0.5))); - // AbstractRecipeLogic - AbstractRecipeLogic recipeLogic = mte.getCapability(GregtechTileCapabilities.CAPABILITY_RECIPE_LOGIC, - facing); - if (recipeLogic != null) { - addWidget(new CycleButtonWidget(35, y, 20, 20, - recipeLogic.getAvailableOverclockingTiers(), recipeLogic::getOverclockTier, - recipeLogic::setOverclockTier) - .setTooltipHoverString("gregtech.gui.overclock.description") - .setButtonTexture(GuiTextures.BUTTON_OVERCLOCK)); - addWidget(new ProgressWidget(recipeLogic::getProgressPercent, 60, y, 63, 20, - GuiTextures.PROGRESS_BAR_ARC_FURNACE, ProgressWidget.MoveType.HORIZONTAL)); - if (recipeLogic instanceof RecipeLogicSteam) { - y += 25; - addWidget(new RectButtonWidget(10, y, size.width - 20, 20, 1) - .setClickListener(clickData -> { - EnumFacing currentVentingSide = ((RecipeLogicSteam) recipeLogic).getVentingSide(); - if (currentVentingSide == facing || mte.getFrontFacing() == facing) return; - ((RecipeLogicSteam) recipeLogic).setVentingSide(facing); - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.console.venting", -1))); - } - } - y += 25; - } - - // SimpleMachineMetaTileEntity - if (mte instanceof SimpleMachineMetaTileEntity) { - SimpleMachineMetaTileEntity simpleMTE = (SimpleMachineMetaTileEntity) mte; - // items output - if (simpleMTE.getExportItems().getSlots() > 0) { - addWidget(new ImageWidget(10, y, 20, 20, new ItemStackTexture(Items.GLOWSTONE_DUST))); - addWidget(new RectButtonWidget(33, y, 50, 20, 1) - .setClickListener(clickData -> { - if (!isRemote() && mte.getFrontFacing() != facing) { - simpleMTE.setOutputFacingItems(facing); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setHoverText("terminal.console.items")); - addWidget(new SimpleTextWidget(58, y + 10, "", -1, - () -> simpleMTE.getOutputFacingItems().toString())); - addWidget(new RectButtonWidget(83, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ITEM_OUTPUT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - simpleMTE.setAutoOutputItems(p); - } - }) - .setInitValue(simpleMTE.isAutoOutputItems()) - .setValueSupplier(false, simpleMTE::isAutoOutputItems) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.auto_output") - .setIcon(GuiTextures.BUTTON_ITEM_OUTPUT.getSubArea(0, 0, 1, 0.5))); - addWidget(new RectButtonWidget(103, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0.5, 1, 0.5), - (c, p) -> { - if (!isRemote()) { - simpleMTE.setAllowInputFromOutputSideItems(p); - } - }) - .setInitValue(simpleMTE.isAllowInputFromOutputSideItems()) - .setValueSupplier(false, simpleMTE::isAllowInputFromOutputSideItems) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.input") - .setIcon(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0, 1, 0.5))); - y += 20; - } - - // fluids output - if (simpleMTE.getExportFluids().getTanks() > 0) { - addWidget(new ImageWidget(10, y, 20, 20, new ItemStackTexture(Items.WATER_BUCKET))); - addWidget(new RectButtonWidget(33, y, 50, 20, 1) - .setClickListener(clickData -> { - if (!isRemote() && simpleMTE.getFrontFacing() != facing) { - simpleMTE.setOutputFacingFluids(facing); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setHoverText("terminal.console.fluids")); - addWidget(new SimpleTextWidget(58, y + 10, "", -1, - () -> simpleMTE.getOutputFacingFluids().toString())); - addWidget(new RectButtonWidget(83, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_FLUID_OUTPUT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - simpleMTE.setAutoOutputFluids(p); - } - }) - .setInitValue(simpleMTE.isAutoOutputFluids()) - .setValueSupplier(false, simpleMTE::isAutoOutputFluids) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.auto_output") - .setIcon(GuiTextures.BUTTON_FLUID_OUTPUT.getSubArea(0, 0, 1, 0.5))); - addWidget(new RectButtonWidget(103, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0.5, 1, 0.5), - (c, p) -> { - if (!isRemote()) { - simpleMTE.setAllowInputFromOutputSideFluids(p); - } - }) - .setInitValue(simpleMTE.isAllowInputFromOutputSideFluids()) - .setValueSupplier(false, simpleMTE::isAllowInputFromOutputSideFluids) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.input") - .setIcon(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0, 1, 0.5))); - y += 20; - } - y += 5; - } - - // MetaTileEntityQuantumTank - if (mte instanceof MetaTileEntityQuantumChest) { - MetaTileEntityQuantumChest chest = (MetaTileEntityQuantumChest) mte; - addWidget(new ImageWidget(10, y, 20, 20, new ItemStackTexture(Items.GLOWSTONE_DUST))); - addWidget(new RectButtonWidget(33, y, 50, 20, 1) - .setClickListener(clickData -> { - if (!isRemote() && mte.getFrontFacing() != facing) { - chest.setOutputFacing(facing); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setHoverText("terminal.console.items")); - addWidget(new SimpleTextWidget(58, y + 10, "", -1, () -> chest.getOutputFacing().toString())); - addWidget(new RectButtonWidget(83, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ITEM_OUTPUT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - chest.setAutoOutputItems(p); - } - }) - .setInitValue(chest.isAutoOutputItems()) - .setValueSupplier(false, chest::isAutoOutputItems) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.auto_output") - .setIcon(GuiTextures.BUTTON_ITEM_OUTPUT.getSubArea(0, 0, 1, 0.5))); - addWidget(new RectButtonWidget(103, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - chest.setAllowInputFromOutputSide(p); - } - }) - .setInitValue(chest.isAllowInputFromOutputSideItems()) - .setValueSupplier(false, chest::isAllowInputFromOutputSideItems) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.input") - .setIcon(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0, 1, 0.5))); - y += 25; - } else if (mte instanceof MetaTileEntityQuantumTank) { - MetaTileEntityQuantumTank tank = (MetaTileEntityQuantumTank) mte; - addWidget(new ImageWidget(10, y, 20, 20, new ItemStackTexture(Items.WATER_BUCKET))); - addWidget(new RectButtonWidget(33, y, 50, 20, 1) - .setClickListener(clickData -> { - if (!isRemote() && tank.getFrontFacing() != facing) { - tank.setOutputFacing(facing); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setHoverText("terminal.console.fluids")); - addWidget(new SimpleTextWidget(58, y + 10, "", -1, () -> tank.getOutputFacing().toString())); - addWidget(new RectButtonWidget(83, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_FLUID_OUTPUT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - tank.setAutoOutputFluids(p); - } - }) - .setInitValue(tank.isAutoOutputFluids()) - .setValueSupplier(false, tank::isAutoOutputFluids) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.auto_output") - .setIcon(GuiTextures.BUTTON_FLUID_OUTPUT.getSubArea(0, 0, 1, 0.5))); - addWidget(new RectButtonWidget(103, y, 20, 20, 1) - .setToggleButton(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0.5, 1, 0.5), (c, p) -> { - if (!isRemote()) { - tank.setAllowInputFromOutputSide(p); - } - }) - .setInitValue(tank.isAllowInputFromOutputSideFluids()) - .setValueSupplier(false, tank::isAllowInputFromOutputSideFluids) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), 0) - .setHoverText("terminal.console.input") - .setIcon(GuiTextures.BUTTON_ALLOW_IMPORT_EXPORT.getSubArea(0, 0, 1, 0.5))); - y += 25; - } - - // MultiBlockPart - if (mte instanceof MetaTileEntityMultiblockPart) { - // MetaTileEntityMaintenanceHatch - if (mte instanceof MetaTileEntityMaintenanceHatch) { - addWidget(new RectButtonWidget(10, y, size.width - 20, 20, 1) - .setClickListener(clickData -> { - if (!isRemote()) { - ((MetaTileEntityMaintenanceHatch) mte).fixAllMaintenanceProblems(); - } - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.console.maintenance", -1))); - y += 25; - } - } - - // CoverBehavior - Cover cover = mte.getCoverAtSide(facing); - if (cover != null) { - this.addWidget(new SlotWidget(new ItemStackHandler(NonNullList.withSize(1, cover.getPickItem())), 0, - 10, y, false, false)); - addWidget(new SimpleTextWidget(58, y + 10, "terminal.console.cover_rs", -1, - () -> String.valueOf(cover.getRedstoneSignalOutput())).setShadow(true).setCenter(true)); - if (cover instanceof CoverWithUI) { - addWidget(new RectButtonWidget(83, y, 40, 20, 1) - .setClickListener( - clickData -> uiWidgetGroup.openUI(((CoverWithUI) cover).createUI(gui.entityPlayer))) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.console.cover_gui", -1))); - } - y += 25; - } - addWidget(new RectButtonWidget(10, y, size.width - 20, 20, 1) - .setClickListener(clickData -> uiWidgetGroup.openUI(mte.getModularUI(gui.entityPlayer))) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.console.gui", -1))); - - addWidget(uiWidgetGroup); - } - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == 5) { - setFocus(buffer.readBlockPos(), EnumFacing.VALUES[buffer.readByte()]); - } else { - super.handleClientAction(id, buffer); - } - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - if (uiWidgetGroup != null && uiWidgetGroup.isVisible()) { - return; - } - super.drawInForeground(mouseX, mouseY); - } - - private static class UIWidgetGroup extends WidgetGroup { - - private IGuiTexture background; - - public void clearUI() { - background = null; - clearAllWidgets(); - setActive(false); - setVisible(false); - } - - public void openUI(ModularUI ui) { - clearUI(); - if (ui != null) { - background = ui.backgroundPath; - for (Widget widget : ui.guiWidgets.values()) { - if (widget instanceof SlotWidget) { - SlotWidget slotWidget = (SlotWidget) widget; - if (slotWidget.getHandle().getStack() == gui.entityPlayer.getHeldItem(EnumHand.MAIN_HAND)) { - slotWidget.setActive(false); - } - } - addWidget(widget); - } - setSize(new Size(ui.getWidth(), ui.getHeight())); - addSelfPosition(gui.getScreenWidth() / 2 - getPosition().x - ui.getWidth() / 2, - gui.getScreenHeight() / 2 - getPosition().y - ui.getHeight() / 2); - setActive(true); - setVisible(true); - } - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - drawSolidRect(0, 0, gui.getScreenWidth(), gui.getScreenHeight(), 0xbf000000); - if (background != null) { - background.draw(getPosition().x, getPosition().y, getSize().width, getSize().height); - } - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.disableDepth(); - super.drawInBackground(mouseX, mouseY, partialTicks, context); - GlStateManager.enableDepth(); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } - - @Override - public boolean keyTyped(char charTyped, int keyCode) { - if (keyCode == 1) { - clearUI(); - writeClientAction(5, buffer -> buffer.writeBoolean(true)); - return true; - } - super.keyTyped(charTyped, keyCode); - return true; - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == 5) { - if (buffer.readBoolean()) { - clearUI(); - } - } else { - super.handleClientAction(id, buffer); - } - } - - @Override - public boolean mouseWheelMove(int mouseX, int mouseY, int wheelDelta) { - super.mouseWheelMove(mouseX, mouseY, wheelDelta); - return true; - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - super.mouseClicked(mouseX, mouseY, button); - return true; - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - super.mouseDragged(mouseX, mouseY, button, timeDragged); - return true; - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - super.mouseReleased(mouseX, mouseY, button); - return true; - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/maze/MazeApp.java b/src/main/java/gregtech/common/terminal/app/game/maze/MazeApp.java deleted file mode 100644 index bd944c9d9da..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/maze/MazeApp.java +++ /dev/null @@ -1,274 +0,0 @@ -package gregtech.common.terminal.app.game.maze; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.ClickButtonWidget; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.terminal.app.game.maze.widget.EnemyWidget; -import gregtech.common.terminal.app.game.maze.widget.MazeWidget; -import gregtech.common.terminal.app.game.maze.widget.PlayerWidget; - -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -public class MazeApp extends AbstractApplication { - - private int gameState = 0; - private PlayerWidget player; - private EnemyWidget enemy; - private MazeWidget maze; - private int timer = 0; - private int mazesSolved = 0; - private float speed = 25; - private int lastPlayerInput = -2; - public static int MAZE_SIZE = 9; - private List movementStore; - private boolean lastPausePress; - - private List[] FSM; - - public MazeApp() { - super("maze"); - } - - public AbstractApplication initApp() { - if (isClient) { - movementStore = new ArrayList<>(); - FSM = new List[4]; - FSM[0] = new LinkedList<>(); - FSM[1] = new LinkedList<>(); - FSM[2] = new LinkedList<>(); - FSM[3] = new LinkedList<>(); - this.setOs(os); - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2)); - // enemy 0: Title - this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "terminal.maze.title", 0xFFFFFFFF).setXCentered(true), - 0); - this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 30, 30, "terminal.maze.play", - (clickData -> { - this.setGameState(1); - this.resetGame(); - })).setShouldClientCallback(true), 0); - // GameState 1: Play - this.setMaze(new MazeWidget()); - this.setPlayer(new PlayerWidget(0, 0, this)); - this.setEnemy(new EnemyWidget(-100, -100, this)); - // GameState 2: Pause - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, new ColorRectTexture(0xFF000000)), 2, 3); - this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 50, 20, "terminal.maze.continue", - (clickData) -> this.setGameState(1)).setShouldClientCallback(true), 2); - this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "terminal.maze.pause", 0xFFFFFFFF).setXCentered(true), - 2); - // GameState 3: Death - this.addWidget( - new SimpleTextWidget(333 / 2, 232 / 2 - 40, "", 0xFFFFFFFF, () -> "terminal.maze.death.1", true), - 3); - this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 28, "terminal.maze.death.2", 0xFFFFFFFF, - () -> String.valueOf(this.getMazesSolved()), true), 3); - this.addWidget( - new SimpleTextWidget(333 / 2, 232 / 2 - 16, "", 0xFFFFFFFF, () -> "terminal.maze.death.3", true), - 3); - this.addWidget( - new ClickButtonWidget(323 / 2 - 10, 222 / 2 + 10, 40, 20, "terminal.maze.retry", (clickData -> { - this.setGameState(1); - this.setMazesSolved(0); - MAZE_SIZE = 9; - speed = 25; - this.resetGame(); - })).setShouldClientCallback(true), 3); - } - return this; - } - - public void addWidget(Widget widget, int... visibleStates) { - this.addWidget(widget); - for (int state : visibleStates) { - FSM[state].add(widget); - } - widget.setVisible(Arrays.stream(visibleStates).allMatch(state -> state == gameState)); - } - - public void setPlayer(PlayerWidget player) { - this.player = player; - this.addWidget(player, 1, 2, 3); - } - - public void setMaze(MazeWidget maze) { - this.maze = maze; - this.addWidget(maze, 1, 2, 3); - } - - public void setEnemy(EnemyWidget enemy) { - this.enemy = enemy; - this.addWidget(enemy, 1, 2, 3); - } - - @Override - public boolean canOpenMenuOnEdge() { - return gameState != 1; - } - - @Override - public boolean isClientSideApp() { - return true; - } - - @Override - public void updateScreen() { - super.updateScreen(); - int lastState = gameState; - if (gameState == 1) { - if (Keyboard.isKeyDown(Keyboard.KEY_P)) { - gameState = 2; - lastPausePress = true; - } - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) ^ Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) - attemptMovePlayer(0); // Left - else - attemptMovePlayer(1); // Right - } - if (Keyboard.isKeyDown(Keyboard.KEY_UP) ^ Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) - attemptMovePlayer(2); // Up - else - attemptMovePlayer(3); // Down - } - timer++; - if (enemy.posX < 0 && timer % (speed * MAZE_SIZE - 1) < 1) { - enemy.setGridPosition(0, 0); - } else if (timer % speed < 1) { - moveEnemy(); - } - if (enemy.posX == player.posX && enemy.posY == player.posY) { - gameState = 3; - } - } - if (gameState == 2) { - if (!Keyboard.isKeyDown(Keyboard.KEY_P)) - lastPausePress = false; - if (Keyboard.isKeyDown(Keyboard.KEY_P) && !lastPausePress) - gameState = 1; - } - if (gameState != lastState) { - FSM[lastState].forEach(widget -> widget.setVisible(false)); - FSM[gameState].forEach(widget -> widget.setVisible(true)); - } - } - - public int getGameState() { - return gameState; - } - - public void setGameState(int gameState) { - if (gameState != this.gameState) { - FSM[this.gameState].forEach(widget -> widget.setVisible(false)); - FSM[gameState].forEach(widget -> widget.setVisible(true)); - } - this.gameState = gameState; - } - - public int getRenderX(int posX) { - return this.maze.getSelfPosition().x + posX * 10; - } - - public int getRenderY(int posY) { - return this.maze.getSelfPosition().y + posY * 10; - } - - public int getTimer() { - return timer; - } - - private void attemptMovePlayer(int direction) { - if (timer < lastPlayerInput + 2) { - return; - } - lastPlayerInput = timer; - - // Did the player reach the end? - if (player.posX == MAZE_SIZE - 1 && player.posY == MAZE_SIZE - 1 && direction == 3) { - mazesSolved++; - speed *= 0.95; - if (mazesSolved % 4 == 0) { - MAZE_SIZE += 2; - speed *= 1.07; - } - resetGame(); - return; - } - - if (direction == 0 && !maze.isThereWallAt(player.posX, player.posY, false)) { - player.move(-1, 0); - if (movementStore.size() > 0 && movementStore.get(movementStore.size() - 1) == 1) { - movementStore.remove(movementStore.size() - 1); - } else { - movementStore.add(direction); - } - } else if (direction == 1 && !maze.isThereWallAt(player.posX + 1, player.posY, false)) { - player.move(1, 0); - if (movementStore.size() > 0 && movementStore.get(movementStore.size() - 1) == 0) { - movementStore.remove(movementStore.size() - 1); - } else { - movementStore.add(direction); - } - } else if (direction == 2 && !maze.isThereWallAt(player.posX, player.posY, true)) { - player.move(0, -1); - if (movementStore.size() > 0 && movementStore.get(movementStore.size() - 1) == 3) { - movementStore.remove(movementStore.size() - 1); - } else { - movementStore.add(direction); - } - } else if (direction == 3 && !maze.isThereWallAt(player.posX, player.posY + 1, true)) { - player.move(0, 1); - if (movementStore.size() > 0 && movementStore.get(movementStore.size() - 1) == 2) { - movementStore.remove(movementStore.size() - 1); - } else { - movementStore.add(direction); - } - } - } - - private void moveEnemy() { // Move enemy with the latest movements - if (enemy.posX < 0 || movementStore.isEmpty()) - return; - - int direction = movementStore.get(0); - if (direction == 0) { - enemy.move(-1, 0); - } else if (direction == 1) { - enemy.move(1, 0); - } else if (direction == 2) { - enemy.move(0, -1); - } else if (direction == 3) { - enemy.move(0, 1); - } - movementStore.remove(0); - } - - private void resetGame() { - player.setGridPosition(0, 0); - maze.recalculateSize(); - maze.initMaze(); - movementStore.clear(); - timer = 0; - lastPlayerInput = -5; - enemy.setGridPosition(-100, -100); - } - - public int getMazesSolved() { - return mazesSolved; - } - - public void setMazesSolved(int mazesSolved) { - this.mazesSolved = mazesSolved; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/maze/widget/EnemyWidget.java b/src/main/java/gregtech/common/terminal/app/game/maze/widget/EnemyWidget.java deleted file mode 100644 index e16117666e2..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/maze/widget/EnemyWidget.java +++ /dev/null @@ -1,17 +0,0 @@ -package gregtech.common.terminal.app.game.maze.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.util.Position; -import gregtech.common.terminal.app.game.maze.MazeApp; - -public class EnemyWidget extends PlayerWidget { - - public EnemyWidget(int posX, int posY, MazeApp app) { - super(posX, posY, app); - } - - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - this.setSelfPosition(new Position(app.getRenderX(posX), app.getRenderY(posY))); - drawSolidRect(this.getPosition().x, this.getPosition().y, 10, 10, 0xFFFFAAAA); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/maze/widget/MazeWidget.java b/src/main/java/gregtech/common/terminal/app/game/maze/widget/MazeWidget.java deleted file mode 100644 index d3f71ebf18e..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/maze/widget/MazeWidget.java +++ /dev/null @@ -1,191 +0,0 @@ -package gregtech.common.terminal.app.game.maze.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.util.math.Vec2f; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static gregtech.common.terminal.app.game.maze.MazeApp.MAZE_SIZE; - -public class MazeWidget extends Widget { - - boolean[][] topWalls = new boolean[MAZE_SIZE][MAZE_SIZE]; - boolean[][] leftWalls = new boolean[MAZE_SIZE][MAZE_SIZE]; - boolean[][] includedSpots; - private int squaresChecked; - - public MazeWidget() { - super(333 / 2 - (MAZE_SIZE * 5), 232 / 2 - (MAZE_SIZE * 5), MAZE_SIZE * 10, MAZE_SIZE * 10); - initMaze(); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - // Draw outer lines - createBorder(); - // Draw inner lines - createInternalLines(); - } - - public void recalculateSize() { - this.setSelfPosition(new Position(333 / 2 - (MAZE_SIZE * 5), 232 / 2 - (MAZE_SIZE * 5))); - this.setSize(new Size(MAZE_SIZE * 10, MAZE_SIZE * 10)); - topWalls = new boolean[MAZE_SIZE][MAZE_SIZE]; - leftWalls = new boolean[MAZE_SIZE][MAZE_SIZE]; - } - - public void createBorder() { - List lineBuffer = new ArrayList<>(); - lineBuffer.add(new Vec2f(getPosition().x + 10, getPosition().y)); - lineBuffer.add(new Vec2f(this.getSize().width + getPosition().x, getPosition().y)); - lineBuffer.add(new Vec2f(this.getSize().width + getPosition().x, this.getSize().height + getPosition().y + 2)); // Corrects - // for - // line - // width - // misalignment - drawLines(lineBuffer, 0xFFFFFFFF, 0xFFFFFFFF, 4); - lineBuffer.clear(); - lineBuffer.add(new Vec2f(this.getSize().width + getPosition().x - 10, this.getSize().height + getPosition().y)); - lineBuffer.add(new Vec2f(getPosition().x, this.getSize().height + getPosition().y)); - lineBuffer.add(new Vec2f(getPosition().x, getPosition().y - 2)); - drawLines(lineBuffer, 0xFFFFFFFF, 0xFFFFFFFF, 4); - } - - public boolean isThereWallAt(int x, int y, boolean onTops) { - if (x >= MAZE_SIZE || y >= MAZE_SIZE) - return true; - if (x < 0 || y < 0) - return true; - if ((x == 0 && !onTops) || (y == 0 && onTops)) - return true; - if (onTops) { - return topWalls[x][y]; - } else { - return leftWalls[x][y]; - } - } - - public void createInternalLines() { - for (int i = 0; i < MAZE_SIZE; i++) { - for (int j = 0; j < MAZE_SIZE; j++) { - List list = new ArrayList<>(); - if (j != 0 && isThereWallAt(i, j, true)) { - list.add(new Vec2f(getPosition().x + 10 * i, getPosition().y + 10 * j)); - list.add(new Vec2f(getPosition().x + 10 * (i + 1), getPosition().y + 10 * j)); - drawLines(list, 0xFFFFFFFF, 0xFFFFFFFF, 2); - list.clear(); - } - if (i != 0 && isThereWallAt(i, j, false)) { - list.add(new Vec2f(getPosition().x + 10 * i, getPosition().y + 10 * j)); - list.add(new Vec2f(getPosition().x + 10 * i, getPosition().y + 10 * (j + 1))); - drawLines(list, 0xFFFFFFFF, 0xFFFFFFFF, 2); - } - } - } - } - - public void initMaze() { - includedSpots = new boolean[MAZE_SIZE][MAZE_SIZE]; - for (int i = 0; i < MAZE_SIZE; i++) { // Fill array with walls so that they can be carved out - for (int j = 0; j < MAZE_SIZE; j++) { - leftWalls[i][j] = true; - topWalls[i][j] = true; - } - } - - includedSpots[(int) (Math.random() * MAZE_SIZE)][(int) (Math.random() * MAZE_SIZE)] = true; // Can seed our - // particular maze - // Improves maze randomization. - List positions = new ArrayList<>(); - for (int i = 0; i < MAZE_SIZE * MAZE_SIZE; i++) { - positions.add(i); - } - Collections.shuffle(positions); - - for (int position : positions) { - if (!includedSpots[position / MAZE_SIZE][position % MAZE_SIZE]) { - do { - resetStuckCounter(); - } while (!this.createPath(position / MAZE_SIZE, position % MAZE_SIZE, - new boolean[MAZE_SIZE][MAZE_SIZE])); - } - } - } - - // Wilson random walk maze generation - public boolean createPath(int x, int y, boolean[][] walkedPaths) { - squaresChecked++; - if (squaresChecked > 20000) // Probably stuck. - return false; - if (walkedPaths[x][y]) - return false; - if (this.includedSpots[x][y]) - return true; - this.includedSpots[x][y] = true; - walkedPaths[x][y] = true; - // Find unoccupied directions - // Left 0 - List directions = new ArrayList<>(); - if (x != 0 && !walkedPaths[x - 1][y]) { - directions.add(0); - } - // Right 1 - if (x != MAZE_SIZE - 1 && !walkedPaths[x + 1][y]) { - directions.add(1); - } - // Up 2 - if (y != 0 && !walkedPaths[x][y - 1]) { - directions.add(2); - } - // Down 3 - if (y != MAZE_SIZE - 1 && !walkedPaths[x][y + 1]) { - directions.add(3); - } - Collections.shuffle(directions); - // Select one - while (directions.size() > 0) { - int direction = directions.get(directions.size() - 1); - // Use direction to create new coordinates - int newX = x; - int newY = y; - if (direction == 0) { - newX--; - } else if (direction == 1) { - newX++; - } else if (direction == 2) { - newY--; - } else if (direction == 3) { - newY++; - } - if (createPath(newX, newY, walkedPaths)) { - // Delete walls and return - if (direction == 0) { - leftWalls[x][y] = false; - } else if (direction == 1) { - leftWalls[x + 1][y] = false; - } else if (direction == 2) { - topWalls[x][y] = false; - } else if (direction == 3) { - topWalls[x][y + 1] = false; - } - return true; - } else { - directions.remove(directions.size() - 1); - } - } - // Reset current position - this.includedSpots[x][y] = false; - walkedPaths[x][y] = false; - return false; - } - - public void resetStuckCounter() { - squaresChecked = 0; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/maze/widget/PlayerWidget.java b/src/main/java/gregtech/common/terminal/app/game/maze/widget/PlayerWidget.java deleted file mode 100644 index 2198456833c..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/maze/widget/PlayerWidget.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.common.terminal.app.game.maze.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.util.Position; -import gregtech.common.terminal.app.game.maze.MazeApp; - -public class PlayerWidget extends Widget { - - protected MazeApp app; - public int posX; - public int posY; - - public PlayerWidget(int posX, int posY, MazeApp app) { - super(app.getRenderX(posX), app.getRenderY(posY), 10, 10); - this.app = app; - this.posX = posX; - this.posY = posY; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - this.setSelfPosition(new Position(app.getRenderX(posX), app.getRenderY(posY))); - drawSolidRect(this.getPosition().x, this.getPosition().y, 10, 10, 0xAAAAAAFF); - } - - public void move(int deltaX, int deltaY) { - this.posX += deltaX; - this.posY += deltaY; - } - - public void setGridPosition(int posX, int posY) { - this.posX = posX; - this.posY = posY; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/minesweeper/MinesweeperApp.java b/src/main/java/gregtech/common/terminal/app/game/minesweeper/MinesweeperApp.java deleted file mode 100644 index 7608e54b85d..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/minesweeper/MinesweeperApp.java +++ /dev/null @@ -1,82 +0,0 @@ -package gregtech.common.terminal.app.game.minesweeper; - -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.common.terminal.app.game.minesweeper.widget.MineMapWidget; - -public class MinesweeperApp extends AbstractApplication { - - private MineMapWidget mineField; - private WidgetGroup textGroup; - private int timer; - private int resetCountdown = 100; - - public MinesweeperApp() { - super("minesweeper"); - } - - @Override - public AbstractApplication initApp() { - mineField = new MineMapWidget(20, 12, 40); - this.addWidget(mineField); - this.addWidget(new SimpleTextWidget(333 / 6, 10, "", 0xFFCCCCCC, this::getFlagsPercentage, true)); - textGroup = new WidgetGroup(0, 0, 200, 50); - this.addWidget(textGroup); - setTextStatus(); - - return this; - } - - @Override - public boolean canOpenMenuOnEdge() { - return false; - } - - @Override - public void updateScreen() { - super.updateScreen(); - if (mineField.hasWon() || mineField.hasLost()) { - if (mineField.hasWon()) { - mineField.notifyWon(); - } - resetCountdown--; - setTextStatus(); - } else - timer++; - if (resetCountdown == 0) { - mineField.resetData(); - resetCountdown = 100; - timer = 0; - setTextStatus(); - } - } - - public String getFlagsPercentage() { - return mineField.flagsPlaced + "/" + mineField.mineCount; - } - - public void setTextStatus() { // swap widget for localization - if (resetCountdown == 100) { - textGroup.clearAllWidgets(); - textGroup.addWidget(new SimpleTextWidget(333 / 8 * 5, 10, "terminal.minesweeper.time", 0xFFCCCCCC, - () -> String.valueOf(timer / 20), true)); // Normal - } else if (resetCountdown == 99) { - textGroup.clearAllWidgets(); - if (mineField.hasLost()) { - textGroup.addWidget(new SimpleTextWidget(333 / 8 * 5, 10, "terminal.minesweeper.lose", 0xFFCCCCCC, - () -> String.valueOf(resetCountdown / 20), true)); // Losing condition - } else { - textGroup.addWidget(new SimpleTextWidget(333 / 8 * 5, 10, "terminal.minesweeper.win.1", 0xFFCCCCCC, - () -> String.valueOf(timer / 20), true)); // Winning condition - textGroup.addWidget(new SimpleTextWidget(333 / 8 * 5, 20, "terminal.minesweeper.win.2", 0xFFCCCCCC, - () -> String.valueOf(resetCountdown / 20), true)); - } - } - } - - @Override - public boolean isClientSideApp() { - return true; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/minesweeper/widget/MineMapWidget.java b/src/main/java/gregtech/common/terminal/app/game/minesweeper/widget/MineMapWidget.java deleted file mode 100644 index 5037833c929..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/minesweeper/widget/MineMapWidget.java +++ /dev/null @@ -1,220 +0,0 @@ -package gregtech.common.terminal.app.game.minesweeper.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.util.interpolate.RGBInterpolator; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; - -public class MineMapWidget extends Widget { - - private static final TextureArea COVERED = new TextureArea( - new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/covered.png"), 0, 0, 1, 1); - private static final TextureArea FLAG = new TextureArea( - new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/flag.png"), 0, 0, 1, 1); - private static final TextureArea BOMB = new TextureArea( - new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/bomb.png"), 0, 0, 1, 1); - - private static final TextureArea[] NUMBERS = { - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/blank.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/1.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/2.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/3.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/4.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/5.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/6.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/7.png"), 0, 0, 1, 1), - new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/minesweeper/8.png"), 0, 0, 1, 1) - }; - - public int mineCount; - public int flagsPlaced; - - private int width; - private int height; - - private boolean isPrepared; - - private boolean[][] mines; - private boolean[][] flags; - private boolean[][] checkedSpaces; - private int[][] generatedNumbers; - - private boolean isLost; - private boolean isWon; - private int timer = 0; - private static final RGBInterpolator interpolator = new RGBInterpolator(5, - (r, g, b) -> GlStateManager.color(r.floatValue(), g.floatValue(), b.floatValue()), - (r, g, b) -> GlStateManager.color(0, 0, 0)); - - public MineMapWidget(int width, int height, int mineCount) { - super(333 / 2 - width * 8, 232 / 2 - height * 8, width * 16, height * 16); - this.width = width; - this.height = height; - this.resetData(); - this.mineCount = mineCount; - } - - public void resetData() { - mines = new boolean[width][height]; - generatedNumbers = new int[width][height]; - checkedSpaces = new boolean[width][height]; - flags = new boolean[width][height]; - isLost = false; - isWon = false; - isPrepared = false; - flagsPlaced = 0; - } - - public void initMines(int startX, int startY) { - int minesPlaced = 0; - while (minesPlaced < mineCount) { - for (; minesPlaced < mineCount; minesPlaced++) { - placeMine(startX, startY); - } - - // Are there any sections that we can't figure out what's inside? - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - boolean isTrapped = true; - // The weird ternaries here are making sure to not cause overflows - for (int xMod = i == 0 ? 0 : -1; xMod < (i == width - 1 ? 1 : 2); xMod++) { - for (int yMod = j == 0 ? 0 : -1; yMod < (j == height - 1 ? 1 : 2); yMod++) { - isTrapped &= mines[i + xMod][j + yMod]; - } - } - if (isTrapped) { - // Yes, so just take out the middle - mines[i][j] = false; - minesPlaced--; - } - } - } - } - - // Add to surrounding numbers for the mine - // The weird ternaries here are making sure to not cause overflows - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - if (mines[x][y]) { - for (int xMod = x == 0 ? 0 : -1; xMod < (x == width - 1 ? 1 : 2); xMod++) { - for (int yMod = y == 0 ? 0 : -1; yMod < (y == height - 1 ? 1 : 2); yMod++) { - generatedNumbers[x + xMod][y + yMod]++; - } - } - } - } - } - isPrepared = true; - } - - private void placeMine(int startX, int startY) { - int x = (int) (Math.random() * width); - int y = (int) (Math.random() * height); - - // The weird part to the right is making sure the player doesn't start on a numbered tile - while (mines[x][y] || ((startX < x + 3 && startX > x - 3) && (startY < y + 3 && startY > y - 3))) { - x = (int) (Math.random() * width); - y = (int) (Math.random() * height); - } - mines[x][y] = true; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - timer++; - if (isWon && !interpolator.isActivated()) { // Fancy colors :) - interpolator.start(); - } - if (!isWon && interpolator.isActivated()) { - interpolator.stop(); - } - interpolator.update(); - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - if (isLost && mines[i][j]) // If the player lost, show where the mines are. - BOMB.draw(i * 16 + getPosition().getX(), j * 16 + getPosition().getY(), 16, 16); - else if (!checkedSpaces[i][j]) { - if (flags[i][j]) - FLAG.draw(i * 16 + getPosition().getX(), j * 16 + getPosition().getY(), 16, 16); - else - COVERED.draw(i * 16 + getPosition().getX(), j * 16 + getPosition().getY(), 16, 16); - } else if (!mines[i][j]) - NUMBERS[generatedNumbers[i][j]].draw(i * 16 + getPosition().getX(), j * 16 + getPosition().getY(), - 16, 16); - else - BOMB.draw(i * 16 + getPosition().getX(), j * 16 + getPosition().getY(), 16, 16); - } - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isWon || isLost) { - return false; // Don't let them interact now... - } - - int gridX = (mouseX - getPosition().getX()) / 16; - int gridY = (mouseY - getPosition().getY()) / 16; - if (gridX >= width || gridY >= height || gridX < 0 || gridY < 0) { - return false; - } - - if (button == 0 && !flags[gridX][gridY]) { - if (!isPrepared) - initMines(gridX, gridY); - if (generatedNumbers[gridX][gridY] == 0) - uncoverSafeTiles(gridX, gridY); - else - checkedSpaces[gridX][gridY] = true; - if (mines[gridX][gridY]) - isLost = true; - } else if (button == 1 && !checkedSpaces[gridX][gridY]) { - flags[gridX][gridY] = !flags[gridX][gridY]; - if (flags[gridX][gridY]) - flagsPlaced++; - else - flagsPlaced--; - } - - return true; - } - - private void uncoverSafeTiles(int x, int y) { - checkedSpaces[x][y] = true; - if (generatedNumbers[x][y] != 0) - return; - // Weird ternaries again for preventing ArrayIndexOutOfBounds exceptions - for (int xMod = x == 0 ? 0 : -1; xMod < (x == width - 1 ? 1 : 2); xMod++) { - for (int yMod = y == 0 ? 0 : -1; yMod < (y == height - 1 ? 1 : 2); yMod++) { - if (!checkedSpaces[x + xMod][y + yMod]) - uncoverSafeTiles(x + xMod, y + yMod); - } - } - } - - public boolean hasLost() { - return isLost; - } - - public boolean hasWon() { - if (!isPrepared) - return false; - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - if (mines[i][j] != flags[i][j] || checkedSpaces[i][j] == mines[i][j]) { // If there is an unchecked safe - // square, or an uncovered - // bomb... - return false; - } - } - } - return true; - } - - public void notifyWon() { - isWon = true; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/pong/PongApp.java b/src/main/java/gregtech/common/terminal/app/game/pong/PongApp.java deleted file mode 100644 index 32d3ad523aa..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/pong/PongApp.java +++ /dev/null @@ -1,175 +0,0 @@ -package gregtech.common.terminal.app.game.pong; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.common.terminal.app.game.pong.widget.BallWidget; -import gregtech.common.terminal.app.game.pong.widget.PaddleWidget; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.util.vector.Vector2f; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -public class PongApp extends AbstractApplication { - - private BallWidget ball; - private int leftScore; - private int rightScore; - private List paddles; - private List solidObjects; - private int userInput = -1; - private int timer = 0; - - public PongApp() { - super("pong"); - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - paddles = new ArrayList<>(); - solidObjects = new ArrayList<>(); - this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2)); - this.addWidget(new ImageWidget(333 / 2 - 4, 5, 6, 232 - 10, new ColorRectTexture(0xAAAAAAAA))); - this.setBall(new BallWidget(333 / 2 - 1, 232 / 2 - 1)); - this.addWidget(new SimpleTextWidget(50, 20, "", 0xAAAAAA, () -> String.valueOf(this.getScore(true)), true)); - this.addWidget( - new SimpleTextWidget(283, 20, "", 0xAAAAAA, () -> String.valueOf(this.getScore(false)), true)); - this.initPaddles(); - } - return this; - } - - @Override - public boolean canOpenMenuOnEdge() { - return false; - } - - @Override - public boolean isClientSideApp() { - return true; - } - - public void setBall(BallWidget ball) { - this.ball = ball; - this.addWidget(ball); - } - - public void initPaddles() { - paddles.add(new PaddleWidget(20, 232 / 2 - 1, 4, 20, (PaddleWidget paddle) -> this.getUserInput())); - paddles.add(new PaddleWidget(313, 232 / 2 - 1, 4, 20, this::simplePaddleAI)); - paddles.forEach(this::addWidget); - this.solidObjects.add(new Rectangle(0, 0, 333, 10)); - this.solidObjects.add(new Rectangle(0, 222, 333, 10)); - } - - public void score(boolean side) { - if (side) { - leftScore++; - ball.theta = (float) Math.PI; - } else { - rightScore++; - ball.theta = (float) 0; - } - ball.theta += Math.random() * 0.2; - ball.setSelfPosition(new Position(333 / 2 - 1, 232 / 2 - 1)); - } - - @Override - public void updateScreenOnFrame() { - if (ball.getSelfPosition().getX() < 10) { - this.score(false); // Right side gains a point - } else if (ball.getSelfPosition().getX() > 323) { - this.score(true); // Left side gains a point - } else { - paddles.forEach((paddle) -> solidObjects.add(new Rectangle(paddle.toSelfRectangleBox()))); - int timeLeft = 1; - - TwoDimensionalRayTracer.TwoDimensionalRayTraceResult result = TwoDimensionalRayTracer - .nearestBoxSegmentCollision( - new Vector2f(ball.getSelfPosition().x, ball.getSelfPosition().y), - new Vector2f((float) (Math.cos(ball.theta) * 2), (float) (Math.sin(ball.theta) * 2)), - solidObjects, - new Vector2f(4, 4)); - while (result.time != 1 && timeLeft != 0) { - float angleMod = 0; - if (result.pos.y < result.collidedWith.getCenterY() - 2) { - angleMod -= Math.signum(result.normal.x) * 0.6; - } else if (result.pos.x > result.collidedWith.getCenterY() + 2) { - angleMod += Math.signum(result.normal.x) * 0.6; - } - ball.theta = (float) (Math.acos(result.normal.x) * 2 - ball.theta + Math.PI + angleMod) % (2 * Math.PI); // Reflects - // with - // a - // slight - // angle - // modification. - - if (ball.theta > Math.PI / 2 - 0.5 && ball.theta < Math.PI / 2 + 0.5) { - if (ball.theta <= Math.PI / 2) - ball.theta = Math.PI / 2 - 0.51; - else - ball.theta = Math.PI / 2 + 0.51; - } - if (ball.theta > 3 * Math.PI / 2 - 0.5 && ball.theta < 3 * Math.PI / 2 + 0.5) { - if (ball.theta < 3 * Math.PI / 2) - ball.theta = 3 * Math.PI / 2 - 0.51; - else - ball.theta = 3 * Math.PI / 2 + 0.51; - } - timeLeft -= result.time * timeLeft; - result = TwoDimensionalRayTracer.nearestBoxSegmentCollision( - new Vector2f(ball.getSelfPosition().x, ball.getSelfPosition().y), - new Vector2f((float) (Math.cos(ball.theta) * 3 * timeLeft), - (float) (Math.sin(ball.theta) * 3 * timeLeft)), - solidObjects, - new Vector2f(4, 4)); - // To prevent it getting permanently lodged into something. - ball.addSelfPosition((Math.cos(ball.theta) * 2 * (result.time + 0.1) * (timeLeft + 0.1)), - (Math.sin(ball.theta) * 2 * (result.time + 0.1) * (timeLeft + 0.1))); - } - ball.addSelfPosition((Math.cos(ball.theta) * 2 * timeLeft), (Math.sin(ball.theta) * 2 * timeLeft)); - solidObjects.remove(2); - solidObjects.remove(2); - } - if (ball.getSelfPosition().getY() > 222) { - ball.setSelfPosition(new Position(ball.getSelfPosition().getX(), 211)); - } else if (ball.getSelfPosition().getY() < 10) - ball.setSelfPosition(new Position(ball.getSelfPosition().getX(), 21)); - timer++; - if (Keyboard.isKeyDown(Keyboard.KEY_UP) ^ Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) - userInput = 1; - else - userInput = 0; - } else { - userInput = -1; - } - super.updateScreenOnFrame(); - } - - public int simplePaddleAI(PaddleWidget paddle) { - if (this.timer % 3 == 0) - return -1; - if ((ball.getSelfPosition().getY() + 2 * paddle.getSelfPosition().getY()) / 3 < paddle.getSelfPosition().getY()) - return 1; - else if ((ball.getSelfPosition().getY() + 2 * paddle.getSelfPosition().getY()) / 3 > - paddle.getSelfPosition().getY()) - return 0; - return -1; - } - - public int getScore(boolean side) { - return side ? leftScore : rightScore; - } - - public int getUserInput() { - return userInput; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/pong/TwoDimensionalRayTracer.java b/src/main/java/gregtech/common/terminal/app/game/pong/TwoDimensionalRayTracer.java deleted file mode 100644 index a32469e6fcb..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/pong/TwoDimensionalRayTracer.java +++ /dev/null @@ -1,86 +0,0 @@ -package gregtech.common.terminal.app.game.pong; - -import org.lwjgl.util.vector.Vector2f; - -import java.awt.*; -import java.util.List; - -import static net.minecraft.util.math.MathHelper.clamp; - -// Huge thanks to https://noonat.github.io/intersect! -public class TwoDimensionalRayTracer { - - public static class TwoDimensionalRayTraceResult { - - public Vector2f pos = new Vector2f(); - public Vector2f delta = new Vector2f(); - public Vector2f normal = new Vector2f(); - public float time = -1; - public Rectangle collidedWith = new Rectangle(); - } - - /** - * Detects the intersection between a segment and a box, if there is any. - * - * @param pos The original position of the point. - * @param delta The proposed new position of the point. - * @param boxSize The half-width and half-height of the box - * @return The resulting intersection between a segment and a box, or else null - */ - public static TwoDimensionalRayTraceResult intersectBoxSegment(Vector2f pos, Vector2f delta, Vector2f boxCenter, - Vector2f boxSize) { - float scaleX = (float) (1.0 / delta.x); - float scaleY = (float) (1.0 / delta.y); - float signX = Math.signum(scaleX); - float signY = Math.signum(scaleY); - float nearTimeX = (boxCenter.x - signX * (boxSize.x) - pos.x) * scaleX; - float nearTimeY = (boxCenter.y - signY * (boxSize.y) - pos.y) * scaleY; - float farTimeX = (boxCenter.x + signX * (boxSize.x) - pos.x) * scaleX; - float farTimeY = (boxCenter.y + signY * (boxSize.y) - pos.y) * scaleY; - - if (nearTimeX > farTimeY || nearTimeY > farTimeX) { - return null; - } - - double nearTime = Math.max(nearTimeX, nearTimeY); - double farTime = Math.min(farTimeX, farTimeY); - - if (nearTime >= 1 || farTime <= 0) { - return null; - } - - TwoDimensionalRayTraceResult result = new TwoDimensionalRayTraceResult(); - - result.time = (float) clamp(nearTime, 0, 1); - if (nearTimeX > nearTimeY) { - result.normal.x = -signX; - result.normal.y = 0; - } else { - result.normal.x = 0; - result.normal.y = -signY; - } - result.delta.x = (float) ((1.0 - result.time) * -delta.x); - result.delta.y = (float) ((1.0 - result.time) * -delta.y); - result.pos.x = pos.x + delta.x * result.time; - result.pos.y = pos.y + delta.y * result.time; - return result; - } - - public static TwoDimensionalRayTraceResult nearestBoxSegmentCollision(Vector2f pos, Vector2f delta, - List boxes, Vector2f padding) { - TwoDimensionalRayTraceResult result = new TwoDimensionalRayTraceResult(); - result.time = 1; - result.pos.x = pos.x + delta.x; - result.pos.y = pos.y + delta.y; - for (Rectangle box : boxes) { - TwoDimensionalRayTraceResult sweep = intersectBoxSegment(pos, delta, - new Vector2f((float) box.getCenterX(), (float) box.getCenterY()), - new Vector2f((float) box.getWidth() / 2 + padding.x, (float) box.getHeight() / 2 + padding.y)); - if (sweep != null && sweep.time < result.time) { - result = sweep; - result.collidedWith = box; - } - } - return result; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/pong/widget/BallWidget.java b/src/main/java/gregtech/common/terminal/app/game/pong/widget/BallWidget.java deleted file mode 100644 index 49aa63629af..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/pong/widget/BallWidget.java +++ /dev/null @@ -1,48 +0,0 @@ -package gregtech.common.terminal.app.game.pong.widget; - -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.util.Position; - -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.util.vector.Vector2f; - -public class BallWidget extends ImageWidget { - - public double theta; - private double xAccurate; - private double yAccurate; - - public BallWidget(int xPosition, int yPosition) { - super(xPosition, yPosition, 8, 8, - new TextureArea(new ResourceLocation("gregtech:textures/gui/widget/pong_ball.png"), 0, 0, 1, 1)); - theta = (Math.random() > 0.5 ? Math.PI : Math.PI / 2) + Math.random() * 0.2; - xAccurate = xPosition; - yAccurate = yPosition; - } - - @Override - public void setSelfPosition(Position selfPosition) { - super.setSelfPosition(selfPosition); - xAccurate = selfPosition.x; - yAccurate = selfPosition.y; - } - - @Override - public Position addSelfPosition(int addX, int addY) { - xAccurate += addX; - yAccurate += addY; - return super.addSelfPosition(addX, addY); - } - - public void addSelfPosition(double addX, double addY) { - xAccurate += addX; - yAccurate += addY; - super.setSelfPosition(new Position((int) xAccurate, (int) yAccurate)); - } - - public Vector2f getPreciseSelfPosition() { - return new Vector2f((float) xAccurate, (float) yAccurate); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/game/pong/widget/PaddleWidget.java b/src/main/java/gregtech/common/terminal/app/game/pong/widget/PaddleWidget.java deleted file mode 100644 index 758f2c80a20..00000000000 --- a/src/main/java/gregtech/common/terminal/app/game/pong/widget/PaddleWidget.java +++ /dev/null @@ -1,54 +0,0 @@ -package gregtech.common.terminal.app.game.pong.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.util.Position; - -import java.awt.*; -import java.util.function.Function; - -public class PaddleWidget extends Widget { - - Function controlSupplier; - - public PaddleWidget(int x, int y, int width, int height, Function controlSupplier) { - super(x, y, width, height); - this.controlSupplier = controlSupplier; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - drawSolidRect(this.toRectangleBox().x - this.toRectangleBox().width / 2, - this.toRectangleBox().y - this.toRectangleBox().height / 2, this.toRectangleBox().width, - this.toRectangleBox().height, 0xFFFFFFFF); - } - - @Override - public void updateScreenOnFrame() { - super.updateScreenOnFrame(); - if (this.getSelfPosition().getY() < 30) { - this.setSelfPosition(new Position(this.getSelfPosition().getX(), 30)); - } - if (this.getSelfPosition().getY() > 202) { - this.setSelfPosition(new Position(this.getSelfPosition().getX(), 202)); - } - int speed; - switch (controlSupplier.apply(this)) { - case 0: - speed = 2; - break; - case 1: - speed = -2; - break; - default: - speed = 0; - } - this.addSelfPosition(0, speed); - } - - public Rectangle toSelfRectangleBox() { - return new Rectangle(this.getSelfPosition().x - this.toRectangleBox().width / 2 - 2, - this.getSelfPosition().y - this.toRectangleBox().height / 2, - this.toRectangleBox().width, this.toRectangleBox().height); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/GuideApp.java b/src/main/java/gregtech/common/terminal/app/guide/GuideApp.java deleted file mode 100644 index 2d94001217a..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/GuideApp.java +++ /dev/null @@ -1,337 +0,0 @@ -package gregtech.common.terminal.app.guide; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.TreeListWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.terminal.util.TreeNode; -import gregtech.api.util.FileUtility; -import gregtech.api.util.GTLog; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guide.widget.GuidePageWidget; -import gregtech.common.terminal.component.SearchComponent; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraftforge.fml.common.FMLCommonHandler; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public abstract class GuideApp extends AbstractApplication implements - SearchComponent.IWidgetSearch>> { - - private GuidePageWidget pageWidget; - private TreeListWidget tree; - private TreeNode ROOT; - private Map jsonObjectMap; - private final IGuiTexture icon; - private float scale = 1; - - public GuideApp(String name, IGuiTexture icon) { - super(name); - this.icon = icon; - } - - @Override - public IGuiTexture getIcon() { - return icon; - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - ROOT = new TreeNode<>(0, "root"); - jsonObjectMap = new HashMap<>(); - loadJsonFiles(); - buildTree(); - } - return this; - } - - protected void loadPage(TreeNode leaf) { - if (leaf == null) { - return; - } - if (this.pageWidget != null) { - this.removeWidget(this.pageWidget); - } - this.pageWidget = new GuidePageWidget(getOs().getSize().width - 200, 0, 200, getOs().getSize().height, 5); - if (leaf.isLeaf() && leaf.getContent() != null) { - JsonObject page = jsonObjectMap.get(leaf.getContent()); - if (page != null) { - this.pageWidget.loadJsonConfig(page); - } - } - this.addWidget(this.pageWidget); - this.onOSSizeUpdate(getOs().getSize().width, getOs().getSize().height); - } - - @Override - public boolean isClientSideApp() { - return true; - } - - protected IGuiTexture itemIcon(T item) { - return null; - } - - /** - * Should return a localised representation of the item - * - * @param item item - * @return localised name - */ - protected abstract String itemName(T item); - - protected abstract String rawItemName(T item); - - protected final TreeNode getTree() { - return ROOT; - } - - public final void loadJsonFiles() { - List jsons = new ArrayList<>(); - String lang = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(); - try { - Path guidePath = TerminalRegistry.TERMINAL_PATH.toPath().resolve("guide/" + this.getRegistryName()); - Path en_us = guidePath.resolve("en_us"); - List configPaths; - try (Stream stream = Files.walk(en_us)) { - configPaths = stream.filter(Files::isRegularFile) - .filter(f -> f.toString().endsWith(".json")) - .collect(Collectors.toList()); - } - configPaths.forEach(file -> { - File langFile = guidePath.resolve(lang + "/" + en_us.relativize(file)).toFile(); - JsonObject json = GuideApp.getConfig(langFile); - if (json == null) { - json = GuideApp.getConfig(file.toFile()); - } - if (json != null) { - jsons.add(json); - } - }); - } catch (IOException e) { - GTLog.logger.error("Failed to load file on path {}", "terminal", e); - } - ROOT = new TreeNode<>(0, "root"); - jsonObjectMap = new HashMap<>(); - for (JsonObject json : jsons) { - T t = ofJson(json); - if (t != null) { - registerItem(t, json.get("section").getAsString()); - jsonObjectMap.put(t, json); - } - } - } - - public abstract T ofJson(JsonObject json); - - private static JsonObject getConfig(File file) { - JsonElement je = FileUtility.loadJson(file); - return je == null ? null : je.isJsonObject() ? je.getAsJsonObject() : null; - } - - // ISearch - @Override - public boolean isManualInterrupt() { - return true; - } - - @Override - public void search(String word, Consumer>> find) { - Stack> stack = new Stack<>(); - if (getTree() != null) { - stack.push(getTree()); - dfsSearch(Thread.currentThread(), stack, word.toLowerCase(), find); - } - } - - private boolean dfsSearch(Thread thread, Stack> stack, String regex, - Consumer>> find) { - if (thread.isInterrupted()) { - return true; - } else { - TreeNode node = stack.peek(); - if (!node.isLeaf() && I18n.format(node.getKey()).toLowerCase().contains(regex)) { - find.accept((Stack>) stack.clone()); - } else if (node.isLeaf()) { - String name = itemName(node.getContent()); - if (name == null) { - name = node.getKey(); - } - if (I18n.format(name).toLowerCase().contains(regex)) { - find.accept((Stack>) stack.clone()); - } - } - if (node.getChildren() != null) { - for (TreeNode child : node.getChildren()) { - stack.push(child); - if (dfsSearch(thread, stack, regex, find)) return true; - stack.pop(); - } - } - } - return false; - } - - protected void registerItem(T item, String path) { - if (FMLCommonHandler.instance().getSide().isClient()) { - String[] parts = path.split("/"); - TreeNode child = ROOT; - if (!parts[0].isEmpty()) { - for (String sub : parts) { - child = child.getOrCreateChild(sub); - } - } - child.addContent(rawItemName(item), item); - } - } - - @Override - public void selectResult(Stack> result) { - if (result.size() > 0 && tree != null) { - List path = result.stream().map(TreeNode::getKey).collect(Collectors.toList()); - path.remove(0); - loadPage(tree.jumpTo(path)); - } - } - - @Override - public String resultDisplay(Stack> result) { - Iterator> iterator = result.iterator(); - if (!iterator.hasNext()) return ""; - iterator.next(); // skip root - StringBuilder builder = new StringBuilder(); - while (iterator.hasNext()) { - TreeNode node = iterator.next(); - builder.append(node.getContent() == null ? node.getKey() : itemName(node.getContent())); - if (iterator.hasNext()) - builder.append(" / "); - } - return builder.toString(); - } - - @Override - public List getMenuComponents() { - return Collections.singletonList(new SearchComponent<>(this)); - } - - private void buildTree() { - this.tree = new TreeListWidget<>(0, 0, getOs().getSize().width - 200, getOs().getSize().height, getTree(), - this::loadPage).setContentIconSupplier(this::itemIcon) - .setContentNameSupplier(this::itemName) - .setKeyNameSupplier(key -> key) - .setNodeTexture(GuiTextures.BORDERED_BACKGROUND) - .setLeafTexture(GuiTextures.SLOT_DARKENED); - this.addWidget(this.tree); - } - - @Override - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (this.tree != null) this.tree.drawInBackground(mouseX, mouseY, partialTicks, context); - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - GlStateManager.translate(position.x * (1 - scale), 0, 0); - GlStateManager.scale(scale, scale, 1); - this.pageWidget.drawInBackground(mouseX, mouseY, partialTicks, context); - GlStateManager.scale(1 / scale, 1 / scale, 1); - GlStateManager.translate(position.x * (scale - 1), 0, 0); - } - } - - @Override - protected void hookDrawInForeground(int mouseX, int mouseY) { - if (this.tree != null) this.tree.drawInForeground(mouseX, mouseY); - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - GlStateManager.translate(position.x * (1 - scale), 0, 0); - GlStateManager.scale(scale, scale, 1); - this.pageWidget.drawInForeground(mouseX, mouseY); - GlStateManager.scale(1 / scale, 1 / scale, 1); - GlStateManager.translate(position.x * (scale - 1), 0, 0); - } - } - - @Override - public boolean mouseWheelMove(int mouseX, int mouseY, int wheelDelta) { - if (this.tree != null && this.tree.mouseWheelMove(mouseX, mouseY, wheelDelta)) return true; - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - return this.pageWidget.mouseWheelMove(mouseX, mouseY, wheelDelta); - } - return false; - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (this.tree != null && this.tree.mouseClicked(mouseX, mouseY, button)) return true; - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - return this.pageWidget.mouseClicked(mouseX, mouseY, button); - } - return false; - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - if (this.tree != null && this.tree.mouseDragged(mouseX, mouseY, button, timeDragged)) return true; - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - return this.pageWidget.mouseDragged(mouseX, mouseY, button, timeDragged); - } - return false; - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - if (this.tree != null && this.tree.mouseReleased(mouseX, mouseY, button)) return true; - if (this.pageWidget != null) { - Position position = this.pageWidget.getPosition(); - mouseX = (int) ((mouseX - position.x * (1 - scale)) / scale); - mouseY = (int) (mouseY / scale); - return this.pageWidget.mouseReleased(mouseX, mouseY, button); - } - return false; - } - - @Override - public void onOSSizeUpdate(int width, int height) { - this.setSize(new Size(width, height)); - int treeWidth = Math.max(TerminalOSWidget.DEFAULT_WIDTH - 200, getOs().getSize().width / 3); - if (this.tree != null) { - this.tree.setSize(new Size(treeWidth, height)); - } - if (this.pageWidget != null) { - this.scale = (width - treeWidth) / 200f; - this.pageWidget.setSize(new Size(200, (int) (height / scale))); - this.pageWidget.setSelfPosition(new Position(treeWidth, 0)); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/ItemGuideApp.java b/src/main/java/gregtech/common/terminal/app/guide/ItemGuideApp.java deleted file mode 100644 index d86bfe35d0c..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/ItemGuideApp.java +++ /dev/null @@ -1,103 +0,0 @@ -package gregtech.common.terminal.app.guide; - -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.items.metaitem.MetaItem; -import gregtech.common.items.MetaItems; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.Objects; - -public class ItemGuideApp extends GuideApp { - - public ItemGuideApp() { - super("items", new ItemStackTexture(MetaItems.PROSPECTOR_LV.getStackForm())); - } - - @Override - protected String itemName(GuideItem item) { - return item.stack.getDisplayName(); - } - - @Override - protected String rawItemName(GuideItem item) { - if (item.stack.getItem() instanceof MetaItem) { - MetaItem.MetaValueItem metaValueItem = ((MetaItem) item.stack.getItem()) - .getItem((short) item.stack.getMetadata()); - if (metaValueItem != null) return metaValueItem.unlocalizedName; - } - return item.stack.getTranslationKey(); - } - - @Override - protected IGuiTexture itemIcon(GuideItem item) { - return new ItemStackTexture(item.stack); - } - - @Override - public GuideItem ofJson(JsonObject json) { - return GuideItem.ofJson(json); - } - - public static class GuideItem { - - public final ItemStack stack; - public final String name; - - public GuideItem(ItemStack stack, String name) { - this.stack = stack; - this.name = name; - } - - public GuideItem(ItemStack stack) { - this(stack, Objects.requireNonNull(stack.getItem().getRegistryName()) + ":" + stack.getMetadata()); - } - - public GuideItem(MetaItem.MetaValueItem item) { - this(item.getStackForm(), item.unlocalizedName); - } - - public static GuideItem ofJson(JsonObject json) { - if (json.has("item")) { - JsonElement element = json.get("item"); - if (element.isJsonPrimitive()) { - String[] s = element.getAsString().split(":"); - if (s.length < 2) return null; - Item item = Item.getByNameOrId(s[0] + ":" + s[1]); - if (item == null) return null; - int meta = 0; - if (s.length > 2) - meta = Integer.parseInt(s[2]); - return new GuideItem(new ItemStack(item, 1, meta)); - } - } - if (json.has("metaitem")) { - String metaItemId = json.get("metaitem").getAsString(); - for (MetaItem metaItem : MetaItem.getMetaItems()) { - MetaItem.MetaValueItem metaValueItem = metaItem.getAllItems().stream() - .filter(m -> m.unlocalizedName.equals(metaItemId)).findFirst().orElse(null); - if (metaValueItem != null) return new GuideItem(metaValueItem); - } - } - return null; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - GuideItem guideItem = (GuideItem) o; - return Objects.equals(stack, guideItem.stack) && Objects.equals(name, guideItem.name); - } - - @Override - public int hashCode() { - return Objects.hash(stack, name); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/MultiBlockGuideApp.java b/src/main/java/gregtech/common/terminal/app/guide/MultiBlockGuideApp.java deleted file mode 100644 index 4f731b0572e..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/MultiBlockGuideApp.java +++ /dev/null @@ -1,50 +0,0 @@ -package gregtech.common.terminal.app.guide; - -import gregtech.api.GregTechAPI; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GTUtility; -import gregtech.common.metatileentities.MetaTileEntities; - -import net.minecraft.util.ResourceLocation; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -public class MultiBlockGuideApp extends GuideApp { - - public MultiBlockGuideApp() { - super("multiblocks", new ItemStackTexture(MetaTileEntities.ELECTRIC_BLAST_FURNACE.getStackForm())); - } - - @Override - public MetaTileEntity ofJson(JsonObject json) { - String[] valids = { "multiblock", "metatileentity" }; - if (json.isJsonObject()) { - for (String valid : valids) { - JsonElement id = json.getAsJsonObject().get(valid); - if (id != null && id.isJsonPrimitive()) { - ResourceLocation location = GTUtility.gregtechId(id.getAsString()); - return GregTechAPI.mteManager.getRegistry(location.getNamespace()).getObject(location); - } - } - } - return null; - } - - @Override - protected IGuiTexture itemIcon(MetaTileEntity item) { - return new ItemStackTexture(item.getStackForm()); - } - - @Override - protected String itemName(MetaTileEntity item) { - return item.getStackForm().getDisplayName(); - } - - @Override - protected String rawItemName(MetaTileEntity item) { - return item.metaTileEntityId.getPath(); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/SimpleMachineGuideApp.java b/src/main/java/gregtech/common/terminal/app/guide/SimpleMachineGuideApp.java deleted file mode 100644 index cec7ee6d88f..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/SimpleMachineGuideApp.java +++ /dev/null @@ -1,51 +0,0 @@ -package gregtech.common.terminal.app.guide; - -import gregtech.api.GTValues; -import gregtech.api.GregTechAPI; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GTUtility; -import gregtech.common.metatileentities.MetaTileEntities; - -import net.minecraft.util.ResourceLocation; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -public class SimpleMachineGuideApp extends GuideApp { - - public SimpleMachineGuideApp() { - super("machines", new ItemStackTexture(MetaTileEntities.CHEMICAL_REACTOR[GTValues.LV].getStackForm())); - } - - @Override - protected IGuiTexture itemIcon(MetaTileEntity item) { - return new ItemStackTexture(item.getStackForm()); - } - - @Override - protected String itemName(MetaTileEntity item) { - return item.getStackForm().getDisplayName(); - } - - @Override - protected String rawItemName(MetaTileEntity item) { - return item.metaTileEntityId.getPath(); - } - - @Override - public MetaTileEntity ofJson(JsonObject json) { - String[] valids = { "machine", "generator", "metatileentity" }; - if (json.isJsonObject()) { - for (String valid : valids) { - JsonElement id = json.getAsJsonObject().get(valid); - if (id != null && id.isJsonPrimitive()) { - ResourceLocation location = GTUtility.gregtechId(id.getAsString()); - return GregTechAPI.mteManager.getRegistry(location.getNamespace()).getObject(location); - } - } - } - return null; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/TutorialGuideApp.java b/src/main/java/gregtech/common/terminal/app/guide/TutorialGuideApp.java deleted file mode 100644 index eeed5585413..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/TutorialGuideApp.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.common.terminal.app.guide; - -import gregtech.api.gui.resources.ItemStackTexture; - -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; - -import com.google.gson.JsonObject; - -public class TutorialGuideApp extends GuideApp { - - public TutorialGuideApp() { - super("tutorials", new ItemStackTexture(Items.PAPER)); - } - - @Override - protected String itemName(String item) { - return I18n.format(item); - } - - @Override - protected String rawItemName(String item) { - return item; - } - - @Override - public String ofJson(JsonObject json) { - if (json.has("tutorial")) - return json.get("tutorial").getAsString(); - return json.get("title").getAsString(); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/CardWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/CardWidget.java deleted file mode 100644 index 3d59cc9f862..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/CardWidget.java +++ /dev/null @@ -1,80 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.BooleanConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.NumberConfigurator; - -import com.google.gson.JsonObject; - -import java.util.function.Consumer; - -public class CardWidget extends GuideWidget { - - public final static String NAME = "card"; - - // config - public int width; - public int height; - public boolean isShadow; - - @Override - public String getRegistryName() { - return NAME; - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = super.getTemplate(isFixed); - template.addProperty("fill", -3745585); - template.addProperty("width", 120); - template.addProperty("height", 60); - template.addProperty("isShadow", true); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - group.addWidget(new BooleanConfigurator(group, config, "isShadow", true).setOnUpdated(needUpdate)); - if (!isFixed) { - group.addWidget(new NumberConfigurator(group, config, "width").setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "height").setOnUpdated(needUpdate)); - } - super.loadConfigurator(group, config, isFixed, needUpdate); - } - - @Override - protected Widget initStream() { - int pageWidth = getSize().width; - int x = getSelfPosition().x; - int y = getSelfPosition().y; - if (page != null) { - x = page.getMargin(); - pageWidth = page.getPageWidth() - 2 * x; - } - this.setSelfPosition(new Position(x + (pageWidth - width) / 2, y)); - return initFixed(); - } - - @Override - protected Widget initFixed() { - this.setSize(new Size(width, height)); - return this; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (isShadow) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - drawRectShadow(x, y, width, height, 5); - } - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/GuidePageWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/GuidePageWidget.java deleted file mode 100644 index bf388e66b09..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/GuidePageWidget.java +++ /dev/null @@ -1,190 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class GuidePageWidget extends DraggableScrollableWidgetGroup { - - public static final Map REGISTER_WIDGETS = new HashMap<>(); - - static { // register guide widgets - REGISTER_WIDGETS.put(TextBoxWidget.NAME, new TextBoxWidget()); - REGISTER_WIDGETS.put(ImageWidget.NAME, new ImageWidget()); - REGISTER_WIDGETS.put(CardWidget.NAME, new CardWidget()); - REGISTER_WIDGETS.put(SlotListWidget.NAME, new SlotListWidget()); - REGISTER_WIDGETS.put(TankListWidget.NAME, new TankListWidget()); - } - - protected TextBoxWidget title; - protected List stream = new ArrayList<>(); - protected List fixed = new ArrayList<>(); - protected Interpolator interpolator; - private final int margin; - - public GuidePageWidget(int xPosition, int yPosition, int width, int height, int margin) { - super(xPosition, yPosition, width, height); - this.margin = margin; - this.setBackground(new ColorRectTexture(-1)) - .setDraggable(true) - .setYScrollBarWidth(4) - .setYBarStyle(new ColorRectTexture(new Color(142, 142, 142)), - new ColorRectTexture(new Color(148, 226, 193))); - this.setUseScissor(false); - } - - public int getPageWidth() { - return this.getSize().width - yBarWidth; - } - - public int getMargin() { - return margin; - } - - public void setTitle(String config) { - int x = 5; - int y = 2; - int width = this.getSize().width - yBarWidth - 10; - int height = 0; - if (title != null) { - height = title.getSize().height; - x = title.getSelfPosition().x; - y = title.getSelfPosition().y; - removeWidget(title); - } - title = new TextBoxWidget(5, 2, width, - Collections.singletonList(config), - 0, 15, 0xffffffff, 0x6fff0000, 0xff000000, - true, true); - this.addWidget(title); - title.setSelfPosition(new Position(x, y)); - int offset = title.getSize().height - height; - if (offset != 0) { - for (Widget widget : stream) { - widget.addSelfPosition(0, offset); - } - } - } - - public String getTitle() { - return title == null ? "" : String.join("\n", title.content); - } - - public String loadJsonConfig(String config) { - try { - loadJsonConfig(new JsonParser().parse(config).getAsJsonObject()); - } catch (Exception e) { - this.clearAllWidgets(); - return e.getMessage(); - } - return null; - } - - public void loadJsonConfig(JsonObject config) { - this.stream.clear(); - this.fixed.clear(); - this.title = null; - this.clearAllWidgets(); - int pageWidth = getPageWidth(); - int margin = getMargin(); - // add title - setTitle(config.get("title").getAsString()); - - // add stream widgets - if (config.has("stream")) { - stream = new ArrayList<>(); - int y = title.getSize().height + 10; - for (JsonElement element : config.getAsJsonArray("stream")) { - JsonObject widgetConfig = element.getAsJsonObject(); - Widget widget = REGISTER_WIDGETS.get(widgetConfig.get("type").getAsString()) - .updateOrCreateStreamWidget(margin, y, pageWidth - 2 * margin, widgetConfig); - y += widget.getSize().height + 5; - stream.add(widget); - this.addWidget(widget); - } - } - // add fixed widgets - if (config.has("fixed")) { - fixed = new ArrayList<>(); - for (JsonElement element : config.getAsJsonArray("fixed")) { - JsonObject widgetConfig = element.getAsJsonObject(); - Widget widget = REGISTER_WIDGETS.get(widgetConfig.get("type").getAsString()).updateOrCreateFixedWidget( - widgetConfig.get("x").getAsInt(), - widgetConfig.get("y").getAsInt(), - widgetConfig.get("width").getAsInt(), - widgetConfig.get("height").getAsInt(), - widgetConfig); - fixed.add(widget); - this.addWidget(widget); - } - } - } - - public void onSizeUpdate(Widget widget, Size oldSize) { - int offset = widget.getSize().height - oldSize.height; - maxHeight = Math.max(maxHeight, widget.getSize().height + widget.getSelfPosition().y); - int index = stream.indexOf(widget); - if (index < 0) return; - for (int i = stream.size() - 1; i > index; i--) { - Widget nextWidget = stream.get(i); - nextWidget.addSelfPosition(0, offset); - } - } - - public void onPositionUpdate(Widget widget, Position oldPosition) { - if (oldPosition.y + widget.getSize().height == maxHeight) { - maxHeight = 0; - for (Widget widget1 : widgets) { - maxHeight = Math.max(maxHeight, widget1.getSize().height + widget1.getSelfPosition().y + scrollYOffset); - } - } - } - - protected int getStreamBottom() { - if (stream != null && stream.size() > 0) { - Widget widget = stream.get(stream.size() - 1); - return widget.getSize().height + widget.getSelfPosition().y + scrollYOffset; - } else { - return title.getSize().height + 10; - } - } - - @Override - public void updateScreen() { - if (interpolator != null) interpolator.update(); - super.updateScreen(); - } - - public void jumpToRef(String ref) { - if (interpolator != null && !interpolator.isFinish()) return; - for (Widget widget : widgets) { - if (widget instanceof IGuideWidget && ref.equals(((IGuideWidget) widget).getRef())) { - interpolator = new Interpolator(scrollYOffset, widget.getSelfPosition().y + scrollYOffset, 20, - Eases.QUAD_OUT, - value -> setScrollYOffset(value.intValue()), - value -> interpolator = null); - interpolator.start(); - } - } - } - - @Override - public void addWidget(Widget widget) { - super.addWidget(widget); - if (widget instanceof IGuideWidget) { - ((IGuideWidget) widget).setPage(this); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidget.java deleted file mode 100644 index 9055e6cf1cb..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidget.java +++ /dev/null @@ -1,185 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.ColorConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.NumberConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.StringConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.TextListConfigurator; - -import net.minecraft.item.ItemStack; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -public abstract class GuideWidget extends Widget implements IGuideWidget { - - // config - public String ref; - public int fill; - public int stroke; - public int stroke_width = 1; - public String link; - public List hover_text; - - private transient boolean isFixed; - protected transient GuidePageWidget page; - protected transient JsonObject config; - - public GuideWidget(int x, int y, int width, int height) { - super(x, y, width, height); - } - - public GuideWidget() { - super(Position.ORIGIN, Size.ZERO); - } - - @Override - public JsonObject getConfig() { - return config; - } - - @Override - public boolean isFixed() { - return isFixed; - } - - protected abstract Widget initFixed(); - - protected Widget initStream() { - return initFixed(); - } - - @Override - public void setStroke(int color) { - this.stroke = color; - } - - @Override - public void setSize(Size size) { - Size oldSize = this.getSize(); - super.setSize(size); - if (page != null) { - page.onSizeUpdate(this, oldSize); - } - } - - @Override - protected void recomputePosition() { - Position oldPosition = getPosition(); - super.recomputePosition(); - if (page != null) { - page.onPositionUpdate(this, oldPosition); - } - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = new JsonObject(); - template.addProperty("type", getRegistryName()); - if (isFixed) { - template.addProperty("x", 0); - template.addProperty("y", 0); - template.addProperty("width", 100); - template.addProperty("height", 100); - } - template.addProperty("ref", (String) null); - template.addProperty("stroke", (String) null); - template.addProperty("stroke_width", (String) null); - template.addProperty("fill", (String) null); - template.addProperty("link", (String) null); - template.add("hover_text", new Gson().toJsonTree(hover_text)); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - group.addWidget(new ColorConfigurator(group, config, "fill", 0).setOnUpdated(needUpdate)); - group.addWidget(new ColorConfigurator(group, config, "stroke", 0).setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "stroke_width", 1).setOnUpdated(needUpdate)); - group.addWidget(new StringConfigurator(group, config, "ref", "").setOnUpdated(needUpdate)); - group.addWidget(new StringConfigurator(group, config, "link", "").setOnUpdated(needUpdate)); - group.addWidget(new TextListConfigurator(group, 40, config, "hover_text", "").setOnUpdated(needUpdate)); - } - - @Override - public String getRef() { - return ref; - } - - @Override - public Widget updateOrCreateStreamWidget(int x, int y, int pageWidth, JsonObject config) { - if (config == null) { - return initStream(); - } - GuideWidget widget = new Gson().fromJson(config, this.getClass()); - widget.isFixed = false; - widget.setSelfPosition(new Position(x, y)); - widget.setSize(new Size(pageWidth, 0)); - widget.config = config; - return widget.initStream(); - } - - @Override - public Widget updateOrCreateFixedWidget(int x, int y, int width, int height, JsonObject config) { - if (config == null) { - return initFixed(); - } - GuideWidget widget = new Gson().fromJson(config, this.getClass()); - widget.isFixed = true; - widget.setSelfPosition(new Position(x, y)); - widget.setSize(new Size(width, height)); - widget.config = config; - return widget.initFixed(); - } - - @Override - public void setPage(GuidePageWidget page) { - this.page = page; - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - if (link != null && isMouseOverElement(mouseX, mouseY)) { - Position position = getPosition(); - Size size = getSize(); - drawBorder(position.x, position.y, size.width, size.height, 0xff0000ff, stroke_width); - } - if ((hover_text != null || link != null) && isMouseOverElement(mouseX, mouseY)) { - List tooltip = hover_text == null ? new ArrayList<>() : new ArrayList<>(hover_text); - if (link != null) { - tooltip.add("§9Ctrl+Click§r §e(" + link + ")§r"); - } - drawHoveringText(ItemStack.EMPTY, tooltip, 100, mouseX, mouseY); - } - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - Position position = getPosition(); - Size size = getSize(); - if (stroke != 0) { - drawBorder(position.x, position.y, size.width, size.height, stroke, stroke_width); - } - if (fill != 0) { - drawSolidRect(position.x, position.y, size.width, size.height, fill); - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (link != null && isMouseOverElement(mouseX, mouseY) && isCtrlDown()) { - page.jumpToRef(link); - return true; - } - return false; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidgetGroup.java b/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidgetGroup.java deleted file mode 100644 index 51a91cf93dc..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/GuideWidgetGroup.java +++ /dev/null @@ -1,196 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.ColorConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.NumberConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.StringConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.TextListConfigurator; - -import net.minecraft.item.ItemStack; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -public abstract class GuideWidgetGroup extends WidgetGroup implements IGuideWidget { - - // config - public String ref; - public int fill; - public int stroke; - public int stroke_width = 1; - public String link; - public List hover_text; - - private transient boolean isFixed; - protected transient GuidePageWidget page; - protected transient JsonObject config; - - public GuideWidgetGroup(int x, int y, int width, int height) { - super(x, y, width, height); - } - - public GuideWidgetGroup() { - super(Position.ORIGIN, Size.ZERO); - } - - @Override - public JsonObject getConfig() { - return config; - } - - @Override - public boolean isFixed() { - return isFixed; - } - - @Override - public void setStroke(int color) { - this.stroke = color; - } - - @Override - public void setSize(Size size) { - Size oldSize = this.getSize(); - super.setSize(size); - if (page != null) { - page.onSizeUpdate(this, oldSize); - } - } - - @Override - protected void recomputePosition() { - Position oldPosition = getPosition(); - super.recomputePosition(); - if (page != null) { - page.onPositionUpdate(this, oldPosition); - } - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = new JsonObject(); - template.addProperty("type", getRegistryName()); - if (isFixed) { - template.addProperty("x", 0); - template.addProperty("y", 0); - template.addProperty("width", 100); - template.addProperty("height", 100); - } - template.addProperty("ref", (String) null); - template.addProperty("stroke", (String) null); - template.addProperty("stroke_width", (String) null); - template.addProperty("fill", (String) null); - template.addProperty("link", (String) null); - template.add("hover_text", new Gson().toJsonTree(hover_text)); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - group.addWidget(new ColorConfigurator(group, config, "fill", 0).setOnUpdated(needUpdate)); - group.addWidget(new ColorConfigurator(group, config, "stroke", 0).setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "stroke_width", 1).setOnUpdated(needUpdate)); - group.addWidget(new StringConfigurator(group, config, "ref", "").setOnUpdated(needUpdate)); - group.addWidget(new StringConfigurator(group, config, "link", "").setOnUpdated(needUpdate)); - group.addWidget(new TextListConfigurator(group, 40, config, "hover_text", "").setOnUpdated(needUpdate)); - } - - @Override - public String getRef() { - return ref; - } - - protected Widget initStream() { - return initFixed(); - } - - protected abstract Widget initFixed(); - - @Override - public Widget updateOrCreateStreamWidget(int x, int y, int pageWidth, JsonObject config) { - if (config == null) { - return initStream(); - } - GuideWidgetGroup widget = new Gson().fromJson(config, this.getClass()); - widget.isFixed = false; - widget.setSelfPosition(new Position(x, y)); - widget.setSize(new Size(pageWidth, 0)); - widget.config = config; - return widget.initStream(); - } - - @Override - public Widget updateOrCreateFixedWidget(int x, int y, int width, int height, JsonObject config) { - if (config == null) { - return initFixed(); - } - GuideWidgetGroup widget = new Gson().fromJson(config, this.getClass()); - widget.isFixed = true; - widget.setSelfPosition(new Position(x, y)); - widget.setSize(new Size(width, height)); - widget.config = config; - return widget.initFixed(); - } - - @Override - public void setPage(GuidePageWidget page) { - this.page = page; - } - - @Override - public void addWidget(Widget widget) { - super.addWidget(widget); - if (widget instanceof IGuideWidget) { - ((IGuideWidget) widget).setPage(page); - } - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - if (link != null && isMouseOverElement(mouseX, mouseY)) { - Position position = getPosition(); - Size size = getSize(); - drawBorder(position.x, position.y, size.width, size.height, 0xff0000ff, stroke_width); - } - if ((hover_text != null || link != null) && isMouseOverElement(mouseX, mouseY)) { - List tooltip = hover_text == null ? new ArrayList<>() : new ArrayList<>(hover_text); - if (link != null) { - tooltip.add("§9Ctrl+Click§r §e(" + link + ")§r"); - } - drawHoveringText(ItemStack.EMPTY, tooltip, 100, mouseX, mouseY); - } - super.drawInForeground(mouseX, mouseY); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - Position position = getPosition(); - Size size = getSize(); - if (stroke != 0) { - drawBorder(position.x, position.y, size.width, size.height, stroke, stroke_width); - } - if (fill != 0) { - drawSolidRect(position.x, position.y, size.width, size.height, fill); - } - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (link != null && isMouseOverElement(mouseX, mouseY) && isCtrlDown()) { - page.jumpToRef(link); - return true; - } - return super.mouseClicked(mouseX, mouseY, button); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/IGuideWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/IGuideWidget.java deleted file mode 100644 index 7fb947c8c26..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/IGuideWidget.java +++ /dev/null @@ -1,61 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.lang.reflect.Field; -import java.util.function.Consumer; - -public interface IGuideWidget { - - String getRegistryName(); - - JsonObject getConfig(); - - boolean isFixed(); - - Widget updateOrCreateStreamWidget(int x, int y, int pageWidth, JsonObject config); - - Widget updateOrCreateFixedWidget(int x, int y, int width, int height, JsonObject config); - - void setPage(GuidePageWidget page); - - default void updateValue(String field) { - JsonObject config = getConfig(); - if (config != null && config.has(field)) { - try { - Field f = this.getClass().getField(field); - JsonElement value = config.get(field); - if (value.isJsonNull()) { // default - f.set(this, f.get(GuidePageWidget.REGISTER_WIDGETS.get(getRegistryName()))); - } else { - f.set(this, new Gson().fromJson(value, f.getGenericType())); - } - if (isFixed()) { - updateOrCreateFixedWidget(0, 0, 0, 0, null); - } else { - updateOrCreateStreamWidget(0, 0, 0, null); - } - } catch (Exception ignored) {} - } - } - - String getRef(); - - JsonObject getTemplate(boolean isFixed); - - void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate); - - void setStroke(int color); - - default void onFixedPositionSizeChanged(Position position, Size size) { - updateOrCreateFixedWidget(0, 0, 0, 0, null); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/ImageWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/ImageWidget.java deleted file mode 100644 index b5f6fd5d71b..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/ImageWidget.java +++ /dev/null @@ -1,112 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.resources.URLTexture; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.NumberConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.SelectorConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.StringConfigurator; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; - -import com.google.gson.JsonObject; - -import java.util.Arrays; -import java.util.function.Consumer; - -public class ImageWidget extends GuideWidget { - - public final static String NAME = "image"; - // config - public String form; - public String source; - public int width; - public int height; - - public transient IGuiTexture image; - - @Override - public String getRegistryName() { - return NAME; - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = super.getTemplate(isFixed); - template.addProperty("form", "resource"); - template.addProperty("source", "gregtech:textures/gui/icon/gregtech_logo.png"); - template.addProperty("width", 50); - template.addProperty("height", 50); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - if (!isFixed) { - group.addWidget(new NumberConfigurator(group, config, "width").setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "height").setOnUpdated(needUpdate)); - } - group.addWidget(new SelectorConfigurator(group, config, "form", Arrays.asList("url", "item", "resource")) - .setOnUpdated(needUpdate)); - group.addWidget(new StringConfigurator(group, config, "source").setOnUpdated(needUpdate)); - super.loadConfigurator(group, config, isFixed, needUpdate); - } - - @Override - public void updateScreen() { - if (image != null) { - image.updateTick(); - } - } - - @Override - protected Widget initStream() { - int pageWidth = getSize().width; - int x = getSelfPosition().x; - int y = getSelfPosition().y; - if (page != null) { - x = page.getMargin(); - pageWidth = page.getPageWidth() - 2 * x; - } - this.setSelfPosition(new Position(x + (pageWidth - Math.max(0, width)) / 2, y)); - return initFixed(); - } - - @Override - protected Widget initFixed() { - width = Math.max(0, width); - height = Math.max(0, height); - this.setSize(new Size(width, height)); - switch (form) { - case "url": - image = new URLTexture(source); - break; - case "item": - image = new ItemStackTexture(Item.getByNameOrId(source)); - break; - case "resource": - image = new TextureArea(new ResourceLocation(source), 0.0, 0.0, 1.0, 1.0); - break; - } - return this; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (image != null) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - GlStateManager.color(1, 1, 1, 1); - Position position = getPosition(); - image.draw(position.x, position.y, getSize().width, getSize().height); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/SlotListWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/SlotListWidget.java deleted file mode 100644 index 4fcb005954c..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/SlotListWidget.java +++ /dev/null @@ -1,118 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.ItemStackConfigurator; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.items.ItemStackHandler; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; - -public class SlotListWidget extends GuideWidgetGroup { - - public final static String NAME = "slots"; - - // config - public List item_list; - - @Override - public Widget initFixed() { - this.clearAllWidgets(); - ItemStackHandler itemStackHandler = new ItemStackHandler(item_list.size()); - IGuiTexture background = new ColorRectTexture(0x4f000000); - int size = item_list.size(); - int maxXSize = getSize().width / 18; - int xPos; - if (maxXSize < 1) { - maxXSize = 1; - xPos = 0; - } else { - xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2; - } - int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1); - for (int y = 0; y <= size / maxXSize; y++) { - for (int x = 0; x < maxXSize; x++) { - int i = x + y * maxXSize; - if (i < size) { - itemStackHandler.setStackInSlot(i, item_list.get(i).getInstance()); - SlotWidget widget = new SlotWidget(itemStackHandler, i, xPos + x * 18, y * 18, false, false); - widget.setBackgroundTexture(background); - this.addWidget(widget); - } - } - } - setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18)); - return this; - } - - @Override - public String getRegistryName() { - return NAME; - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = super.getTemplate(isFixed); - template.add("item_list", - new Gson().toJsonTree(Collections.singletonList(new ItemStackInfo("minecraft:ender_pearl", 0, 1)))); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - super.loadConfigurator(group, config, isFixed, needUpdate); - group.addWidget(new ItemStackConfigurator(group, config, "item_list").setOnUpdated(needUpdate)); - } - - public static class ItemStackInfo { - - // config - public String id; - public int damage; - public int count = 1; - - private transient ItemStack itemStack; - - public ItemStackInfo() {} - - public void update(ItemStack itemStack) { - ResourceLocation resourceLocation = itemStack.getItem().getRegistryName(); - id = resourceLocation == null ? "minecraft:air" : resourceLocation.toString(); - damage = itemStack.getItemDamage(); - count = itemStack.getCount(); - } - - public ItemStackInfo(String id, int damage, int count) { - this.id = id; - this.damage = damage; - this.count = count; - } - - public ItemStack getInstance() { - if (itemStack == null && id != null) { - Item item = Item.getByNameOrId(id); - if (item == null) { - itemStack = ItemStack.EMPTY; - return itemStack; - } - itemStack = item.getDefaultInstance(); - itemStack.setCount(count); - itemStack.setItemDamage(damage); - } - return itemStack == null ? ItemStack.EMPTY : itemStack; - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/TankListWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/TankListWidget.java deleted file mode 100644 index 8de6641bd72..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/TankListWidget.java +++ /dev/null @@ -1,121 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.TankWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.FluidStackConfigurator; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.awt.*; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; - -public class TankListWidget extends GuideWidgetGroup { - - public final static String NAME = "tanks"; - - // config - public List fluid_list; - - protected transient Rectangle scissor; - - @Override - public Widget initFixed() { - this.clearAllWidgets(); - IGuiTexture background = new ColorRectTexture(0x4f000000); - int size = fluid_list.size(); - int maxXSize = getSize().width / 18; - int xPos; - if (maxXSize < 1) { - maxXSize = 1; - xPos = 0; - } else { - xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2; - } - int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1); - for (int y = 0; y <= size / maxXSize; y++) { - for (int x = 0; x < maxXSize; x++) { - int i = x + y * maxXSize; - if (i < size) { - FluidStack fluidStack = fluid_list.get(i).getInstance(); - TankWidget widget = new TankWidget(new FluidTank(fluidStack, fluid_list.get(i).amount), - xPos + x * 18, y * 18, 18, 18); - widget.setBackgroundTexture(background).setAlwaysShowFull(true).setClient(); - this.addWidget(widget); - } - } - } - setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18)); - return this; - } - - @Override - public String getRegistryName() { - return NAME; - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = super.getTemplate(isFixed); - template.add("fluid_list", - new Gson().toJsonTree(Collections.singletonList(new FluidStackInfo("distilled_water", 1)))); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - super.loadConfigurator(group, config, isFixed, needUpdate); - group.addWidget(new FluidStackConfigurator(group, config, "fluid_list").setOnUpdated(needUpdate)); - } - - public static class FluidStackInfo { - - // config - public String id; - public int amount = 1; - - private transient FluidStack fluidStack; - - public FluidStackInfo() {} - - public void update(FluidStack itemStack) { - if (itemStack != null) { - id = FluidRegistry.getFluidName(itemStack.getFluid()); - amount = itemStack.amount; - } else { - id = null; - fluidStack = null; - amount = 0; - } - } - - public FluidStackInfo(String id, int amount) { - this.id = id; - this.amount = amount; - } - - public FluidStack getInstance() { - if (fluidStack == null && id != null) { - Fluid fluid = FluidRegistry.getFluid(id); - if (fluid != null) { - fluidStack = new FluidStack(fluid, amount); - } else { - id = null; - } - } - return fluidStack; - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guide/widget/TextBoxWidget.java b/src/main/java/gregtech/common/terminal/app/guide/widget/TextBoxWidget.java deleted file mode 100644 index 465a4679b60..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guide/widget/TextBoxWidget.java +++ /dev/null @@ -1,125 +0,0 @@ -package gregtech.common.terminal.app.guide.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.guideeditor.widget.configurator.BooleanConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.ColorConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.NumberConfigurator; -import gregtech.common.terminal.app.guideeditor.widget.configurator.TextListConfigurator; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; - -public class TextBoxWidget extends GuideWidget { - - public final static String NAME = "textbox"; - - // config - public List content; - public int space = 1; - public int fontSize = 9; - public int fontColor = 0xff000000; - public boolean isShadow = false; - public boolean isCenter = false; - - private transient List textLines; - - public TextBoxWidget(int x, int y, int width, List content, int space, int fontSize, int fontColor, - int fill, int stroke, boolean isCenter, boolean isShadow) { - super(x, y, width, 0); - this.content = content; - this.space = space; - this.fontSize = fontSize; - this.fontColor = fontColor; - this.fill = fill; - this.stroke = stroke; - this.isCenter = isCenter; - this.isShadow = isShadow; - this.initFixed(); - } - - public TextBoxWidget() {} - - @Override - public String getRegistryName() { - return NAME; - } - - @Override - public JsonObject getTemplate(boolean isFixed) { - JsonObject template = super.getTemplate(isFixed); - template.addProperty("space", (String) null); - template.addProperty("fontSize", (String) null); - template.addProperty("fontColor", (String) null); - template.addProperty("isCenter", (String) null); - template.addProperty("isShadow", (String) null); - template.add("content", new Gson().toJsonTree(Arrays.asList("this is a", "textbox!"))); - return template; - } - - @Override - public void loadConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, boolean isFixed, - Consumer needUpdate) { - group.addWidget(new TextListConfigurator(group, 200, config, "content").setOnUpdated(needUpdate)); - group.addWidget(new BooleanConfigurator(group, config, "isCenter", false).setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "fontSize", 9).setOnUpdated(needUpdate)); - group.addWidget(new BooleanConfigurator(group, config, "isShadow", false).setOnUpdated(needUpdate)); - group.addWidget(new ColorConfigurator(group, config, "fontColor", 0xff000000).setOnUpdated(needUpdate)); - group.addWidget(new NumberConfigurator(group, config, "space", 1).setOnUpdated(needUpdate)); - super.loadConfigurator(group, config, isFixed, needUpdate); - } - - @Override - protected Widget initFixed() { - this.textLines = new ArrayList<>(); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - this.space = Math.max(space, 0); - this.fontSize = Math.max(fontSize, 1); - int wrapWidth = getSize().width * font.FONT_HEIGHT / fontSize; - if (content != null) { - for (String textLine : content) { - this.textLines.addAll(font.listFormattedStringToWidth(I18n.format(textLine), wrapWidth)); - } - } - this.setSize(new Size(this.getSize().width, this.textLines.size() * (fontSize + space))); - return this; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - if (!textLines.isEmpty()) { - Position position = getPosition(); - Size size = getSize(); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - float scale = fontSize * 1.0f / font.FONT_HEIGHT; - GlStateManager.pushMatrix(); - GlStateManager.scale(scale, scale, 1); - GlStateManager.translate(position.x / scale, position.y / scale, 0); - float x = 0; - float y = 0; - float ySpace = font.FONT_HEIGHT + space / scale; - for (String textLine : textLines) { - if (isCenter) { - x = (size.width / scale - font.getStringWidth(textLine)) / 2; - } - font.drawString(textLine, x, y, fontColor, isShadow); - y += ySpace; - } - GlStateManager.popMatrix(); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/GuideEditorApp.java b/src/main/java/gregtech/common/terminal/app/guideeditor/GuideEditorApp.java deleted file mode 100644 index a8d19adf9e7..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/GuideEditorApp.java +++ /dev/null @@ -1,61 +0,0 @@ -package gregtech.common.terminal.app.guideeditor; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.common.terminal.app.guideeditor.widget.GuideConfigEditor; -import gregtech.common.terminal.app.guideeditor.widget.GuidePageEditorWidget; -import gregtech.common.terminal.component.ClickComponent; - -import java.util.Arrays; -import java.util.List; - -public class GuideEditorApp extends AbstractApplication { - - private GuideConfigEditor configEditor; - - public GuideEditorApp() { - super("guide_editor"); - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - this.configEditor = new GuideConfigEditor(0, 0, 133, 232, this); - GuidePageEditorWidget pageEditor = new GuidePageEditorWidget(133, 0, 200, 232, 5); - this.configEditor.setGuidePageEditorWidget(pageEditor); - pageEditor.setGuideConfigEditor(this.configEditor); - this.addWidget(pageEditor); - this.addWidget(this.configEditor); - } - return this; - } - - @Override - public List getMenuComponents() { - ClickComponent newPage = new ClickComponent().setIcon(GuiTextures.ICON_NEW_PAGE) - .setHoverText("terminal.component.new_page").setClickConsumer(cd -> { - if (configEditor != null) { - configEditor.newPage(); - } - }); - ClickComponent importPage = new ClickComponent().setIcon(GuiTextures.ICON_LOAD) - .setHoverText("terminal.component.load_file").setClickConsumer(cd -> { - if (configEditor != null) { - configEditor.loadJson(); - } - }); - ClickComponent exportPage = new ClickComponent().setIcon(GuiTextures.ICON_SAVE) - .setHoverText("terminal.component.save_file").setClickConsumer(cd -> { - if (configEditor != null) { - configEditor.saveJson(); - } - }); - return Arrays.asList(newPage, importPage, exportPage); - } - - @Override - public boolean isClientSideApp() { - return true; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuideConfigEditor.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuideConfigEditor.java deleted file mode 100644 index 0e23f2b6e46..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuideConfigEditor.java +++ /dev/null @@ -1,339 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget; - -import gregtech.api.GregTechAPI; -import gregtech.api.block.machines.MachineItemBlock; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.AbstractWidgetGroup; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.PhantomSlotWidget; -import gregtech.api.gui.widgets.TabGroup; -import gregtech.api.gui.widgets.TextFieldWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.gui.widgets.tab.IGuiTextureTabInfo; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.registry.MTERegistry; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.CustomTabListRenderer; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.SelectorWidget; -import gregtech.api.terminal.gui.widgets.TextEditorWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.FileUtility; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.common.inventory.handlers.SingleItemStackHandler; -import gregtech.common.terminal.app.guide.GuideApp; -import gregtech.common.terminal.app.guide.ItemGuideApp; -import gregtech.common.terminal.app.guide.MultiBlockGuideApp; -import gregtech.common.terminal.app.guide.SimpleMachineGuideApp; -import gregtech.common.terminal.app.guide.widget.GuidePageWidget; -import gregtech.common.terminal.app.guide.widget.IGuideWidget; -import gregtech.common.terminal.app.guideeditor.GuideEditorApp; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.items.IItemHandlerModifiable; - -import com.google.gson.JsonObject; - -import java.awt.*; -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -public class GuideConfigEditor extends TabGroup { - - public String json; - private IGuideWidget selected; - private GuidePageEditorWidget pageEditor; - private TextEditorWidget titleEditor; - private final DraggableScrollableWidgetGroup widgetSelector; - private final DraggableScrollableWidgetGroup widgetConfigurator; - private final CircleButtonWidget[] addButton; - private final GuideEditorApp app; - private final IItemHandlerModifiable handler; - private final List candidates; - private String type; - - public GuideConfigEditor(int x, int y, int width, int height, GuideEditorApp app) { - super(x, y + 10, new CustomTabListRenderer(TerminalTheme.COLOR_F_2, TerminalTheme.COLOR_B_3, 30, 10)); - setSize(new Size(width, height)); - candidates = TerminalRegistry.getAllApps().stream().filter(GuideApp.class::isInstance) - .map(AbstractApplication::getUnlocalizedName).collect(Collectors.toList()); - type = candidates.get(candidates.size() - 1); - handler = new SingleItemStackHandler(1); - addButton = new CircleButtonWidget[2]; - widgetSelector = createWidgetSelector(); - widgetConfigurator = createConfigurator(); - this.addTab(new IGuiTextureTabInfo(new TextTexture("P", -1), "terminal.guide_editor.page_config"), - createPageConfig()); - this.addTab(new IGuiTextureTabInfo(new TextTexture("W", -1), "terminal.guide_editor.widgets_box"), - widgetSelector); - this.addTab(new IGuiTextureTabInfo(new TextTexture("C", -1), "terminal.guide_editor.widget_config"), - widgetConfigurator); - this.setOnTabChanged((oldIndex, newIndex) -> { - if (newIndex == 1) { - addButton[0].setVisible(true); - addButton[1].setVisible(true); - } else { - addButton[0].setVisible(false); - addButton[1].setVisible(false); - } - }); - addButton[0] = new CircleButtonWidget(115, 15, 8, 1, 8) - .setColors(new Color(255, 255, 255, 0).getRGB(), - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_4.getColor()) - .setIcon(GuiTextures.ICON_ADD) - .setHoverText("terminal.guide_editor.add_stream") - .setClickListener(this::addStream); - addButton[1] = new CircleButtonWidget(115, 35, 8, 1, 8) - .setColors(new Color(255, 255, 255, 0).getRGB(), - TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_5.getColor()) - .setIcon(GuiTextures.ICON_ADD) - .setHoverText("terminal.guide_editor.add_fixed") - .setClickListener(this::addFixed); - addButton[0].setVisible(false); - addButton[1].setVisible(false); - this.app = app; - this.addWidget(addButton[0]); - this.addWidget(addButton[1]); - } - - public void setGuidePageEditorWidget(GuidePageEditorWidget pageEditor) { - this.pageEditor = pageEditor; - } - - public GuidePageEditorWidget getPageEditor() { - return pageEditor; - } - - private DraggableScrollableWidgetGroup createPageConfig() { - DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, - getSize().height - 10) - .setBackground(TerminalTheme.COLOR_B_3) - .setYScrollBarWidth(4) - .setYBarStyle(null, TerminalTheme.COLOR_F_1); - group.addWidget(new LabelWidget(5, 5, "section", -1).setShadow(true)); - group.addWidget(new TextFieldWidget(5, 15, 116, 20, new ColorRectTexture(0x9f000000), null, null) - .setTextResponder(s -> { - if (pageEditor != null) { - pageEditor.setSection(s); - } - }, true) - .setTextSupplier(() -> getPageEditor().getSection(), true) - .setMaxStringLength(Integer.MAX_VALUE) - .setValidator(s -> true)); - group.addWidget(new ImageWidget(5, 40, 116, 1, new ColorRectTexture(-1))); - group.addWidget(new LabelWidget(5, 45, "type", -1).setShadow(true)); - - group.addWidget(new SelectorWidget(30, 55, 91, 20, candidates, -1, - () -> type, true).setIsUp(true) - .setOnChanged(type -> this.type = type) - .setColors(TerminalTheme.COLOR_B_2.getColor(), TerminalTheme.COLOR_F_1.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setBackground(TerminalTheme.COLOR_6)); - group.addWidget(new PhantomSlotWidget(handler, 0, 6, 56).setBackgroundTexture(TerminalTheme.COLOR_B_2)); - - group.addWidget(new ImageWidget(5, 80, 116, 1, new ColorRectTexture(-1))); - - group.addWidget(new LabelWidget(5, 85, "title", -1).setShadow(true)); - titleEditor = new TextEditorWidget(5, 95, 116, 70, s -> { - if (pageEditor != null) { - pageEditor.setTitle(s); - } - }, true).setContent("Template").setBackground(new ColorRectTexture(0xA3FFFFFF)); - group.addWidget(titleEditor); - return group; - } - - public void updateTitle(String title) { - titleEditor.setContent(title); - } - - private DraggableScrollableWidgetGroup createWidgetSelector() { - DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, - getSize().height - 10) - .setBackground(TerminalTheme.COLOR_B_3) - .setYScrollBarWidth(4) - .setYBarStyle(null, TerminalTheme.COLOR_F_1); - int y = 10; // 133 - for (Map.Entry entry : GuidePageWidget.REGISTER_WIDGETS.entrySet()) { - IGuideWidget widgetTemplate = entry.getValue(); - JsonObject template = widgetTemplate.getTemplate(false); - Widget guideWidget = widgetTemplate.updateOrCreateStreamWidget(5, y + 10, getSize().width - 14, template); - group.addWidget(new LabelWidget(getSize().width / 2 - 1, y - 3, entry.getKey(), -1).setXCentered(true) - .setShadow(true)); - y += guideWidget.getSize().height + 25; - group.addWidget(guideWidget); - } - group.addWidget(new WidgetGroup(new Position(5, group.getWidgetBottomHeight() + 5), Size.ZERO)); - return group; - } - - private DraggableScrollableWidgetGroup createConfigurator() { - return new DraggableScrollableWidgetGroup(0, 0, getSize().width, getSize().height - 10) - .setBackground(TerminalTheme.COLOR_B_3) - .setYScrollBarWidth(4) - .setYBarStyle(null, TerminalTheme.COLOR_F_1); - } - - public void loadConfigurator(IGuideWidget widget) { - widgetConfigurator.clearAllWidgets(); - if (widget != null) { - widget.loadConfigurator(widgetConfigurator, widget.getConfig(), widget.isFixed(), type -> { - widget.updateValue(type); - if (pageEditor != null) { - pageEditor.computeMax(); - } - }); - widgetConfigurator.addWidget( - new WidgetGroup(new Position(5, widgetConfigurator.getWidgetBottomHeight() + 5), Size.ZERO)); - } - } - - public void newPage() { - TerminalDialogWidget - .showConfirmDialog(app.getOs(), "terminal.component.new_page", "terminal.component.confirm", res -> { - if (res) { - pageEditor.loadJsonConfig( - "{\"section\":\"default\",\"title\":\"Template\",\"stream\":[],\"fixed\":[]}"); - getPageEditor().setSection("default"); - updateTitle("Template"); - type = candidates.get(candidates.size() - 1); - handler.setStackInSlot(0, ItemStack.EMPTY); - } - }).setClientSide().open(); - } - - public void loadJson() { - if (pageEditor != null) { - File file = new File(TerminalRegistry.TERMINAL_PATH, "guide"); - TerminalDialogWidget.showFileDialog(app.getOs(), "terminal.component.load_file", file, true, result -> { - if (result != null && result.isFile()) { - try { - JsonObject config = Objects.requireNonNull(FileUtility.loadJson(result)).getAsJsonObject(); - pageEditor.loadJsonConfig(config); - getPageEditor().setSection(config.get("section").getAsString()); - updateTitle(config.get("title").getAsString()); - for (AbstractApplication app : TerminalRegistry.getAllApps()) { - if (app instanceof GuideApp) { - Object object = ((GuideApp) app).ofJson(config); - if (object != null) { - type = app.getUnlocalizedName(); - if (object instanceof ItemGuideApp.GuideItem) { - handler.setStackInSlot(0, ((ItemGuideApp.GuideItem) object).stack.copy()); - } else if (object instanceof MetaTileEntity) { - handler.setStackInSlot(0, ((MetaTileEntity) object).getStackForm()); - } else if (object instanceof ItemStack) { - handler.setStackInSlot(0, ((ItemStack) object).copy()); - } else { - handler.setStackInSlot(0, ItemStack.EMPTY); - } - break; - } - } - } - } catch (Exception e) { - TerminalDialogWidget.showInfoDialog(app.getOs(), "terminal.component.error", - "terminal.component.load_file.error").setClientSide().open(); - } - } - }).setClientSide().open(); - } - } - - public void saveJson() { - if (pageEditor != null) { - File file = new File(TerminalRegistry.TERMINAL_PATH, "guide"); - TerminalDialogWidget.showFileDialog(app.getOs(), "terminal.component.save_file", file, false, result -> { - if (result != null) { - if (!FileUtility.saveJson(result, saveType(pageEditor.getJsonConfig()))) { - TerminalDialogWidget.showInfoDialog(app.getOs(), "terminal.component.error", - "terminal.component.save_file.error").setClientSide().open(); - } - } - }).setClientSide().open(); - } - } - - private JsonObject saveType(JsonObject jsonObject) { - ItemStack stack = handler.getStackInSlot(0); - for (AbstractApplication app : TerminalRegistry.getAllApps()) { - if (app instanceof GuideApp) { - if (type.equals(app.getUnlocalizedName())) { - if (app instanceof ItemGuideApp) { - if (stack.isEmpty()) { - TerminalDialogWidget.showInfoDialog(app.getOs(), "terminal.component.warning", - "terminal.guide_editor.error_type").setClientSide().open(); - } else { - jsonObject.addProperty("item", Item.REGISTRY.getNameForObject(stack.getItem()).toString() + - ":" + stack.getMetadata()); - } - } else if ((app instanceof MultiBlockGuideApp || app instanceof SimpleMachineGuideApp) && - stack.getItem() instanceof MachineItemBlock) { - MTERegistry registry = GregTechAPI.mteManager.getRegistry( - Objects.requireNonNull(stack.getItem().getRegistryName()).getNamespace()); - MetaTileEntity mte = registry.getObjectById(stack.getItemDamage()); - if (mte != null) { - jsonObject.addProperty("metatileentity", - registry.getNameForObject(mte).getPath()); - } else { - TerminalDialogWidget.showInfoDialog(app.getOs(), "terminal.component.warning", - "terminal.guide_editor.error_type").setClientSide().open(); - } - } - return jsonObject; - } - } - } - return jsonObject; - } - - private void addFixed(ClickData data) { - if (pageEditor != null && selected != null) { - selected.setStroke(0); - pageEditor.addGuideWidget(selected, true); - selected.setStroke(0xFF7CA1FF); - } - } - - private void addStream(ClickData data) { - if (pageEditor != null && selected != null) { - selected.setStroke(0); - pageEditor.addGuideWidget(selected, false); - selected.setStroke(0xFF7CA1FF); - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - boolean flag = super.mouseClicked(mouseX, mouseY, button); - if (selectedTabIndex == 1 && widgetSelector != null) { - for (Widget widget : widgetSelector.widgets) { - if (widget.isMouseOverElement(mouseX, mouseY)) { - if (widget instanceof IGuideWidget) { - if (selected != null) { - selected.setStroke(0); - } - ((IGuideWidget) widget).setStroke(0xFF7CA1FF); - selected = (IGuideWidget) widget; - } - playButtonClickSound(); - return true; - } - } - } - return flag; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuidePageEditorWidget.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuidePageEditorWidget.java deleted file mode 100644 index 9f15e37b052..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/GuidePageEditorWidget.java +++ /dev/null @@ -1,408 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.gui.widgets.CustomPositionSizeWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.api.util.Size; -import gregtech.api.util.interpolate.Eases; -import gregtech.api.util.interpolate.Interpolator; -import gregtech.common.terminal.app.guide.widget.GuidePageWidget; -import gregtech.common.terminal.app.guide.widget.IGuideWidget; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -public class GuidePageEditorWidget extends GuidePageWidget { - - private Widget selected; - private final WidgetGroup toolButtons; - private final CustomPositionSizeWidget customPositionSizeWidget; - private GuideConfigEditor configEditor; - private String section = "default"; - - public GuidePageEditorWidget(int xPosition, int yPosition, int width, int height, int margin) { - super(xPosition, yPosition, width, height, margin); - this.setDraggable(false); - setTitle("Template"); - customPositionSizeWidget = new CustomPositionSizeWidget(0xff0000ff, 0xffff0000, 2) - .setOnUpdated(this::onPosSizeChanged); - toolButtons = new WidgetGroup(Position.ORIGIN, Size.ZERO); - toolButtons.setVisible(false); - toolButtons.addWidget(new CircleButtonWidget(-20, -4, 8, 1, 12) - .setColors(0, - TerminalTheme.COLOR_B_2.getColor(), - TerminalTheme.COLOR_1.getColor()) - .setIcon(GuiTextures.ICON_UP) - .setHoverText("terminal.guide_editor.up") - .setClickListener(this::moveUp)); - toolButtons.addWidget(new CircleButtonWidget(0, -4, 8, 1, 12) - .setColors(0, - TerminalTheme.COLOR_B_2.getColor(), - TerminalTheme.COLOR_2.getColor()) - .setIcon(GuiTextures.ICON_DOWN) - .setHoverText("terminal.guide_editor.down") - .setClickListener(this::moveDown)); - toolButtons.addWidget(new CircleButtonWidget(20, -4, 8, 1, 12) - .setColors(0, - TerminalTheme.COLOR_B_2.getColor(), - TerminalTheme.COLOR_3.getColor()) - .setIcon(GuiTextures.ICON_REMOVE) - .setHoverText("terminal.guide_editor.remove") - .setClickListener(this::delete)); - addWidget(customPositionSizeWidget); - addWidget(toolButtons); - } - - public void setSection(String section) { - this.section = section; - } - - public String getSection() { - return section; - } - - private void onPosSizeChanged(Position pos, Size size) { - Widget widget = customPositionSizeWidget.getControlled(); - if (widget instanceof IGuideWidget && ((IGuideWidget) widget).isFixed()) { - JsonObject config = ((IGuideWidget) widget).getConfig(); - if (config.has("x")) { - config.addProperty("x", pos.x + scrollXOffset); - ((IGuideWidget) widget).updateValue("x"); - } - if (config.has("y")) { - config.addProperty("y", pos.y + scrollYOffset); - ((IGuideWidget) widget).updateValue("y"); - } - if (config.has("width")) { - config.addProperty("width", size.width); - ((IGuideWidget) widget).updateValue("width"); - } - if (config.has("height")) { - config.addProperty("height", size.height); - ((IGuideWidget) widget).updateValue("height"); - } - ((IGuideWidget) widget).onFixedPositionSizeChanged(pos, size); - } - toolButtons.setSelfPosition(new Position(pos.x + size.width / 2, pos.y)); - } - - public void setGuideConfigEditor(GuideConfigEditor configEditor) { - this.configEditor = configEditor; - } - - private void setToolButton(Widget widget) { - customPositionSizeWidget.setControlled(widget); - customPositionSizeWidget.setVisible(true); - customPositionSizeWidget.setActive(!(widget instanceof IGuideWidget) || ((IGuideWidget) widget).isFixed()); - toolButtons.setVisible(true); - toolButtons.setSelfPosition( - new Position(widget.getSelfPosition().x + widget.getSize().width / 2, widget.getSelfPosition().y)); - } - - private void delete(ClickData clickData) { - removeWidget(selected); - selected = null; - configEditor.loadConfigurator(null); - toolButtons.setSelfPosition(new Position(-scrollYOffset, -scrollYOffset)); - customPositionSizeWidget.setControlled(null); - toolButtons.setVisible(false); - } - - private void moveUp(ClickData clickData) { - moveUp(selected); - } - - private void moveDown(ClickData clickData) { - moveDown(selected); - } - - public JsonObject getJsonConfig() { - JsonObject json = new JsonObject(); - json.addProperty("section", section); - json.addProperty("title", title.content.get(0)); - JsonArray array = new JsonArray(); - json.add("stream", array); - stream.forEach(widget -> { - if (widget instanceof IGuideWidget) { - array.add(((IGuideWidget) widget).getConfig()); - } - }); - - JsonArray array2 = new JsonArray(); - json.add("fixed", array2); - fixed.forEach(widget -> { - if (widget instanceof IGuideWidget) { - array2.add(((IGuideWidget) widget).getConfig()); - } - }); - - return json; - } - - public JsonObject addGuideWidget(IGuideWidget widget, boolean isFixed) { - int pageWidth = getPageWidth(); - int margin = getMargin(); - JsonObject widgetConfig = widget.getTemplate(isFixed); - Widget guideWidget; - if (isFixed) { - int width = widgetConfig.get("width").getAsInt(); - int height = widgetConfig.get("height").getAsInt(); - - guideWidget = widget.updateOrCreateFixedWidget( - (pageWidth - width) / 2 + 5, - this.scrollYOffset + (this.getSize().height - height) / 2, - width, - height, - widgetConfig); - fixed.add(guideWidget); - this.addWidget(guideWidget); - } else { - int index = stream.indexOf(selected); - if (index >= 0) { - guideWidget = widget.updateOrCreateStreamWidget(margin, - selected.getSize().height + selected.getSelfPosition().y + scrollYOffset + 5, - pageWidth - 2 * margin, widgetConfig); - for (int i = index + 1; i < stream.size(); i++) { - stream.get(i).addSelfPosition(0, guideWidget.getSize().height + 5); - } - stream.add(index + 1, guideWidget); - } else { - guideWidget = widget.updateOrCreateStreamWidget(margin, getStreamBottom() + 5, pageWidth - 2 * margin, - widgetConfig); - stream.add(guideWidget); - } - this.addWidget(guideWidget); - computeMax(); - } - return widgetConfig; - } - - public void moveUp(Widget widget) { - int index = stream.indexOf(widget); - if (index > 0) { - Widget target = stream.get(index - 1); - if (interpolator == null) { - int offsetD = 5 + widget.getSize().height; - int offsetU = widget.getPosition().y - target.getPosition().y; - int y1 = widget.getSelfPosition().y; - int y2 = target.getSelfPosition().y; - interpolator = new Interpolator(0, 1, 10, Eases.LINEAR, value -> { - widget.setSelfPosition( - new Position(widget.getSelfPosition().x, (int) (y1 - value.floatValue() * offsetU))); - target.setSelfPosition( - new Position(target.getSelfPosition().x, (int) (y2 + value.floatValue() * offsetD))); - if (widget == selected) { - setToolButton(selected); - } - widget.setVisible(widget.getSelfPosition().y < scrollYOffset + getSize().height && - widget.getSelfPosition().y + widget.getSize().height > 0); - target.setVisible(target.getSelfPosition().y < scrollYOffset + getSize().height && - target.getSelfPosition().y + target.getSize().height > 0); - }, value -> { - interpolator = null; - stream.remove(widget); - stream.add(index - 1, widget); - }).start(); - } - } else { - int index2 = fixed.indexOf(widget); - if (index2 >= 0 && index2 < fixed.size() - 1) { - Widget target = fixed.get(index2 + 1); - fixed.remove(widget); - fixed.add(index2 + 1, widget); - } - } - } - - public void moveDown(Widget widget) { - int index = stream.indexOf(widget); - if (index >= 0 && index < stream.size() - 1) { - Widget target = stream.get(index + 1); - if (interpolator == null) { - int offsetD = 5 + target.getSize().height; - int offsetU = target.getPosition().y - widget.getPosition().y; - int y1 = widget.getSelfPosition().y; - int y2 = target.getSelfPosition().y; - interpolator = new Interpolator(0, 1, 10, Eases.LINEAR, value -> { - widget.setSelfPosition( - new Position(widget.getSelfPosition().x, (int) (y1 + value.floatValue() * offsetD))); - target.setSelfPosition( - new Position(target.getSelfPosition().x, (int) (y2 - value.floatValue() * offsetU))); - if (widget == selected) { - setToolButton(selected); - } - widget.setVisible(widget.getSelfPosition().y < getSize().height - xBarHeight && - widget.getSelfPosition().y + widget.getSize().height > 0); - target.setVisible(target.getSelfPosition().y < getSize().height - xBarHeight && - target.getSelfPosition().y + target.getSize().height > 0); - }, value -> { - interpolator = null; - stream.remove(widget); - stream.add(index + 1, widget); - }).start(); - } - } else { - int index2 = fixed.indexOf(widget); - if (index2 > 0) { - Widget target = fixed.get(index2 - 1); - fixed.remove(widget); - fixed.add(index2 - 1, widget); - } - } - } - - @Override - protected void setScrollYOffset(int scrollYOffset) { - if (scrollYOffset == this.scrollYOffset) return; - int offset = scrollYOffset - this.scrollYOffset; - this.scrollYOffset = scrollYOffset; - for (Widget widget : widgets) { - Position newPos = widget.addSelfPosition(0, -offset); - if (widget != toolButtons) { - widget.setVisible(newPos.y < getSize().height - xBarHeight && newPos.y + widget.getSize().height > 0); - } - } - } - - @Override - public void removeWidget(Widget widget) { - int index = stream.indexOf(widget); - if (index >= 0) { - int offset = widget.getSize().height + 5; - for (int i = stream.size() - 1; i > index; i--) { - Widget bottom = stream.get(i); - Position newPos = bottom.addSelfPosition(0, -offset); - bottom.setVisible(newPos.y < getSize().height - xBarHeight && newPos.y + widget.getSize().height > 0); - } - stream.remove(widget); - } else { - fixed.remove(widget); - } - super.removeWidget(widget); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (super.mouseClicked(mouseX, mouseY, button)) { - return true; - } - boolean flag = false; - for (int i = fixed.size() - 1; i >= 0; i--) { - Widget widget = fixed.get(i); - if (widget.isMouseOverElement(mouseX, mouseY)) { - if (widget instanceof IGuideWidget && widget != selected) { - configEditor.loadConfigurator((IGuideWidget) widget); - selected = widget; - setToolButton(selected); - } - playButtonClickSound(); - flag = true; - break; - } - } - if (!flag) { - for (Widget widget : stream) { - if (widget.isMouseOverElement(mouseX, mouseY)) { - if (widget instanceof IGuideWidget && widget != selected) { - configEditor.loadConfigurator((IGuideWidget) widget); - selected = widget; - setToolButton(selected); - } - playButtonClickSound(); - flag = true; - break; - } - } - } - return flag; - } - - @Override - protected boolean hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int width = getSize().width; - if (title.isVisible()) { - title.drawInBackground(mouseX, mouseY, partialTicks, context); - } - for (Widget widget : stream) { - if (widget.isVisible()) { - widget.drawInBackground(mouseX, mouseY, partialTicks, context); - } - } - - boolean flag = false; - for (Widget widget : fixed) { - if (widget.isVisible()) { - widget.drawInBackground(mouseX, mouseY, partialTicks, context); - if (widget.isMouseOverElement(mouseX, mouseY)) { - if (widget != selected) { - drawSelectedBorder(x, width, widget); - } - flag = true; - } - } - } - if (!flag) { - for (Widget widget : stream) { - if (widget.isVisible() && widget != selected && widget.isMouseOverElement(mouseX, mouseY)) { - drawSelectedBorder(x, width, widget); - } - } - } - - if (selected != null) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - int index = fixed.indexOf(selected); - String layer = "L: " + (index >= 0 ? index : stream.indexOf(selected)); - fontRenderer.drawString(layer, - selected.getPosition().x + (selected.getSize().width - fontRenderer.getStringWidth(layer)) / 2F, - selected.getPosition().y - 20, - 0xffff0000, true); - } - if (toolButtons.isVisible()) { - customPositionSizeWidget.drawInBackground(mouseX, mouseY, partialTicks, context); - toolButtons.drawInBackground(mouseX, mouseY, partialTicks, context); - } - return true; - } - - private void drawSelectedBorder(int x, int width, Widget widget) { - Position pos = widget.getPosition(); - Size s = widget.getSize(); - if (stream.contains(widget)) { - drawSolidRect(x, pos.y, width - yBarWidth, s.height, 0x6f000000); - - } else { - drawSolidRect(pos.x, pos.y, s.width, s.height, 0x6f000000); - } - } - - @Override - public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) { - if (super.mouseDragged(mouseX, mouseY, button, timeDragged) && toolButtons.isVisible()) { - setToolButton(selected); - return true; - } - return false; - } - - @Override - public void clearAllWidgets() { - super.clearAllWidgets(); - selected = null; - configEditor.loadConfigurator(null); - toolButtons.setSelfPosition(new Position(-scrollYOffset, -scrollYOffset)); - customPositionSizeWidget.setControlled(null); - toolButtons.setVisible(false); - addWidget(customPositionSizeWidget); - addWidget(toolButtons); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/BooleanConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/BooleanConfigurator.java deleted file mode 100644 index 8814b973136..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/BooleanConfigurator.java +++ /dev/null @@ -1,37 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import com.google.gson.JsonObject; - -import java.awt.*; - -public class BooleanConfigurator extends ConfiguratorWidget { - - public BooleanConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - public BooleanConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, - boolean defaultValue) { - super(group, config, name, defaultValue); - } - - protected void init() { - this.addWidget(new RectButtonWidget(0, 15, 10, 10, 2) - .setToggleButton(new ColorRectTexture(new Color(198, 198, 198).getRGB()), (c, p) -> updateValue(p)) - .setValueSupplier(true, () -> { - if (config.get(name).isJsonNull()) { - return defaultValue; - } - return config.get(name).getAsBoolean(); - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setIcon(new ColorRectTexture(new Color(0, 0, 0, 74).getRGB()))); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ColorConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ColorConfigurator.java deleted file mode 100644 index 5ed6aec5fe6..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ColorConfigurator.java +++ /dev/null @@ -1,26 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.terminal.gui.widgets.ColorWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; - -import com.google.gson.JsonObject; - -public class ColorConfigurator extends ConfiguratorWidget { - - public ColorConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, int defaultValue) { - super(group, config, name, defaultValue); - } - - public ColorConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - protected void init() { - this.addWidget(new ColorWidget(0, 15, 85, 10).setColorSupplier(() -> { - if (config.get(name).isJsonNull()) { - return defaultValue; - } - return config.get(name).getAsInt(); - }, true).setOnColorChanged(this::updateValue)); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ConfiguratorWidget.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ConfiguratorWidget.java deleted file mode 100644 index 6d05bbac593..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ConfiguratorWidget.java +++ /dev/null @@ -1,126 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.util.Position; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import java.util.Collections; -import java.util.function.Consumer; - -public class ConfiguratorWidget extends WidgetGroup { - - protected T defaultValue; - protected String name; - protected boolean canDefault; - protected boolean isDefault; - protected JsonObject config; - protected DraggableScrollableWidgetGroup group; - private int nameWidth; - private Consumer onUpdated; - - public ConfiguratorWidget(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - this(group, config, name, null); - } - - public ConfiguratorWidget(DraggableScrollableWidgetGroup group, JsonObject config, String name, T defaultValue) { - super(new Position(5, group.getWidgetBottomHeight() + 5)); - this.group = group; - this.defaultValue = defaultValue; - this.name = name; - this.canDefault = defaultValue != null; - this.config = config; - if (config.get(name) == null) { - config.addProperty(name, (String) null); - } - if (canDefault && config.get(name).isJsonNull()) { - isDefault = true; - } - this.addWidget(new LabelWidget(0, 4, name, -1).setShadow(true)); - if (isClientSide()) { - nameWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(name); - } - init(); - } - - protected void init() {} - - protected void updateValue(T value) { - if (canDefault && isDefault) return; - config.add(name, new Gson().toJsonTree(value)); - update(); - } - - public ConfiguratorWidget setOnUpdated(Consumer onUpdated) { - this.onUpdated = onUpdated; - return this; - } - - protected void update() { - if (onUpdated != null) { - onUpdated.accept(name); - } - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - int x = getPosition().x; - int y = getPosition().y; - if (canDefault && isMouseOver(x + nameWidth + 4, y + 6, 5, 5, mouseX, mouseY)) { - drawHoveringText(ItemStack.EMPTY, Collections.singletonList(I18n.format("terminal.guide_editor.default")), - 100, mouseX, mouseY); - } - if (!isDefault) { - super.drawInForeground(mouseX, mouseY); - } - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - drawSolidRect(x, y, this.getSize().width, 1, -1); - if (canDefault) { - drawBorder(x + nameWidth + 4, y + 6, 5, 5, -1, 1); - if (isDefault) { - drawSolidRect(x + nameWidth + 5, y + 7, 3, 3, -1); - } - } - if (canDefault && isDefault) { - super.drawInBackground(-100, -100, partialTicks, context); - drawSolidRect(x, y + 15, this.getSize().width, this.getSize().height - 15, 0x99000000); - } else { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - int x = getPosition().x; - int y = getPosition().y; - if (!isDefault && super.mouseClicked(mouseX, mouseY, button)) { - return true; - } - if (canDefault && isMouseOver(x + nameWidth + 4, y + 6, 5, 5, mouseX, mouseY)) { - isDefault = !isDefault; - if (isDefault) { - config.addProperty(name, (String) null); - update(); - onDefault(); - } - playButtonClickSound(); - return true; - } - return false; - } - - protected void onDefault() {} -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/FluidStackConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/FluidStackConfigurator.java deleted file mode 100644 index 21ab8671f03..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/FluidStackConfigurator.java +++ /dev/null @@ -1,106 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.PhantomFluidWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.terminal.app.guide.widget.TankListWidget; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.List; - -public class FluidStackConfigurator extends ConfiguratorWidget> { - - DraggableScrollableWidgetGroup container; - List tanks; - - public FluidStackConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - protected void init() { - container = new DraggableScrollableWidgetGroup(0, 27, 116, 100); - this.addWidget(container); - this.addWidget(new RectButtonWidget(0, 15, 116, 10, 1) - .setIcon(new TextTexture("terminal.guide_editor.add_slot", -1)) - .setClickListener(cd -> { - addSlot(container, new TankListWidget.FluidStackInfo(null, 0)); - updateValue(); - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor())); - tanks = new ArrayList<>(); - if (!config.get(name).isJsonNull()) { - Gson gson = new Gson(); - for (JsonElement o : config.get(name).getAsJsonArray()) { - addSlot(container, gson.fromJson(o, TankListWidget.FluidStackInfo.class)); - } - } - } - - private void addSlot(DraggableScrollableWidgetGroup container, TankListWidget.FluidStackInfo fluidStackInfo) { - WidgetGroup group = new WidgetGroup(0, tanks.size() * 20, 116, 20); - tanks.add(fluidStackInfo); - group.addWidget(new PhantomFluidWidget(1, 1, 18, 18, null, null) - .setBackgroundTexture(TerminalTheme.COLOR_B_2) - .setFluidStackSupplier(fluidStackInfo::getInstance, true) - .setFluidStackUpdater(fluidStack -> { - fluidStackInfo.update(fluidStack); - updateValue(); - }, true)); - group.addWidget(new RectButtonWidget(20, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount - - (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1)); - updateValue(); - }) - .setHoverText("Shift -10|Ctrl -100|Shift+Ctrl -1000") - .setIcon(new TextTexture("-1", -1))); - group.addWidget(new RectButtonWidget(76, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount + - (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1)); - updateValue(); - }) - .setHoverText("Shift +10|Ctrl +100|Shift+Ctrl +1000") - .setIcon(new TextTexture("+1", -1))); - group.addWidget(new ImageWidget(40, 0, 36, 20, TerminalTheme.COLOR_B_2)); - group.addWidget( - new SimpleTextWidget(58, 10, "", 0xFFFFFF, () -> Integer.toString(fluidStackInfo.amount), true)); - group.addWidget(new RectButtonWidget(96, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - container.waitToRemoved(group); - tanks.remove(fluidStackInfo); - int index = container.widgets.indexOf(group); - for (int i = container.widgets.size() - 1; i > index; i--) { - container.widgets.get(i).addSelfPosition(0, -20); - } - updateValue(); - }) - .setIcon(GuiTextures.ICON_REMOVE)); - container.addWidget(group); - } - - private void updateValue() { - updateValue(tanks); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ItemStackConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ItemStackConfigurator.java deleted file mode 100644 index 5171fd0cab7..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/ItemStackConfigurator.java +++ /dev/null @@ -1,104 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.PhantomSlotWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.inventory.handlers.SingleItemStackHandler; -import gregtech.common.terminal.app.guide.widget.SlotListWidget; - -import net.minecraftforge.items.IItemHandlerModifiable; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.List; - -public class ItemStackConfigurator extends ConfiguratorWidget> { - - DraggableScrollableWidgetGroup container; - List slots; - - public ItemStackConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - protected void init() { - container = new DraggableScrollableWidgetGroup(0, 27, 116, 100); - this.addWidget(container); - this.addWidget(new RectButtonWidget(0, 15, 116, 10, 1) - .setIcon(new TextTexture("terminal.guide_editor.add_slot", -1)) - .setClickListener(cd -> { - addSlot(container, new SlotListWidget.ItemStackInfo("minecraft:air", 0, 0)); - updateValue(); - }) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor())); - slots = new ArrayList<>(); - if (!config.get(name).isJsonNull()) { - Gson gson = new Gson(); - for (JsonElement o : config.get(name).getAsJsonArray()) { - addSlot(container, gson.fromJson(o, SlotListWidget.ItemStackInfo.class)); - } - } - } - - private void addSlot(DraggableScrollableWidgetGroup container, SlotListWidget.ItemStackInfo itemStackInfo) { - WidgetGroup group = new WidgetGroup(0, slots.size() * 20, 116, 20); - slots.add(itemStackInfo); - IItemHandlerModifiable handler = new SingleItemStackHandler(1); - handler.setStackInSlot(0, itemStackInfo.getInstance()); - group.addWidget(new PhantomSlotWidget(handler, 0, 1, 1).setBackgroundTexture(TerminalTheme.COLOR_B_2) - .setChangeListener(() -> { - itemStackInfo.update(handler.getStackInSlot(0)); - updateValue(); - })); - group.addWidget(new RectButtonWidget(20, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - itemStackInfo.count = Math.max(0, itemStackInfo.count - (data.isShiftClick ? 10 : 1)); - updateValue(); - }) - .setIcon(new TextTexture("-1", -1))); - group.addWidget(new RectButtonWidget(76, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - itemStackInfo.count = Math.max(0, itemStackInfo.count + (data.isShiftClick ? 10 : 1)); - updateValue(); - }) - .setIcon(new TextTexture("+1", -1))); - group.addWidget(new ImageWidget(40, 0, 36, 20, TerminalTheme.COLOR_B_2)); - group.addWidget(new SimpleTextWidget(58, 10, "", 0xFFFFFF, () -> Integer.toString(itemStackInfo.count), true)); - group.addWidget(new RectButtonWidget(96, 0, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> { - container.waitToRemoved(group); - slots.remove(itemStackInfo); - int index = container.widgets.indexOf(group); - for (int i = container.widgets.size() - 1; i > index; i--) { - container.widgets.get(i).addSelfPosition(0, -20); - } - updateValue(); - }) - .setIcon(GuiTextures.ICON_REMOVE)); - container.addWidget(group); - } - - private void updateValue() { - updateValue(slots); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/NumberConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/NumberConfigurator.java deleted file mode 100644 index 7435a9fdfce..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/NumberConfigurator.java +++ /dev/null @@ -1,69 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -public class NumberConfigurator extends ConfiguratorWidget { - - public NumberConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - public NumberConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, int defaultValue) { - super(group, config, name, defaultValue); - } - - protected void init() { - int y = 15; - this.addWidget(new RectButtonWidget(0, y, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> adjustTransferRate(data.isShiftClick ? -100 : -10)) - .setIcon(new TextTexture("-10", -1))); - this.addWidget(new RectButtonWidget(96, y, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> adjustTransferRate(data.isShiftClick ? +100 : +10)) - .setIcon(new TextTexture("+10", -1))); - this.addWidget(new RectButtonWidget(20, y, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> adjustTransferRate(data.isShiftClick ? -5 : -1)) - .setIcon(new TextTexture("-1", -1))); - this.addWidget(new RectButtonWidget(76, y, 20, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> adjustTransferRate(data.isShiftClick ? +5 : +1)) - .setIcon(new TextTexture("+1", -1))); - this.addWidget(new ImageWidget(40, y, 36, 20, TerminalTheme.COLOR_B_2)); - this.addWidget(new SimpleTextWidget(58, 25, "", 0xFFFFFF, () -> { - JsonElement element = config.get(name); - if (element.isJsonNull()) { - return Integer.toString(defaultValue); - } - return element.getAsString(); - }, true)); - } - - private void adjustTransferRate(int added) { - JsonElement element = config.get(name); - int num = 0; - if (!element.isJsonNull()) { - num = element.getAsInt(); - } else { - num = defaultValue; - } - updateValue(num + added); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/SelectorConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/SelectorConfigurator.java deleted file mode 100644 index e529beb7f32..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/SelectorConfigurator.java +++ /dev/null @@ -1,38 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.SelectorWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import com.google.gson.JsonObject; - -import java.util.List; - -public class SelectorConfigurator extends ConfiguratorWidget { - - public SelectorConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, - List candidates, String defaultValue) { - super(group, config, name, defaultValue); - init(candidates); - } - - public SelectorConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, - List candidates) { - super(group, config, name); - init(candidates); - } - - protected void init(List candidates) { - this.addWidget(new SelectorWidget(0, 15, 80, 20, candidates, -1, () -> { - if (config.get(name).isJsonNull()) { - return defaultValue; - } - return config.get(name).getAsString(); - }, true) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setIsUp(true) - .setOnChanged(this::updateValue)); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/StringConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/StringConfigurator.java deleted file mode 100644 index a838e3952aa..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/StringConfigurator.java +++ /dev/null @@ -1,48 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.TextFieldWidget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import com.google.gson.JsonObject; - -public class StringConfigurator extends ConfiguratorWidget { - - private TextFieldWidget textFieldWidget; - - public StringConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name) { - super(group, config, name); - } - - public StringConfigurator(DraggableScrollableWidgetGroup group, JsonObject config, String name, - String defaultValue) { - super(group, config, name, defaultValue); - } - - protected void init() { - this.addWidget(new RectButtonWidget(76, 15, 40, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(data -> updateString()) - .setIcon(new TextTexture("terminal.guide_editor.update", -1))); - textFieldWidget = new TextFieldWidget(0, 15, 76, 20, TerminalTheme.COLOR_B_2, null, null) - .setMaxStringLength(Integer.MAX_VALUE) - .setValidator(s -> true); - if (config.has(name) && config.get(name).isJsonPrimitive()) { - textFieldWidget.setCurrentString(config.get(name).getAsString()); - } - this.addWidget(textFieldWidget); - } - - private void updateString() { - updateValue(textFieldWidget.getCurrentString()); - } - - @Override - protected void onDefault() { - textFieldWidget.setCurrentString(defaultValue); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/TextListConfigurator.java b/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/TextListConfigurator.java deleted file mode 100644 index f40ed1f8255..00000000000 --- a/src/main/java/gregtech/common/terminal/app/guideeditor/widget/configurator/TextListConfigurator.java +++ /dev/null @@ -1,48 +0,0 @@ -package gregtech.common.terminal.app.guideeditor.widget.configurator; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.TextEditorWidget; - -import com.google.gson.*; - -import java.util.Collections; -import java.util.List; - -public class TextListConfigurator extends ConfiguratorWidget> { - - private TextEditorWidget editor; - - public TextListConfigurator(DraggableScrollableWidgetGroup group, int height, JsonObject config, String name) { - super(group, config, name); - init(height); - } - - public TextListConfigurator(DraggableScrollableWidgetGroup group, int height, JsonObject config, String name, - String defaultValue) { - super(group, config, name, Collections.singletonList(defaultValue)); - init(height); - } - - protected void init(int height) { - JsonElement element = config.get(name); - String initValue = ""; - if (!element.isJsonNull()) { - List init = new Gson().fromJson(element, List.class); - initValue = String.join("\n", init); - - } - editor = new TextEditorWidget(0, 15, 116, height, this::updateTextList, true).setContent(initValue) - .setBackground(new ColorRectTexture(0xA3FFFFFF)); - this.addWidget(editor); - } - - private void updateTextList(String saved) { - updateValue(Collections.singletonList(saved)); - } - - @Override - protected void onDefault() { - editor.setContent(defaultValue.get(0)); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareManagerApp.java b/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareManagerApp.java deleted file mode 100644 index 21554ada83b..00000000000 --- a/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareManagerApp.java +++ /dev/null @@ -1,110 +0,0 @@ -package gregtech.common.terminal.app.hardwaremanager; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.*; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.client.shader.Shaders; -import gregtech.common.items.MetaItems; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import java.util.concurrent.atomic.AtomicInteger; - -public class HardwareManagerApp extends AbstractApplication { - - private static final TextureArea CIRCUIT_LINE = TextureArea - .fullImage("textures/gui/terminal/hardware_manager/circuit.png"); - @SideOnly(Side.CLIENT) - private ShaderTexture circuit; - private HardwareSlotWidget selected; - private WidgetGroup apps; - - public HardwareManagerApp() { - super("hardware"); - } - - @Override - public IGuiTexture getIcon() { - return new ItemStackTexture(MetaItems.INTEGRATED_CIRCUIT.getStackForm()); - } - - @Override - public AbstractApplication initApp() { - apps = new WidgetGroup(); - this.addWidget(apps); - int x = 10; - int y = 65; - for (Hardware hardware : os.hardwareProvider.getProviders().values()) { - HardwareSlotWidget hardwareSlotWidget = new HardwareSlotWidget(x, y, os, hardware); - this.addWidget(hardwareSlotWidget); - hardwareSlotWidget.setOnSelected(() -> { - selected = hardwareSlotWidget; - apps.clearAllWidgets(); - AtomicInteger index = new AtomicInteger(0); - for (AbstractApplication installed : getOs().installedApps) { - TerminalRegistry - .getAppHardwareDemand(installed.getRegistryName(), - getOs().tabletNBT.getCompoundTag(installed.getRegistryName()).getInteger("_tier")) - .stream() - .filter(hardware::isHardwareAdequate).findFirst() - .ifPresent(X -> { - apps.addWidget(new RectButtonWidget(162 + (index.get() % 4) * 25, - 122 + (index.get() / 4) * 30, 20, 20, 2) - .setIcon(installed.getIcon()) - .setHoverText(installed.getUnlocalizedName()) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0)); - index.getAndIncrement(); - }); - } - }); - x += 25; - } - return this; - } - - @Override - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - float time = (gui.entityPlayer.ticksExisted + partialTicks) / 20f; - if (Shaders.allowedShader()) { - if (circuit == null) { - circuit = ShaderTexture.createShader("circuit.frag"); - } - ResourceHelper.bindTexture("textures/gui/terminal/terminal_background.png"); - circuit.draw(x, y, width, height, uniformCache -> { - uniformCache.glUniform1F("u_time", time); - uniformCache.glUniform2F("u_mouse", - (float) (mouseX - x) * circuit.getResolution(), - (float) (mouseY - y) * circuit.getResolution()); - }); - } else { - drawSolidRect(x, y, width, height, TerminalTheme.COLOR_B_2.getColor()); - } - GlStateManager.color(1, 1, 1, 0.8f); - CIRCUIT_LINE.draw(x, y, width, height); - GlStateManager.color(1, 1, 1, 1); - - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - if (selected != null) { - int sX = x + selected.getSelfPosition().x; - int sY = y + selected.getSelfPosition().y; - int sW = selected.getSize().width; - int sH = selected.getSize().height; - drawBorder(sX, sY, sW, sH, 0xff00af00, 1); - drawSolidRect(sX + sW / 2, sY + sH, 1, 10, 0xff00af00); - drawSolidRect(sX + sW / 2, sY + sH + 10, x + 210 - sX - sW / 2, 1, 0xff00af00); - drawSolidRect(x + 210, sY + sH + 10, 1, y + 110 - sY - sH, 0xff00af00); - } - drawBorder(x + 160, y + 120, 25 * 4, 25 * 4, selected == null ? -1 : 0xff00af00, 1); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareSlotWidget.java b/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareSlotWidget.java deleted file mode 100644 index 25c0e795dd3..00000000000 --- a/src/main/java/gregtech/common/terminal/app/hardwaremanager/HardwareSlotWidget.java +++ /dev/null @@ -1,132 +0,0 @@ -package gregtech.common.terminal.app.hardwaremanager; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; - -import java.util.Arrays; -import java.util.Collections; - -public class HardwareSlotWidget extends WidgetGroup { - - private final Hardware hardware; - private final TerminalOSWidget os; - private Runnable onSelected; - - public HardwareSlotWidget(int x, int y, TerminalOSWidget os, Hardware hardware) { - super(x, y, 20, 20); - this.os = os; - this.hardware = hardware; - } - - public void setOnSelected(Runnable onSelected) { - this.onSelected = onSelected; - } - - private void showDialog(int button) { - if (button == 0) { - if (hardware.hasHW()) { - onSelected.run(); - } else { - TerminalDialogWidget.showItemSelector(os, "terminal.hardware.select", true, - itemStack -> hardware.acceptItemStack(itemStack) != null, - itemStack -> { - NBTTagCompound tag = hardware.acceptItemStack(itemStack); - if (tag != null) { - tag.setTag("item", itemStack.serializeNBT()); - os.hardwareProvider.getOrCreateHardwareCompound().setTag(hardware.getRegistryName(), - tag); - os.hardwareProvider.cleanCache(hardware.getRegistryName()); - } - }).open(); - } - } else { - if (hardware.hasHW()) { - boolean emptySlot = false; - for (ItemStack itemStack : gui.entityPlayer.inventory.mainInventory) { - if (itemStack.isEmpty()) { - emptySlot = true; - break; - } - } - if (emptySlot) { - TerminalDialogWidget - .showConfirmDialog(os, "terminal.hardware.remove", "terminal.component.confirm", result -> { - if (result) { - NBTTagCompound tag = os.hardwareProvider.getOrCreateHardwareCompound() - .getCompoundTag(hardware.getRegistryName()); - if (!tag.isEmpty() && tag.hasKey("item")) { - gui.entityPlayer.inventory.addItemStackToInventory( - hardware.onHardwareRemoved(new ItemStack(tag.getCompoundTag("item")))); - } - os.hardwareProvider.getOrCreateHardwareCompound() - .removeTag(hardware.getRegistryName()); - os.hardwareProvider.cleanCache(hardware.getRegistryName()); - } - }).open(); - } else { - TerminalDialogWidget - .showInfoDialog(os, "terminal.component.warning", "terminal.hardware.remove.full").open(); - } - } - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - writeClientAction(1, buffer -> buffer.writeVarInt(button)); - showDialog(button); - return true; - } - return false; - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == 1) { - showDialog(buffer.readVarInt()); - } - } - - @Override - public void drawInForeground(int mouseX, int mouseY) { - if (hardware != null && isMouseOverElement(mouseX, mouseY)) { - if (!hardware.hasHW()) { - drawHoveringText(ItemStack.EMPTY, Collections.singletonList(hardware.getLocalizedName()), 300, mouseX, - mouseY); - } else { - String info = hardware.addInformation(); - if (info == null) { - drawHoveringText(ItemStack.EMPTY, - Arrays.asList(hardware.getLocalizedName(), I18n.format("terminal.hardware.tip.remove")), - 300, mouseX, mouseY); - } else { - drawHoveringText(ItemStack.EMPTY, - Arrays.asList(String.format("%s (%s)", hardware.getLocalizedName(), info), - I18n.format("terminal.hardware.tip.remove")), - 300, mouseX, mouseY); - } - } - } - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - boolean missing = !hardware.hasHW(); - drawBorder(x - 1, y - 1, width + 2, height + 1, missing ? 0x6fffffff : -1, 1); - hardware.getIcon().draw(x, y, width, height); - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/multiblockhelper/MachineBuilderWidget.java b/src/main/java/gregtech/common/terminal/app/multiblockhelper/MachineBuilderWidget.java deleted file mode 100644 index 899e1dc9d37..00000000000 --- a/src/main/java/gregtech/common/terminal/app/multiblockhelper/MachineBuilderWidget.java +++ /dev/null @@ -1,279 +0,0 @@ -package gregtech.common.terminal.app.multiblockhelper; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; -import gregtech.api.pattern.MultiblockShapeInfo; -import gregtech.api.pattern.PatternError; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.gui.widgets.MachineSceneWidget; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.BlockInfo; -import gregtech.client.utils.RenderBufferHelper; -import gregtech.common.inventory.handlers.CycleItemStackHandler; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockBush; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/09/15 - * @Description: - */ -public class MachineBuilderWidget extends WidgetGroup { - - private BlockPos pos; - private EnumFacing facing; - private SlotWidget[] slotWidgets; - TerminalOSWidget os; - @SideOnly(Side.CLIENT) - private MachineSceneWidget sceneWidget; - @SideOnly(Side.CLIENT) - private Set highLightBlocks; - private final MultiblockControllerBase controllerBase; - private int selected = -1; - @SideOnly(Side.CLIENT) - private DraggableScrollableWidgetGroup candidates; - @SideOnly(Side.CLIENT) - private List handlers; - - public MachineBuilderWidget(int x, int y, int width, int height, MultiblockControllerBase controllerBase, - TerminalOSWidget os) { - super(x, y, width, height); - this.os = os; - this.controllerBase = controllerBase; - addWidget(new ImageWidget(0, 0, width, height, GuiTextures.BACKGROUND)); - addWidget(new RectButtonWidget(12, 125, width - 24, 20, 1) - .setClickListener(this::autoBuildButton) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.multiblock_ar.builder.auto", -1))); - addWidget(new RectButtonWidget(12, 125 + 25, width - 24, 20, 1) - .setClickListener(this::placeButton) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.multiblock_ar.builder.place", -1))); - addWidget(new RectButtonWidget(12, 125 + 50, width - 24, 20, 1) - .setClickListener(this::debugButton) - .setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_7.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setIcon(new TextTexture("terminal.multiblock_ar.builder.debug", -1))); - if (os.isRemote()) { - candidates = new DraggableScrollableWidgetGroup(-20, 0, 20, 180); - addWidget(candidates); - } - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == -2) { // select - this.selected = buffer.readVarInt(); - } else if (id == -3) { // update pos facing - this.pos = buffer.readBlockPos(); - this.facing = EnumFacing.VALUES[buffer.readByte()]; - } else { - super.handleClientAction(id, buffer); - } - } - - /** - * I had to add slotWidget after parent widget be added, because of gtce's {@link gregtech.api.gui.INativeWidget} - * interface. - * Hopefully one day I can remove this worse interface. - */ - public void addPlayerInventory() { - InventoryPlayer inventoryPlayer = gui.entityPlayer.inventory; - slotWidgets = new SlotWidget[36]; - for (int row = 0; row < 6; row++) { - for (int col = 0; col < 6; col++) { - int index = col + row * 6; - boolean isActive = inventoryPlayer.getStackInSlot(index).getItem() instanceof ItemBlock; - slotWidgets[index] = new SlotWidget(inventoryPlayer, index, 12 + col * 18, 12 + row * 18, false, - false) { - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY) && isActive()) { - if (selected != index) { - selected = index; - MachineBuilderWidget.this.writeClientAction(-2, buf -> buf.writeVarInt(index)); - } - } - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.drawInBackground(mouseX, mouseY, partialTicks, context); - if (selected == index) { - drawSolidRect(getPosition().x, getPosition().y, getSize().width, getSize().height, - 0x4f00ff00); - } - } - }.setBackgroundTexture(GuiTextures.SLOT); - slotWidgets[index].setActive(isActive); - this.addWidget(slotWidgets[index]); - } - } - } - - @SideOnly(Side.CLIENT) - public void setSceneWidget(MachineSceneWidget sceneWidget) { - this.sceneWidget = sceneWidget; - this.highLightBlocks = new HashSet<>(); - MachineSceneWidget.getWorldSceneRenderer().addRenderedBlocks(highLightBlocks, this::highLightRender); - sceneWidget.setOnSelected(this::setFocus); - sceneWidget.getAround().clear(); - Set cores = sceneWidget.getCores(); - int rX = 5; - int rY = 5; - int rZ = 5; - for (MultiblockShapeInfo shapeInfo : controllerBase.getMatchingShapes()) { - BlockInfo[][][] blockInfos = shapeInfo.getBlocks(); - rX = Math.max(blockInfos.length, rX); - rY = Math.max(blockInfos[0].length, rY); - rZ = Math.max(blockInfos[0][0].length, rZ); - } - for (int x = -rX; x <= rX; x++) { - for (int y = -rY; y <= rY; y++) { - for (int z = -rZ; z <= rZ; z++) { - cores.add(controllerBase.getPos().add(x, y, z)); - } - } - } - } - - @SideOnly(Side.CLIENT) - private void setFocus(BlockPos pos, EnumFacing facing) { - this.pos = new BlockPos(pos); - this.facing = facing; - writeClientAction(-3, buf -> { - buf.writeBlockPos(pos); - buf.writeByte(facing.getIndex()); - }); - } - - private void placeButton(ClickData clickData) { - if (pos != null && facing != null && selected != -1) { - World world = controllerBase.getWorld(); - BlockPos offset = pos.offset(facing); - if (world.getBlockState(offset).getBlock() == Blocks.AIR) { - ItemStack itemStack = slotWidgets[selected].getHandle().getStack(); - if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) { - ItemBlock itemBlock = (ItemBlock) itemStack.getItem(); - float hitX = pos.getX() + 0.5f; - float hitY = pos.getY() + 0.5f; - float hitZ = pos.getZ() + 0.5f; - Block block = itemBlock.getBlock(); - IBlockState state = block.getStateFromMeta(itemBlock.getMetadata(itemStack.getMetadata())); - if (block instanceof BlockBush) { - // Prevent placing lilypads, grass, etc where they should not be - if (!((BlockBush) block).canBlockStay(world, offset, state)) { - if (clickData.isClient) { - TerminalDialogWidget.showInfoDialog(os, "terminal.component.error", - "This Block cannot be placed here").setClientSide().open(); - } - return; - } - } - - itemBlock.placeBlockAt(itemStack, gui.entityPlayer, world, offset, facing, hitX, hitY, hitZ, state); - itemStack.shrink(1); - } - } - } - } - - @SideOnly(Side.CLIENT) - private void highLightRender(boolean isTESR, int pass, BlockRenderLayer layer) { - if (isTESR && pass == 0) return; - - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.glLineWidth(5); - - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.getBuffer(); - - buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); - - for (BlockPos pos : highLightBlocks) { - RenderBufferHelper.renderCubeFrame(buffer, - pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1, - 1, 0, 0, 1); - } - - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.enableDepth(); - GlStateManager.color(1, 1, 1, 1); - } - - private void debugButton(ClickData clickData) { - if (clickData.isClient && controllerBase != null) { - highLightBlocks.clear(); - if (controllerBase.structurePattern.checkPatternFastAt( - controllerBase.getWorld(), controllerBase.getPos(), controllerBase.getFrontFacing().getOpposite(), - controllerBase.getUpwardsFacing(), controllerBase.allowsFlip()) == null) { - PatternError error = controllerBase.structurePattern.getError(); - highLightBlocks.add(new BlockPos(error.getPos())); - List> candidatesItemStack = error.getCandidates(); - candidates.clearAllWidgets(); - int y = 1; - handlers = new ArrayList<>(); - for (List candidate : candidatesItemStack) { - CycleItemStackHandler handler = new CycleItemStackHandler( - NonNullList.from(ItemStack.EMPTY, candidate.toArray(new ItemStack[0]))); - handlers.add(handler); - candidates.addWidget(new SlotWidget(handler, 0, 1, y, false, false) - .setBackgroundTexture(TerminalTheme.COLOR_B_2)); - y += 20; - } - TerminalDialogWidget.showInfoDialog(os, "terminal.component.error", error.getErrorInfo()) - .setClientSide().open(); - } - } - } - - private void autoBuildButton(ClickData clickData) { - if (controllerBase != null) { - if (!clickData.isClient && controllerBase.structurePattern != null) { - controllerBase.structurePattern.autoBuild(gui.entityPlayer, controllerBase); - } - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/multiblockhelper/MultiBlockPreviewARApp.java b/src/main/java/gregtech/common/terminal/app/multiblockhelper/MultiBlockPreviewARApp.java deleted file mode 100644 index 6e9d04b4705..00000000000 --- a/src/main/java/gregtech/common/terminal/app/multiblockhelper/MultiBlockPreviewARApp.java +++ /dev/null @@ -1,273 +0,0 @@ -package gregtech.common.terminal.app.multiblockhelper; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.ShaderTexture; -import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; -import gregtech.api.pattern.MultiblockShapeInfo; -import gregtech.api.terminal.app.ARApplication; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.MachineSceneWidget; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.client.renderer.handler.MultiblockPreviewRenderer; -import gregtech.client.shader.Shaders; -import gregtech.client.utils.RenderUtil; -import gregtech.common.ConfigHolder; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL13; - -import java.util.*; - -public class MultiBlockPreviewARApp extends ARApplication { - - @SideOnly(Side.CLIENT) - int lastMouseX; - @SideOnly(Side.CLIENT) - int lastMouseY; - @SideOnly(Side.CLIENT) - float partialTicks; - - public MultiBlockPreviewARApp() { - super("multiblock_ar"); - } - - @Override - public AbstractApplication initApp() { // 232 333 - int bW = 120; - int bH = 120; - - addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()))); - addWidget(new ImageWidget(333 / 2, 20, 1, 222 - 40, new ColorRectTexture(-1))); - - addWidget(new LabelWidget(10 + 313 / 4, 35, "terminal.multiblock_ar.tier.0", -1).setXCentered(true) - .setYCentered(true)); - addWidget(new RectButtonWidget(10 + (313 / 2 - bW) / 2, 50, bW, bH) - .setIcon(TextureArea.fullImage("textures/gui/terminal/multiblock_ar/profile.png")) - .setColors(-1, 0xff00ff00, 0) - .setHoverText("terminal.ar.open") - .setClickListener(clickData -> openAR())); - - addWidget(new LabelWidget(333 / 2 + 313 / 4, 35, "terminal.multiblock_ar.tier.1", - getAppTier() == 0 ? 0xffff0000 : -1).setXCentered(true).setYCentered(true)); - addWidget(new RectButtonWidget(333 / 2 + (313 / 2 - bW) / 2, 50, bW, bH) - .setIcon(this::drawBuilderButton) - .setColors(getAppTier() == 0 ? 0xffff0000 : -1, getAppTier() == 0 ? 0xffff0000 : 0xff00ff00, 0) - .setHoverText( - getAppTier() > 0 ? "terminal.multiblock_ar.builder.hover" : "terminal.multiblock_ar.unlock") - .setClickListener(clickData -> buildMode())); - return this; - } - - private void drawBuilderButton(double x, double y, int width, int height) { - if (Shaders.allowedShader()) { - float time = (gui.entityPlayer.ticksExisted + partialTicks) / 20f; - - MultiblockControllerBase controllerBase = getController(); - int color = controllerBase == null ? -1 : controllerBase.getPaintingColorForRendering(); - - if (controllerBase != null) { - GlStateManager.setActiveTexture(GL13.GL_TEXTURE0); - GlStateManager.enableTexture2D(); - RenderUtil.bindTextureAtlasSprite(controllerBase.getFrontDefaultTexture()); - GlStateManager.setActiveTexture(GL13.GL_TEXTURE1); - GlStateManager.enableTexture2D(); - RenderUtil.bindTextureAtlasSprite(controllerBase.getBaseTexture(null).getParticleSprite()); - } - ShaderTexture.createShader("showcube.frag").draw(x, y, width, height, uniformCache -> { - uniformCache.glUniform1I("faceTexture", 0); - uniformCache.glUniform1I("baseTexture", 1); - uniformCache.glUniform1F("u_time", time); - uniformCache.glUniform3F("f_color", (color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, - (color & 255) / 255.0F); - uniformCache.glUniformBoolean("block", controllerBase != null); - if (isMouseOver((int) x, (int) y, width, height, lastMouseX, lastMouseY)) { - uniformCache.glUniform2F("u_mouse", - (float) (((lastMouseX - x) / 2 + width / 3) * ConfigHolder.client.resolution), - (float) (height / 2 * ConfigHolder.client.resolution)); - } - }); - - GlStateManager.setActiveTexture(GL13.GL_TEXTURE1); - GlStateManager.bindTexture(0); - - GlStateManager.setActiveTexture(GL13.GL_TEXTURE0); - GlStateManager.bindTexture(0); - - } else { - GuiTextures.MULTIBLOCK_CATEGORY.draw(x, y, width, height); - } - } - - @Override - public int getMaxTier() { - return 1; - } - - private MultiblockControllerBase getController() { - if (os.clickPos != null) { - TileEntity te = gui.entityPlayer.world.getTileEntity(os.clickPos); - if (te instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MultiblockControllerBase) { - return (MultiblockControllerBase) ((IGregTechTileEntity) te).getMetaTileEntity(); - } - } - return null; - } - - private void buildMode() { - if (getAppTier() == 0) { - TerminalDialogWidget.showInfoDialog(getOs(), "terminal.dialog.notice", "terminal.multiblock_ar.unlock") - .open(); - } else if (getController() != null) { - widgets.forEach(this::waitToRemoved); - MultiblockControllerBase controllerBase = getController(); - MachineBuilderWidget builderWidget = new MachineBuilderWidget(200, 16, 133, 200, controllerBase, getOs()); - this.addWidget(builderWidget); - builderWidget.addPlayerInventory(); - if (isClient) { - MachineSceneWidget sceneWidget = new MachineSceneWidget(0, 16, 200, 200, controllerBase); - builderWidget.setSceneWidget(sceneWidget); - this.addWidget(0, sceneWidget); - this.addWidget(new ImageWidget(0, 0, 333, 16, GuiTextures.UI_FRAME_SIDE_UP)); - this.addWidget(new ImageWidget(0, 216, 333, 16, GuiTextures.UI_FRAME_SIDE_DOWN)); - } else { - this.addWidget(0, new WidgetGroup()); // placeholder - } - } else { - TerminalDialogWidget.showInfoDialog(getOs(), "terminal.dialog.notice", "terminal.console.notice").open(); - } - } - - @Override - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - lastMouseX = mouseX; - lastMouseY = mouseY; - this.partialTicks = partialTicks; - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - } - - ////////////////////////////////////// AR///////////////////////////////////////// - - @SideOnly(Side.CLIENT) - private static Map controllerList; - @SideOnly(Side.CLIENT) - private static Set found; - @SideOnly(Side.CLIENT) - private static BlockPos lastPos; - private static int opList = -1; - - @Override - public void onAROpened() { - controllerList = new HashMap<>(); - found = new HashSet<>(); - } - - @SideOnly(Side.CLIENT) - private static boolean inRange(BlockPos playerPos, BlockPos controllerPos) { - return Math.abs(playerPos.getX() - controllerPos.getX()) < 30 && - Math.abs(playerPos.getY() - controllerPos.getY()) < 30 && - Math.abs(playerPos.getZ() - controllerPos.getZ()) < 30; - } - - @SideOnly(Side.CLIENT) - @Override - public void tickAR(EntityPlayer player) { - World world = player.world; - int tick = Math.abs(player.ticksExisted % 27); // 0 - 26 - if (tick == 0) { - boolean reRender = false; - Iterator iterator = controllerList.keySet().iterator(); - if (iterator.hasNext()) { - MultiblockControllerBase controller = iterator.next(); - if (!controller.isValid() || controller.isStructureFormed() || - !inRange(player.getPosition(), controller.getPos())) { - iterator.remove(); - reRender = true; - } - } - for (MultiblockControllerBase controllerBase : found) { - if (!controllerList.containsKey(controllerBase)) { - List shapeInfos = controllerBase.getMatchingShapes(); - if (!shapeInfos.isEmpty()) { - controllerList.put(controllerBase, shapeInfos.get(0)); - reRender = true; - } - } - } - found.clear(); - lastPos = player.getPosition(); - if (reRender) { - opList = GLAllocation.generateDisplayLists(1); // allocate op list - GlStateManager.glNewList(opList, GL11.GL_COMPILE); - controllerList.forEach((controller, shapes) -> MultiblockPreviewRenderer - .renderControllerInList(controller, shapes, 0)); - GlStateManager.glEndList(); - } - } - if (lastPos == null) { - lastPos = player.getPosition(); - } - for (int i = tick * 1000; i < (tick + 1) * 1000; i++) { - int x = i % 30 - 15; - int y = (i / 30) % 30 - 15; - int z = (i / 900) - 15; - TileEntity tileEntity = world.getTileEntity(lastPos.add(x, y, z)); - if (tileEntity instanceof IGregTechTileEntity) { - if (((IGregTechTileEntity) tileEntity).getMetaTileEntity() instanceof MultiblockControllerBase) { - found.add((MultiblockControllerBase) ((IGregTechTileEntity) tileEntity).getMetaTileEntity()); - } - } - } - } - - @SideOnly(Side.CLIENT) - @Override - public void drawARScreen(RenderWorldLastEvent event) { - if (opList != -1) { - MultiblockPreviewRenderer.resetMultiblockRender(); - Minecraft mc = Minecraft.getMinecraft(); - Entity entity = mc.getRenderViewEntity(); - if (entity == null) entity = mc.player; - - float partialTicks = event.getPartialTicks(); - - double tx = entity.lastTickPosX + ((entity.posX - entity.lastTickPosX) * partialTicks); - double ty = entity.lastTickPosY + ((entity.posY - entity.lastTickPosY) * partialTicks); - double tz = entity.lastTickPosZ + ((entity.posZ - entity.lastTickPosZ) * partialTicks); - - Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - GlStateManager.color(1F, 1F, 1F, 1F); - GlStateManager.pushMatrix(); - GlStateManager.translate(-tx, -ty, -tz); - GlStateManager.enableBlend(); - - GlStateManager.callList(opList); - - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - GlStateManager.color(1F, 1F, 1F, 0F); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/prospector/ProspectorApp.java b/src/main/java/gregtech/common/terminal/app/prospector/ProspectorApp.java deleted file mode 100644 index fb2144909ce..00000000000 --- a/src/main/java/gregtech/common/terminal/app/prospector/ProspectorApp.java +++ /dev/null @@ -1,221 +0,0 @@ -package gregtech.common.terminal.app.prospector; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.util.GTLog; -import gregtech.common.terminal.app.prospector.widget.WidgetOreList; -import gregtech.common.terminal.app.prospector.widget.WidgetProspectingMap; -import gregtech.common.terminal.component.ClickComponent; -import gregtech.common.terminal.component.SearchComponent; -import gregtech.core.network.packets.PacketProspecting; - -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import com.google.common.collect.Maps; -import com.google.common.collect.Table; -import com.google.common.collect.Tables; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -public class ProspectorApp extends AbstractApplication implements SearchComponent.IWidgetSearch { - - private WidgetOreList widgetOreList; - private WidgetProspectingMap widgetProspectingMap; - private ColorRectTexture background; - @SideOnly(Side.CLIENT) - private Table persist; - private final ProspectorMode mode; - - public ProspectorApp(@NotNull ProspectorMode mode) { - super(mode.terminalName); - this.mode = mode; - } - - @Override - public AbstractApplication createAppInstance(TerminalOSWidget os, boolean isClient, NBTTagCompound nbt) { - ProspectorApp app = new ProspectorApp(mode); - app.isClient = isClient; - app.nbt = nbt; - return app; - } - - @Override - public AbstractApplication initApp() { - int chunkRadius = getAppTier() + 3; - int offset = (232 - 32 * 7 + 16) / 2; - background = new ColorRectTexture(0xA0000000); - this.addWidget(new ImageWidget(0, 0, 333, 232, background)); - if (isClient) { - this.addWidget(new ImageWidget(0, 0, 333, offset, GuiTextures.UI_FRAME_SIDE_UP)); - this.addWidget(new ImageWidget(0, 232 - offset, 333, offset, GuiTextures.UI_FRAME_SIDE_DOWN)); - this.widgetOreList = new WidgetOreList(32 * chunkRadius - 16, offset, 333 - 32 * chunkRadius + 16, - 232 - 2 * offset); - this.addWidget(this.widgetOreList); - } - this.widgetProspectingMap = new WidgetProspectingMap(0, offset + (7 - chunkRadius) * 16, chunkRadius, - this.widgetOreList, mode, 1); - if (isClient) { - persist = Tables.newCustomTable(Maps.newHashMap(), Maps::newHashMap); - widgetProspectingMap.setOnPacketReceived(packet -> persist.put(packet.chunkX, packet.chunkZ, packet)); - } - - this.addWidget(1, this.widgetProspectingMap); - loadLocalConfig(nbt -> { - this.widgetProspectingMap.setDarkMode(nbt.getBoolean("dark")); - background.setColor(this.widgetProspectingMap.getDarkMode() ? 0xA0000000 : 0xA0ffffff); - }); - if (isClient) { - loadPacketLocalConfig(); - // Cardinal directions - this.addWidget(new LabelWidget(-2 + (16 * (chunkRadius * 2 - 1)) / 2, offset, "N", this::labelColor) - .setShadow(true)); - this.addWidget(new LabelWidget(-2 + (16 * (chunkRadius * 2 - 1)) / 2, - offset - 6 + 16 * (chunkRadius * 2 - 1), "S", this::labelColor).setShadow(true)); - this.addWidget(new LabelWidget(0, offset - 3 + (16 * (chunkRadius * 2 - 1)) / 2, "W", this::labelColor) - .setShadow(true)); - this.addWidget(new LabelWidget(-6 + 16 * (chunkRadius * 2 - 1), - offset - 3 + (16 * (chunkRadius * 2 - 1)) / 2, "E", this::labelColor).setShadow(true)); - } - return this; - } - - int labelColor() { - return this.widgetProspectingMap.getDarkMode() ? 0xF0F0F0 : 0x404040; - } - - @SideOnly(Side.CLIENT) - protected void loadPacketLocalConfig() { - new Thread(() -> { // thread for better QoL - int posX = gui.entityPlayer.getPosition().getX(); - int posZ = gui.entityPlayer.getPosition().getZ(); - - if (posX % 16 > 7 || posX % 16 == 0) { - posX -= 1; - } else { - posX += 1; - } - // draw red horizontal line - if (posZ % 16 > 7 || posZ % 16 == 0) { - posZ -= 1; - } else { - posZ += 1; - } - - int playerChunkX = gui.entityPlayer.chunkCoordX; - int playerChunkZ = gui.entityPlayer.chunkCoordZ; - int chunkRadius = getAppTier() + 3 - 1; - for (int i = playerChunkX - chunkRadius; i <= playerChunkX + chunkRadius; i++) { - for (int j = playerChunkZ - chunkRadius; j <= playerChunkZ + chunkRadius; j++) { - NBTTagCompound nbt = null; - try { - nbt = CompressedStreamTools.read(new File(TerminalRegistry.TERMINAL_PATH, - String.format("%s/%d/%d_%d.nbt", getRegistryName(), mode.ordinal(), i, j))); - } catch (IOException e) { - GTLog.logger.error("error while loading local nbt for {}", getRegistryName(), e); - } - if (nbt != null) { - PacketProspecting packet = PacketProspecting.readPacketData(nbt); - if (packet != null) { - packet.posX = posX; - packet.posZ = posZ; - persist.put(i, j, packet); - widgetProspectingMap.addPacketToQueue(packet); - } - } - } - } - }).start(); - } - - @SideOnly(Side.CLIENT) - protected void savePacketLocalConfig() { - new Thread(() -> { // thread for better QoL - File folder = new File(TerminalRegistry.TERMINAL_PATH, - String.format("%s/%d", getRegistryName(), mode.ordinal())); - if (!folder.exists()) { - if (!folder.mkdirs()) return; - } - for (Table.Cell cell : persist.cellSet()) { - if (cell.getValue() != null) { - NBTTagCompound nbt = cell.getValue().writePacketData(); - try { - if (!nbt.isEmpty()) { - CompressedStreamTools.safeWrite(nbt, new File(folder, - String.format("%d_%d.nbt", cell.getRowKey(), cell.getColumnKey()))); - } - } catch (IOException e) { - GTLog.logger.error("error while saving local nbt for {}", getRegistryName(), e); - } - } - } - }).start(); - } - - @Override - public NBTTagCompound closeApp() { - saveLocalConfig(nbt -> { - nbt.setBoolean("dark", this.widgetProspectingMap.getDarkMode()); - }); - if (isClient) savePacketLocalConfig(); - return super.closeApp(); - } - - @Override - public int getMaxTier() { - return 4; - } - - @Override - public List getMenuComponents() { - ClickComponent darkMode = new ClickComponent().setIcon(GuiTextures.ICON_VISIBLE) - .setHoverText("terminal.prospector.vis_mode").setClickConsumer(cd -> { - if (cd.isClient) { - widgetProspectingMap.setDarkMode(!widgetProspectingMap.getDarkMode()); - background.setColor(this.widgetProspectingMap.getDarkMode() ? 0xA0000000 : 0xA0ffffff); - } - }); - return Arrays.asList(darkMode, new SearchComponent<>(this)); - } - - @Override - public String resultDisplay(String result) { - if (widgetOreList != null) { - return widgetOreList.ores.get(result); - } - return ""; - } - - @Override - public void selectResult(String result) { - if (widgetOreList != null) { - widgetOreList.setSelected(result); - } - } - - @Override - public void search(String word, Consumer find) { - if (widgetOreList != null) { - word = word.toLowerCase(); - for (Map.Entry entry : widgetOreList.ores.entrySet()) { - if (entry.getKey().toLowerCase().contains(word) || entry.getValue().toLowerCase().contains(word)) { - find.accept(entry.getKey()); - } - } - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/FluidStackHelper.java b/src/main/java/gregtech/common/terminal/app/recipechart/FluidStackHelper.java deleted file mode 100644 index e55f040f585..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/FluidStackHelper.java +++ /dev/null @@ -1,61 +0,0 @@ -package gregtech.common.terminal.app.recipechart; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.TankWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; - -public class FluidStackHelper implements IngredientHelper { - - public static final FluidStackHelper INSTANCE = new FluidStackHelper(); - - @Override - public byte getTypeId() { - return 2; - } - - @Override - public int getAmount(FluidStack fluidStack) { - return fluidStack.amount; - } - - @Override - public void setAmount(FluidStack fluidStack, int amount) { - fluidStack.amount = amount; - } - - @Override - public boolean areEqual(FluidStack t1, FluidStack t2) { - return t1 != null && t1.isFluidEqual(t2); - } - - @Override - public boolean isEmpty(FluidStack fluidStack) { - return fluidStack.getFluid() == null || fluidStack.amount <= 0; - } - - @Override - public String getDisplayName(FluidStack fluidStack) { - return fluidStack.getLocalizedName(); - } - - @Override - public Widget createWidget(FluidStack fluidStack) { - FluidTank tank = new FluidTank(fluidStack, Integer.MAX_VALUE); - return new TankWidget(tank, 0, 0, 18, 18).setAlwaysShowFull(true).setBackgroundTexture(TerminalTheme.COLOR_B_2) - .setClient(); - } - - @Override - public FluidStack deserialize(NBTTagCompound nbt) { - return FluidStack.loadFluidStackFromNBT(nbt); - } - - @Override - public NBTTagCompound serialize(FluidStack fluidStack) { - return fluidStack.writeToNBT(new NBTTagCompound()); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/IngredientHelper.java b/src/main/java/gregtech/common/terminal/app/recipechart/IngredientHelper.java deleted file mode 100644 index 74d5fcbf5a1..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/IngredientHelper.java +++ /dev/null @@ -1,49 +0,0 @@ -package gregtech.common.terminal.app.recipechart; - -import gregtech.api.gui.Widget; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Objects; - -public interface IngredientHelper { - - static IngredientHelper getFor(Object o) { - Objects.requireNonNull(o); - if (o.getClass() == ItemStack.class) { - return (IngredientHelper) ItemStackHelper.INSTANCE; - } - if (o.getClass() == FluidStack.class) { - return (IngredientHelper) FluidStackHelper.INSTANCE; - } - throw new IllegalArgumentException(); - } - - static IngredientHelper getForTypeId(int type) { - return switch (type) { - case 1 -> ItemStackHelper.INSTANCE; - case 2 -> FluidStackHelper.INSTANCE; - default -> throw new IllegalArgumentException(); - }; - } - - byte getTypeId(); - - int getAmount(T t); - - void setAmount(T t, int amount); - - boolean areEqual(T t1, T t2); - - boolean isEmpty(T t); - - String getDisplayName(T t); - - Widget createWidget(T t); - - T deserialize(NBTTagCompound nbt); - - NBTTagCompound serialize(T t); -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/ItemStackHelper.java b/src/main/java/gregtech/common/terminal/app/recipechart/ItemStackHelper.java deleted file mode 100644 index 268f6799226..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/ItemStackHelper.java +++ /dev/null @@ -1,62 +0,0 @@ -package gregtech.common.terminal.app.recipechart; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.items.ItemHandlerHelper; -import net.minecraftforge.items.ItemStackHandler; - -public class ItemStackHelper implements IngredientHelper { - - public static final ItemStackHelper INSTANCE = new ItemStackHelper(); - - @Override - public byte getTypeId() { - return 1; - } - - @Override - public int getAmount(ItemStack t) { - return t.getCount(); - } - - @Override - public void setAmount(ItemStack t, int amount) { - t.setCount(amount); - } - - @Override - public boolean areEqual(ItemStack t1, ItemStack t2) { - return ItemHandlerHelper.canItemStacksStack(t1, t2); - } - - @Override - public boolean isEmpty(ItemStack stack) { - return stack.isEmpty(); - } - - @Override - public String getDisplayName(ItemStack stack) { - return stack.getDisplayName(); - } - - @Override - public Widget createWidget(ItemStack stack) { - ItemStackHandler handler = new ItemStackHandler(1); - handler.setStackInSlot(0, stack); - return new SlotWidget(handler, 0, 0, 0, false, false).setBackgroundTexture(TerminalTheme.COLOR_B_2); - } - - @Override - public ItemStack deserialize(NBTTagCompound nbt) { - return new ItemStack(nbt); - } - - @Override - public NBTTagCompound serialize(ItemStack stack) { - return stack.serializeNBT(); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/RecipeChartApp.java b/src/main/java/gregtech/common/terminal/app/recipechart/RecipeChartApp.java deleted file mode 100644 index e4abbcd2497..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/RecipeChartApp.java +++ /dev/null @@ -1,238 +0,0 @@ -package gregtech.common.terminal.app.recipechart; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.Widget; -import gregtech.api.gui.impl.ModularUIContainer; -import gregtech.api.gui.ingredient.IRecipeTransferHandlerWidget; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.TabGroup; -import gregtech.api.gui.widgets.tab.IGuiTextureTabInfo; -import gregtech.api.gui.widgets.tab.ITabInfo; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.CustomTabListRenderer; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.terminal.os.menu.IMenuComponent; -import gregtech.api.util.Size; -import gregtech.common.terminal.app.recipechart.widget.RGContainer; -import gregtech.common.terminal.app.recipechart.widget.RGNode; -import gregtech.common.terminal.component.ClickComponent; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -import mezz.jei.api.gui.IRecipeLayout; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -public class RecipeChartApp extends AbstractApplication implements IRecipeTransferHandlerWidget { - - private TabGroup tabGroup; - - public RecipeChartApp() { - super("recipe_chart"); - } - - @Override - public int getThemeColor() { - return 0xff008001; - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - this.tabGroup = new TabGroup<>(0, 10, new CustomTabListRenderer(TerminalTheme.COLOR_F_2, - TerminalTheme.COLOR_B_3, 333 / getMaxPages(), 10)); - this.tabGroup.setOnTabChanged(this::onPagesChanged); - this.addWidget(this.tabGroup); - loadLocalConfig(nbt -> { - if (nbt == null || nbt.isEmpty()) { - this.addTab("default"); - } else { - for (NBTBase l : nbt.getTagList("list", Constants.NBT.TAG_COMPOUND)) { - NBTTagCompound container = (NBTTagCompound) l; - this.addTab(container.getString("name")).loadFromNBT((NBTTagCompound) container.getTag("data")); - } - tabGroup.setSelectedTab(nbt.getInteger("focus")); - } - }); - } - return this; - } - - private void onPagesChanged(int oldPage, int newPage) { - ITabInfo tabInfo = tabGroup.getTabInfo(newPage); - if (tabInfo instanceof IGuiTextureTabInfo && ((IGuiTextureTabInfo) tabInfo).texture instanceof TextTexture) { - ((TextTexture) ((IGuiTextureTabInfo) tabInfo).texture).setType(TextTexture.TextType.ROLL); - } - tabInfo = tabGroup.getTabInfo(oldPage); - if (tabInfo instanceof IGuiTextureTabInfo && ((IGuiTextureTabInfo) tabInfo).texture instanceof TextTexture) { - ((TextTexture) ((IGuiTextureTabInfo) tabInfo).texture).setType(TextTexture.TextType.HIDE); - } - } - - private RGContainer addTab(String name) { - name = name.isEmpty() ? "default" : name; - RGContainer container = new RGContainer(0, 0, 333, 222, getOs()); - container.setBackground(TerminalTheme.COLOR_B_3); - tabGroup.addTab(new IGuiTextureTabInfo(new TextTexture(name, -1).setWidth(333 / getMaxPages() - 5) - .setType(tabGroup.getAllTag().isEmpty() ? TextTexture.TextType.ROLL : TextTexture.TextType.HIDE), name), - container); - return container; - } - - public int getMaxPages() { - return getAppTier() + 5; - } - - @Override - public List getMenuComponents() { - ClickComponent newPage = new ClickComponent().setIcon(GuiTextures.ICON_NEW_PAGE) - .setHoverText("terminal.component.new_page").setClickConsumer(cd -> { - if (tabGroup == null) return; - if (tabGroup.getAllTag().size() < getMaxPages()) { - TerminalDialogWidget - .showTextFieldDialog(getOs(), "terminal.component.page_name", s -> true, s -> { - if (s != null) { - addTab(s); - } - }).setClientSide().open(); - } else { - TerminalDialogWidget - .showInfoDialog(getOs(), "terminal.component.warning", "terminal.recipe_chart.limit") - .setClientSide().open(); - } - }); - ClickComponent deletePage = new ClickComponent().setIcon(GuiTextures.ICON_REMOVE) - .setHoverText("terminal.recipe_chart.delete").setClickConsumer(cd -> { - if (tabGroup == null) return; - if (tabGroup.getAllTag().size() > 1) { - TerminalDialogWidget.showConfirmDialog(getOs(), "terminal.recipe_chart.delete", - "terminal.component.confirm", r -> { - if (r) { - tabGroup.removeTab(tabGroup.getAllTag().indexOf(tabGroup.getCurrentTag())); - } - }).setClientSide().open(); - } else { - TerminalDialogWidget - .showInfoDialog(getOs(), "terminal.component.warning", "terminal.recipe_chart.limit") - .setClientSide().open(); - } - }); - ClickComponent addSlot = new ClickComponent().setIcon(GuiTextures.ICON_ADD) - .setHoverText("terminal.recipe_chart.add_slot").setClickConsumer(cd -> { - if (tabGroup == null) return; - if (tabGroup.getCurrentTag() != null) { - tabGroup.getCurrentTag().addNode(50, 100); - } - }); - ClickComponent importPage = new ClickComponent().setIcon(GuiTextures.ICON_LOAD) - .setHoverText("terminal.component.load_file").setClickConsumer(cd -> { - if (tabGroup == null) return; - if (tabGroup.getAllTag().size() < getMaxPages()) { - File file = new File(TerminalRegistry.TERMINAL_PATH, "recipe_chart"); - TerminalDialogWidget - .showFileDialog(getOs(), "terminal.component.load_file", file, true, result -> { - if (result != null && result.isFile()) { - try { - NBTTagCompound nbt = CompressedStreamTools.read(result); - addTab(result.getName()).loadFromNBT(nbt); - } catch (IOException e) { - TerminalDialogWidget - .showInfoDialog(getOs(), "terminal.component.error", - "terminal.component.load_file.error") - .setClientSide().open(); - } - } - }).setClientSide().open(); - } else { - TerminalDialogWidget - .showInfoDialog(getOs(), "terminal.component.warning", "terminal.recipe_chart.limit") - .setClientSide().open(); - } - }); - ClickComponent exportPage = new ClickComponent().setIcon(GuiTextures.ICON_SAVE) - .setHoverText("terminal.component.save_file").setClickConsumer(cd -> { - if (tabGroup == null) return; - if (tabGroup.getCurrentTag() != null) { - File file = new File(TerminalRegistry.TERMINAL_PATH, "recipe_chart"); - TerminalDialogWidget - .showFileDialog(getOs(), "terminal.component.save_file", file, false, result -> { - if (result != null) { - try { - CompressedStreamTools.safeWrite(tabGroup.getCurrentTag().saveAsNBT(), - result); - } catch (IOException e) { - TerminalDialogWidget - .showInfoDialog(getOs(), "terminal.component.error", - "terminal.component.save_file.error") - .setClientSide().open(); - } - } - }).setClientSide().open(); - } - }); - return Arrays.asList(newPage, deletePage, addSlot, importPage, exportPage); - } - - @Override - public NBTTagCompound closeApp() { // synced data to server side. - saveLocalConfig(nbt -> { - NBTTagList list = new NBTTagList(); - for (int i = 0; i < tabGroup.getAllTag().size(); i++) { - IGuiTextureTabInfo tabInfo = (IGuiTextureTabInfo) tabGroup.getTabInfo(i); - NBTTagCompound container = new NBTTagCompound(); - container.setString("name", tabInfo.nameLocale); - container.setTag("data", tabGroup.getTabWidget(i).saveAsNBT()); - list.appendTag(container); - } - nbt.setTag("list", list); - nbt.setInteger("focus", tabGroup.getAllTag().indexOf(tabGroup.getCurrentTag())); - }); - return super.closeApp(); - } - - @Override - public boolean isClientSideApp() { - return true; - } - - @Override - public String transferRecipe(ModularUIContainer container, IRecipeLayout recipeLayout, EntityPlayer player, - boolean maxTransfer, boolean doTransfer) { - for (Widget widget : getContainedWidgets(false)) { - if (widget instanceof RGNode && - ((RGNode) widget).transferRecipe(container, recipeLayout, player, maxTransfer, doTransfer)) { - return null; - } - } - return "please select a node."; - } - - @Override - public int getMaxTier() { - return 3; - } - - @Override - public void onOSSizeUpdate(int width, int height) { - this.setSize(new Size(width, height)); - if (tabGroup != null) { - Size size = new Size(width, height - 10); - for (Widget widget : tabGroup.widgets) { - if (widget instanceof RGContainer) { - widget.setSize(size); - } - } - tabGroup.setSize(size); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/widget/PhantomWidget.java b/src/main/java/gregtech/common/terminal/app/recipechart/widget/PhantomWidget.java deleted file mode 100644 index 280722e7dbc..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/widget/PhantomWidget.java +++ /dev/null @@ -1,148 +0,0 @@ -package gregtech.common.terminal.app.recipechart.widget; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.ingredient.IGhostIngredientTarget; -import gregtech.api.gui.widgets.PhantomFluidWidget; -import gregtech.api.gui.widgets.PhantomSlotWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.inventory.handlers.SingleItemStackHandler; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.items.IItemHandlerModifiable; - -import mezz.jei.api.gui.IGhostIngredientHandler; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; - -public class PhantomWidget extends WidgetGroup implements IGhostIngredientTarget { - - private final IItemHandlerModifiable itemHandler; - private FluidStack fluidStack; - private PhantomFluidWidget fluidWidget; - private PhantomSlotWidget slotWidget; - private Consumer onChanged; - - public PhantomWidget(int x, int y, Object defaultObj) { - super(x, y, 18, 18); - itemHandler = new SingleItemStackHandler(1); - fluidStack = null; - fluidWidget = new PhantomFluidWidget(0, 0, 18, 18, null, null) - .setFluidStackUpdater(fluid -> { - fluidStack = fluid.copy(); - if (fluidStack != null && fluidStack.amount > 0) { - itemHandler.setStackInSlot(0, ItemStack.EMPTY); - slotWidget.setVisible(false); - fluidWidget.setVisible(true); - if (onChanged != null) { - onChanged.accept(fluidStack); - } - } - }, true).setBackgroundTexture(TerminalTheme.COLOR_B_2).showTip(true) - .setFluidStackSupplier(() -> fluidStack, true); - slotWidget = new PhantomSlotWidget(itemHandler, 0, 0, 0) { - - @Override - public boolean isEnabled() { - return isActive(); - } - }; - slotWidget.setChangeListener(() -> { - if (!itemHandler.getStackInSlot(0).isEmpty()) { - fluidStack = null; - fluidWidget.setVisible(false); - slotWidget.setVisible(true); - if (onChanged != null) { - onChanged.accept(itemHandler.getStackInSlot(0)); - } - } - }).setBackgroundTexture(TerminalTheme.COLOR_B_2); - this.addWidget(fluidWidget); - this.addWidget(slotWidget); - - if (defaultObj instanceof ItemStack) { - itemHandler.setStackInSlot(0, (ItemStack) defaultObj); - fluidWidget.setVisible(false); - slotWidget.setVisible(true); - } else if (defaultObj instanceof FluidStack) { - fluidStack = (FluidStack) defaultObj; - slotWidget.setVisible(false); - fluidWidget.setVisible(true); - } - } - - public PhantomWidget setChangeListener(Consumer onChanged) { - this.onChanged = onChanged; - return this; - } - - public void setObject(FluidStack fluid) { - if (fluid != null) { - fluidStack = fluid.copy(); - if (fluidStack != null && fluidStack.amount > 0) { - itemHandler.setStackInSlot(0, ItemStack.EMPTY); - slotWidget.setVisible(false); - fluidWidget.setVisible(true); - if (onChanged != null) { - onChanged.accept(fluidStack); - } - } - } - } - - public void setObject(ItemStack item) { - if (item != null && !item.isEmpty()) { - ItemStack copy = item.copy(); - copy.setCount(1); - itemHandler.setStackInSlot(0, copy); - fluidStack = null; - fluidWidget.setVisible(false); - slotWidget.setVisible(true); - if (onChanged != null) { - onChanged.accept(copy); - } - } - } - - @Override - public List> getPhantomTargets(Object ingredient) { - if (!isVisible()) { - return Collections.emptyList(); - } - ArrayList> targets = new ArrayList<>(); - for (Widget widget : widgets) { - if (widget instanceof IGhostIngredientTarget) { - targets.addAll(((IGhostIngredientTarget) widget).getPhantomTargets(ingredient)); - } - } - return targets; - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - ItemStack itemStack = gui.entityPlayer.inventory.getItemStack(); - if (!itemStack.isEmpty()) { - IFluidHandler handlerItem = itemStack - .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - if (handlerItem != null && handlerItem.getTankProperties().length > 0) { - FluidStack fluidStack = handlerItem.getTankProperties()[0].getContents(); - if (fluidStack != null) { - this.setObject(fluidStack); - return true; - } - } - this.setObject(itemStack); - return true; - } - return true; - } - return super.mouseClicked(mouseX, mouseY, button); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGContainer.java b/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGContainer.java deleted file mode 100644 index b6988b8e0a6..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGContainer.java +++ /dev/null @@ -1,207 +0,0 @@ -package gregtech.common.terminal.app.recipechart.widget; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; - -public class RGContainer extends DraggableScrollableWidgetGroup { - - protected TerminalOSWidget os; - private RGNode selectedNode; - private RGLine selectedLine; - protected final List nodes; - protected final List lines; - - public RGContainer(int x, int y, int width, int height, TerminalOSWidget os) { - super(x, y, width, height); - this.os = os; - this.setDraggable(true); - this.setXScrollBarHeight(4); - this.setYScrollBarWidth(4); - this.setXBarStyle(null, TerminalTheme.COLOR_F_1); - this.setYBarStyle(null, TerminalTheme.COLOR_F_1); - nodes = new ArrayList<>(); - lines = new ArrayList<>(); - } - - public RGNode getSelectedNode() { - return selectedNode; - } - - public void setSelectedNode(RGNode selectedNode) { - if (this.selectedNode != null) { - this.selectedNode.updateSelected(false); - } - this.selectedNode = selectedNode; - if (this.selectedNode != null) { - this.selectedNode.updateSelected(true); - } - } - - public RGLine getSelectedLine() { - return selectedLine; - } - - public void setSelectedLine(RGLine selectedLine) { - if (this.selectedLine != null) { - this.selectedLine.updateSelected(false); - } - this.selectedLine = selectedLine; - if (this.selectedLine != null) { - this.selectedLine.updateSelected(true); - } - } - - public RGNode addNode(int x, int y) { - RGNode node = new RGNode(x + getScrollXOffset(), y + getScrollYOffset(), this, null, true); - nodes.add(node); - this.addWidget(node); - return node; - } - - public RGNode addNode(int x, int y, Object object) { - RGNode node = new RGNode(x + getScrollXOffset(), y + getScrollYOffset(), this, object, false); - nodes.add(node); - this.addWidget(node); - return node; - } - - public void removeNode(RGNode node) { - nodes.remove(node); - this.waitToRemoved(node); - } - - public void addOrUpdateLine(RGNode parent, RGNode child) { - Optional optional = lines.stream() - .filter(line -> line.getParent() == parent && line.getChild() == child).findFirst(); - if (!optional.isPresent()) { - RGLine line = new RGLine(parent, child, this); - lines.add(line); - this.addWidget(0, line); - } else { - optional.get().updateLine(); - } - } - - public RGLine getLine(RGNode parent, RGNode child) { - Optional optional = lines.stream() - .filter(line -> line.getParent() == parent && line.getChild() == child).findFirst(); - return optional.orElse(null); - } - - public void removeLine(RGNode parent, RGNode child) { - lines.removeIf(line -> { - if (line.getParent() == parent && line.getChild() == child) { - RGContainer.this.waitToRemoved(line); - return true; - } - return false; - }); - } - - public void loadFromNBT(NBTTagCompound nbt) { - try { - this.clearAllWidgets(); - this.nodes.clear(); - this.lines.clear(); - NBTTagList nodesList = nbt.getTagList("nodes", Constants.NBT.TAG_COMPOUND); - for (NBTBase node : nodesList) { // build nodes - nodes.add(RGNode.deserializeNodeNBT((NBTTagCompound) node, this)); - } - Iterator iterator = nodesList.iterator(); // build relations - for (RGNode node : nodes) { - NBTTagCompound nodeTag = (NBTTagCompound) iterator.next(); - node.deserializeRelationNBT(nodeTag.getTagList("parents", Constants.NBT.TAG_INT_ARRAY), - nodeTag.getTagList("children", Constants.NBT.TAG_INT_ARRAY)); - this.addWidget(node); - } - for (RGLine line : lines) { - removeWidget(line); - } - lines.clear(); - NBTTagList linesList = nbt.getTagList("lines", Constants.NBT.TAG_COMPOUND); - for (NBTBase node : linesList) { // build nodes - RGLine line = RGLine.deserializeLineNBT((NBTTagCompound) node, this); - lines.add(line); - this.addWidget(0, line); - } - } catch (Exception e) { - TerminalDialogWidget.showInfoDialog(os, "ERROR", e.getMessage()).setClientSide().open(); - } - } - - public NBTTagCompound saveAsNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - NBTTagList nodesTag = new NBTTagList(); - for (RGNode node : nodes) { - nodesTag.appendTag(node.serializeNodeNBT()); - } - nbt.setTag("nodes", nodesTag); - NBTTagList linesTag = new NBTTagList(); - for (RGLine line : lines) { - linesTag.appendTag(line.serializeLineNBT()); - } - nbt.setTag("lines", linesTag); - return nbt; - } - - @Override - protected int getMaxHeight() { - return super.getMaxHeight() + 20; - } - - @Override - protected int getMaxWidth() { - return super.getMaxWidth() + 20; - } - - @Override - protected boolean hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (draggedWidget != null && draggedWidget == selectedNode) { - for (RGNode node : nodes) { - if (node != selectedNode && node.canMerge(selectedNode)) { - drawBorder(node.getPosition().x, node.getPosition().y, 18, 18, 0XFF0000FF, 2); - break; - } - } - } - return super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean mouseReleased(int mouseX, int mouseY, int button) { - if (draggedWidget != null && draggedWidget == selectedNode) { - for (RGNode node : nodes) { - if (node != selectedNode && node.canMerge(selectedNode)) { - node.mergeNode(selectedNode); - break; - } - } - } - return super.mouseReleased(mouseX, mouseY, button); - } - - @Override - public boolean mouseWheelMove(int mouseX, int mouseY, int wheelDelta) { - for (int i = widgets.size() - 1; i >= 0; i--) { - Widget widget = widgets.get(i); - if (widget.isVisible() && widget.isActive() && widget.mouseWheelMove(mouseX, mouseY, wheelDelta)) { - return true; - } - } - return false; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGLine.java b/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGLine.java deleted file mode 100644 index 4fca6a6ea70..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGLine.java +++ /dev/null @@ -1,225 +0,0 @@ -package gregtech.common.terminal.app.recipechart.widget; - -import gregtech.api.GTValues; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.GTUtility; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.Vec2f; -import net.minecraftforge.items.ItemStackHandler; - -import java.util.ArrayList; -import java.util.List; - -public class RGLine extends WidgetGroup { - - protected final RGNode parent; - protected final RGNode child; - protected final ItemStack catalyst; - protected int ratio; - private boolean isSelected; - private final List points; - private final RGContainer container; - private final WidgetGroup infoGroup; - private final WidgetGroup toolGroup; - - public RGLine(RGNode parent, RGNode child, RGContainer container) { - super(0, 0, 0, 0); - this.parent = parent; - this.child = child; - this.container = container; - this.points = new ArrayList<>(); - this.catalyst = parent.catalyst; - - infoGroup = new WidgetGroup(0, 0, 0, 0); - if (catalyst != null) { - ItemStackHandler handler = new ItemStackHandler(); - handler.setStackInSlot(0, catalyst); - infoGroup.addWidget( - new SlotWidget(handler, 0, 0, 0, false, false).setBackgroundTexture(new ColorRectTexture(0))); - MetaTileEntity mte = GTUtility.getMetaTileEntity(catalyst); - if (mte instanceof SimpleMachineMetaTileEntity) { - infoGroup.addWidget(new LabelWidget(9, -10, - I18n.format("terminal.recipe_chart.tier") + - GTValues.VN[((SimpleMachineMetaTileEntity) mte).getTier()], - -1).setXCentered(true).setShadow(true)); - } - } - - infoGroup.setVisible(false); - infoGroup.setActive(false); - this.addWidget(infoGroup); - - toolGroup = new WidgetGroup(0, 0, 0, 0); - toolGroup.addWidget(new CircleButtonWidget(-8, 0, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_VISIBLE) - .setHoverText("terminal.recipe_chart.visible") - .setClickListener(cd -> { - infoGroup.setActive(!infoGroup.isActive()); - infoGroup.setVisible(!infoGroup.isVisible()); - })); - toolGroup.addWidget(new CircleButtonWidget(8, 0, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_CALCULATOR) - .setHoverText("terminal.recipe_chart.ratio") - .setClickListener(cd -> TerminalDialogWidget - .showTextFieldDialog(container.os, "terminal.recipe_chart.ratio", s -> { - try { - return Integer.parseInt(s) > 0; - } catch (Exception ignored) { - return false; - } - }, s -> { - if (s != null) { - ratio = Integer.parseInt(s); - parent.updateDemand(parent.getHeadDemand()); - } - }).setClientSide().open())); - toolGroup.addWidget(new SimpleTextWidget(0, -18, "", -1, () -> Integer.toString(ratio), true).setShadow(true)); - toolGroup.setVisible(false); - this.addWidget(toolGroup); - this.ratio = 1; - updateLine(); - } - - public static RGLine deserializeLineNBT(NBTTagCompound nbt, RGContainer container) { - RGLine line = new RGLine(container.nodes.get(nbt.getInteger("parent")), - container.nodes.get(nbt.getInteger("child")), container); - line.ratio = nbt.getInteger("ratio"); - boolean visible = nbt.getBoolean("visible"); - line.infoGroup.setVisible(visible); - line.infoGroup.setActive(visible); - return line; - } - - public NBTTagCompound serializeLineNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("parent", container.nodes.indexOf(parent)); - nbt.setInteger("child", container.nodes.indexOf(child)); - nbt.setInteger("ratio", ratio); - nbt.setBoolean("visible", infoGroup.isVisible()); - return nbt; - } - - public RGNode getParent() { - return parent; - } - - public RGNode getChild() { - return child; - } - - public List getPoints() { - return points; - } - - public ItemStack getCatalyst() { - return catalyst; - } - - public void updateSelected(boolean isSelected) { - this.isSelected = isSelected; - toolGroup.setVisible(this.isSelected); - } - - public void updateLine() { - this.points.clear(); - Position pos1 = parent.getNodePosition(child); - Position pos2 = child.getNodePosition(null); - int x1, x2, y1, y2; - if (Math.abs(pos1.x - pos2.x) > Math.abs(pos1.y - pos2.y)) { - if (pos1.x > pos2.x) { - x1 = pos1.x; - y1 = pos1.y + 9; - x2 = pos2.x + 18; - } else { - x1 = pos1.x + 18; - y1 = pos1.y + 9; - x2 = pos2.x; - } - y2 = pos2.y + 9; - points.addAll(genBezierPoints(new Vec2f(x1, y1), new Vec2f(x2, y2), true, 0.01f)); - } else { - if (pos1.y > pos2.y) { - x1 = pos1.x + 9; - y1 = pos1.y; - y2 = pos2.y + 18; - } else { - x1 = pos1.x + 9; - y1 = pos1.y + 18; - y2 = pos2.y; - } - x2 = pos2.x + 9; - points.addAll(genBezierPoints(new Vec2f(x1, y1), new Vec2f(x2, y2), false, 0.01f)); - } - Position position = pos2.subtract(child.getSelfPosition()); - this.setSelfPosition(new Position(Math.min(x1, x2), Math.min(y1, y2)).subtract(position)); - int width = Math.abs(x1 - x2); - int height = Math.abs(y1 - y2); - this.setSize(new Size(width, height)); - this.setVisible(true); - this.setActive(true); - toolGroup.setSelfPosition(new Position((width) / 2, 0)); - infoGroup.setSelfPosition(new Position((width - 18) / 2, (height - 18) / 2)); - } - - public boolean isMouseOver(int mouseX, int mouseY) { - if (points == null || points.size() == 0) return false; - float x = points.get(0).x; - float y = points.get(0).y; - float x2 = points.get(points.size() - 1).x; - float y2 = points.get(points.size() - 1).y; - if (mouseX >= Math.min(x, x2) && mouseY >= Math.min(y, y2) && Math.max(x, x2) > mouseX && - Math.max(y, y2) > mouseY) { - for (Vec2f point : points) { - if ((mouseX - point.x) * (mouseX - point.x) + (mouseY - point.y) * (mouseY - point.y) < 4) { - return true; - } - } - } - return false; - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - if (isSelected) { - drawSolidRect(getPosition().x, getPosition().y, getSize().width, getSize().height, 0x2fffffff); - drawLines(points, 0x2fff0000, 0xffff0000, 2); - } else { - drawLines(points, 0x2fffff00, 0xff00ff00, 2); - } - Vec2f point = points.get(points.size() - 1); - drawSolidRect((int) (point.x - 1.5), (int) (point.y - 1.5), 3, 3, 0XFF00FF00); - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (super.mouseClicked(mouseX, mouseY, button)) { - return true; - } else if (isMouseOver(mouseX, mouseY)) { - if (!isSelected) { - container.setSelectedLine(this); - } - } else if (isSelected) { - container.setSelectedLine(null); - } - return false; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGNode.java b/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGNode.java deleted file mode 100644 index b8b466fb311..00000000000 --- a/src/main/java/gregtech/common/terminal/app/recipechart/widget/RGNode.java +++ /dev/null @@ -1,626 +0,0 @@ -package gregtech.common.terminal.app.recipechart.widget; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.Widget; -import gregtech.api.gui.impl.ModularUIContainer; -import gregtech.api.gui.widgets.SimpleTextWidget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.gui.widgets.TankWidget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; -import gregtech.api.recipes.Recipe; -import gregtech.api.terminal.gui.IDraggable; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.GTUtility; -import gregtech.api.util.Position; -import gregtech.common.terminal.app.recipechart.IngredientHelper; -import gregtech.integration.jei.JustEnoughItemsModule; -import gregtech.integration.jei.recipe.GTRecipeWrapper; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagIntArray; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import net.minecraftforge.items.ItemStackHandler; - -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.recipe.IFocus; -import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.gui.Focus; -import mezz.jei.gui.recipes.RecipeLayout; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -public class RGNode extends WidgetGroup implements IDraggable { - - private IngredientHelper headHelper; - protected Object head; - protected int recipePer = 1; - protected ItemStack catalyst; - private boolean isSelected; - private WidgetGroup toolGroup; - private WidgetGroup inputsGroup; - private RGContainer container; - private SimpleTextWidget textWidget; - protected Map parentNodes; - protected Map> children; - - public RGNode(int x, int y, RGContainer container, Object head, boolean isPhantom) { - super(x, y, 18, 18); - init(container); - this.head = head; - if (head != null) { - this.headHelper = IngredientHelper.getFor(head); - } - if (isPhantom) { - PhantomWidget phantom = new PhantomWidget(0, 0, head).setChangeListener(object -> { - RGNode.this.head = object; - RGNode.this.headHelper = object != null ? IngredientHelper.getFor(object) : null; - // Reset any children nodes, now that the parent has changed - for (Set childs : children.values()) { - for (RGNode child : childs) { - child.removeParent(this); - } - } - children.clear(); - - // Clear the Inputs for the replaced parent - this.inputsGroup.widgets.clear(); - - }); - this.addWidget(phantom); - toolGroup.addWidget(new CircleButtonWidget(-11, 49, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_CALCULATOR) - .setHoverText("terminal.recipe_chart.calculator") - .setClickListener(cd -> TerminalDialogWidget - .showTextFieldDialog(container.os, "terminal.recipe_chart.demand", s -> { - try { - return Integer.parseInt(s) > 0; - } catch (Exception ignored) { - return false; - } - }, s -> { - if (s != null && !s.isEmpty()) { - updateDemand(Integer.parseInt(s)); - } - }).setClientSide().open())); - toolGroup.addWidget(new CircleButtonWidget(9, 49, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_ADD) - .setHoverText("terminal.recipe_chart.add") - .setClickListener(cd -> TerminalDialogWidget - .showItemSelector(container.os, "terminal.recipe_chart.demand", false, itemStack -> true, - itemStack -> { - if (itemStack != null && !itemStack.isEmpty()) { - IFluidHandler handlerItem = itemStack.getCapability( - CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - if (handlerItem != null && handlerItem.getTankProperties().length > 0) { - FluidStack fluidStack = handlerItem.getTankProperties()[0] - .getContents(); - if (fluidStack != null) { - phantom.setObject(fluidStack); - return; - } - } - phantom.setObject(itemStack); - - // Reset any children nodes, now that the parent has changed - for (Set childs : children.values()) { - for (RGNode child : childs) { - child.removeParent(this); - } - } - children.clear(); - - // Clear the Inputs for the replaced parent - this.inputsGroup.widgets.clear(); - } - }) - .setClientSide().open())); - } else { - addWidget(this.headHelper.createWidget(head)); - } - } - - private void init(RGContainer container) { - this.container = container; - textWidget = new SimpleTextWidget(9, -5, "", -1, - () -> this.head != null ? this.headHelper.getDisplayName(this.head) : "terminal.recipe_chart.drag", - true).setShadow(true); - textWidget.setVisible(false); - textWidget.setActive(false); - this.addWidget(textWidget); - inputsGroup = new WidgetGroup(0, 0, 0, 0); - this.addWidget(inputsGroup); - toolGroup = new WidgetGroup(0, 0, 0, 0); - this.addWidget(toolGroup); - toolGroup.addWidget(new CircleButtonWidget(-11, 9, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), TerminalTheme.COLOR_3.getColor()) - .setIcon(GuiTextures.ICON_REMOVE) - .setHoverText("terminal.guide_editor.remove") - .setClickListener(cd -> remove())); - toolGroup.addWidget(new CircleButtonWidget(-11, 29, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_VISIBLE) - .setHoverText("terminal.recipe_chart.visible") - .setClickListener(cd -> { - textWidget.setActive(!textWidget.isActive()); - textWidget.setVisible(!textWidget.isVisible()); - })); - toolGroup.addWidget(new CircleButtonWidget(9, 29, 8, 1, 12) - .setColors(0, TerminalTheme.COLOR_7.getColor(), 0) - .setIcon(GuiTextures.ICON_LOCATION) - .setHoverText("terminal.recipe_chart.jei") - .setClickListener(cd -> { - if (JustEnoughItemsModule.jeiRuntime != null && head != null && !this.headHelper.isEmpty(head)) { - JustEnoughItemsModule.jeiRuntime.getRecipesGui().show(new Focus<>(IFocus.Mode.OUTPUT, head)); - } - })); - inputsGroup.setVisible(false); - inputsGroup.setActive(false); - toolGroup.setVisible(false); - toolGroup.setActive(false); - parentNodes = new HashMap<>(); - children = new LinkedHashMap<>(); // important - } - - public int getHeadDemand() { - return this.headHelper.getAmount(this.head); - } - - public int getChildDemand(RGNode child) { - for (Map.Entry> entry : children.entrySet()) { - if (entry.getValue().contains(child)) { - int perC = 0; - if (entry.getKey() instanceof SlotWidget) { - perC = ((SlotWidget) entry.getKey()).getHandle().getStack().getCount(); - } else if (entry.getKey() instanceof TankWidget) { - perC = ((TankWidget) entry.getKey()).fluidTank.getFluidAmount(); - } - int ratioSum = entry.getValue().stream().mapToInt(it -> container.getLine(RGNode.this, it).ratio).sum(); - return MathHelper.ceil(perC * MathHelper.ceil(getHeadDemand() / (float) recipePer) * - container.getLine(RGNode.this, child).ratio / (float) ratioSum); - } - } - return 0; - } - - public boolean canMerge(RGNode node) { - if (this.headHelper == node.headHelper && this.headHelper.areEqual(this.head, node.head)) { - return checkMergeAvailable(node); - } - return false; - } - - private boolean checkMergeAvailable(RGNode node) { - Position pos1 = this.getPosition(); - Position pos2 = node.getPosition(); - return Math.abs(pos1.x - pos2.x) < 18 && Math.abs(pos1.y - pos2.y) < 18 && - !this.findAllChildren().contains(node) && - !node.findAllChildren().contains(this); - } - - public Set findAllChildren() { - Set result = new HashSet<>(); - for (Set nodes : children.values()) { - for (RGNode node : nodes) { - result.add(node); - result.addAll(node.findAllChildren()); - } - } - return result; - } - - public void mergeNode(RGNode node) { - for (RGNode parentNode : node.parentNodes.keySet()) { - for (Set value : parentNode.children.values()) { - if (value.remove(node)) { - value.add(this); - addParent(parentNode); - parentNode.updateDemand(parentNode.getHeadDemand()); - break; - } - } - } - node.remove(); - } - - public void remove() { - if (isSelected) { - container.setSelectedNode(null); - } - container.removeNode(this); - for (RGNode parentNode : parentNodes.keySet()) { - container.removeLine(parentNode, this); - parentNode.onChildRemoved(this); - } - parentNodes.clear(); - for (Set childs : children.values()) { - for (RGNode child : childs) { - child.removeParent(this); - } - } - children.clear(); - } - - public Position getNodePosition(RGNode child) { - if (child != null && isSelected) { - for (Map.Entry> nodeEntry : children.entrySet()) { - if (nodeEntry.getValue().contains(child)) { - return nodeEntry.getKey().getPosition(); - } - } - } - return this.getPosition(); - } - - public void addParent(RGNode parent) { - container.addOrUpdateLine(parent, this); - this.parentNodes.put(parent, parent.getChildDemand(this)); - updateDemand(parentNodes.values().stream().mapToInt(it -> it).sum()); - } - - public void updateDemand(int demand) { - dfsUpdateDemand(demand, new Stack<>()); - } - - private void dfsUpdateDemand(int demand, Stack updated) { - if (updated.contains(this)) return; - updated.push(this); - this.headHelper.setAmount(this.head, demand); - for (Set children : children.values()) { - for (RGNode child : children) { - child.parentNodes.put(this, this.getChildDemand(child)); - child.dfsUpdateDemand(child.parentNodes.values().stream().mapToInt(it -> it).sum(), updated); - } - } - updated.pop(); - } - - public void removeParent(RGNode parent) { - this.parentNodes.remove(parent); - if (parentNodes.size() == 0) { - for (Set childs : children.values()) { - for (RGNode child : childs) { - child.removeParent(RGNode.this); - } - } - children.clear(); - container.removeNode(this); - } else { - updateDemand(parentNodes.values().stream().mapToInt(it -> it).sum()); - } - container.removeLine(parent, this); - } - - public void onChildRemoved(RGNode child) { - for (Set childs : children.values()) { - if (childs.remove(child)) { - updateDemand(getHeadDemand()); - break; - } - } - } - - @Override - protected void onPositionUpdate() { - super.onPositionUpdate(); - for (RGNode parentNode : parentNodes.keySet()) { - container.addOrUpdateLine(parentNode, this); - } - for (Set childs : children.values()) { - for (RGNode child : childs) { - container.addOrUpdateLine(this, child); - } - } - } - - public boolean transferRecipe(ModularUIContainer x, IRecipeLayout recipeLayout, EntityPlayer player, - boolean maxTransfer, boolean doTransfer) { - if (isSelected) { - Object obj = recipeLayout.getFocus() == null ? null : recipeLayout.getFocus().getValue(); - IngredientHelper otherHelper = IngredientHelper.getFor(obj); - if (this.headHelper != otherHelper || !this.headHelper.areEqual(this.head, obj)) { - return false; - } - if (!doTransfer) return true; - RGNode.this.recipePer = 0; - - // items - List itemInputs = new ArrayList<>(); - recipeLayout.getItemStacks().getGuiIngredients().values().forEach(it -> { - if (it.isInput() && it.getDisplayedIngredient() != null) { - ItemStack input = it.getDisplayedIngredient(); - for (ItemStack itemInput : itemInputs) { - if (itemInput.isItemEqual(input)) { - itemInput.setCount(itemInput.getCount() + input.getCount()); - return; - } - } - itemInputs.add(input.copy()); - } else if (head instanceof ItemStack && !it.isInput()) { - for (ItemStack ingredient : it.getAllIngredients()) { - if (((ItemStack) head).isItemEqual(ingredient)) { - RGNode.this.recipePer += ingredient.getCount(); - break; - } - } - } - }); - - // fluids - List fluidInputs = new ArrayList<>(); - recipeLayout.getFluidStacks().getGuiIngredients().values().forEach(it -> { - if (it.isInput() && it.getDisplayedIngredient() != null) { - FluidStack input = it.getDisplayedIngredient(); - for (FluidStack fluidInput : fluidInputs) { - if (fluidInput.isFluidEqual(input)) { - fluidInput.amount += input.amount; - return; - } - } - fluidInputs.add(input.copy()); - } else if (head instanceof FluidStack && !it.isInput()) { - for (FluidStack ingredient : it.getAllIngredients()) { - if (((FluidStack) head).isFluidEqual(ingredient)) { - RGNode.this.recipePer += ingredient.amount; - break; - } - } - } - }); - // CHECK GTCE RECIPES - Recipe recipe = null; - if (recipeLayout instanceof RecipeLayout) { - IRecipeWrapper recipeWrapper = ObfuscationReflectionHelper.getPrivateValue(RecipeLayout.class, - (RecipeLayout) recipeLayout, "recipeWrapper"); - if (recipeWrapper instanceof GTRecipeWrapper) { - recipe = ((GTRecipeWrapper) recipeWrapper).getRecipe(); - } - } - IRecipeCategory category = recipeLayout.getRecipeCategory(); - List catalysts = JustEnoughItemsModule.jeiRuntime.getRecipeRegistry().getRecipeCatalysts(category); - ItemStack catalyst = null; - - if (recipe != null) { // GT - int tierRequire = GTUtility.getTierByVoltage(recipe.getEUt()); - for (Object o : catalysts) { - if (o instanceof ItemStack) { - MetaTileEntity mte = GTUtility.getMetaTileEntity((ItemStack) o); - if (mte instanceof SimpleMachineMetaTileEntity) { - if (tierRequire < ((SimpleMachineMetaTileEntity) mte).getTier()) { - catalyst = (ItemStack) o; - break; - } - } - } - } - } - - if (catalyst == null) { - for (Object o : catalysts) { - if (o instanceof ItemStack) { - catalyst = (ItemStack) o; - break; - } - } - } - setRecipe(itemInputs, fluidInputs, catalyst, Math.max(1, this.recipePer)); - return true; - } - return false; - } - - public void deserializeRelationNBT(NBTTagList parentsTag, NBTTagList childrenTag) { - for (NBTBase nbtBase : parentsTag) { - int[] nbt = ((NBTTagIntArray) nbtBase).getIntArray(); - parentNodes.put(container.nodes.get(nbt[0]), nbt[1]); - } - Iterator iterator = children.keySet().iterator(); - for (NBTBase nbtBase : childrenTag) { - int[] nbt = ((NBTTagIntArray) nbtBase).getIntArray(); - children.get(iterator.next()) - .addAll(Arrays.stream(nbt).mapToObj(it -> container.nodes.get(it)).collect(Collectors.toList())); - } - } - - public static RGNode deserializeNodeNBT(NBTTagCompound nodeTag, RGContainer container) { - byte type = nodeTag.getByte("type"); // 0-null 1-itemstack 2-fluidstack - Object head = null; - if (type != 0) { - IngredientHelper headHelper = (IngredientHelper) IngredientHelper.getForTypeId(type); - head = headHelper.deserialize(nodeTag.getCompoundTag("nbt")); - headHelper.setAmount(head, nodeTag.getInteger("count")); - } - RGNode node = new RGNode(nodeTag.getInteger("x"), nodeTag.getInteger("y"), container, head, - nodeTag.getBoolean("phantom")); - NBTTagList itemsList = nodeTag.getTagList("items", Constants.NBT.TAG_COMPOUND); - NBTTagList fluidsList = nodeTag.getTagList("fluids", Constants.NBT.TAG_COMPOUND); - List itemInputs = new LinkedList<>(); - itemsList.forEach(base -> { - if (base instanceof NBTTagCompound) { - itemInputs.add(new ItemStack((NBTTagCompound) base)); - } - }); - List fluidsInputs = new LinkedList<>(); - fluidsList.forEach(base -> { - if (base instanceof NBTTagCompound) { - fluidsInputs.add(FluidStack.loadFluidStackFromNBT((NBTTagCompound) base)); - } - }); - node.setRecipe(itemInputs, fluidsInputs, - nodeTag.hasKey("catalyst") ? new ItemStack(nodeTag.getCompoundTag("catalyst")) : null, - nodeTag.getInteger("per")); - boolean visible = nodeTag.getBoolean("visible"); - node.textWidget.setVisible(visible); - node.textWidget.setActive(visible); - return node; - } - - public NBTTagCompound serializeNodeNBT() { - // head - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("x", getSelfPosition().x + container.getScrollXOffset()); - nbt.setInteger("y", getSelfPosition().y + container.getScrollYOffset()); - nbt.setByte("type", this.head == null ? 0 : this.headHelper.getTypeId()); - if (this.head != null) { - nbt.setTag("nbt", this.headHelper.serialize(this.head)); - nbt.setInteger("count", this.headHelper.getAmount(this.head)); - } - nbt.setBoolean("phantom", widgets.stream().anyMatch(it -> it instanceof PhantomWidget)); - // recipe + children - NBTTagList itemsList = new NBTTagList(); - NBTTagList fluidsList = new NBTTagList(); - NBTTagList childrenList = new NBTTagList(); - for (Map.Entry> entry : children.entrySet()) { - Widget widget = entry.getKey(); - if (widget instanceof SlotWidget) { - itemsList.appendTag(((SlotWidget) widget).getHandle().getStack().serializeNBT()); - } else if (widget instanceof TankWidget) { - fluidsList.appendTag(((TankWidget) widget).fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } else { - continue; - } - NBTTagIntArray childList = new NBTTagIntArray( - entry.getValue().stream().mapToInt(it -> container.nodes.indexOf(it)).toArray()); - childrenList.appendTag(childList); - } - nbt.setTag("items", itemsList); - nbt.setTag("fluids", fluidsList); - nbt.setTag("children", childrenList); - if (catalyst != null) { - nbt.setTag("catalyst", catalyst.serializeNBT()); - } - nbt.setInteger("per", recipePer); - // parent - NBTTagList parentsList = new NBTTagList(); - for (Map.Entry entry : parentNodes.entrySet()) { - parentsList.appendTag( - new NBTTagIntArray(new int[] { container.nodes.indexOf(entry.getKey()), entry.getValue() })); - } - nbt.setTag("parents", parentsList); - nbt.setBoolean("visible", textWidget.isVisible()); - return nbt; - } - - private void setRecipe(List itemInputs, List fluidInputs, ItemStack catalyst, - int recipePer) { - this.recipePer = recipePer; - this.catalyst = catalyst; - inputsGroup.clearAllWidgets(); - for (Set childs : children.values()) { - for (RGNode child : childs) { - child.removeParent(this); - } - } - children.clear(); - AtomicInteger y = new AtomicInteger(-20); - for (ItemStack itemInput : itemInputs) { - ItemStackHandler handler = new ItemStackHandler(1); - handler.setStackInSlot(0, itemInput); - Widget widget = new SlotWidget(handler, 0, 0, y.addAndGet(20), false, false) { - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - return RGNode.this.handleTipsSlotClick(mouseX, mouseY, this, handler.getStackInSlot(0).copy()); - } - }.setBackgroundTexture(TerminalTheme.COLOR_B_2); - inputsGroup.addWidget(widget); - children.put(widget, new HashSet<>()); - } - for (FluidStack fluidInput : fluidInputs) { - FluidTank tank = new FluidTank(fluidInput, Integer.MAX_VALUE); - Widget widget = new TankWidget(tank, 0, y.addAndGet(20), 18, 18) { - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - return RGNode.this.handleTipsSlotClick(mouseX, mouseY, this, tank.getFluid().copy()); - } - }.setAlwaysShowFull(true).setBackgroundTexture(TerminalTheme.COLOR_B_2).setClient(); - inputsGroup.addWidget(widget); - children.put(widget, new HashSet<>()); - } - inputsGroup.setSelfPosition(new Position(25, -(inputsGroup.widgets.size() * 20) / 2 + 8)); - } - - private boolean handleTipsSlotClick(int mouseX, int mouseY, Widget slot, Object object) { - if (slot.isMouseOverElement(mouseX, mouseY)) { - Position position = inputsGroup.getSelfPosition(); - RGNode child = container.addNode(RGNode.this.getSelfPosition().x + 50, - RGNode.this.getSelfPosition().y + position.y + slot.getSelfPosition().y, object); - Set childs = RGNode.this.children.get(slot); - childs.add(child); - - child.addParent(RGNode.this); - RGNode.this.updateDemand(RGNode.this.getHeadDemand()); - return true; - } - return false; - } - - public void updateSelected(boolean selected) { - isSelected = selected; - if (selected) { - toolGroup.setActive(true); - toolGroup.setVisible(true); - inputsGroup.setActive(true); - inputsGroup.setVisible(true); - } else { - toolGroup.setActive(false); - toolGroup.setVisible(false); - inputsGroup.setActive(false); - inputsGroup.setVisible(false); - } - children.forEach((widget, rgNode) -> rgNode.forEach(child -> container.addOrUpdateLine(RGNode.this, child))); - } - - @Override - public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - int x = getPosition().x; - int y = getPosition().y; - int width = getSize().width; - int height = getSize().height; - if (isSelected) { - drawBorder(x, y, width, height, 0xff00ff00, 2); - } - super.drawInBackground(mouseX, mouseY, partialTicks, context); - } - - @Override - public boolean allowDrag(int mouseX, int mouseY, int button) { - return isMouseOverElement(mouseX, mouseY); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (isMouseOverElement(mouseX, mouseY)) { - if (!isSelected) { - container.setSelectedNode(this); - } - super.mouseClicked(mouseX, mouseY, button); - return false; - } else if (super.mouseClicked(mouseX, mouseY, button)) { - return true; - } else if (isSelected) { - container.setSelectedNode(null); - } - return false; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/settings/SettingsApp.java b/src/main/java/gregtech/common/terminal/app/settings/SettingsApp.java deleted file mode 100644 index a04035afc07..00000000000 --- a/src/main/java/gregtech/common/terminal/app/settings/SettingsApp.java +++ /dev/null @@ -1,64 +0,0 @@ -package gregtech.common.terminal.app.settings; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.TextTexture; -import gregtech.api.gui.widgets.AbstractWidgetGroup; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.TabGroup; -import gregtech.api.gui.widgets.tab.IGuiTextureTabInfo; -import gregtech.api.gui.widgets.tab.ITabInfo; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.CustomTabListRenderer; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.common.terminal.app.settings.widgets.HomeButtonSettings; -import gregtech.common.terminal.app.settings.widgets.OsSettings; -import gregtech.common.terminal.app.settings.widgets.ThemeSettings; - -public class SettingsApp extends AbstractApplication { - - private TabGroup tabGroup; - - public SettingsApp() { - super("settings"); - } - - @Override - public AbstractApplication initApp() { - if (isClient) { - this.addWidget(new ImageWidget(5, 15, 323, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()))); - this.tabGroup = new TabGroup<>(5, 15, - new CustomTabListRenderer(TerminalTheme.COLOR_B_2, TerminalTheme.COLOR_F_2, 323 / 3, 10)); - this.addWidget(this.tabGroup); - this.tabGroup.setOnTabChanged(this::onPagesChanged); - addTab("terminal.settings.theme", new ThemeSettings(getOs())); - addTab("terminal.settings.home", new HomeButtonSettings(getOs())); - addTab("terminal.settings.os", new OsSettings(getOs())); - } - return this; - } - - private void onPagesChanged(int oldPage, int newPage) { - ITabInfo tabInfo = tabGroup.getTabInfo(newPage); - if (tabInfo instanceof IGuiTextureTabInfo && ((IGuiTextureTabInfo) tabInfo).texture instanceof TextTexture) { - ((TextTexture) ((IGuiTextureTabInfo) tabInfo).texture).setType(TextTexture.TextType.ROLL); - } - tabInfo = tabGroup.getTabInfo(oldPage); - if (tabInfo instanceof IGuiTextureTabInfo && ((IGuiTextureTabInfo) tabInfo).texture instanceof TextTexture) { - ((TextTexture) ((IGuiTextureTabInfo) tabInfo).texture).setType(TextTexture.TextType.HIDE); - } - } - - private void addTab(String name, AbstractWidgetGroup widget) { - tabGroup.addTab( - new IGuiTextureTabInfo( - new TextTexture(name, -1).setWidth(323 / 3 - 5).setType( - tabGroup.getAllTag().isEmpty() ? TextTexture.TextType.ROLL : TextTexture.TextType.HIDE), - name), - widget); - } - - @Override - public boolean isClientSideApp() { - return true; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/settings/widgets/HomeButtonSettings.java b/src/main/java/gregtech/common/terminal/app/settings/widgets/HomeButtonSettings.java deleted file mode 100644 index 48ab589601f..00000000000 --- a/src/main/java/gregtech/common/terminal/app/settings/widgets/HomeButtonSettings.java +++ /dev/null @@ -1,133 +0,0 @@ -package gregtech.common.terminal.app.settings.widgets; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.AbstractWidgetGroup; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.TextFieldWidget; -import gregtech.api.terminal.gui.widgets.SelectorWidget; -import gregtech.api.terminal.os.SystemCall; -import gregtech.api.terminal.os.TerminalHomeButtonWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.client.resources.I18n; - -import org.apache.commons.lang3.tuple.MutablePair; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -public class HomeButtonSettings extends AbstractWidgetGroup { - - final TerminalOSWidget os; - - public HomeButtonSettings(TerminalOSWidget os) { - super(Position.ORIGIN, new Size(323, 212)); - this.os = os; - List candidates = Arrays.stream(SystemCall.values()).map(SystemCall::getTranslateKey) - .collect(Collectors.toList()); - candidates.add(0, "terminal.system_call.null"); - TerminalHomeButtonWidget home = this.os.home; - this.addWidget(new LabelWidget(10, 15, "terminal.settings.home.double", -1).setYCentered(true)); - this.addWidget(new LabelWidget(50, 15, "+Ctrl", -1).setYCentered(true)); - this.addWidget(new LabelWidget(85, 15, "+Shift", -1).setYCentered(true)); - this.addWidget( - new LabelWidget(170, 15, "terminal.settings.home.action", -1).setXCentered(true).setYCentered(true)); - this.addWidget( - new LabelWidget(270, 15, "terminal.settings.home.args", -1).setXCentered(true).setYCentered(true)); - - for (int shift = 0; shift < 2; shift++) { - for (int ctrl = 0; ctrl < 2; ctrl++) { - for (int doubleClick = 0; doubleClick < 2; doubleClick++) { - int i = TerminalHomeButtonWidget.actionMap(doubleClick == 1, ctrl == 1, shift == 1); - Pair pair = home.getActions()[i]; - int y = i * 22 + 30; - if (doubleClick == 1) { - this.addWidget(new ImageWidget(15, y + 5, 10, 10, GuiTextures.ICON_VISIBLE)); - } - if (ctrl == 1) { - this.addWidget(new ImageWidget(55, y + 5, 10, 10, GuiTextures.ICON_VISIBLE)); - } - if (shift == 1) { - this.addWidget(new ImageWidget(90, y + 5, 10, 10, GuiTextures.ICON_VISIBLE)); - } - TextFieldWidget textFieldWidget = new TextFieldWidget(230, y, 80, 20, TerminalTheme.COLOR_B_3, null, - null) - .setMaxStringLength(Integer.MAX_VALUE) - .setTextResponder(arg -> { - if (arg != null && home.getActions()[i] != null) { - home.getActions()[i].setValue(arg); - } - home.saveConfig(); - }, true) - .setValidator(s -> true); - if (pair != null && pair.getValue() != null) { - textFieldWidget.setCurrentString(pair.getValue()); - } else { - textFieldWidget.setCurrentString(""); - } - - this.addWidget(new SelectorWidget(120, y, 100, 20, candidates, -1, - () -> { - Pair _pair = home.getActions()[i]; - if (_pair != null) { - return _pair.getKey().getTranslateKey(); - } - return "terminal.system_call.null"; - }, true) - .setIsUp(i > 3) - .setHoverText(I18n - .format(doubleClick == 1 ? "terminal.settings.home.double_click" : - "terminal.settings.home.click") + - (ctrl == 1 ? "+Ctrl" : "") + (shift == 1 ? "+Shift" : "")) - .setOnChanged(selected -> { - SystemCall action = SystemCall.getFromName(selected); - if (action != null) { - if (home.getActions()[i] == null) { - home.getActions()[i] = new MutablePair<>(action, null); - } else { - home.getActions()[i] = new MutablePair<>(action, - home.getActions()[i].getValue()); - } - } else { - home.getActions()[i] = null; - } - home.saveConfig(); - }) - .setOnShowChange(isShow -> { - if (isShow) { - for (Widget widget : widgets) { - if (widget instanceof SelectorWidget) { - ((SelectorWidget) widget).hide(); - } - } - } - }) - .setColors(TerminalTheme.COLOR_B_2.getColor(), TerminalTheme.COLOR_F_1.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setBackground(TerminalTheme.COLOR_6)); - - this.addWidget(textFieldWidget); - } - } - } - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - for (int i = widgets.size() - 1; i >= 0; i--) { - Widget widget = widgets.get(i); - if (widget.isVisible() && widget.isActive() && widget.mouseClicked(mouseX, mouseY, button)) { - mouseX = -10000; - mouseY = -10000; - } - } - return mouseX == -10000; - } -} diff --git a/src/main/java/gregtech/common/terminal/app/settings/widgets/OsSettings.java b/src/main/java/gregtech/common/terminal/app/settings/widgets/OsSettings.java deleted file mode 100644 index 1ed390a5352..00000000000 --- a/src/main/java/gregtech/common/terminal/app/settings/widgets/OsSettings.java +++ /dev/null @@ -1,72 +0,0 @@ -package gregtech.common.terminal.app.settings.widgets; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.AbstractWidgetGroup; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.GTLog; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.common.FMLCommonHandler; - -import java.io.File; -import java.io.IOException; - -public class OsSettings extends AbstractWidgetGroup { - - public static boolean DOUBLE_CHECK; - static { - if (FMLCommonHandler.instance().getSide().isClient()) { - NBTTagCompound nbt = null; - try { - nbt = CompressedStreamTools.read(new File(TerminalRegistry.TERMINAL_PATH, "config/os_settings.nbt")); - } catch (IOException e) { - GTLog.logger.error("error while loading local nbt for the os settings", e); - } - if (nbt == null) { - DOUBLE_CHECK = true; - } else { - DOUBLE_CHECK = nbt.getBoolean("double_check"); - } - } - } - final TerminalOSWidget os; - - public static void saveConfig() { - if (FMLCommonHandler.instance().getSide().isClient()) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setBoolean("double_check", DOUBLE_CHECK); - try { - if (!nbt.isEmpty()) { - CompressedStreamTools.safeWrite(nbt, - new File(TerminalRegistry.TERMINAL_PATH, "config/os_settings.nbt")); - } - } catch (IOException e) { - GTLog.logger.error("error while saving local nbt for the os settings", e); - } - } - } - - public OsSettings(TerminalOSWidget os) { - super(Position.ORIGIN, new Size(323, 212)); - this.os = os; - this.addWidget(new LabelWidget(25, 15, "terminal.settings.os.double_check", -1).setYCentered(true)); - this.addWidget(new RectButtonWidget(10, 10, 10, 10, 2) - .setToggleButton(new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()), (c, p) -> { - DOUBLE_CHECK = !p; - saveConfig(); - }) - .setValueSupplier(true, () -> !DOUBLE_CHECK) - .setColors(TerminalTheme.COLOR_B_3.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_3.getColor()) - .setIcon(new ColorRectTexture(TerminalTheme.COLOR_7.getColor())) - .setHoverText("terminal.settings.os.double_check.desc")); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/settings/widgets/ThemeSettings.java b/src/main/java/gregtech/common/terminal/app/settings/widgets/ThemeSettings.java deleted file mode 100644 index d0894a487c1..00000000000 --- a/src/main/java/gregtech/common/terminal/app/settings/widgets/ThemeSettings.java +++ /dev/null @@ -1,167 +0,0 @@ -package gregtech.common.terminal.app.settings.widgets; - -import gregtech.api.gui.resources.*; -import gregtech.api.gui.widgets.*; -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.gui.widgets.ColorWidget; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.gui.widgets.SelectorWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalOSWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.Position; -import gregtech.api.util.Size; - -import net.minecraft.util.ResourceLocation; - -import java.util.Arrays; -import java.util.function.Consumer; - -public class ThemeSettings extends AbstractWidgetGroup { - - private final WidgetGroup textureGroup; - final TerminalOSWidget os; - - public ThemeSettings(TerminalOSWidget os) { - super(Position.ORIGIN, new Size(323, 212)); - this.os = os; - float x = 323 * 1.0f / 13; - int y = 40; - this.addWidget(new LabelWidget(323 / 2, 10, "terminal.settings.theme.color", -1).setXCentered(true)); - this.addColorButton(TerminalTheme.COLOR_1, "COLOR_1", (int) x, y); - this.addColorButton(TerminalTheme.COLOR_2, "COLOR_2", (int) (x * 2), y); - this.addColorButton(TerminalTheme.COLOR_3, "COLOR_3", (int) (x * 3), y); - this.addColorButton(TerminalTheme.COLOR_4, "COLOR_4", (int) (x * 4), y); - this.addColorButton(TerminalTheme.COLOR_5, "COLOR_5", (int) (x * 5), y); - this.addColorButton(TerminalTheme.COLOR_6, "COLOR_6", (int) (x * 6), y); - this.addColorButton(TerminalTheme.COLOR_7, "COLOR_7", (int) (x * 7), y); - this.addColorButton(TerminalTheme.COLOR_F_1, "COLOR_F_1", (int) (x * 8), y); - this.addColorButton(TerminalTheme.COLOR_F_2, "COLOR_F_2", (int) (x * 9), y); - this.addColorButton(TerminalTheme.COLOR_B_1, "COLOR_B_1", (int) (x * 10), y); - this.addColorButton(TerminalTheme.COLOR_B_2, "COLOR_B_2", (int) (x * 11), y); - this.addColorButton(TerminalTheme.COLOR_B_3, "COLOR_B_3", (int) (x * 12), y); - this.addWidget(new LabelWidget(323 / 2, 75, "terminal.settings.theme.wallpaper", -1).setXCentered(true)); - this.addWidget(new ImageWidget((int) x, 95, 150, 105, TerminalTheme.WALL_PAPER).setBorder(2, -1)); - this.addWidget(new SelectorWidget((int) (x + 170), 95, 116, 20, - Arrays.asList( - "terminal.settings.theme.wallpaper.resource", - "terminal.settings.theme.wallpaper.url", - "terminal.settings.theme.wallpaper.color", - "terminal.settings.theme.wallpaper.file"), - -1, this::getLocalizedWallpaperTypeName, true) - .setIsUp(true) - .setOnChanged(this::onModifyTextureChanged) - .setColors(TerminalTheme.COLOR_B_2.getColor(), TerminalTheme.COLOR_F_1.getColor(), - TerminalTheme.COLOR_B_2.getColor()) - .setBackground(TerminalTheme.COLOR_6)); - textureGroup = new WidgetGroup((int) (x + 170), 122, (int) (x * 11 - 170), 65); - this.addWidget(textureGroup); - } - - private String getLocalizedWallpaperTypeName() { - switch (TerminalTheme.WALL_PAPER.getTypeName()) { - case "resource": - return "terminal.settings.theme.wallpaper.resource"; - case "url": - return "terminal.settings.theme.wallpaper.url"; - case "color": - return "terminal.settings.theme.wallpaper.color"; - case "file": - return "terminal.settings.theme.wallpaper.file"; - } - return null; - } - - private void addColorButton(ColorRectTexture texture, String name, int x, int y) { - CircleButtonWidget buttonWidget = new CircleButtonWidget(x, y, 8, 1, 0).setFill(texture.getColor()) - .setStrokeAnima(-1).setHoverText(name); - buttonWidget.setClickListener(cd -> TerminalDialogWidget.showColorDialog(os, name, color -> { - if (color != null) { - buttonWidget.setFill(color); - texture.setColor(color); - if (!TerminalTheme.saveConfig()) { - TerminalDialogWidget - .showInfoDialog(os, "terminal.component.error", "terminal.component.save_file.error") - .setClientSide().open(); - } - } - }, texture.color).setClientSide().open()); - addWidget(buttonWidget); - } - - private void onModifyTextureChanged(String type) { - textureGroup.clearAllWidgets(); - switch (type) { - case "terminal.settings.theme.wallpaper.resource": - if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof TextureArea)) { - TerminalTheme.WALL_PAPER.setTexture(new TextureArea( - new ResourceLocation("gregtech:textures/gui/terminal/terminal_background.png"), 0.0, 0.0, - 1.0, 1.0)); - TerminalTheme.saveConfig(); - } - addStringSetting(((TextureArea) TerminalTheme.WALL_PAPER.getTexture()).imageLocation.toString(), - s -> { - TerminalTheme.WALL_PAPER - .setTexture(new TextureArea(new ResourceLocation(s), 0.0, 0.0, 1.0, 1.0)); - TerminalTheme.saveConfig(); - }); - break; - case "terminal.settings.theme.wallpaper.url": - if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof URLTexture)) { - TerminalTheme.WALL_PAPER.setTexture(new URLTexture(null)); - TerminalTheme.saveConfig(); - } - addStringSetting(((URLTexture) TerminalTheme.WALL_PAPER.getTexture()).url, s -> { - TerminalTheme.WALL_PAPER.setTexture(new URLTexture(s)); - TerminalTheme.saveConfig(); - }); - break; - case "terminal.settings.theme.wallpaper.color": - ColorRectTexture texture; - if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof ColorRectTexture)) { - texture = new ColorRectTexture(-1); - TerminalTheme.WALL_PAPER.setTexture(texture); - TerminalTheme.saveConfig(); - } else { - texture = (ColorRectTexture) TerminalTheme.WALL_PAPER.getTexture(); - } - textureGroup.addWidget(new ColorWidget(0, 0, 80, 10) - .setColorSupplier(texture::getColor, true) - .setOnColorChanged(texture::setColor)); - break; - case "terminal.settings.theme.wallpaper.file": - if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof FileTexture)) { - TerminalTheme.WALL_PAPER.setTexture(new FileTexture(null)); - TerminalTheme.saveConfig(); - } - textureGroup.addWidget(new RectButtonWidget(0, 0, 116, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(cd -> TerminalDialogWidget.showFileDialog(os, "terminal.settings.theme.image", - TerminalRegistry.TERMINAL_PATH, true, file -> { - if (file != null && file.isFile()) { - TerminalTheme.WALL_PAPER.setTexture(new FileTexture(file)); - TerminalTheme.saveConfig(); - } - }).setClientSide().open()) - .setIcon(new TextTexture("terminal.settings.theme.select", -1))); - break; - } - } - - private void addStringSetting(String init, Consumer callback) { - TextFieldWidget textFieldWidget = new TextFieldWidget(0, 0, 76, 20, TerminalTheme.COLOR_B_2, null, null) - .setMaxStringLength(Integer.MAX_VALUE) - .setValidator(s -> true) - .setCurrentString(init == null ? "" : init); - textureGroup.addWidget(textFieldWidget); - textureGroup.addWidget(new RectButtonWidget(76, 0, 40, 20) - .setColors(TerminalTheme.COLOR_B_1.getColor(), - TerminalTheme.COLOR_1.getColor(), - TerminalTheme.COLOR_B_1.getColor()) - .setClickListener(cd -> callback.accept(textFieldWidget.getCurrentString())) - .setIcon(new TextTexture("terminal.guide_editor.update", -1))); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/teleport/TeleportApp.java b/src/main/java/gregtech/common/terminal/app/teleport/TeleportApp.java deleted file mode 100644 index 288f5f39bd2..00000000000 --- a/src/main/java/gregtech/common/terminal/app/teleport/TeleportApp.java +++ /dev/null @@ -1,118 +0,0 @@ -package gregtech.common.terminal.app.teleport; - -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.widgets.*; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.os.SystemCall; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.util.TeleportHandler; -import gregtech.common.entities.PortalEntity; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.chunk.Chunk; - -public class TeleportApp extends AbstractApplication { - - private int coordinateX = 0; - private int coordinateY = 1; - private int coordinateZ = 0; - - private int dimension = 0; - - public TeleportApp() { - super("teleport"); - } - - @Override - public AbstractApplication initApp() { - if (nbt != null && nbt.hasKey("LastTeleport")) { - BlockPos pos = BlockPos.fromLong(nbt.getLong("LastTeleport")); - this.coordinateX = pos.getX(); - this.coordinateY = pos.getY(); - this.coordinateZ = pos.getZ(); - this.dimension = nbt.getShort("LastDim"); - } - - // background - this.addWidget(new ImageWidget(5, 5, 323, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()))); - int textFieldColor = TerminalTheme.COLOR_B_2.getColor(); - textFieldColor &= 0xFFFFFF; // remove alpha - textFieldColor |= (200 << 24); // alpha 175 - // text field backgrounds - this.addWidget(new ImageWidget(9, 104, 77, 10, new ColorRectTexture(textFieldColor))); - this.addWidget(new ImageWidget(9, 64, 77, 10, new ColorRectTexture(textFieldColor))); - this.addWidget(new ImageWidget(9, 44, 77, 10, new ColorRectTexture(textFieldColor))); - this.addWidget(new ImageWidget(9, 24, 77, 10, new ColorRectTexture(textFieldColor))); - // text field labels - this.addWidget(new LabelWidget(10, 15, "X: ", 0xFFFFFF)); - this.addWidget(new LabelWidget(10, 35, "Y: ", 0xFFFFFF)); - this.addWidget(new LabelWidget(10, 55, "Z: ", 0xFFFFFF)); - this.addWidget( - new SimpleTextWidget(10, 95, "terminal.teleporter.dimension", 0xFFFFFF, () -> "").setCenter(false)); - - this.addWidget(new TextFieldWidget2(10, 105, 75, 16, () -> String.valueOf(dimension), value -> { - if (!value.isEmpty()) { - dimension = Integer.parseInt(value); - } - }).setMaxLength(9).setNumbersOnly(Short.MIN_VALUE, Short.MAX_VALUE)); - this.addWidget(new TextFieldWidget2(10, 65, 75, 16, () -> String.valueOf(coordinateZ), value -> { - if (!value.isEmpty()) { - coordinateZ = Integer.parseInt(value); - } - }).setMaxLength(9).setNumbersOnly(-30000000, 30000000)); - this.addWidget(new TextFieldWidget2(10, 45, 75, 16, () -> String.valueOf(coordinateY), value -> { - if (!value.isEmpty()) { - coordinateY = Integer.parseInt(value); - } - }).setMaxLength(9).setNumbersOnly(1, 255)); - this.addWidget(new TextFieldWidget2(10, 25, 75, 16, () -> String.valueOf(coordinateX), value -> { - if (!value.isEmpty()) { - coordinateX = Integer.parseInt(value); - } - }).setMaxLength(9).setNumbersOnly(-30000000, 30000000)); - - this.addWidget(new ClickButtonWidget(15, 140, 65, 20, "terminal.teleporter.spawn_portal", - data -> this.spawnPortals())); - - return this; - } - - @Override - public NBTTagCompound closeApp() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("LastTeleport", new BlockPos(coordinateX, coordinateY, coordinateZ).toLong()); - nbt.setShort("LastDim", (short) dimension); - return nbt; - } - - /** - * Creates two portals, one 5 blocks in front of the player targeting the other portal, the other at the destination - * targeting the first portal - */ - public void spawnPortals() { - Vec3d position = new Vec3d( - gui.entityPlayer.getPosition().getX() + gui.entityPlayer.getLookVec().x * 5, - gui.entityPlayer.getPosition().getY(), - gui.entityPlayer.getPosition().getZ() + gui.entityPlayer.getLookVec().z * 5); - - PortalEntity portal1 = new PortalEntity(gui.entityPlayer.getEntityWorld(), position.x, position.y, position.z); - portal1.setRotation(gui.entityPlayer.rotationYaw, 0.F); - - PortalEntity portal2 = new PortalEntity(gui.entityPlayer.getEntityWorld(), coordinateX, coordinateY, - coordinateZ); - portal2.setRotation(gui.entityPlayer.rotationYaw, 0.F); - - portal1.setTargetCoordinates(dimension, coordinateX, coordinateY, coordinateZ); - portal2.setTargetCoordinates(gui.entityPlayer.dimension, position.x, position.y, position.z); - - gui.entityPlayer.getEntityWorld().spawnEntity(portal1); - Chunk destination = TeleportHandler.getWorldByDimensionID(dimension).getChunkProvider() - .provideChunk(coordinateX >> 4, coordinateZ >> 4); - TeleportHandler.getWorldByDimensionID(dimension).spawnEntity(portal2); - TeleportHandler.getWorldByDimensionID(dimension).getChunkProvider().queueUnload(destination); - - SystemCall.SHUT_DOWN.call(getOs(), isClient); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/worldprospector/WorldProspectorARApp.java b/src/main/java/gregtech/common/terminal/app/worldprospector/WorldProspectorARApp.java deleted file mode 100644 index 8ead4466af8..00000000000 --- a/src/main/java/gregtech/common/terminal/app/worldprospector/WorldProspectorARApp.java +++ /dev/null @@ -1,521 +0,0 @@ -package gregtech.common.terminal.app.worldprospector; - -import gregtech.api.gui.IRenderContext; -import gregtech.api.gui.resources.ColorRectTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.gui.resources.ShaderTexture; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.PhantomSlotUtil; -import gregtech.api.gui.widgets.PhantomSlotWidget; -import gregtech.api.terminal.app.ARApplication; -import gregtech.api.terminal.app.AbstractApplication; -import gregtech.api.terminal.gui.widgets.CircleButtonWidget; -import gregtech.api.terminal.gui.widgets.RectButtonWidget; -import gregtech.api.terminal.os.TerminalDialogWidget; -import gregtech.api.terminal.os.TerminalTheme; -import gregtech.api.unification.OreDictUnifier; -import gregtech.api.unification.stack.MaterialStack; -import gregtech.api.util.GTLog; -import gregtech.api.util.Mods; -import gregtech.client.shader.Shaders; -import gregtech.client.utils.DepthTextureUtil; -import gregtech.client.utils.RenderBufferHelper; -import gregtech.client.utils.TooltipHelper; -import gregtech.common.inventory.handlers.SingleItemStackHandler; -import gregtech.common.items.MetaItems; -import gregtech.common.terminal.app.worldprospector.matcher.BlockStateMatcher; -import gregtech.common.terminal.app.worldprospector.matcher.IMatcher; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ClickType; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Tuple; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import mezz.jei.api.gui.IGhostIngredientHandler; -import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class WorldProspectorARApp extends ARApplication { - - private SingleItemStackHandler[] handlers; - private int[] colors; - - public WorldProspectorARApp() { - super("world_prospector"); - } - - @Override - public AbstractApplication initApp() { - addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor()))); - addWidget(new LabelWidget(15 + 150 / 2, 232 / 2, "terminal.world_prospector.radius", -1, - new Object[] { getMaxRadius() }) - .setShadow(true) - .setYCentered(true) - .setXCentered(true)); - int slotSize = (int) Math.pow(2, getAppTier()); - int x = 250 - slotSize * 12; - int y = 232 / 2 - 18; - handlers = new SingleItemStackHandler[slotSize]; - colors = new int[slotSize]; - for (int i = 0; i < slotSize; i++) { - int index = i; - Tuple stack = getSlotStack(i); - if (stack == null) { - handlers[i] = new SingleItemStackHandler(ItemStack.EMPTY); - colors[i] = 0; - } else { - handlers[i] = new SingleItemStackHandler(stack.getFirst()); - colors[i] = stack.getSecond(); - } - RectButtonWidget buttonWidget = new RectButtonWidget(x + i * 24, y + 18, 18, 18, 1); - addWidget(new PhantomSlotWidget(handlers[i], 0, x + i * 24, y) { - - @Override - public List> getPhantomTargets(Object ingredient) { - if (!(ingredient instanceof ItemStack)) { - return Collections.emptyList(); - } - Rectangle rectangle = toRectangleBox(); - return Collections.singletonList(new IGhostIngredientHandler.Target() { - - @NotNull - @Override - public Rectangle getArea() { - return rectangle; - } - - @Override - public void accept(@NotNull Object ingredient) { - if (ingredient instanceof ItemStack) { - int mouseButton = Mouse.getEventButton(); - boolean shiftDown = TooltipHelper.isShiftDown(); - ClickType clickType = shiftDown ? ClickType.QUICK_MOVE : ClickType.PICKUP; - PhantomSlotUtil.slotClickPhantom(slotReference, mouseButton, clickType, - (ItemStack) ingredient); - updateBlockSelectionAndColor((ItemStack) ingredient, index, buttonWidget); - writeClientAction(1, buffer -> { - buffer.writeItemStack((ItemStack) ingredient); - buffer.writeVarInt(mouseButton); - buffer.writeBoolean(shiftDown); - }); - } - } - }); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if (handlers[index].getStackInSlot(0).isEmpty() && isMouseOverElement(mouseX, mouseY)) { - writeClientAction(-1, buffer -> {}); - selectReference(index, buttonWidget); - return true; - } else if (isMouseOverElement(mouseX, mouseY)) { - writeClientAction(0, buffer -> {}); - updateBlockSelectionAndColor(ItemStack.EMPTY, index, buttonWidget); - } - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public void handleClientAction(int id, PacketBuffer buffer) { - if (id == -1) { - selectReference(index, buttonWidget); - } else if (id == 0) { - updateBlockSelectionAndColor(ItemStack.EMPTY, index, buttonWidget); - } else if (id == 1) { - try { - buffer.markReaderIndex(); // just want to reset reader index, not both with .clear - ItemStack stack = buffer.readItemStack(); - updateBlockSelectionAndColor(stack, index, buttonWidget); - buffer.resetReaderIndex(); - } catch (IOException e) { - GTLog.logger.error("Could not update block selection from world prospector buffer", e); - } - super.handleClientAction(id, buffer); - } else { - super.handleClientAction(id, buffer); - } - } - }.setBackgroundTexture(new ColorRectTexture(0x4fffffff))); - addWidget(buttonWidget - .setHoverText("terminal.world_prospector.color") - .setColors(0x4fffffff, -1, colors[i]) - .setClickListener(cd -> TerminalDialogWidget - .showColorDialog(getOs(), "terminal.world_prospector.color", res -> { - if (res != null) { - buttonWidget.setFill(res | 0xff000000); - colors[index] = res | 0xff000000; - } - }, colors[index]).open())); - } - addWidget(new CircleButtonWidget(333 / 2, 200) - .setClickListener(cd -> openAR()) - .setHoverText("terminal.ar.open") - .setColors(0, -1, TerminalTheme.COLOR_B_3.getColor()) - .setIcon(new ItemStackTexture(MetaItems.CAMERA.getStackForm()))); - return this; - } - - private void updateBlockSelectionAndColor(ItemStack stack, int index, RectButtonWidget buttonWidget) { - if (stack.getItem() instanceof ItemBlock) { - ItemStack copy = stack.copy(); - copy.setCount(1); - handlers[index].setStackInSlot(0, copy); - - MaterialStack ms = OreDictUnifier.getMaterial(copy); - Block block = ((ItemBlock) copy.getItem()).getBlock(); - if (block instanceof BlockFalling) { - colors[index] = ((BlockFalling) block).getDustColor(block.getStateFromMeta(copy.getMetadata())); - } else if (ms != null) { - colors[index] = ms.material.getMaterialRGB(); - } else { - colors[index] = block.getStateFromMeta(copy.getMetadata()).getMaterial() - .getMaterialMapColor().colorValue; - } - if (colors[index] == 0) { - colors[index] = block.hashCode(); - } - colors[index] = colors[index] | 0xff000000; - buttonWidget.setFill(colors[index]); - } else if (stack.isEmpty()) { - handlers[index].setStackInSlot(0, stack); - colors[index] = 0x00000000; - buttonWidget.setFill(colors[index]); - } - } - - @Override - public NBTTagCompound closeApp() { - NBTTagCompound slots = new NBTTagCompound(); - nbt.removeTag("slots"); - for (int i = 0; i < handlers.length; i++) { - if (!handlers[i].getStackInSlot(0).isEmpty()) { - NBTTagCompound itemTag = new NBTTagCompound(); - itemTag.setTag("item", handlers[i].getStackInSlot(0).serializeNBT()); - itemTag.setInteger("color", colors[i]); - slots.setTag("s" + i, itemTag); - } - } - nbt.setTag("slots", slots); - return nbt; - } - - @Override - public int getMaxTier() { - return 2; - } - - @Override - protected void hookDrawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) { - super.hookDrawInBackground(mouseX, mouseY, partialTicks, context); - float time = (gui.entityPlayer.ticksExisted + partialTicks) / 20f; - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - if (Shaders.allowedShader()) { - ShaderTexture.createShader("lightring.frag").draw(getPosition().x + 15, getPosition().y + (232 - 150) / 2f, - 150, 150, uniformCache -> uniformCache.glUniform1F("u_time", time)); - } - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private void selectReference(int index, RectButtonWidget buttonWidget) { - TerminalDialogWidget.showItemSelector(getOs(), "terminal.world_prospector.reference", false, - stack -> stack.getItem() instanceof ItemBlock, - stack -> updateBlockSelectionAndColor(stack, index, buttonWidget)).open(); - } - - private int getMaxRadius() { - return (int) (15 * Math.pow(2, getAppTier())); - } - - private Tuple getSlotStack(int i) { - if (nbt != null) { - NBTTagCompound slots = nbt.getCompoundTag("slots"); - if (slots.hasKey("s" + i)) { - NBTTagCompound itemTag = slots.getCompoundTag("s" + i); - return new Tuple<>(new ItemStack(itemTag.getCompoundTag("item")), itemTag.getInteger("color")); - } - } - return null; - } - - private List> getAllSlotStack() { - List> stacks = new ArrayList<>(); - if (nbt != null) { - NBTTagCompound slots = nbt.getCompoundTag("slots"); - for (String key : slots.getKeySet()) { - NBTTagCompound itemTag = slots.getCompoundTag(key); - stacks.add(new Tuple<>(new ItemStack(itemTag.getCompoundTag("item")), itemTag.getInteger("color"))); - } - } - return stacks; - } - - ////////////////////////////////////// AR///////////////////////////////////////// - - @SideOnly(Side.CLIENT) - private static Set matchers; - @SideOnly(Side.CLIENT) - private static Map>> founds; - @SideOnly(Side.CLIENT) - private static BlockPos lastPos; - @SideOnly(Side.CLIENT) - private static int radius; - @SideOnly(Side.CLIENT) - private static int maxRadius; - - @SideOnly(Side.CLIENT) - @Override - public void onAROpened() { - founds = new HashMap<>(); - radius = 0; - maxRadius = getMaxRadius(); - lastPos = null; - matchers = new HashSet<>(); - for (Tuple stack : getAllSlotStack()) { - if (stack.getFirst().getItem() instanceof ItemBlock) { - Block block = ((ItemBlock) stack.getFirst().getItem()).getBlock(); - - if (block != Blocks.AIR) { - matchers.add(new BlockStateMatcher(block.getStateFromMeta(stack.getFirst().getMetadata()), - stack.getSecond())); - } - } - } - matchers.forEach(matcher -> founds.put(matcher, new HashMap<>())); - } - - @SideOnly(Side.CLIENT) - private static List bresenhamCircle(int xc, int zc, int r) { - List blockPos = new ArrayList<>(); - int x, z, d; - x = 0; - z = r; - d = 3 - 2 * r; - circlePlot(blockPos, xc, zc, x, z); - while (x < z) { - if (d < 0) { - d = d + 4 * x + 6; - } else { - d = d + 4 * (x - z) + 10; - z--; - } - x++; - circlePlot(blockPos, xc, zc, x, z); - } - return blockPos; - } - - @SideOnly(Side.CLIENT) - private static void circlePlot(List blockPos, int xc, int zc, int x, int z) { - blockPos.add(new BlockPos(xc + x, 0, zc + z)); - blockPos.add(new BlockPos(xc - x, 0, zc + z)); - blockPos.add(new BlockPos(xc + x, 0, zc - z)); - blockPos.add(new BlockPos(xc - x, 0, zc - z)); - blockPos.add(new BlockPos(xc + z, 0, zc + x)); - blockPos.add(new BlockPos(xc - z, 0, zc + x)); - blockPos.add(new BlockPos(xc + z, 0, zc - x)); - blockPos.add(new BlockPos(xc - z, 0, zc - x)); - } - - @SideOnly(Side.CLIENT) - private static void addCluster(BlockPos pos, Map> found) { - final BlockPos min = pos.add(-1, -1, -1); - final BlockPos max = pos.add(1, 1, 1); - - AxisAlignedBB root = null; - for (int y = min.getY(); y <= max.getY(); y++) { - for (int x = min.getX(); x <= max.getX(); x++) { - for (int z = min.getZ(); z <= max.getZ(); z++) { - Vec3d clusterPos = new Vec3d(x + 0.5, y + 0.5, z + 0.5); - AxisAlignedBB find = null; - for (AxisAlignedBB bb : found.keySet()) { - if (bb != root && bb.contains(clusterPos)) { - find = bb; - break; - } - } - if (find != null) { - AxisAlignedBB union; - Set blocks; - if (root == null) { - union = new AxisAlignedBB(pos).union(find); - blocks = found.get(find); - found.remove(find); - } else { - union = root.union(find); - blocks = new HashSet<>(); - blocks.addAll(found.get(find)); - blocks.addAll(found.get(root)); - found.remove(find); - found.remove(root); - } - found.put(union, blocks); - root = union; - found.get(root).add(pos); - } - } - } - } - if (root == null) { - Set blocks = new HashSet<>(); - blocks.add(pos); - found.put(new AxisAlignedBB(pos), blocks); - } - } - - @SideOnly(Side.CLIENT) - @Override - public void tickAR(EntityPlayer player) { - World world = player.world; - if (Minecraft.getMinecraft().isGamePaused()) return; - - if (radius == 0 || lastPos == null) { - lastPos = player.getPosition(); - } - - int maxY = Math.min(256, maxRadius + player.getPosition().getY()); - int minY = Math.max(0, -maxRadius + player.getPosition().getY()); - for (BlockPos pos : bresenhamCircle(lastPos.getX(), lastPos.getZ(), radius)) { - for (int y = minY; y <= maxY; y++) { - for (IMatcher matcher : matchers) { - BlockPos blockPos = new BlockPos(pos.getX(), y, pos.getZ()); - if (matcher.match(world.getBlockState(blockPos))) { - addCluster(blockPos, founds.get(matcher)); - } - } - - } - } - - if (radius == maxRadius) { - radius = 0; - for (IMatcher matcher : matchers) { - Iterator>> it = founds.get(matcher).entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); - entry.getValue().removeIf(pos -> !matcher.match(world.getBlockState(pos))); - if (entry.getValue().isEmpty()) { - it.remove(); - } - } - } - } else { - radius++; - } - } - - @SideOnly(Side.CLIENT) - @Override - public void drawARScreen(RenderWorldLastEvent event) { - renderScan(event.getPartialTicks()); - renderAxisAlignedBB(event.getPartialTicks()); - } - - @SideOnly(Side.CLIENT) - private static void renderAxisAlignedBB(float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - Entity entity = mc.getRenderViewEntity(); - if (entity == null) return; - final double posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks; - final double posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks; - final double posZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks; - - GlStateManager.disableLighting(); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - - GlStateManager.pushMatrix(); - GlStateManager.translate(-posX, -posY, -posZ); - - final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder buffer = tessellator.getBuffer(); - - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - - for (IMatcher matcher : matchers) { - int color = matcher.getColor(); - final float r = ((color >> 16) & 0xFF) / 255f; - final float g = ((color >> 8) & 0xFF) / 255f; - final float b = (color & 0xFF) / 255f; - final float a = 1; - for (AxisAlignedBB bound : founds.get(matcher).keySet()) { - RenderBufferHelper.renderCubeFace(buffer, bound.minX, bound.minY, bound.minZ, bound.maxX, bound.maxY, - bound.maxZ, r, g, b, a); - } - } - - tessellator.draw(); - - GlStateManager.popMatrix(); - - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.enableDepth(); - GlStateManager.enableLighting(); - } - - @SideOnly(Side.CLIENT) - private static void renderScan(float getPartialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - World world = mc.world; - Entity viewer = mc.getRenderViewEntity(); - if (world != null && viewer != null && !Mods.Optifine.isModLoaded()) { - - Framebuffer fbo = mc.getFramebuffer(); - - GlStateManager.depthMask(false); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - - DepthTextureUtil.bindDepthTexture(); - - float time = (viewer.ticksExisted + getPartialTicks) / 20; - - Shaders.renderFullImageInFBO(fbo, Shaders.SCANNING, uniformCache -> { - uniformCache.glUniform1F("u_time", time); - uniformCache.glUniform1F("radius", radius + getPartialTicks); - uniformCache.glUniform1F("u_zFar", mc.gameSettings.renderDistanceChunks * 16 * MathHelper.SQRT_2); - uniformCache.glUniform1F("u_FOV", mc.gameSettings.fovSetting); - }); - - DepthTextureUtil.unBindDepthTexture(); - - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableBlend(); - GlStateManager.depthMask(true); - - } - } -} diff --git a/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/BlockStateMatcher.java b/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/BlockStateMatcher.java deleted file mode 100644 index 1848972b122..00000000000 --- a/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/BlockStateMatcher.java +++ /dev/null @@ -1,71 +0,0 @@ -package gregtech.common.terminal.app.worldprospector.matcher; - -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.IBlockState; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -public class BlockStateMatcher implements IMatcher { - - private final IBlockState reference; - private final List> properties = new ArrayList<>(); - private final int meta; - private final int color; - - public BlockStateMatcher(IBlockState state, int color) { - this.reference = state; - for (final IProperty property : state.getPropertyKeys()) { - if (Objects.equals(property.getName(), "variant") || // Vanilla Minecraft. - Objects.equals(property.getName(), "type") || // E.g. ThermalFoundation, TiCon, IC2, Immersive - // Engineering. - Objects.equals(property.getName(), "ore") || // E.g. BigReactors. - Objects.equals(property.getName(), "oretype") || // E.g. DeepResonance. - Objects.equals(property.getName(), "stone_type") || // E.g. gtce. - Objects.equals(property.getName(), "basictype")) { // Galacticraft. - properties.add(property); - } - } - this.meta = reference.getBlock().getMetaFromState(reference); - this.color = color; - } - - public boolean match(final IBlockState state) { - if (reference.getBlock() != state.getBlock()) { - return false; - } - - if (state.getBlock().getMetaFromState(state) != meta) { - return false; - } - - if (properties.isEmpty()) { - return true; - } - - for (final IProperty property : properties) { - if (!state.getPropertyKeys().contains(property)) { - continue; - } - if (!Objects.equals(state.getValue(property), reference.getValue(property))) { - return false; - } - } - - return true; - } - - @Override - public int getColor() { - return color; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof BlockStateMatcher) { - return match(((BlockStateMatcher) obj).reference); - } - return super.equals(obj); - } -} diff --git a/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/IMatcher.java b/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/IMatcher.java deleted file mode 100644 index c96a6c22c36..00000000000 --- a/src/main/java/gregtech/common/terminal/app/worldprospector/matcher/IMatcher.java +++ /dev/null @@ -1,17 +0,0 @@ -package gregtech.common.terminal.app.worldprospector.matcher; - -import net.minecraft.block.state.IBlockState; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/09/16 - * @Description: - */ -public interface IMatcher { - - boolean match(final IBlockState state); - - int getColor(); -} diff --git a/src/main/java/gregtech/common/terminal/component/ClickComponent.java b/src/main/java/gregtech/common/terminal/component/ClickComponent.java deleted file mode 100644 index 24031ee4c73..00000000000 --- a/src/main/java/gregtech/common/terminal/component/ClickComponent.java +++ /dev/null @@ -1,46 +0,0 @@ -package gregtech.common.terminal.component; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.terminal.os.menu.IMenuComponent; - -import java.util.function.Consumer; - -public class ClickComponent implements IMenuComponent { - - private IGuiTexture icon; - private String hoverText; - private Consumer consumer; - - public ClickComponent setIcon(IGuiTexture icon) { - this.icon = icon; - return this; - } - - public ClickComponent setHoverText(String hoverText) { - this.hoverText = hoverText; - return this; - } - - public ClickComponent setClickConsumer(Consumer consumer) { - this.consumer = consumer; - return this; - } - - @Override - public IGuiTexture buttonIcon() { - return icon; - } - - @Override - public String hoverText() { - return hoverText; - } - - @Override - public void click(Widget.ClickData clickData) { - if (consumer != null) { - consumer.accept(clickData); - } - } -} diff --git a/src/main/java/gregtech/common/terminal/component/setting/GuiTextureSetter.java b/src/main/java/gregtech/common/terminal/component/setting/GuiTextureSetter.java deleted file mode 100644 index add78dfa301..00000000000 --- a/src/main/java/gregtech/common/terminal/component/setting/GuiTextureSetter.java +++ /dev/null @@ -1,33 +0,0 @@ -package gregtech.common.terminal.component.setting; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.widgets.WidgetGroup; - -import java.util.function.Consumer; - -public class GuiTextureSetter extends WidgetGroup implements ISetting { - - private final String name; - private Consumer updated; - - public GuiTextureSetter(String name, Consumer updated) { - this.name = name; - this.updated = updated; - } - - @Override - public String getName() { - return name; - } - - @Override - public IGuiTexture getIcon() { - return null; - } - - @Override - public Widget getWidget() { - return null; - } -} diff --git a/src/main/java/gregtech/common/terminal/component/setting/ISetting.java b/src/main/java/gregtech/common/terminal/component/setting/ISetting.java deleted file mode 100644 index 2b3f2fa05d2..00000000000 --- a/src/main/java/gregtech/common/terminal/component/setting/ISetting.java +++ /dev/null @@ -1,13 +0,0 @@ -package gregtech.common.terminal.component.setting; - -import gregtech.api.gui.Widget; -import gregtech.api.gui.resources.IGuiTexture; - -public interface ISetting { - - String getName(); - - IGuiTexture getIcon(); - - Widget getWidget(); -} diff --git a/src/main/java/gregtech/common/terminal/component/setting/IWidgetSettings.java b/src/main/java/gregtech/common/terminal/component/setting/IWidgetSettings.java deleted file mode 100644 index e3affc80eb1..00000000000 --- a/src/main/java/gregtech/common/terminal/component/setting/IWidgetSettings.java +++ /dev/null @@ -1,8 +0,0 @@ -package gregtech.common.terminal.component.setting; - -import gregtech.api.terminal.util.TreeNode; - -public interface IWidgetSettings { - - TreeNode getSettings(); -} diff --git a/src/main/java/gregtech/common/terminal/component/setting/SettingComponent.java b/src/main/java/gregtech/common/terminal/component/setting/SettingComponent.java deleted file mode 100644 index 1f011df5a03..00000000000 --- a/src/main/java/gregtech/common/terminal/component/setting/SettingComponent.java +++ /dev/null @@ -1,29 +0,0 @@ -package gregtech.common.terminal.component.setting; - -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.Widget; -import gregtech.api.gui.widgets.WidgetGroup; -import gregtech.api.terminal.gui.widgets.TreeListWidget; -import gregtech.api.terminal.os.menu.IMenuComponent; - -public class SettingComponent extends WidgetGroup implements IMenuComponent { - - private Widget settingWidget; - - public SettingComponent(IWidgetSettings settings) { - this.addWidget(new TreeListWidget<>(0, 0, 130, 232, settings.getSettings(), (selected) -> { - if (selected.getContent() != null) { - if (settingWidget != null) { - removeWidget(settingWidget); - } - settingWidget = selected.getContent().getWidget(); - if (settingWidget != null) { - addWidget(settingWidget); - } - } - }).setContentIconSupplier(ISetting::getIcon) - .setContentNameSupplier(ISetting::getName) - .setNodeTexture(GuiTextures.BORDERED_BACKGROUND) - .setLeafTexture(GuiTextures.SLOT_DARKENED)); - } -} diff --git a/src/main/java/gregtech/common/terminal/hardware/BatteryHardware.java b/src/main/java/gregtech/common/terminal/hardware/BatteryHardware.java deleted file mode 100644 index b9343e2df94..00000000000 --- a/src/main/java/gregtech/common/terminal/hardware/BatteryHardware.java +++ /dev/null @@ -1,202 +0,0 @@ -package gregtech.common.terminal.hardware; - -import gregtech.api.GTValues; -import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.capability.IElectricItem; -import gregtech.api.capability.impl.ElectricItem; -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.terminal.hardware.IHardwareCapability; -import gregtech.common.items.MetaItems; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.capabilities.Capability; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiConsumer; - -/** - * Created with IntelliJ IDEA. - * - * @Author: KilaBash - * @Date: 2021/08/28 - * @Description: - */ -public class BatteryHardware extends Hardware implements IElectricItem, IHardwareCapability { - - protected final List> listeners = new ArrayList<>(); - - public BatteryHardware() {} - - @Override - public boolean isHardwareAdequate(Hardware demand) { - return demand instanceof BatteryHardware && ((BatteryHardware) demand).getTier() <= this.getTier() && - this.getCharge() > 0; - } - - @Override - public String addInformation() { - return GTValues.VN[getTier()]; - } - - @Override - public Hardware createHardware(ItemStack itemStack) { - return new BatteryHardware(); - } - - @Override - public NBTTagCompound acceptItemStack(ItemStack itemStack) { - IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); - if (electricItem == null || !electricItem.canProvideChargeExternally() || !electricItem.chargeable()) { - return null; - } - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("maxCharge", electricItem.getMaxCharge()); - nbt.setLong("charge", electricItem.getCharge()); - nbt.setInteger("tier", electricItem.getTier()); - return nbt; - } - - @Override - public String getRegistryName() { - return "battery"; - } - - @Override - public IGuiTexture getIcon() { - if (!hasHW()) { - return super.getIcon(); - } - return new ItemStackTexture(isCreative() ? MetaItems.ULTIMATE_BATTERY.getInfiniteChargedStack() : getItem()); - } - - @Override - public void addChargeListener(BiConsumer chargeListener) { - listeners.add(chargeListener); - } - - public void setCharge(long change) { - getNBT().setLong("charge", change); - listeners.forEach(l -> l.accept(provider.getItemStack(), change)); - } - - @Override - public long getTransferLimit() { - return GTValues.V[getTier()]; - } - - @Override - public long getMaxCharge() { - return isCreative() ? Long.MAX_VALUE : getNBT().getLong("maxCharge"); - } - - public long getCharge() { - return isCreative() ? Long.MAX_VALUE : getNBT().getLong("charge"); - } - - @Override - public boolean canProvideChargeExternally() { - return false; - } - - @Override - public boolean chargeable() { - return true; - } - - @Override - public long charge(long amount, int chargerTier, boolean ignoreTransferLimit, boolean simulate) { - if (provider.getItemStack().getCount() != 1) { - return 0L; - } - if ((chargerTier >= getTier()) && amount > 0L) { - long canReceive = getMaxCharge() - getCharge(); - if (!ignoreTransferLimit) { - amount = Math.min(amount, getTransferLimit()); - } - long charged = Math.min(amount, canReceive); - if (!simulate) { - setCharge(getCharge() + charged); - } - return charged; - } - return 0; - } - - @Override - public long discharge(long amount, int chargerTier, boolean ignoreTransferLimit, boolean externally, - boolean simulate) { - if (provider.getItemStack().getCount() != 1) { - return 0L; - } - if ((!externally || amount == Long.MAX_VALUE) && (chargerTier >= getTier()) && amount > 0L) { - if (!ignoreTransferLimit) { - amount = Math.min(amount, getTransferLimit()); - } - long charge = getCharge(); - long discharged = Math.min(amount, charge); - if (!simulate) { - setCharge(charge - discharged); - } - return discharged; - } - return 0; - } - - @Override - public int getTier() { - return isCreative() ? GTValues.V.length - 1 : getNBT().getInteger("tier"); - } - - @Override - public boolean hasCapability(@NotNull Capability capability) { - return capability == GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM; - } - - @Nullable - @Override - public T getCapability(@NotNull Capability capability) { - return capability == GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM ? - GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM.cast(this) : null; - } - - @Override - public ItemStack onHardwareRemoved(ItemStack itemStack) { - IElectricItem item = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); - if (item instanceof ElectricItem) { - ((ElectricItem) item).setCharge(getCharge()); - } - return itemStack; - } - - public static class BatteryDemand extends BatteryHardware { - - public final int tier; - public final long cost; - - public BatteryDemand(int tier, long cost) { - this.tier = tier; - this.cost = cost; - } - - @Override - public int getTier() { - return tier; - } - - @Override - public long getCharge() { - return this.getCost(); - } - - public long getCost() { - return cost; - } - } -} diff --git a/src/main/java/gregtech/common/terminal/hardware/DeviceHardware.java b/src/main/java/gregtech/common/terminal/hardware/DeviceHardware.java deleted file mode 100644 index ccfa77d077d..00000000000 --- a/src/main/java/gregtech/common/terminal/hardware/DeviceHardware.java +++ /dev/null @@ -1,142 +0,0 @@ -package gregtech.common.terminal.hardware; - -import gregtech.api.gui.resources.IGuiTexture; -import gregtech.api.gui.resources.ItemStackTexture; -import gregtech.api.items.metaitem.MetaItem; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.common.items.MetaItems; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class DeviceHardware extends Hardware { - - private final int slot; - - public DeviceHardware(int slot) { - this.slot = slot; - } - - @Override - public String getRegistryName() { - return "device" + slot; - } - - @SideOnly(Side.CLIENT) - @Override - public String getLocalizedName() { - return I18n.format("terminal.hw.device") + " " + slot; - } - - @Override - protected Hardware createHardware(ItemStack itemStack) { - return new DeviceHardware(slot); - } - - @Override - public NBTTagCompound acceptItemStack(ItemStack itemStack) { - for (DEVICE device : DEVICE.values()) { - if (device.itemStack.isItemEqual(itemStack)) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("d", device.ordinal()); - return nbt; - } - } - return null; - } - - @Override - public IGuiTexture getIcon() { - if (!hasHW()) { - return super.getIcon(); - } - if (isCreative()) { - return new ItemStackTexture(DEVICE.values()[slot % DEVICE.values().length].itemStack); - } - return new ItemStackTexture(getDevice().itemStack); - } - - @Override - public boolean isHardwareAdequate(Hardware demand) { - if (demand instanceof DeviceHardware && isCreative()) { - return DEVICE.values()[slot % DEVICE.values().length] == ((DeviceHardware) demand).getDevice(); - } - return demand instanceof DeviceHardware && ((DeviceHardware) demand).getDevice() == this.getDevice(); - } - - @Override - public String addInformation() { - if (isCreative()) { - return DEVICE.values()[slot % DEVICE.values().length].itemStack.getDisplayName(); - } - return getDevice().itemStack.getDisplayName(); - } - - public DEVICE getDevice() { - return DEVICE.values()[getNBT().getInteger("d") % DEVICE.values().length]; - } - - public enum DEVICE { - - PROSPECTOR_LV(MetaItems.PROSPECTOR_LV, "prospector"), - PROSPECTOR_HV(MetaItems.PROSPECTOR_HV, "advanced_prospector"), - WIRELESS(MetaItems.WIRELESS, "wireless"), - CAMERA(MetaItems.CAMERA, "camera"), - - // FIELD GEN - FIELD_GENERATOR_UV(MetaItems.FIELD_GENERATOR_UV, "field_generator"), - - // SOLAR - SOLAR_LV(MetaItems.COVER_SOLAR_PANEL_LV, "solar_lv"); - - ItemStack itemStack; - String name; - - DEVICE(ItemStack itemStack, String name) { - this.itemStack = itemStack; - this.name = name; - } - - DEVICE(MetaItem.MetaValueItem metaItem, String name) { - this.itemStack = metaItem.getStackForm(); - this.name = name; - } - - public static DEVICE fromString(String name) { - for (DEVICE device : values()) { - if (device.name.equals(name.toLowerCase())) { - return device; - } - } - return null; - } - } - - public static class DeviceDemand extends DeviceHardware { - - private final DEVICE device; - - public DeviceDemand(DEVICE device) { - super(0); - this.device = device; - } - - public DeviceDemand(String device) { - super(0); - this.device = DEVICE.fromString(device); - } - - @Override - public String getLocalizedName() { - return I18n.format("terminal.hw.device"); - } - - @Override - public DEVICE getDevice() { - return device; - } - } -} diff --git a/src/main/java/gregtech/core/network/packets/PacketProspecting.java b/src/main/java/gregtech/core/network/packets/PacketProspecting.java index 47a1780f930..babd70b0db6 100644 --- a/src/main/java/gregtech/core/network/packets/PacketProspecting.java +++ b/src/main/java/gregtech/core/network/packets/PacketProspecting.java @@ -1,6 +1,6 @@ package gregtech.core.network.packets; -import gregtech.common.terminal.app.prospector.ProspectorMode; +import gregtech.common.gui.widget.prospector.ProspectorMode; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; diff --git a/src/main/java/gregtech/integration/crafttweaker/CraftTweakerModule.java b/src/main/java/gregtech/integration/crafttweaker/CraftTweakerModule.java index 37fb6535fe5..f66293465e9 100644 --- a/src/main/java/gregtech/integration/crafttweaker/CraftTweakerModule.java +++ b/src/main/java/gregtech/integration/crafttweaker/CraftTweakerModule.java @@ -8,13 +8,11 @@ import gregtech.integration.IntegrationModule; import gregtech.integration.IntegrationSubmodule; import gregtech.integration.crafttweaker.recipe.MetaItemBracketHandler; -import gregtech.integration.crafttweaker.terminal.CTTerminalRegistry; import gregtech.modules.GregTechModules; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -47,11 +45,6 @@ public void preInit(FMLPreInitializationEvent event) { CT_OREDICT_ITEM.setRegistryName("meta_oredict_item_ct"); } - @Override - public void postInit(FMLPostInitializationEvent event) { - CTTerminalRegistry.register(); - } - @Override public void loadComplete(FMLLoadCompleteEvent event) { MetaItemBracketHandler.clearComponentRegistry(); diff --git a/src/main/java/gregtech/integration/crafttweaker/terminal/CTTerminalRegistry.java b/src/main/java/gregtech/integration/crafttweaker/terminal/CTTerminalRegistry.java deleted file mode 100644 index 6b3989d8447..00000000000 --- a/src/main/java/gregtech/integration/crafttweaker/terminal/CTTerminalRegistry.java +++ /dev/null @@ -1,184 +0,0 @@ -package gregtech.integration.crafttweaker.terminal; - -import gregtech.api.terminal.TerminalRegistry; -import gregtech.api.terminal.hardware.Hardware; -import gregtech.api.util.GTLog; -import gregtech.common.terminal.hardware.BatteryHardware; -import gregtech.common.terminal.hardware.DeviceHardware; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.EnumHelper; - -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.minecraft.CraftTweakerMC; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -@ZenClass("mods.gregtech.TerminalRegistry") -@ZenRegister -@SuppressWarnings("unused") -public class CTTerminalRegistry { - - private static List ctAppRegistryBuilders = new LinkedList<>(); - - @ZenMethod - public static CTAppRegistryBuilder createAppRegistryBuilder(String appName) { - return new CTAppRegistryBuilder(appName); - } - - @ZenMethod - public static void registerDevice(IItemStack device, String name) { - ItemStack itemStack = CraftTweakerMC.getItemStack(device).copy(); - if (!itemStack.isEmpty()) { - itemStack.setCount(1); - EnumHelper.addEnum(DeviceHardware.DEVICE.class, name.toUpperCase(), - new Class[] { ItemStack.class, String.class }, itemStack, name.toLowerCase()); - } - } - - public static void registerAPP(CTAppRegistryBuilder builder) { - if (TerminalRegistry.APP_REGISTER.containsKey(builder.appName)) { - if (builder.isDefaultApp != null) { - TerminalRegistry.DEFAULT_APPS.remove(builder.appName); - if (builder.isDefaultApp) { - TerminalRegistry.DEFAULT_APPS.add(builder.appName); - } - } - if (!builder.hardware.isEmpty()) { - int maxTier = TerminalRegistry.APP_HW_DEMAND.get(builder.appName).length; - List[] hardware = new List[maxTier]; - for (int i = 0; i < maxTier; i++) { - List list = new LinkedList<>(); - if (builder.battery.containsKey(i)) { - list.add(builder.battery.get(i)); - } else if (builder.battery.containsKey(-1)) { - list.add(builder.battery.get(-1)); - } - if (builder.hardware.containsKey(i)) { - list.addAll(builder.hardware.get(i)); - } else if (builder.hardware.containsKey(-1)) { - list.addAll(builder.hardware.get(-1)); - } - if (list.size() > 0) { - hardware[i] = list; - } - } - TerminalRegistry.APP_HW_DEMAND.put(builder.appName, hardware); - } - if (!builder.upgrade.isEmpty()) { - int maxTier = TerminalRegistry.APP_UPGRADE_CONDITIONS.get(builder.appName).length; - List[] upgrade = new List[maxTier]; - if (builder.upgrade.containsKey(-1)) { // register for all tier - Arrays.fill(upgrade, builder.upgrade.get(-1)); - } - builder.upgrade.forEach((tier, listBuilder) -> { // register for specific tier - if (tier != -1 && tier < maxTier) { - upgrade[tier] = listBuilder; - } - }); - TerminalRegistry.APP_UPGRADE_CONDITIONS.put(builder.appName, upgrade); - } - } else { - GTLog.logger.error("Not found the app {}, while load the CT script", builder.appName); - } - } - - public static void register() { - ctAppRegistryBuilders.forEach(CTTerminalRegistry::registerAPP); - ctAppRegistryBuilders = null; - } - - @ZenClass("mods.gregtech.AppRegistryBuilder") - @ZenRegister - public static class CTAppRegistryBuilder { - - final String appName; - Boolean isDefaultApp; - Map battery; - Map> hardware; - Map> upgrade; - - public CTAppRegistryBuilder(String appName) { - this.appName = appName; - this.battery = new HashMap<>(); - this.hardware = new HashMap<>(); - this.upgrade = new HashMap<>(); - } - - @ZenMethod - public CTAppRegistryBuilder isDefaultApp(boolean isDefaultApp) { - this.isDefaultApp = isDefaultApp; - return this; - } - - @ZenMethod - public CTAppRegistryBuilder battery(int batteryTier, long cost) { - battery.put(-1, new BatteryHardware.BatteryDemand(batteryTier, cost)); - return this; - } - - @ZenMethod - public CTAppRegistryBuilder battery(int tier, int batteryTier, long cost) { - battery.put(tier, new BatteryHardware.BatteryDemand(batteryTier, cost)); - return this; - } - - @ZenMethod - public CTAppRegistryBuilder device(String... device) { - Hardware[] hw = Arrays.stream(device).map(DeviceHardware.DeviceDemand::new) - .filter(deviceDemand -> deviceDemand.getDevice() != null).toArray(Hardware[]::new); - hardware(hw); - return this; - } - - @ZenMethod - public CTAppRegistryBuilder device(int tier, String... device) { - this.hardware(tier, Arrays.stream(device).map(DeviceHardware.DeviceDemand::new) - .filter(deviceDemand -> deviceDemand.getDevice() != null).toArray(Hardware[]::new)); - return this; - } - - private void hardware(Hardware... hardware) { - hardware(-1, hardware); - } - - private void hardware(int tier, Hardware... hardware) { - this.hardware.put(tier, new LinkedList<>()); - for (Hardware hw : hardware) { - this.hardware.get(tier).add(hw); - } - } - - @ZenMethod - public CTAppRegistryBuilder upgrade(IItemStack... upgrades) { - upgrade(-1, upgrades); - return this; - } - - @ZenMethod - public CTAppRegistryBuilder upgrade(int tier, IItemStack... upgrades) { - this.upgrade.put(tier, new LinkedList<>()); - for (ItemStack up : Arrays.stream(upgrades).map(CraftTweakerMC::getItemStack) - .filter(itemStack -> !itemStack.isEmpty()).toArray(ItemStack[]::new)) { - this.upgrade.get(tier).add(up); - } - return this; - } - - @ZenMethod - public void build() { - if (ctAppRegistryBuilders == null) { - registerAPP(this); - } else { - ctAppRegistryBuilders.add(this); - } - } - } -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/activity_detector.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/activity_detector.json deleted file mode 100644 index 6e5523990e7..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/activity_detector.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Activity Detector", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:302" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/advanced_activity_detector.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/advanced_activity_detector.json deleted file mode 100644 index d6e5d2faf81..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/advanced_activity_detector.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Advanced Activity Detector", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:303" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/computer_monitor.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/computer_monitor.json deleted file mode 100644 index 9557d8c2c78..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/computer_monitor.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Computer Monitorc", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:307" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/conveyor.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/conveyor.json deleted file mode 100644 index 11e8a651db3..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/conveyor.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Conveyor Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:157" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/crafting_table.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/crafting_table.json deleted file mode 100644 index c6fd856c2d0..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/crafting_table.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Crafting Table Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:308" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/digital_interface_cover.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/digital_interface_cover.json deleted file mode 100644 index 3e9b91d7b99..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/digital_interface_cover.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "metaitem": "cover.digital", - "section": "Covers", - "title": "Digital Interface Cover", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "§cDigital Interface Cover §ris a new cover, hereinafter referred to as the §lDIC§r.\n" - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 312, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 313, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "§lContents:" - ] - }, - { - "type": "textbox", - "link": "introduction", - "content": [ - "1. §9Introduction" - ] - }, - { - "type": "textbox", - "link": "fluid", - "content": [ - "2. §9Fluid Mode" - ] - }, - { - "type": "textbox", - "link": "item", - "content": [ - "3. §r§9Item Mode" - ] - }, - { - "type": "textbox", - "link": "energy", - "content": [ - "4. §9Energy Mode" - ] - }, - { - "type": "textbox", - "link": "machine", - "content": [ - "5. §9Machine Mode" - ] - }, - { - "type": "textbox", - "link": "proxy", - "content": [ - "6. §9Proxy Mode" - ] - }, - { - "type": "textbox", - "link": "wireless", - "content": [ - "7. §9Wireless Cover" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "introduction", - "content": [ - "§lIntroduction:" - ] - }, - { - "type": "textbox", - "content": [ - "You can place it at any side of machines, including the front side. It will automatically detect the machine and display the information of the machine.\n\nUsing the Screwdriver right click the §4DIC§r to open GUI.\n\nThere are five modes supported: §lFluid, Item, Energy, Machine, and Proxy§r.\n\nIn addition to the GUI, you can interact with DIC directly by hand.Try exploring on your own." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "fluid", - "content": [ - "§lFluid Mode:" - ] - }, - { - "type": "textbox", - "content": [ - "monitor and interact(fill or drain) with fluids." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397364-8d212680-6b39-11eb-9152-b91f8f559ed6.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "item", - "content": [ - "§lItem Mode:" - ] - }, - { - "type": "textbox", - "content": [ - "monitor and interact(fill or extract) with items." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397608-c8235a00-6b39-11eb-95ad-77e4e5bc5d8b.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "energy", - "content": [ - "§lEnergy Mode:" - ] - }, - { - "type": "textbox", - "content": [ - "monitor the Energy usage. (monitoring energy stored, input and output per second)." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397946-1a647b00-6b3a-11eb-8680-52d13dd56e59.png", - "width": 190, - "height": 110 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "machine", - "content": [ - "§lMachine Mode:" - ] - }, - { - "type": "textbox", - "content": [ - "monitor and interact (stop or active) with workable machines. (low power, is working, working progress, isActive)." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107398096-42ec7500-6b3a-11eb-8c26-b708ae183c3d.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "proxy", - "content": [ - "§lProxy Mode:" - ] - }, - { - "type": "textbox", - "content": [ - "should be used with the §1§lCentral Monitor§r." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107856228-c1f6eb80-6e61-11eb-8098-454ea7133ca1.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "wireless", - "content": [ - "§lWireless:" - ] - }, - { - "type": "textbox", - "content": [ - "The wireless cover only has §4proxy Mode§r, allowing the §1§lCentral Monitor§r to access the cover remotely. Bind it remotely by right-clicking on a Central Monitor, and clear the binding by shift-right-clicking on Air." - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ender_fluid_link.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ender_fluid_link.json deleted file mode 100644 index d88198015f9..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ender_fluid_link.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Ender Fluid Link Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:311" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/energy_detector.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/energy_detector.json deleted file mode 100644 index 8d5fc2e475b..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/energy_detector.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Energy Detector", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:306" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_detector.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_detector.json deleted file mode 100644 index 9562d8b3b92..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_detector.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Fluid Detector", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:304" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_filter.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_filter.json deleted file mode 100644 index 6c60268ca91..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_filter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Fluid Filter", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:290" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_regulator.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_regulator.json deleted file mode 100644 index 163bed84c5a..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/fluid_regulator.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Fluid Regulator Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:247" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/infinite_water.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/infinite_water.json deleted file mode 100644 index c7c7301571b..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/infinite_water.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Infinite Water Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:310" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_detector.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_detector.json deleted file mode 100644 index 71ec3aa4ed6..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_detector.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Item Detector", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:305" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_filter.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_filter.json deleted file mode 100644 index 52d6678b331..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/item_filter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Item Filter", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:291" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/machine_controller.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/machine_controller.json deleted file mode 100644 index a930161ac5c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/machine_controller.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Machine Controller", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:301" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ore_dictionary_filter.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ore_dictionary_filter.json deleted file mode 100644 index d08d8d18401..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/ore_dictionary_filter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Ore Dictionary Filter", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:292" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/pump.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/pump.json deleted file mode 100644 index c5f615d74cb..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/pump.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Pump Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:142" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/robot_arm.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/robot_arm.json deleted file mode 100644 index 28294c1190e..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/robot_arm.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Robot Arm Cover", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:187" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/shutter_module.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/shutter_module.json deleted file mode 100644 index db8644be3b4..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/shutter_module.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Shutter Module", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:309" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/smart_item_filter.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/smart_item_filter.json deleted file mode 100644 index b8c617b0b67..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/covers/smart_item_filter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Covers", - "title": "Smart Item Filter", - "stream": [], - "fixed": [], - "item": "gregtech:meta_item_1:293" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/axe.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/axe.json deleted file mode 100644 index 30e9c44f99a..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/axe.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Tools", - "title": "Axe", - "stream": [], - "fixed": [], - "item": "gregtech:meta_tool:3" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/buzzsaw.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/buzzsaw.json deleted file mode 100644 index 747a0c678e5..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/buzzsaw.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Tools", - "title": "Buzzsaw", - "stream": [], - "fixed": [], - "item": "gregtech:meta_tool:32" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/drill.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/drill.json deleted file mode 100644 index a8cdb41186e..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/drill.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Tools", - "title": "Drill", - "stream": [], - "fixed": [], - "item": "gregtech:meta_tool:20" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/file.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/file.json deleted file mode 100644 index e37a5a6437d..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/file.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Tools", - "title": "File", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6File§r is a tool that is only used for crafting recipes. No special uses unfortunately.\n\nLike most Gregtech tools, it can be repaired in an anvil." - ] - } - ], - "fixed": [], - "item": "gregtech:meta_tool:9" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/hammer.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/hammer.json deleted file mode 100644 index 466e74ee9b5..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/hammer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Tools", - "title": "Hammer", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Hammer§r is a tool mainly used in crafting recipes.\n\nHowever, it has one special use outside of crafting recipes. When Right Clicked on a machine, it will mute the sounds of the machine running. Simply Right Click again to unmute.\n\nLike most Gregtech tools, it can be repaired in an anvil." - ] - } - ], - "fixed": [], - "item": "gregtech:meta_tool:6" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/mining_hammer.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/mining_hammer.json deleted file mode 100644 index c83b8f534a8..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/mining_hammer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Tools", - "title": "Mining Hammer", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Mining Hammer§r is an Early Game alternative to the §6Drill§r, which does not require a source of power. It mines in a simple 3x3 area, and will mine in a 1x1 area when sneaking. Make sure to make some before going mining.\n\nLike most Gregtech tools, it can be repaired in an anvil." - ] - } - ], - "fixed": [], - "item": "gregtech:meta_tool:19" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/saw.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/saw.json deleted file mode 100644 index 0be14973fff..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/saw.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Tools", - "title": "Saw", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Saw§r is a Gregtech tool that is mainly using in crafting recipes, but has some special uses outside of crafting recipes.\n\nFirstly, it will harvest §1Ice§r and §1Packed Ice§r as if it had Silk Touch, dropping the actual items.\n\nSecondly, it will act like Shears when harvesting §1Leaves§r and §1Vines§r, meaning that the actual blocks will be dropped." - ] - } - ], - "fixed": [], - "item": "gregtech:meta_tool:5" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/screwdriver.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/screwdriver.json deleted file mode 100644 index f0b0125daca..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/screwdriver.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Tools", - "title": "Screwdriver", - "stream": [], - "fixed": [], - "item": "gregtech:meta_tool:11" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/sense.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/sense.json deleted file mode 100644 index a291d156b8c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/sense.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Tools", - "title": "Sense", - "stream": [], - "fixed": [], - "item": "gregtech:meta_tool:17" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/wrench.json b/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/wrench.json deleted file mode 100644 index 99a163904d9..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/en_us/tools/wrench.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "section": "Tools", - "title": "Wrench", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "The §6Wrench§r is one of the main tools in §1Gregtech§r and has several important uses.\n\nFirst, the Wrench can be the designated tool for breaking machines (Config option, default false). If a Wrench is not used to break the machine, it will break slower.\n\nSecondly, the Wrench can be used to set the output side for machines and multiblock components. Using the §4Machine Grid§r or just clicking on the desired face, Right Clicking with a Wrench will set the output face.\n\nRelated to the above, the Wrench can be used to set the Front Face of machines. Sneaking while Right Clicking (either directly on a face of the machine or using the machine grid) will change the front face of a machine, if it can be changed.\n\nIn addition to manipulating machines, wrenches are used for manipulating pipes. When Right Clicking on a pipe with a wrench, it will enable or disable the pipe connections to the corresponding face. When Sneaking while Right Clicking, pipes will have their travel routes blocked instead (Fluid Pipes only).\n\nLike most Gregtech tools, it can be repaired in an anvil." - ] - } - ], - "fixed": [], - "item": "gregtech:meta_tool:8" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/covers/digital_interface_cover.json b/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/covers/digital_interface_cover.json deleted file mode 100644 index 59fd56d2cad..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/covers/digital_interface_cover.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "metaitem": "cover.digital", - "section": "覆盖版", - "title": "数字化接口覆盖版", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "§c数字化接口覆盖版 §r是一个新覆盖版, 一下简称 §lDIC§r.\n" - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 312, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 313, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "§l目录:" - ] - }, - { - "type": "textbox", - "link": "introduction", - "content": [ - "1. §9介绍" - ] - }, - { - "type": "textbox", - "link": "fluid", - "content": [ - "2. §9流体模式" - ] - }, - { - "type": "textbox", - "link": "item", - "content": [ - "3. §r§9物品模式" - ] - }, - { - "type": "textbox", - "link": "energy", - "content": [ - "4. §9能源模式" - ] - }, - { - "type": "textbox", - "link": "machine", - "content": [ - "5. §9机器模式" - ] - }, - { - "type": "textbox", - "link": "proxy", - "content": [ - "6. §9代理模式" - ] - }, - { - "type": "textbox", - "link": "wireless", - "content": [ - "7. §9无线覆盖板" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "introduction", - "content": [ - "§l介绍:" - ] - }, - { - "type": "textbox", - "content": [ - "你可以将DIC放在任机器何面(包括正面)。它会自动检测机器并可视化信息。\n\n用扳手右键§4DIC§r 可以打开GUI。\n\n有五种模式: §l流体, 物品, 能源, 机器, 以及代理§r.\n\n此外,你也能直接用手和覆盖版进行交互。尝试着自己探索吧!" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "fluid", - "content": [ - "§l流体模式:" - ] - }, - { - "type": "textbox", - "content": [ - "监控并交互(填充或抽取)流体." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397364-8d212680-6b39-11eb-9152-b91f8f559ed6.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "item", - "content": [ - "§l物品模式:" - ] - }, - { - "type": "textbox", - "content": [ - "监控并交互(提取或存放)物品。" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397608-c8235a00-6b39-11eb-95ad-77e4e5bc5d8b.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "energy", - "content": [ - "§l能源模式:" - ] - }, - { - "type": "textbox", - "content": [ - "监控能源情况。 (监控能源储量,输入/输出的每秒流量)" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107397946-1a647b00-6b3a-11eb-8680-52d13dd56e59.png", - "width": 190, - "height": 110 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "machine", - "content": [ - "§l机器模式:" - ] - }, - { - "type": "textbox", - "content": [ - "监控并交互(暂停或启动)机器(是否低电量,是否工作,当前配方进度,是否启动)。" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107398096-42ec7500-6b3a-11eb-8c26-b708ae183c3d.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "proxy", - "content": [ - "§l代理模式:" - ] - }, - { - "type": "textbox", - "content": [ - "应该配合§1§l中央监控器§r使用。" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107856228-c1f6eb80-6e61-11eb-8098-454ea7133ca1.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "wireless", - "content": [ - "§l无线覆盖版:" - ] - }, - { - "type": "textbox", - "content": [ - "无线覆盖版只有 §4代理模式§r, 允许§1§l中央监控器§r 远程访问改覆盖版. 通过右键点击中央监控器来绑定,通过对空气shfit右键点击来取消绑定。" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/tools/wrench.json b/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/tools/wrench.json deleted file mode 100644 index 1a48f7fc6c3..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/items/zh_cn/tools/wrench.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "metaitem": "tool.wrench", - "section": "工具", - "title": "Wrench", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "扳扳这,扳扳那" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fontSize": 5, - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/machines/en_us/steam/steam_boiler_coal_bronze.json b/src/main/resources/assets/gregtech/terminal/guide/machines/en_us/steam/steam_boiler_coal_bronze.json deleted file mode 100644 index ea0ae9bbbdf..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/machines/en_us/steam/steam_boiler_coal_bronze.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "machine": "steam_boiler_coal_bronze", - "section": "Steam", - "title": "Small Steam Coal Boiler", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "Wrench this, wrench that" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fontSize": 5, - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_fluid_drilling_plant.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_fluid_drilling_plant.json deleted file mode 100644 index 20f7045ceac..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_fluid_drilling_plant.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Advanced Fluid Drilling Plant", - "stream": [ - { - "type": "textbox", - "content": [ - "§oExtreme is very apprioriate this time around, and you will see why.§r\n\nAt the cost of 4x the drilling Power, the §3Advanced Fluid Drilling Rig§r will be gaining §616x the output§r in Fluid.\nThe depletion of veins is also halved. This means you will get a total of §632x§r as much Oil (or whatever fluid) from a bedrock fluid vein until depletion!\n\nEven when depleted, you can still use this and be very power positive.\n\nOne single §3Advanced Fluid Drilling Rig§r should be enough to supply Power for a base up to §dLuV§r Age and possibly beyond!\n\nAs a brief §9reminder§r:\n§9-§r §aLight Oil§r can be used for §dLPG§r and §dMethane§r, to run in §3Large Gas Turbines§r.\n§9-§r §aOil§r can be used for §dDiesel§r and §dCetane-Boosted Diesel§r, to run in §3Large Combustion Engines§r.\n§9-§r §aHeavy Oil§r can be used for §dNitrobenzene§r, to run in §3Large Gas Turbines§r." - ] - } - ], - "fixed": [], - "metatileentity": "fluid_drilling_rig.hv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_processing_array.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_processing_array.json deleted file mode 100644 index 2ffe5eb1b67..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/advanced_processing_array.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Electric", - "title": "Advanced Processing Array", - "stream": [], - "fixed": [], - "metatileentity": "advanced_processing_array" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/assembly_line.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/assembly_line.json deleted file mode 100644 index 379c8bca589..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/assembly_line.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Assembly Line", - "stream": [ - { - "type": "textbox", - "content": [ - "§oNo. The Assembly Line is not just a big Assembler, it\u0027s a lot more than that!\nYou can also call it the Assline. Do not feel guilty.§r\n\nMaking §dLuV§r Components will require more work.\nThe §3Assembly Line§r is an entry point towards late game.\n\nThis Multiblock has a §cvariable size§r. Each §3ULV Input Bus§r accepts a different stack of items.\nYou will want to build this with a size of §d10§r to get started, or of a size of §d14§r to accept all possible recipes.\n\nRecipes require §aFluids§r, so it is a good idea to keep the §3Input Hatches§r permanently filled with §dSoldering Alloy§r, §dLubricant§r and §dStyrene-Butadienne Rubber§r.\n\nMy recommendation of Assembly Line §4automation§r goes as follows:\nHave your Interface face an §3Item P2P§r. Set two output P2Ps, into the first §3Input Bus§r, and into §3Item Pipes§r. Make your Item Pipes connect to all Input Buses including the first.\nDo not forget §dBlocking Mode§r, and you have got yourself an easy automation! This will also work flawlessly once we inevitably add ordered item inputs.\n\n\n§bLots of Lore:§r GT5\u0027s Assembly Line is a massive project to work towards, even more so than here. You are required to scan items to put their construction data into a Data Stick. That Data Stick is then required to fit into a Data Hatch which has limited slots on the Assembly Line.\n\nThe recipe could only be viewed by printing a book with the Data Stick! It was then made to display in NEI once you acquire the item.\nTecTech made a nice machine which acts as a recipe viewer for the Data Stick (this mod is so great...).\n\nFurthermore, Item and Fluid inputs are required to be ordered the same way as the recipe indicates it. This makes automation of the Assembly Line a nice challenge which can be solved using other mods, redstone, GT item pipes... you pick it.\n\nWe are planning to port some of the GT5 features, as the Assembly Line §lshould be a challenge§r for the player." - ] - } - ], - "fixed": [], - "metatileentity": "assembly_line" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_fluid_drilling_rig.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_fluid_drilling_rig.json deleted file mode 100644 index e504de906ab..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_fluid_drilling_rig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Basic Fluid Drilling Rig", - "stream": [ - { - "type": "textbox", - "content": [ - "§oFinally, Fluid Drilling Rigs in GTCEu!§r\n\nIt is quite an investment to get to run a §3Fluid Drilling Rig§r, but it is by far the most prominent §6source of Oil§r.\nIt pumps fluids from underneath Bedrock. Note that the fluids aren\u0027t actually there, instead they are simulated.\n\nFluid veins are stored within regions of §48x8 chunks§r. Each vein has a different fluid, but they are mostly types Oil.\nYou are not able to do prospection for fluid veins §oyet§r, this will come in the §6HV§r Age.\n\nEach vein generates with a different base yield. This is typically between §d150L§r to §d300L per second§r.\n\nWhen drained, fluid veins will slowly deplete. This will cause the fluid yield to decrease over time, until it reaches its depletion yield. At that point you should move the Rig to somewhere else.\nA §3Basic Fluid Drilling Rig§r will last for 100,000 operations (with 1 second per operation) until depletion. This is enough for §6well over 10,000§r buckets of Oil. Higher tier Rigs will massively increase the yield, while also decreasing the depletion rate.\n\n\nWhat you can find in the §2Overworld§r:\n§9Oil:§r richer in §aLight Fuel§r, the most appreciated variant.\n§9Light Oil:§r richer in §aRefinery Gas§r, usable for power.\n§9Heavy Oil:§r richer in §aHeavy Fuel§r, which has uses that are more niche.\n§9Raw Oil:§r essentially a less dense version of §aOil§r, the least appreciated.\n§9Natural Gas:§r grants §aRefinery Gas§r with no distillation required.\n§9Salt Water:§r grants §aSodium§r and §aChlorine§r, useful later.\n\n§rWhat you can find in the §cNether§r:\n§9Natural Gas:§r grants §aRefinery Gas§r but with higher yield than the Overworld vein.\n§9Lava:§r you know what this is.\n\n\nFor starters you may have to tap randomly until you find something you like. Whatever you pump can be used to refuel your Fluid Rig." - ] - } - ], - "fixed": [], - "metatileentity": "fluid_drilling_rig.mv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_ore_drilling_plant.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_ore_drilling_plant.json deleted file mode 100644 index 200af4c7c9f..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/basic_ore_drilling_plant.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Basic Ore Drilling Plant", - "stream": [ - { - "type": "textbox", - "content": [ - "A completely §doptional§r Multiblock.\n\nThe §3Larger Miner§r is ridiculously good to collect ores from veins!\n\nOres are mined as if they were §amacerated§r, but they yield §6three times§r as many §dCrushed ores§r.\n\nYou will need §aDrilling Fluid§r automation to run this.\n\nYou might also want to use a §3Quantum Tunnel§r from AE2 and §3GTEU P2P Tunnels§r to transfer the items and to power it up.\n\n\n§bLore:§r There were some interesting side effects from porting this over from Gregicality, as the multiblock originated from GregTech 5... It\u0027s not perfect, as there isn\u0027t really any advantage on upgrading this miner to the advanced versions. We were thinking of rebalancing the energy costs and yield per tier, so there may be rework for this miner at some point!" - ] - } - ], - "fixed": [], - "metatileentity": "large_miner.ev" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/central_monitor.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/central_monitor.json deleted file mode 100644 index 1c130bac657..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/central_monitor.json +++ /dev/null @@ -1,183 +0,0 @@ -{ - "metatileentity": "central_monitor", - "section": "Electric", - "title": "Central Monitor", - "stream": [ - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1029, - "count": 1 - }, - { - "id": "gregtech:machine", - "damage": 1667, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "§lContents:" - ] - }, - { - "type": "textbox", - "link": "introduction", - "content": [ - "1. §9Introduction" - ] - }, - { - "type": "textbox", - "link": "fluid", - "content": [ - "2. §9How to build it" - ] - }, - { - "type": "textbox", - "link": "item", - "content": [ - "3. §r§9How to use it" - ] - }, - { - "type": "textbox", - "link": "energy", - "content": [ - "4. §9Plugins" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107856228-c1f6eb80-6e61-11eb-8098-454ea7133ca1.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "ref": "introduction", - "content": [ - "§lIntroduction" - ] - }, - { - "type": "textbox", - "content": [ - "§c§lCentral Monitor§r is a multi machine for monitor (visualization and interaction).\n\nIt can monitor the storage and status of machines, including all §9Digital Interface Cover§r§9\u0027s §rfeatures, and extends the capabilities of machines to the screen.\n\nIn addition, there are many plugins that support more advanced features." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "fluid", - "content": [ - "§lHow to build it?" - ] - }, - { - "type": "textbox", - "content": [ - "In order to build it, you need a §c§lCentral Monitor§r, several §c§lMonitor Screen§r, several §c§lSteel Metal Casing§r, and at least one §c§lEnergy Input Hatch§r.\n\nYou can build the screen from 3×2 to 14×9 (width × height). The default build height is 3, and you can adjust the screen height in the GUI before the structure formed.\n\n§lEnergy Cost:§r 50 EU/s for each screen." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "item", - "content": [ - "§lHow to use it?" - ] - }, - { - "type": "textbox", - "content": [ - "1. The back of §c§lCentral Monitor §rcan be connected to cables or wires, which can be connected to the energy net to monitor all the machines being proxied (A §9Digital Interface Cover§r set with proxy mode is placed at the connecting side between the machine and the wire. ). Besides, a §9Wireless Cover §rthat is boung to the central monitor can also be used, avoiding using cables.\n\n2. Right click the §c§lCentral Monitor §ror screwdriver right click the §c§lMonitor§r to open the GUI for settings." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "energy", - "content": [ - "§lPlugins" - ] - }, - { - "type": "textbox", - "content": [ - "Put the plugin into the plugin slot for use. For specific features, please refer to their guide pages. The following are the supported plugins.\n\n§4§lNote§r§4: §rsome plugins need to work with the proxy mode in the §c§lCentral Monitor§r, and the proxy mode is only used for plugins." - ] - }, - { - "type": "card", - "fill": -3745585, - "width": 170, - "height": 60, - "isShadow": true - }, - { - "type": "textbox", - "content": [ - "\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": 48, - "y": 930, - "width": 100, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 780, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 781, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 782, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 783, - "count": 1 - } - ] - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/distillation_tower.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/distillation_tower.json deleted file mode 100644 index cea752f1798..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/distillation_tower.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "section": "Electric", - "title": "Distillation Tower", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Distillation Tower§r is the Variable Layer Multiblock form of the Single Block Distilleries. While the Distillery can only have one output from an input fluid, the Distillation Tower can get all possible outputs from the input fluid.\n\nHowever, the Distillation Tower has a few additional limitations. Most importantly, The number of fluids that the Distillation Tower can output is equal to the number of layers of the of the Multiblock. Additionally, the Distillation Tower cannot be formed with Multifluid output hatches, and the fluid input hatch must be located on the bottom layer of the structure." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1005, - "count": 1 - } - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 10, - "y": 234, - "width": 177, - "height": 90, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 3, - "y": 269, - "width": 52, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1181, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": -1, - "y": 242, - "width": 61, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1196, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": -5, - "y": 296, - "width": 67, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1166, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 50, - "y": 241, - "width": 100, - "height": 20, - "content": [ - "Fluid Output Hatch. Exactly 1 per layer" - ] - }, - { - "type": "textbox", - "x": 49, - "y": 267, - "width": 100, - "height": 20, - "content": [ - "Fluid Input Hatch. Exactly 1" - ] - }, - { - "type": "textbox", - "x": 46, - "y": 294, - "width": 100, - "height": 20, - "content": [ - "Item Output bus. Optionally 1" - ] - } - ], - "metatileentity": "distillation_tower" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/electric_blast_furnace.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/electric_blast_furnace.json deleted file mode 100644 index 483e092d20c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/electric_blast_furnace.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "section": "Electric", - "title": "Electric Blast Furnace", - "stream": [ - { - "type": "textbox", - "isCenter": false, - "content": [ - "The §6Electric Blast Furnace§r is one of the main Multiblock Structures in Gregtech, and the main goal of earlygame progression." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1001, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Like all Gregtech Multiblocks, this structure is modular, and can be made up of many different combinations of Multiblock Parts." - ] - }, - { - "type": "card", - "fill": -3745585, - "width": 180, - "height": 190, - "isShadow": true - }, - { - "type": "textbox", - "content": [ - "The §6Electric Blast Furnace§r can form with any combination of blocks above. For example, if the desired recipe does not deal with fluids, neither of the fluid related hatches are required.\n\nOverclocking the Blast Furnace is as simple as ensuring the the Multiblock has 2 Energy Inputs, so 4 Amps of energy can be received, which will ensure that the mutliblock runs at the tier above the energy inputs.\n\nFor the Blast Furnace specifically, the Muffler Hatch needs to be placed at the center of the top layer, and must face upwards." - ] - }, - { - "type": "textbox", - "content": [ - "The §3Electric Blast Furnace§r, §3Pyrolyse Oven, §3Multi Smelter§r, and §3Cracking Unit§r all require heating Coils. But what are the advantages of using higher tier coils?\n\nThe latter three are quite straightforward. Higher tier coils reduce the §eprocessing time§r of the Pyrolyse Oven, reduce the §9energy usage§r of the Cracking Unit, and increase the §anumber of parallel smelts§r and reduce the §9energy usage§r of the Multi Smelter.\n\nFor the EBF, things get slightly more complicated. The EBF smelts items at a certain §dtemperature§r. This is mainly determined by the tier of heating coil used - §r§6Cupronickel§r is §d1800K§r, §bKanthal§r is §d2700K§r, etc. Additionally, starting from §6HV§r, each tier of energy adds §d100K§r to the temperature.\n\nEach EBF recipe has a certain base temperature, for example, §bAluminium§r is smelted at §d1700K§r. If the EBF temperature is not high enough, the recipe can\u0027t be done. If the EBF temperature is high enough, 2 different bonuses are applied:\n§9-§r For every §d900K§r above the recipe temperature, the amount of energy required is multiplied by §a0.95x§r, which stacks.\n§9-§r For every §d1800K§r above the recipe temperature, one additional overclock will be §6100% efficient§r; in other words, it will §5quadruple the speed§r, instead of doubling it." - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": 12, - "y": 159, - "width": 35, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1001, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 11, - "y": 182, - "width": 36, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1151, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 12, - "y": 206, - "width": 34, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1166, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 13, - "y": 228, - "width": 32, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1181, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 13, - "y": 251, - "width": 32, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1196, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 10, - "y": 273, - "width": 38, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1654, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 10, - "y": 296, - "width": 38, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1657, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 9, - "y": 319, - "width": 40, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1211, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 52, - "y": 159, - "width": 100, - "height": 20, - "content": [ - "The Controller block" - ] - }, - { - "type": "textbox", - "x": 52, - "y": 182, - "width": 100, - "height": 20, - "content": [ - "Item Input. Minimum 1" - ] - }, - { - "type": "textbox", - "x": 51, - "y": 206, - "width": 108, - "height": 10, - "content": [ - "Item Output. Minimum 1" - ] - }, - { - "type": "textbox", - "x": 51, - "y": 230, - "width": 125, - "height": 10, - "content": [ - "Fluid Input. No Minimum" - ] - }, - { - "type": "textbox", - "x": 49, - "y": 251, - "width": 131, - "height": 10, - "content": [ - "Fluid Output. No Minimum" - ] - }, - { - "type": "textbox", - "x": 48, - "y": 271, - "width": 135, - "height": 20, - "content": [ - "Maintence Hatch. Required based on Config. Exactly 1" - ] - }, - { - "type": "textbox", - "x": 48, - "y": 295, - "width": 100, - "height": 20, - "content": [ - "Muffler Hatch. Exactly 1" - ] - }, - { - "type": "textbox", - "x": 47, - "y": 318, - "width": 100, - "height": 20, - "content": [ - "Energy Input. Minimum 1" - ] - } - ], - "metatileentity": "electric_blast_furnace" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_1.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_1.json deleted file mode 100644 index 049f379b986..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_1.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Electric", - "title": "Fusion Reactor MK 1", - "stream": [], - "fixed": [], - "metatileentity": "fusion_reactor.luv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_2.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_2.json deleted file mode 100644 index fbd7234eb99..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Electric", - "title": "Fusion Reactor MK 2", - "stream": [], - "fixed": [], - "metatileentity": "fusion_reactor.zpm" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_3.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_3.json deleted file mode 100644 index 6f896cd695f..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/fusion_reactor_3.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Electric", - "title": "Fusion Reactor MK 3", - "stream": [], - "fixed": [], - "metatileentity": "fusion_reactor.uv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/implosion_compressor.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/implosion_compressor.json deleted file mode 100644 index bb6d263b219..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/implosion_compressor.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "section": "Electric", - "title": "Implosion Compressor", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Implosion Compressor§r is a Multiblock that turns gem dusts back into gems, as well as processes a few other recipes." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1003, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Recipes in the Implosion Compressor use varying explosives with different efficiencies, so make sure to check recipes in JEI." - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 11, - "y": 138, - "width": 179, - "height": 112, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 6, - "y": 147, - "width": 63, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1151, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 6, - "y": 174, - "width": 63, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1166, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 7, - "y": 203, - "width": 63, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1657, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 9, - "y": 229, - "width": 58, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1654, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 56, - "y": 146, - "width": 100, - "height": 20, - "content": [ - "Item Input Bus. Minimum 1" - ] - }, - { - "type": "textbox", - "x": 52, - "y": 172, - "width": 100, - "height": 20, - "content": [ - "Item Output Bus. Minimum 1" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 203, - "width": 100, - "height": 20, - "content": [ - "Muffler Hatch. Exactly 1" - ] - }, - { - "type": "textbox", - "x": 55, - "y": 227, - "width": 100, - "height": 20, - "content": [ - "Maintenance Hatch. Exactly 1" - ] - } - ], - "metatileentity": "implosion_compressor" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/large_chemical_reactor.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/large_chemical_reactor.json deleted file mode 100644 index 257f082cb09..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/large_chemical_reactor.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Large Chemical Reactor", - "stream": [ - { - "type": "textbox", - "content": [ - "The §3Large Chemical Reactor (LCR)§r is a multiblock §3Chemical Reactor§r with more input/output slots, which can handle more recipes thanks to Teflon.\n\nThe §3LCR§r can perform some exclusive reactions which allow you to combine multiple normal §3Chemical Reactor§r steps into a §6single step§r. Examples below:\n§9-§r §aNitrogen Dioxide§r (for Nitric Acid and Dinitrogen Tetroxide)\n§9-§r §aSulfuric Acid§r\n§9-§r §aPhenol§r\n§9-§r §aEpichlorohydrin§r (you need it for Epoxy§r!)\n§9-§r §aEpoxy§r\n\n\nThere are also §3LCR§r exclusive recipes. For example §aRadon§r requires it.\n\nAll §dOverclocks§r in the §3LCR§r are §6100% efficient§r; each overclock will §5quadruple the speed§r, as opposed to doubling it.\n\n\n§9Tip:§r Given the amount of LCRs you may end up using, I would recommend using the §dwallsharing§r to its full potential.\nYou may share one 2A (standard) §3Energy Hatch§r with 2 LCRs.\nYou may share §3Input/Output Hatches§r, but be careful to not make them run the wrong recipes.\nKeep in mind Maintenance is not sharable." - ] - } - ], - "fixed": [], - "metatileentity": "large_chemical_reactor" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/multi_smelter.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/multi_smelter.json deleted file mode 100644 index f2e74134c6e..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/multi_smelter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Multi Smelter", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThe §3§oMulti Smelter§r§o might be the §6§omost powerful Furnace§r§o in modded Minecraft.§r\n\nAt its lowest power (Cupronickel coils and LV Voltage), it smelts 32 items in just 12 seconds - equivalent to §926.7 Furnaces§r, or 3.3 Steam Ovens!\n\nNot to mention, standard §aoverclocks§r are in effect.\nAnd more importantly higher tier §3Coils§r increase the amount of items it can smelt in §dparallel§r! Higher tier §3Coils§r also provide better energy and duration discounts for recipes." - ] - } - ], - "fixed": [], - "metatileentity": "multi_furnace" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/oil_cracking_unit.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/oil_cracking_unit.json deleted file mode 100644 index 0526093adf4..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/oil_cracking_unit.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Oil Cracking Unit", - "stream": [ - { - "type": "textbox", - "content": [ - "§oLet\u0027s get cracking, shall we?§r\n\nThe §3Oil Cracking Unit§r is a multiblock meant to make cracked fluids. It has all the recipes of §3Chemical Reactor§r Cracking, but it is §6lossless§r.\n\nThis multiblock is §doptional§r, but it saves a lot of Fuel in the long term!\n\nHigher Coil tiers provide small energy discount, not too important." - ] - } - ], - "fixed": [], - "metatileentity": "cracker" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/processing_array.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/processing_array.json deleted file mode 100644 index 2ab24c291d6..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/processing_array.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Processing Array", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThe Processing Array does nothing... except that it does a lot!§r\n\nThe §3Processing Array§r is a power §6automation tool§r.\nIt combines several single block machines into one single multiblock.\nPlace up to §d16§r Machines into the §3Machine Access Interface§r.\n\nThe §3PA§r will now §asimulate§r all the machines you put inside, as if they were running at the same time.\nThis means recipes can now be performed up to §d16§r at a time, this is called §4parallel§r.\n\nPower cost is based on the current recipe being run, times the number of §4parallel§r being performed.\nAs an §9example§r, §316 LV Distilleries§r will require an §3HV Energy Hatch§r in order to run effectively.\n\n\n§cWhere or why is the Processing Array useful?§r\n§9-§r §4Parallelization is superior§r to oveclocking. Use it for passive setups such as Ore Processing or Oil Distilling.\n§9-§r §6Distinct buses§r: a §3PA§r can accept up to 10 §3Input Buses§r. Use it for your pattern automation with §3Extruder§r, §3Engraver§r, and many other.\n\n\n§9Note:§r With §2Gregicality Multiblocks§r installed, the §3PA§r can be mostly replaced with all the specialized Multiblocks instead. That\u0027s for you if you hate 3x3 blue cubes, or if you hate crafting numerous low tier machines.\n\n\n§bLore:§r In GregTech 5, the Data Orb was used to Matter Replicator to store data of the material you wanted to replicate. There is no replication here, the Orb is just a crafting component." - ] - } - ], - "fixed": [], - "metatileentity": "processing_array" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/pyrolyse_oven.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/pyrolyse_oven.json deleted file mode 100644 index bb143f76d3c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/pyrolyse_oven.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Electric", - "title": "Pyrolyse Oven", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThe Pyrolyse Oven processes organic products by thermal decomposition in an inert environment.§r\n\nThe §3Pyrolyse Oven§r is an electric equivalent of the §3Coke Oven§r. It can produce §9Coal Coke§r and §9Charcoal§r with a §9Creosote§r byproduct just as before, but also has additional §6Organic Byproducts§r. The most beneficial of these being §aWood Tar§r.\nAnother product is §aBiomass§r, which is more pertinent for progression §oright now§r.\n\nThose byproducts can be Distilled for an array of organic resources, with different byproducts giving different ratios of different chemicals.\nYou will need to read the §9Distillation§r Quest to hopefully understand the full scale..\n\nThere are recipes that can accept §bNitrogen§r to double the speed.\n\nThe §3Cupronickel Coils§r are more than enough to get started, but you will want to upgrade eventually. This is because the §3Cupronickel Coils§r actually have a processing speed malus, making all recipes slower. This malus turns into a processing speed bonus as the coil tier used increases.\n\n\n§9§lNote:§r§l The Plant path is one path towards §9§lEthylene§r§l. The other path involves Oil.§r\nThe Pyrolyse Oven remains §doptional§r. But it is great to have either for Power, or for the various Byproducts.\n\n\n§bLore:§r In GT5u, the structure for the Pyrolyse Oven is a giant box with only 9 coils inside. Players usually spend several minutes debugging what is wrong due to the lack of JEI preview." - ] - } - ], - "fixed": [], - "metatileentity": "pyrolyse_oven" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/vacuum_freezer.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/vacuum_freezer.json deleted file mode 100644 index 01c1f2dc76f..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/electric/vacuum_freezer.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "section": "Electric", - "title": "Vacuum Freezer", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Vacuum Freezer§r is one of the more important Multiblocks, as it allows you to get actual ingots from super heated Blast Furnace outputs." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1002, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Any ingots made in the §6Electric Blast Furnace§r that have a blast temperature of greater than §91750§r K will not generate regular ingots, but instead will generate Hot Ingots. These Ingots will damage the player when held, and are required to be cooled down in the Vacuum Freezer." - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 6, - "y": 189, - "width": 178, - "height": 105, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 7, - "y": 198, - "width": 56, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1151, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 14, - "y": 224, - "width": 43, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1166, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 54, - "y": 199, - "width": 100, - "height": 20, - "content": [ - "Item Input bus. Maximum 1" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 223, - "width": 100, - "height": 20, - "content": [ - "Item Output Bus. Maximum 1" - ] - }, - { - "type": "slots", - "x": 8, - "y": 249, - "width": 55, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1181, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 1, - "y": 274, - "width": 68, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1196, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 52, - "y": 248, - "width": 100, - "height": 20, - "content": [ - "Fluid Input Hatch. Optionally 1" - ] - }, - { - "type": "textbox", - "x": 51, - "y": 273, - "width": 100, - "height": 20, - "content": [ - "Fluid Output Hatch. Optionally 1" - ] - } - ], - "metatileentity": "vacuum_freezer" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/extreme_combustion_engine.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/extreme_combustion_engine.json deleted file mode 100644 index b61c47fa6a7..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/extreme_combustion_engine.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Extreme Combustion Engine", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThe Ultimate Combustion fuel Generator!§r\n\nTo run the §3Extreme Combustion Engine§r, you will most likely want to boost it (§oelse why would you bother...§r).\nYou will want a §34A IV Dynamo Hatch§r as the output, and one §3Vacuum Freezer§r for §aLiquid Oxygen§r.\n\nYou can now harness the equivalent of 1 §dLuV§r Amp, while burning fuel at §6200% efficiency§r!\n\nDon\u0027t forge to keep it supplied with a small amount of §aLubricant§r.\n\nThe §3ECE§r is also void-free, unlike Large Turbines. Any energy that cannot be output will momentarily pause the multiblock.\n\n\n§bLore:§r The ECE comes from GT:NH. However... the story is not so great. The stats on the tooltip looked similar to this one, so far so good.\nHowever if you made calculations, you ended up realizing you needed to run around 16 whole HV Vacuum Freezers to keep up with Liquid Oxygen...\nThe one and only fuel it would accept is High Octane Gasoline, which was stated to be burned at 300% efficiency when boosted, but it was a lie! The efficiency remained 100%!\nThe GT:NH team recently decided to rework the ECE among other power options, phew!" - ] - } - ], - "fixed": [], - "metatileentity": "extreme_combustion_engine" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_bronze_boiler.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_bronze_boiler.json deleted file mode 100644 index ee94e350d65..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_bronze_boiler.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Large Bronze Boiler", - "stream": [ - { - "type": "textbox", - "content": [ - "This is an §6optional§r power generating multiblock, depending on which power options you chose.\n\n\nThe §3Large Boilers§r ultimately are §othe§r option for large scale Steam production. They will run off solid and liquid fuels.\n§cImportant:§r This Boiler can also §cexplode§r similarly to the regular Boilers!\n§cWater supply is crucial§r. But simply upgrading the §3Output Hatch§r on your §3Primitive Pump§r should be enough.\n\n\nOnce fully heated up, the §3LBB§r produces 800 Steam per tick, which is §d400EU/t§r after conversion, or 12.5 Basic Steam Turbines! This (relatively!) immense power comes at the cost of §la lot§r of burnable fuel.\n§5§lBut§r the GUI can let you §9throttle§r the Boiler, down to 25% power for 200 Steam per tick. That is §d100EU/t§r, or slightly above 3 Basic Steam Turbines." - ] - } - ], - "fixed": [], - "metatileentity": "large_boiler.bronze" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_combustion_engine.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_combustion_engine.json deleted file mode 100644 index 1bea232463c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_combustion_engine.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Large Combustion Engine", - "stream": [ - { - "type": "textbox", - "content": [ - "The §3Large Combustion Engine§r is a multiblock able to burn §dCombustion Fuels§r for even more Power Generation!\n\nIt\u0027s default production outputs 2048 EU/t, which is simply the same as 4 §3Turbo Combustion Generators§r.\n\nWhere it shines is the ability to §6boost§r it with §aOxygen§r.\nThis will double the fuel consumption, but §9triple the power generation§r for 6144 EU/t!\nThis results in §6150% Fuel efficiency§r.\n\nIt also requires a small amount of §aLubricant§r, nothing too crazy.\n\nThe §3LCE§r is also void-free, unlike Large Turbines. Any energy that cannot be output will momentarily pause the multiblock.\n\n\n§9Note:§r To harness the 6144 EU/t Power output, you will need a §34A EV Dynamo Hatch§r, or an §3IV Dynamo Hatch§r." - ] - } - ], - "fixed": [], - "metatileentity": "large_combustion_engine" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_gas_turbine.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_gas_turbine.json deleted file mode 100644 index f9cca9cd4c9..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_gas_turbine.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Large Gas Turbine", - "stream": [ - { - "type": "textbox", - "content": [ - "The §3Large Gas Turbine§r may not be so impressive in the §5EV§r Age, but it has the ability to scale really well, to §9better production§r than the base 4096 EU/t, and §9greater efficiency§r.\n\nEach Large Turbine will require a §aTurbine Rotor§r and a §3Rotor Holder§r. More on the Turbine mechanics in the §lnext§r Quest.\n\n§9Note:§r To harness the Power output when using a Rotor having more than 100% Power stats, you will need a §34A EV Dynamo Hatch§r or an §3IV Dynamo Hatch§r.\nTurbines §cvoid§r energy that they can not output." - ] - } - ], - "fixed": [], - "metatileentity": "large_turbine.gas" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_plasma_turbine.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_plasma_turbine.json deleted file mode 100644 index 7ae7b70399d..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_plasma_turbine.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "section": "Generator", - "title": "Large Plasma Turbine", - "stream": [], - "fixed": [], - "metatileentity": "large_turbine.plasma" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steam_turbine.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steam_turbine.json deleted file mode 100644 index c4b7cb22ea6..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steam_turbine.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Large Steam Turbine", - "stream": [ - { - "type": "textbox", - "content": [ - "§oIf you\u0027re still running off Steam, here is a solution for you!§r\n\nThe §3Large Steam Turbine§r is a multiblock Steam Turbine for §6HV§r power. It is a quite expensive multiblock to generate 1024 EU/t, but it also the ability to scale to §9higher Power Production and higher Effiency§r.\n\nThe Turbine will output §dDistilled Water§r given an §3Output Hatch§r, so you can loop it back to your §3Large Boilers§r.\nNot completely recommend, as your Boilers will end up exploding if the system fails...\n\nEach Large Turbine will require a §aTurbine Rotor§r and a §3Rotor Holder§r. More on the Turbine mechanics in the §lnext§r Quest.\n\n§9Note:§r Turbines §cvoid§r energy that they can not output. If you plan on using this with HV power, use a Rotor with close to 100% Power stat." - ] - } - ], - "fixed": [], - "metatileentity": "large_turbine.steam" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steel_boiler.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steel_boiler.json deleted file mode 100644 index 59da1510221..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/generator/large_steel_boiler.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Generator", - "title": "Large Steel Boiler", - "stream": [ - { - "type": "textbox", - "content": [ - "If you\u0027re still running off the §3Large Bronze Boiler§r, you may want to upgrade to the §3Large Steel Boiler§r.\n\nIt is slightly more efficient than the §3LBB§r, and produces §d900 EU/t worth of Steam§r." - ] - } - ], - "fixed": [], - "metatileentity": "large_boiler.steel" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/advanced_maintenance.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/advanced_maintenance.json deleted file mode 100644 index cc2a252d8d8..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/advanced_maintenance.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Hatches", - "title": "Advanced Maintenance", - "stream": [ - { - "type": "textbox", - "content": [ - "You now have access to two §3new Maintenance Hatches§r. Both start with §6no Maintenance required§r.\n\nThe §3Automatic Maintenance Hatch§r is pretty simple, it eliminates the need for Maintenance, §6forever§r.\n\nThe §3Configurable Maintenance Hatch§r is more interesting. You can configure it to cut off §a10% duration§r on recipes, at the cost of making Maintenance happen three times as fast. That is §d16 real hours§r of activity.\n§9Reminder:§r You can put Tape in the maintenance Hatch to automatically fix problems.\n\n\n§bLore:§r The Automatic Maintenance Hatch texture and mechanic comes from TecTech, an addon mod originally made for GregTech: New Horizons. I will be honest with you: that mod is excessively cool!\nMore TecTech references coming up, if you stick with us with the late game!" - ] - } - ], - "fixed": [], - "metatileentity": "maintenance_hatch_full_auto" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/energy_hatch.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/energy_hatch.json deleted file mode 100644 index 49c10bc70bd..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/energy_hatch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Hatches", - "title": "Energy Hatch", - "stream": [ - { - "type": "textbox", - "content": [ - "§oTo power Multiblocks with energy, you need Energy Hatches.§r\n\nMultiblocks do not look at Voltage of recipes, instead they simply check if they have the Power requirement.\nFor example, The EBF needs at least §4120EU/t§r power input to run its recipes. It is achieved with §3two LV Energy Hatches§r. Each one takes 2 Amps of LV, so that\u0027s 4 Amps of LV for 128EU/t maximum power.\n\n\n§9Note:§r Be wary of Cable §closses§r bringing the actual power input below the recipe requirement! I §lhighly§r recommend placing your §3Battery Buffer§r next to the §3Energy Hatches§r for the minimum cable length." - ] - } - ], - "fixed": [], - "metatileentity": "energy_hatch.input.lv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/maintenance_hatch.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/maintenance_hatch.json deleted file mode 100644 index a6db7c6fb68..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/maintenance_hatch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Hatches", - "title": "Maintenance Hatch", - "stream": [ - { - "type": "textbox", - "content": [ - "§oI know what you\u0027re thinking! Don\u0027t think! I mean... Maintenance in GregTech is not as bad as you think, and looking at multiblocks with this hatch makes me feel happy.§r\n\nMost Multiblocks require a §3Maintenance Hatch§r. You will need to do Maintenance for the Multiblock to begin operating.\nThis is done by having a §9Wrench§r, a §9Screwdriver§r, a §9Soft Mallet§r, a §9Hammer§r, a §9Wire Cutter§r, and a §9Crowbar§r in your inventory, opening the Maintenance Hatch and §4clicking the center spot once§r. §cNo need to move tools individually§r.\nAlternatively you can fix problems by placing a §9Tape§r in the Maintenance Hatch, but I would love to tell you that\u0027s unethical.\n\nMaintenance problems may occur after §d48 real hours of activity§r. Needless to say they are very rare. Each problem increases the recipe durations by 10%. Fixing the problems is done the same way as above.\n\n\nAt §6HV§r age, you will unlock other Maintenance Hatches that do not enforce fixing the problems manually.\n\n\n§bLore:§r Maintenance dates back to GregTech 3 for Minecraft 1.5.2. That\u0027s a long time ago!\nMaintenance problems increased power usage instead of duration. And that caused all sorts of \"happy\" issues. Ah, fun times!" - ] - } - ], - "fixed": [], - "metatileentity": "maintenance_hatch" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/muffler_hatch.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/muffler_hatch.json deleted file mode 100644 index e11eef2deb6..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/muffler_hatch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Hatches", - "title": "Muffler Hatch", - "stream": [ - { - "type": "textbox", - "content": [ - "The §3Electric Blast Furnace§r requires a §3Muffler Hatch§r to run. This hatch must be §cunobstructed§r so it can output its beautiful smoke particles.\n\nWhen a recipe is performed, there is a small chance for the §3Muffler Hatch§r to give bonus items, typically tiny Dusts of Ash.\n\n§9Note:§r Do not try to automate the extraction of items from the §3Muffler Hatch§r, it is not intended. It voids excess when full, so do not worry about it stopping machines from running.\n\n\n§bLore:§r In GregTech 5, polluting multiblocks had Muffler Hatches. The higher tier the hatch, the lower the Pollution.\nPollution had interesting effects such as turning grass and dirt into sand.\nMuffler Hatches in GTCEu are more about the look (can you deny that the particles look good!?) and small rewards, rather than punishing game mechanics." - ] - } - ], - "fixed": [], - "metatileentity": "muffler_hatch.lv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/multiblock_input_output.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/multiblock_input_output.json deleted file mode 100644 index 3a6532b2d87..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/hatches/multiblock_input_output.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "section": "Hatches", - "title": "Multiblock Input/Output", - "stream": [ - { - "type": "textbox", - "content": [ - "§3Busses§r are needed to for Multiblocks in order to insert recipe inputs and retrieve recipe outputs.\nHigher tier §3Busses§r have more slots for items\n\nFor fluids, you will need §3Hatches§r.\n\nFor fluids, there are also special §3Multi-Fluid Hatches§r, which can handle multiple fluids at the same time. These come in 4x and 9x versions." - ] - } - ], - "fixed": [], - "metatileentity": "item_bus.import.lv" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/coke_oven.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/coke_oven.json deleted file mode 100644 index 2b300585370..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/coke_oven.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "section": "Primitive", - "title": "Coke Oven", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Coke Oven§r is most likely one of the first Multiblocks that you will make. It is the source of early game §1Charcoal§r, a nice fuel for making §1Steel§r initially." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1017, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Unlike other Multiblocks,this structure has a limited number of multiblock parts that can be added." - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 6, - "y": 137, - "width": 182, - "height": 61, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 3, - "y": 140, - "width": 52, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1017, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": -3, - "y": 163, - "width": 65, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1018, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 46, - "y": 160, - "width": 100, - "height": 20, - "content": [ - "The Coke Oven Hatch. Maximum: 5" - ] - }, - { - "type": "textbox", - "x": 47, - "y": 139, - "width": 100, - "height": 20, - "content": [ - "The Controller Block" - ] - } - ], - "metatileentity": "coke_oven" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_steel_tank.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_steel_tank.json deleted file mode 100644 index b9b4d9b8bc6..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_steel_tank.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "section": "Primitive", - "title": "Steel Multiblock Tank", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Steel Multiblock Tank§r is another early game multiblock for storing fluids. However, unlike the Wooden version, this structure can store gases and hot fluids." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1599, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Similar to the Wooden version, this structure has specific Multiblock Parts used for automating fluid input and output into the structure." - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": 2, - "y": 149, - "width": 52, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1598, - "count": 1 - } - ] - }, - { - "type": "card", - "x": 8, - "y": 146, - "width": 178, - "height": 32, - "fill": -3745585, - "isShadow": true - }, - { - "type": "textbox", - "x": 47, - "y": 149, - "width": 137, - "height": 20, - "content": [ - "Tank Valve for automating structure. Maximum: 2" - ] - } - ], - "metatileentity": "tank.steel" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_wooden_tank.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_wooden_tank.json deleted file mode 100644 index 4fb6f84f526..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/multiblock_wooden_tank.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "section": "Primitive", - "title": "Wooden Multiblock Tank", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Wooden Multiblock Tank§r is an early game solution for storing liquids. Unfortunately, it cannot store much, as it does not handle gases or hot liquids." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1597, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "This Multiblock has one possible Multiblock Part, which is used for automatically filling and extracting fluids from the structure." - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": -12, - "y": 176, - "width": 59, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1596, - "count": 1 - } - ] - }, - { - "type": "card", - "x": 7, - "y": 170, - "width": 178, - "height": 35, - "fill": -3745585, - "isShadow": true - }, - { - "type": "textbox", - "x": 35, - "y": 176, - "width": 137, - "height": 20, - "content": [ - "Tank Valve for automating structure. Maximum: 2" - ] - } - ], - "metatileentity": "tank.wood" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_blast_furnace.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_blast_furnace.json deleted file mode 100644 index 34c471d6958..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_blast_furnace.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "section": "Primitive", - "title": "Primitive Blast Furnace", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Primitive Blast Furnace§r is the main multiblock of the Steam Age. It is used for making the first §1Steel§r, which is the main gateway to the §2LV§r age." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1000, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Unlike other §3Gregtech§r Multiblocks, there are no multiblock parts that can be used in this structure. It is only composed of the controller and the Primitive Bricks." - ] - } - ], - "fixed": [], - "metatileentity": "primitive_blast_furnace.bronze" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_water_pump.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_water_pump.json deleted file mode 100644 index 59377b8d57f..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/primitive_water_pump.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "section": "Primitive", - "title": "Primitive Water Pump", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Primitive Water Pump§r is a Multiblock used for gathering water in the early game. The amount of water gathered depends on the biome that the Multiblock is constructed in. Detailed information on the rates in available on the §3JEI§r information page for the Multiblock." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1648, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "The §6Primitive Water Pump§r has only one possible Multiblock part, though it is limited in what tier the part can be." - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": -23, - "y": 189, - "width": 100, - "height": 18, - "item_list": [] - }, - { - "type": "slots", - "x": 61, - "y": 182, - "width": 67, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1649, - "count": 1 - }, - { - "id": "gregtech:machine", - "damage": 1195, - "count": 1 - }, - { - "id": "gregtech:machine", - "damage": 1196, - "count": 1 - } - ] - }, - { - "type": "card", - "x": 9, - "y": 174, - "width": 180, - "height": 76, - "fill": -3745585, - "isShadow": true - }, - { - "type": "textbox", - "x": 13, - "y": 203, - "width": 168, - "height": 40, - "content": [ - "The §6Primitive Water Pump§r is limited to §rthe specific output hatch, §ra §2ULV§r output hatch, or a §2LV§r output hatch" - ] - } - ], - "metatileentity": "primitive_water_pump" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_grinder.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_grinder.json deleted file mode 100644 index 4a3ad379efd..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_grinder.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "section": "Primitive", - "title": "Steam Grinder", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Steam Grinder§r is an early game multiblock for performing macerator recipes. It can perform up to §58§r recipes in parallel, and has duration of §51.5§r times the normal macerator recipe duration.\n\nHowever, only the first output from the recipe will be output. This means that no byproducts will be recieved from any ores grinded down." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1025, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Unlike other Multiblocks, this structure has specialized hatches for handling steam that must be used." - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 4, - "y": 217, - "width": 182, - "height": 81, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 11, - "y": 224, - "width": 50, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1651, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 5, - "y": 247, - "width": 62, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1652, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 10, - "y": 272, - "width": 52, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1653, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 53, - "y": 224, - "width": 117, - "height": 20, - "content": [ - "Specialized Output bus for Steam Multiblocks" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 250, - "width": 120, - "height": 20, - "content": [ - "Specialized Input bus for Steam Multiblocks" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 273, - "width": 120, - "height": 20, - "content": [ - "Specialized Input Hatch for Steam Multiblocks" - ] - } - ], - "metatileentity": "steam_grinder" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_oven.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_oven.json deleted file mode 100644 index b45a1bf6604..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/en_us/primitive/steam_oven.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "section": "Primitive", - "title": "Steam Oven", - "stream": [ - { - "type": "textbox", - "content": [ - "The §6Steam Oven§r is an early game multiblock for performing furnace recipes. It can perform up to §58§r recipes in parallel, and has duration of §51.5§r times the normal furnace recipe duration.\n\nThis should not really matter, but only the first output from the recipe will be obtained. Although if someone is adding a weird furnace recipe, that is their fault." - ] - }, - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1024, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "Unlike other Multiblocks, this structure has specialized hatches for handling steam that must be used." - ] - } - ], - "fixed": [ - { - "type": "card", - "x": 4, - "y": 217, - "width": 182, - "height": 81, - "fill": -3745585, - "isShadow": true - }, - { - "type": "slots", - "x": 11, - "y": 224, - "width": 50, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1651, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 5, - "y": 247, - "width": 62, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1652, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 10, - "y": 272, - "width": 52, - "height": 18, - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1653, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 53, - "y": 224, - "width": 117, - "height": 20, - "content": [ - "Specialized Output bus for Steam Multiblocks" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 250, - "width": 120, - "height": 20, - "content": [ - "Specialized Input bus for Steam Multiblocks" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 273, - "width": 120, - "height": 20, - "content": [ - "Specialized Input Hatch for Steam Multiblocks" - ] - } - ], - "metatileentity": "steam_oven" -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/zh_cn/electric/central_monitor.json b/src/main/resources/assets/gregtech/terminal/guide/multiblocks/zh_cn/electric/central_monitor.json deleted file mode 100644 index 4de1eb5024f..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/multiblocks/zh_cn/electric/central_monitor.json +++ /dev/null @@ -1,183 +0,0 @@ -{ - "section": "电力", - "title": "中央监控器", - "stream": [ - { - "type": "slots", - "item_list": [ - { - "id": "gregtech:machine", - "damage": 1028, - "count": 1 - }, - { - "id": "gregtech:machine", - "damage": 1667, - "count": 1 - } - ] - }, - { - "type": "textbox", - "content": [ - "§l目录:" - ] - }, - { - "type": "textbox", - "link": "introduction", - "content": [ - "1. §9介绍" - ] - }, - { - "type": "textbox", - "link": "fluid", - "content": [ - "2. §9如何构建它" - ] - }, - { - "type": "textbox", - "link": "item", - "content": [ - "3. §r§9如何使用它" - ] - }, - { - "type": "textbox", - "link": "energy", - "content": [ - "4. §9插件" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/107856228-c1f6eb80-6e61-11eb-8098-454ea7133ca1.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "ref": "introduction", - "content": [ - "§l介绍" - ] - }, - { - "type": "textbox", - "content": [ - "§c§l中央监控仪§r是一个用来监控(可视化和交互)的多方块.\n\n它可以监控并交互机器的存储及运行状态,它包含§9数字化接口覆盖版§r§9§r的所有功能,并将机器的其他接口扩展到屏幕上。\n\n此外,还有许多插件支持更多高级功能。" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "fluid", - "content": [ - "§l怎么构建它?" - ] - }, - { - "type": "textbox", - "content": [ - "为了构建它,你需要一个§c§l中央监控器§r,一些§c§l监控屏幕§r,一些§c§l不锈钢机械方块§r,个至少一个§c§l能源输入仓§r.\n\n屏幕尺寸从3×2到14×9(宽 × 高)不等。默认高度是3,但是你可以在结构成型前在GUI中设置高度。\n\n§l能源消耗:§r每个屏幕50 EU/s。" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "item", - "content": [ - "§l如何使用它?" - ] - }, - { - "type": "textbox", - "content": [ - "1. §c§l中央监控器的§r的背后可以连接线缆,线缆所处的电网中可以监控所有被代理的机器(§9数字化接口覆盖版§r设置为代理模式,并放置在线和机器的接口处。) 此外,绑定了中央控制器的§9无线覆盖版§r同样可以使用,避免使用线缆。\n\n2. 右击§c§l中央监控器§r或者扳手右击§c§l监控屏幕§r可以打开GUI进行设置。" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "energy", - "content": [ - "§l插件" - ] - }, - { - "type": "textbox", - "content": [ - "将插件放入插件槽中使用。有关具体功能,请参阅其指南页。以下是支持的插件。\n\n§4§l注意§r§4: §r在§c§l中央监控器§r中,有些插件需要使用代理模式工作,而代理模式仅用于插件。" - ] - }, - { - "type": "card", - "fill": -3745585, - "width": 170, - "height": 60, - "isShadow": true - }, - { - "type": "textbox", - "content": [ - "\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - } - ], - "fixed": [ - { - "type": "slots", - "x": 48, - "y": 730, - "width": 100, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 780, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 781, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 782, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 783, - "count": 1 - } - ] - } - ], - "metatileentity": "central_monitor" -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/01_definition.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/01_definition.json deleted file mode 100644 index b319e88fe15..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/01_definition.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "Material Definition", - "stream": [ - { - "type": "textbox", - "fontSize": 11, - "fontColor": -65536, - "content": [ - "§lFirstly, you should know what is the Material." - ] - }, - { - "type": "textbox", - "content": [ - "Material is the basis of CEu. It defines to a substance and its properties. It usually takes the form of an §lelement§r or a §lchemical§r, but it can also take the form of something weird like the §lEnder Eye§r." - ] - }, - { - "type": "textbox", - "fontSize": 11, - "fontColor": -16776961, - "content": [ - "§lSecondly, it defines which properties?" - ] - }, - { - "type": "textbox", - "content": [ - "The §lmaterial§r specifies whether it has a §lfluid§r state, §lplasma§r state, §ldust§r state, etc. When it has a specific state, the CEu will register the corresponding item or fluid automatically." - ] - }, - { - "type": "textbox", - "fontSize": 11, - "fontColor": -16731136, - "content": [ - "§lThirdly, What else does it define?" - ] - }, - { - "type": "textbox", - "content": [ - "You can actually define its colors, flag, iconSet, cableProperties, Element, formula, components and so on. Don\u0027t worry, they are not complicated, will be introduced in other pages." - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/02_element.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/02_element.json deleted file mode 100644 index 22f3b6a04af..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/02_element.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "Element", - "stream": [ - { - "type": "textbox", - "fontSize": 9, - "content": [ - "The §lElement§r use to specify a material as an elemental and affects its chemical fomular. CEu basically has the periodic table, so you probably won\u0027t need it. \n\n§lContents:" - ] - }, - { - "type": "textbox", - "link": "element", - "content": [ - "1. §9Element" - ] - }, - { - "type": "textbox", - "link": "ct", - "content": [ - "2. §9CT" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "element", - "content": [ - "§c§lElement:§r\n §l○ §nprotons§r – Amount of Protons\n §l○ §nneutrons§r – Amount of Neutrons (I could have made mistakes with the Neutron amount calculation, please tell me if I did something wrong)\n §l○ §nhalfLifeSeconds§r – Amount of Half Life this Material has in Seconds. -1 for stable Materials\n §l○ §ndecayTo§r – String representing the Elements it decays to. Separated by an \u0027\u0026\u0027 Character\n §l○ §nname§r – Name of the Element\n §l○ §nsymbol§r – Symbol of the Element" - ] - }, - { - "type": "textbox", - "content": [ - "§lExisting elements:" - ] - }, - { - "type": "textbox", - "stroke": 1623820032, - "stroke_width": 3, - "fill": 1623820032, - "content": [ - " §l○ §c§lH§r: 1, 0, -1, null, \"Hydrogen\", \"H\", false\n §l○ §c§lD§r: 1, 1, -1, \"H\", \"Deuterium\", \"D\", true\n §l○ §c§lT§r: 1, 2, -1, \"D\", \"Tritium\", \"T\", true\n §l○ §c§lHe§r: 2, 2, -1, null, \"Helium\", \"He\", false\n §l○ §c§lHe3§r: 2, 1, -1, \"H\u0026D\", \"Helium-3\", \"He-3\", true\n §l○ §c§lLi§r: 3, 4, -1, null, \"Lithium\", \"Li\", false\n §l○ §c§lBe§r: 4, 5, -1, null, \"Beryllium\", \"Be\", false\n §l○ §c§lB§r: 5, 5, -1, null, \"Boron\", \"B\", false\n §l○ §c§lC§r: 6, 6, -1, null, \"Carbon\", \"C\", false\n §l○ §c§lN§r: 7, 7, -1, null, \"Nitrogen\", \"N\", false\n §l○ §c§lO§r: 8, 8, -1, null, \"Oxygen\", \"O\", false\n §l○ §c§lF§r: 9, 9, -1, null, \"Fluorine\", \"F\", false\n §l○ §c§lNe§r: 10, 10, -1, null, \"Neon\", \"Ne\", false\n §l○ §c§lNa§r: 11, 11, -1, null, \"Sodium\", \"Na\", false\n §l○ §c§lMg§r: 12, 12, -1, null, \"Magnesium\", \"Mg\", false\n §l○ §c§lAl§r: 13, 13, -1, null, \"Aluminium\", \"Al\", false\n §l○ §c§lSi§r: 14, 14, -1, null, \"Silicon\", \"Si\", false\n §l○ §c§lP§r: 15, 15, -1, null, \"Phosphorus\", \"P\", false\n §l○ §c§lS§r: 16, 16, -1, null, \"Sulfur\", \"S\", false\n §l○ §c§lCl§r: 17, 18, -1, null, \"Chlorine\", \"Cl\", false\n §l○ §c§lAr§r: 18, 22, -1, null, \"Argon\", \"Ar\", false\n §l○ §c§lK§r: 19, 20, -1, null, \"Potassium\", \"K\", false\n §l○ §c§lCa§r: 20, 20, -1, null, \"Calcium\", \"Ca\", false\n §l○ §c§lSc§r: 21, 24, -1, null, \"Scandium\", \"Sc\", false\n §l○ §c§lTi§r: 22, 26, -1, null, \"Titanium\", \"Ti\", false\n §l○ §c§lV§r: 23, 28, -1, null, \"Vanadium\", \"V\", false\n §l○ §c§lCr§r: 24, 28, -1, null, \"Chrome\", \"Cr\", false\n §l○ §c§lMn§r: 25, 30, -1, null, \"Manganese\", \"Mn\", false\n §l○ §c§lFe§r: 26, 30, -1, null, \"Iron\", \"Fe\", false\n §l○ §c§lCo§r: 27, 32, -1, null, \"Cobalt\", \"Co\", false\n §l○ §c§lNi§r: 28, 30, -1, null, \"Nickel\", \"Ni\", false\n §l○ §c§lCu§r: 29, 34, -1, null, \"Copper\", \"Cu\", false\n §l○ §c§lZn§r: 30, 35, -1, null, \"Zinc\", \"Zn\", false\n §l○ §c§lGa§r: 31, 39, -1, null, \"Gallium\", \"Ga\", false\n §l○ §c§lGe§r: 32, 40, -1, null, \"Germanium\", \"Ge\", false\n §l○ §c§lAs§r: 33, 42, -1, null, \"Arsenic\", \"As\", false\n §l○ §c§lSe§r: 34, 45, -1, null, \"Selenium\", \"Se\", false\n §l○ §c§lBr§r: 35, 45, -1, null, \"Bromine\", \"Br\", false\n §l○ §c§lKr§r: 36, 48, -1, null, \"Krypton\", \"Kr\", false\n §l○ §c§lRb§r: 37, 48, -1, null, \"Rubidium\", \"Rb\", false\n §l○ §c§lSr§r: 38, 49, -1, null, \"Strontium\", \"Sr\", false\n §l○ §c§lY§r: 39, 50, -1, null, \"Yttrium\", \"Y\", false\n §l○ §c§lZr§r: 40, 51, -1, null, \"Zirconium\", \"Zr\", false\n §l○ §c§lNb§r: 41, 53, -1, null, \"Niobium\", \"Nb\", false\n §l○ §c§lMo§r: 42, 53, -1, null, \"Molybdenum\", \"Mo\", false\n §l○ §c§lTc§r: 43, 55, -1, null, \"Technetium\", \"Tc\", false\n §l○ §c§lRu§r: 44, 57, -1, null, \"Ruthenium\", \"Ru\", false\n §l○ §c§lRh§r: 45, 58, -1, null, \"Rhodium\", \"Rh\", false\n §l○ §c§lPd§r: 46, 60, -1, null, \"Palladium\", \"Pd\", false\n §l○ §c§lAg§r: 47, 60, -1, null, \"Silver\", \"Ag\", false\n §l○ §c§lCd§r: 48, 64, -1, null, \"Cadmium\", \"Cd\", false\n §l○ §c§lIn§r: 49, 65, -1, null, \"Indium\", \"In\", false\n §l○ §c§lSn§r: 50, 68, -1, null, \"Tin\", \"Sn\", false\n §l○ §c§lSb§r: 51, 70, -1, null, \"Antimony\", \"Sb\", false\n §l○ §c§lTe§r: 52, 75, -1, null, \"Tellurium\", \"Te\", false\n §l○ §c§lI§r: 53, 74, -1, null, \"Iodine\", \"I\", false\n §l○ §c§lXe§r: 54, 77, -1, null, \"Xenon\", \"Xe\", false\n §l○ §c§lCs§r: 55, 77, -1, null, \"Caesium\", \"Cs\", false\n §l○ §c§lBa§r: 56, 81, -1, null, \"Barium\", \"Ba\", false\n §l○ §c§lLa§r: 57, 81, -1, null, \"Lanthanum\", \"La\", false\n §l○ §c§lCe§r: 58, 82, -1, null, \"Cerium\", \"Ce\", false\n §l○ §c§lPr§r: 59, 81, -1, null, \"Praseodymium\", \"Pr\", false\n §l○ §c§lNd§r: 60, 84, -1, null, \"Neodymium\", \"Nd\", false\n §l○ §c§lPm§r: 61, 83, -1, null, \"Promethium\", \"Pm\", false\n §l○ §c§lSm§r: 62, 88, -1, null, \"Samarium\", \"Sm\", false\n §l○ §c§lEu§r: 63, 88, -1, null, \"Europium\", \"Eu\", false\n §l○ §c§lGd§r: 64, 93, -1, null, \"Gadolinium\", \"Gd\", false\n §l○ §c§lTb§r: 65, 93, -1, null, \"Terbium\", \"Tb\", false\n §l○ §c§lDy§r: 66, 96, -1, null, \"Dysprosium\", \"Dy\", false\n §l○ §c§lHo§r: 67, 97, -1, null, \"Holmium\", \"Ho\", false\n §l○ §c§lEr§r: 68, 99, -1, null, \"Erbium\", \"Er\", false\n §l○ §c§lTm§r: 69, 99, -1, null, \"Thulium\", \"Tm\", false\n §l○ §c§lYb§r: 70, 103, -1, null, \"Ytterbium\", \"Yb\", false\n §l○ §c§lLu§r: 71, 103, -1, null, \"Lutetium\", \"Lu\", false\n §l○ §c§lHf§r: 72, 106, -1, null, \"Hafnium\", \"Hf\", false\n §l○ §c§lTa§r: 73, 107, -1, null, \"Tantalum\", \"Ta\", false\n §l○ §c§lW§r: 74, 109, -1, null, \"Tungsten\", \"W\", false\n §l○ §c§lRe§r: 75, 111, -1, null, \"Rhenium\", \"Re\", false\n §l○ §c§lOs§r: 76, 114, -1, null, \"Osmium\", \"Os\", false\n §l○ §c§lIr§r: 77, 115, -1, null, \"Iridium\", \"Ir\", false\n §l○ §c§lPt§r: 78, 117, -1, null, \"Platinum\", \"Pt\", false\n §l○ §c§lAu§r: 79, 117, -1, null, \"Gold\", \"Au\", false\n §l○ §c§lHg§r: 80, 120, -1, null, \"Mercury\", \"Hg\", false\n §l○ §c§lTl§r: 81, 123, -1, null, \"Thallium\", \"Tl\", false\n §l○ §c§lPb§r: 82, 125, -1, null, \"Lead\", \"Pb\", false\n §l○ §c§lBi§r: 83, 125, -1, null, \"Bismuth\", \"Bi\", false\n §l○ §c§lPo§r: 84, 124, -1, null, \"Polonium\", \"Po\", false\n §l○ §c§lAt§r: 85, 124, -1, null, \"Astatine\", \"At\", false\n §l○ §c§lRn§r: 86, 134, -1, null, \"Radon\", \"Rn\", false\n §l○ §c§lFr§r: 87, 134, -1, null, \"Francium\", \"Fr\", false\n §l○ §c§lRa§r: 88, 136, -1, null, \"Radium\", \"Ra\", false\n §l○ §c§lAc§r: 89, 136, -1, null, \"Actinium\", \"Ac\", false\n §l○ §c§lTh§r: 90, 140, -1, null, \"Thorium\", \"Th\", false\n §l○ §c§lPa§r: 91, 138, -1, null, \"Protactinium\", \"Pa\", false\n §l○ §c§lU§r: 92, 146, -1, null, \"Uranium\", \"U\", false\n §l○ §c§lU238§r: 92, 146, -1, null, \"Uranium-238\", \"U-238\", false\n §l○ §c§lU235§r: 92, 143, -1, null, \"Uranium-235\", \"U-235\", true\n §l○ §c§lNp§r: 93, 144, -1, null, \"Neptunium\", \"Np\", false\n §l○ §c§lPu§r: 94, 152, -1, null, \"Plutonium\", \"Pu\", false\n §l○ §c§lPu239§r: 94, 145, -1, null, \"Plutonium-239\", \"Pu-239\", false\n §l○ §c§lPu241§r: 94, 149, -1, null, \"Plutonium-241\", \"Pu-241\", true\n §l○ §c§lAm§r: 95, 150, -1, null, \"Americium\", \"Am\", false\n §l○ §c§lCm§r: 96, 153, -1, null, \"Curium\", \"Cm\", false\n §l○ §c§lBk§r: 97, 152, -1, null, \"Berkelium\", \"Bk\", false\n §l○ §c§lCf§r: 98, 153, -1, null, \"Californium\", \"Cf\", false\n §l○ §c§lEs§r: 99, 153, -1, null, \"Einsteinium\", \"Es\", false\n §l○ §c§lFm§r: 100, 157, -1, null, \"Fermium\", \"Fm\", false\n §l○ §c§lMd§r: 101, 157, -1, null, \"Mendelevium\", \"Md\", false\n §l○ §c§lNo§r: 102, 157, -1, null, \"Nobelium\", \"No\", false\n §l○ §c§lLr§r: 103, 159, -1, null, \"Lawrencium\", \"Lr\", false\n §l○ §c§lRf§r: 104, 161, -1, null, \"Rutherfordium\", \"Rf\", false\n §l○ §c§lDb§r: 105, 163, -1, null, \"Dubnium\", \"Db\", false\n §l○ §c§lSg§r: 106, 165, -1, null, \"Seaborgium\", \"Sg\", false\n §l○ §c§lBh§r: 107, 163, -1, null, \"Bohrium\", \"Bh\", false\n §l○ §c§lHs§r: 108, 169, -1, null, \"Hassium\", \"Hs\", false\n §l○ §c§lMt§r: 109, 167, -1, null, \"Meitnerium\", \"Mt\", false\n §l○ §c§lDs§r: 110, 171, -1, null, \"Darmstadtium\", \"Ds\", false\n §l○ §c§lRg§r: 111, 169, -1, null, \"Roentgenium\", \"Rg\", false\n §l○ §c§lCn§r: 112, 173, -1, null, \"Copernicium\", \"Cn\", false\n §l○ §c§lNh§r: 113, 171, -1, null, \"Nihonium\", \"Nh\", false\n §l○ §c§lFl§r: 114, 175, -1, null, \"Flerovium\", \"Fl\", false\n §l○ §c§lMc§r: 115, 173, -1, null, \"Moscovium\", \"Mc\", false\n §l○ §c§lLv§r: 116, 177, -1, null, \"Livermorium\", \"Lv\", false\n §l○ §c§lTs§r: 117, 177, -1, null, \"Tennessine\", \"Ts\", false\n §l○ §c§lOg§r: 118, 176, -1, null, \"Oganesson\", \"Og\", false\n §l○ §c§lTr§r: 119, 178, -1, null, \"Tritanium\", \"Tr\", false\n §l○ §c§lDr§r: 120, 180, -1, null, \"Duranium\", \"Dr\", false\n §l○ §c§lKe§r: 125, 198, -1, null, \"Trinium\", \"Ke\", false\n §l○ §c§lNq§r: 174, 352, 140, null, \"Naquadah\", \"Nq\", true\n §l○ §c§lNq1§r: 174, 354, 140, null, \"NaquadahEnriched\", \"Nq+\", true\n §l○ §c§lNq2§r: 174, 348, 140, null, \"Naquadria\", \"*Nq*\", true\n §l○ §c§lNt§r: 0, 1000, -1, null, \"Neutronium\", \"Nt\", false\n §l○ §c§lAd§r: 750, 1000, -1, null, \"Adamantium\", \"Ad\", false\n §l○ §c§lVb§r: 850, 900, -1, null, \"Vibranium\", \"Vb\", false\n §l○ §c§lTn§r: 550, 670, -1, null, \"Taranium\", \"Tn\", false" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ct", - "content": [ - "§lElements.add§r: §o§nElements.add(long protons, long neutrons, long halfLifeSeconds, String decayTo, String name, String symbol, boolean isIsotope)§r \nAdd a new element.\n\n§lElements.get§r: §o§nElements.get(String name)§r \nGet the element by name." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Elements§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0Au§r§5 §r§5\u003d§r§5 §r§0Elements§r§5.§r§0get§r§5(§r§0Au§r§5)§r§5;§r§5 §r§8// get an existing element.§r§5\n§r§9var§r§5 §r§0name§r§5 §r§5\u003d§r§5 §r§0Au§r§5.§r§0name§r§5;§r§5 §r§8// \"Gold\"§r§5\n§r§9var§r§5 §r§0symbol§r§5 §r§5\u003d§r§5 §r§0Au§r§5.§r§0symbol§r§5;§r§5 §r§8// \"Au\"§r§5\n§r§9var§r§5 §r§0protons§r§5 §r§5\u003d§r§5 §r§0Au§r§5.§r§0protons§r§5 §r§8// 79§r§5\n§r§9var§r§5 §r§0neutrons§r§5 §r§5\u003d§r§5 §r§0Au§r§5.§r§0neutrons§r§8// 117§r§5\n§r§9var§r§5 §r§0mass§r§5 §r§5\u003d§r§5 §r§0Au§r§5.§r§0mass§r§5 §r§8// 196§r§5\n§r§5\n§r§9var§r§5 §r§0CEu§r§5 §r§5\u003d§r§5 §r§0Elements§r§5.§r§0add§r§5(§r§c999§r§5,§r§5 §r§c999§r§5,§r§5 §r§5-§r§c1§r§5,§r§5 §r§cnull§r§5,§r§5 §r§2\"GTCEu\"§r§5,§r§5 §r§2\"CEu\"§r§5,§r§5 §r§cfalse§r§5)§r§5;§r§5 §r§8// create a new element.§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0element§r§5(§r§2\"CEu\"§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5 §r§8// register my element.§r§5\n§r" - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/03_flag.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/03_flag.json deleted file mode 100644 index e739ce18cc5..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/03_flag.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "MaterialFlag", - "stream": [ - { - "type": "textbox", - "fontSize": 9, - "content": [ - "The §lMaterialFlag§r refers to some additional features it has.\n\nAvailable MaterialFlag are: " - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "element", - "content": [ - "§r§4§ogeneric:" - ] - }, - { - "type": "textbox", - "content": [ - " §l○ §n\"no_unification\"§r: Add to material to disable it\u0027s unification fully todo implement.\n §l○ §n\"decomposition_requires_hydrogen\"§r: Decomposition recipe requires hydrogen as additional input. Amount is equal to input amount.\n §l○ §n\"decomposition_by_electrolyzing\"§r: Enables electrolyzer decomposition recipe generation.\n §l○ §n\"decomposition_by_centrifuging\"§r: Enables centrifuge decomposition recipe generatio.\n §l○ §n\"disable_decomposition\"§r: Disables decomposition recipe generation for this material and all materials that has it as component.\n §l○ §n\"explosive\"§r: Add to material if it is some kind of explosive.\n §l○ §n\"flammable\"§r: Add to material if it is some kind of flammable." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ct", - "content": [ - "§4§oGenerate a plate for this material If it\u0027s dust material, dust compressor recipe into plate will be generated If it\u0027s metal material, bending machine recipes will be generated If block is found, cutting machine recipe will be also generated:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"generate_plate\"§r, §n\"generate_rod\"§r, §n\"generate_frame\"§r, §n\"generate_gear\"§r, §n\"generate_long_rod\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§4§oThis will prevent material from creating Shapeless recipes for dust to block and vice versa Also preventing extruding and alloy smelting recipes via SHAPE_EXTRUDING/MOLD_BLOCK:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"exclude_block_crafting_recipes\"§r, §n\"exclude_plate_compressor_recipe\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§4§oThis will prevent material from creating Shapeless recipes for dust to block and vice versa:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"exclude_block_crafting_by_hand_recipes\"§r, §n\"mortar_grindable\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§4§oAdd to material if it cannot be worked by any other means, than smashing or smelting. This is used for coated Materials:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"no_working\"§r, §n\"no_smashing\"§r, §n\"no_smelting\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§4§oAdd this to your Material if you want to have its Ore Calcite heated in a Blast Furnace for more output. Already listed are: Iron, Pyrite, PigIron, WroughtIron:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"blast_furnace_calcite_double\"§r, §n\"blast_furnace_calcite_triple\"§r, §n\"generate_foil\"§r, §n\"generate_bolt_screw\"§r, §n\"generate_ring\"§r, §n\"generate_spring\"§r, §n\"generate_spring_small\"§r, §n\"generate_small_gear\"§r, §n\"generate_fine_wire\"§r, §n\"generate_rotor\"§r, §n\"generate_dense\"§r, §n\"generate_round\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§4§oIf this material can be crystallized:" - ] - }, - { - "type": "textbox", - "content": [ - "§n\"crystallizable\"§r, §n\"generate_lens\"§r, §n\"high_sifter_output\"§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/04_icon_set.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/04_icon_set.json deleted file mode 100644 index f0749c2b2a5..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/04_icon_set.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "MaterialIconSet", - "stream": [ - { - "type": "textbox", - "fontSize": 9, - "content": [ - "The §lMaterialIconSet§r will determine the appearance of the material." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "element", - "content": [ - "§rAvailable MaterialIconSet are:" - ] - }, - { - "type": "textbox", - "content": [ - "§l\"NONE\", \"METALLIC\", \"DULL\", \"MAGNETIC\", \"QUARTZ\", \"DIAMOND\", \"EMERALD\", \"SHINY\", \"ROUGH\", \"FINE\", \"SAND\", \"FLINT\", \"RUBY\", \"LAPIS\", \"FLUID\", \"GAS\", \"LIGNITE\", \"OPAL\", \"GLASS\", \"WOOD\", \"GEM_HORIZONTAL\", \"GEM_VERTICAL\", \"PAPER\", \"NETHERSTAR\", \"BRIGHT\"§r." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ct", - "content": [ - "For example, the following figure shows the appearance of ores with different Materialiconsets." - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/143435701-058dcfea-ea35-4976-a7ba-7901fa791e36.png", - "width": 190, - "height": 100 - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/05_create.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/05_create.json deleted file mode 100644 index feaa04ef1f8..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/05_create.json +++ /dev/null @@ -1,257 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "Create a Material", - "stream": [ - { - "type": "textbox", - "fontSize": 9, - "content": [ - "You can help create a Material by the §lMaterialBuilder§r.\n\n§lContents:" - ] - }, - { - "type": "textbox", - "link": "bui", - "content": [ - "1. §9MaterialBuilder" - ] - }, - { - "type": "textbox", - "link": "pro", - "content": [ - "2. §9Material Properties" - ] - }, - { - "type": "textbox", - "link": "ico", - "content": [ - "3. §9Material IconSet" - ] - }, - { - "type": "textbox", - "link": "com", - "content": [ - "4. §9Material Component" - ] - }, - { - "type": "textbox", - "link": "fla", - "content": [ - "5. §9Material Flag" - ] - }, - { - "type": "textbox", - "link": "ele", - "content": [ - "6§r. §9Material Element" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "content": [ - "§lMaterialBuilder" - ], - "ref": "bui" - }, - { - "type": "textbox", - "ref": "element", - "content": [ - "§o§nMaterialBuilder(String materialName)§r" - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5\n" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "pro", - "content": [ - "§lMaterial Properties" - ] - }, - { - "type": "textbox", - "content": [ - "§lcolor§r: §o§ncolor(int color)§r\nSet the Color of this Material. Defaults to 0xFFFFFF unless §ncolorAverage()§r.\n\n§lcolorAverage§r: §o§ncolorAverage(int color)§r\nColor will be a weighted average of the components of the Material.\n\n§lFluid§r: §o§nfluid(@Optional String type, @Optional boolean hasBlock)§r\nAdd a FluidProperty to this Material.\n §l○§r type – The Material.FluidType of this Material, either \"fluid\" or \"gas\".\n §l○§r hasBlock – If true, create a Fluid Block for this Material.\n\n§lplasma§r: §o§nplasma()§r \nAdd a PlasmaProperty to this Material.\n §l○§r type – The Material.FluidType of this Material, either \"fluid\" or \"gas\".\n §l○§r hasBlock – If true, create a Fluid Block for this Material.\n\n§ldust§r: §o§ndust(@Optional int harvestLevel, @Optional int burnTime)§r \nAdd a DustProperty to this Material.\n §l○§r harvestLevel – The Harvest Level of this block for Mining. If this Material also has a ToolProperty, this value will also be used to determine the tool\u0027s Mining Level.\n §l○§r burnTime – The Burn Time (in ticks) of this Material as a Furnace Fuel.\n\n§lingot§r: §o§ningot(@Optional int harvestLevel, @Optional int burnTime)§r \nAdd an IngotProperty to this Material.\n §l○§r harvestLevel – The Harvest Level of this block for Mining. If this Material also has a ToolProperty, this value will also be used to determine the tool\u0027s Mining level. If this Material already had a Harvest Level defined, it will be overridden.\n §l○§r burnTime – The Burn Time (in ticks) of this Material as a Furnace Fuel. If this Material already had a Burn Time defined, it will be overridden.\n\n§lgem§r: §o§ngem(@Optional int harvestLevel, @Optional int burnTime)§r \nAdd a GemProperty to this Material.\n §l○§r harvestLevel – The Harvest Level of this block for Mining. If this Material also has a ToolProperty, this value will also be used to determine the tool\u0027s Mining level. If this Material already had a Harvest Level defined, it will be overridden.\n §l○§r burnTime – The Burn Time (in ticks) of this Material as a Furnace Fuel. If this Material already had a Burn Time defined, it will be overridden.\n\n§ltoolStats§r: §o§ntoolStats(float speed, float damage, int durability, int enchantability)§r \nSet the stat for tools which are made from this Material.\n §l○§r speed – Speed.\n §l○§r damage – Attack damage.\n §l○§r durability – Durability of tools.\n §l○§r enchantability – Enchantability of tools.\n\n§lblastTemp§r: §o§nblastTemp(int temp)§r \nBlast Furnace Temperature of this Material. If below 1000K, Primitive Blast Furnace recipes will be also added. If above 1750K, a Hot Ingot and its Vacuum Freezer recipe will be also added.\n\nIf a Material with this Property has a Fluid, its temperature will be set to this if it is the default Fluid temperature.\n §l○§r temp – Temperature.\n\n§lore§r: §o§nore(@Optional int oreMultiplier, @Optional int byproductMultiplier, @Optional boolean emissive)§r \nAdd ore blocks of this Material.\n §l○§r oreMultiplier – Crushed Ore output amount multiplier during Maceration. Default: 1 (no multiplier).\n §l○§r byproductMultiplier – Byproducts output amount multiplier during Maceration. Default: 1 (no multiplier).\n §l○§r emissive – Should ore block use the emissive texture. Default: false.\n\nEmissive ore as follow:" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/143446969-80de6354-ad12-4170-81f5-071d6c0bb7cd.png", - "width": 190, - "height": 110 - }, - { - "type": "textbox", - "content": [ - "§lwashedIn§r: §o§nwashedIn(String materialName, @Optional int washedAmount)§r \n\n§lwashedIn§r: §o§nwashedIn(Material material, @Optional int washedAmount)§r \nSet washing product of this Material (must has the ore property).\n §l○§r material – material.\n §l○§r washedAmount – amount.\n\n§lseparatedInto§r: §o§nseparatedInto(String... materialNames)§r \n\n§lseparatedInto§r: §o§nseparatedInto(Material... materials)§r \nSet separated products of this Material (must has the ore property).\n §l○§r materials – separated materials.\n\n§laddOreByproducts§r: §o§naddOreByproducts(String... materialNames)§r \n\n§laddOreByproducts§r: §o§naddOreByproducts(Material... materials)§r \nSet ore byproducts of this Material (must has the ore property).\n §l○§r materials – separated materials.\n\n§loreSmeltInto§r: §o§noreSmeltInto(String materialName)§r \n\n§loreSmeltInto§r: §o§noreSmeltInto(Material material)§r \nSet smelt product of this Material (must has the ore property).\n §l○§r material – material.\n\n§lpolarizesInto§r: §o§npolarizesInto(String materialName)§r \n\n§lpolarizesInto§r: §o§npolarizesInto(Material material)§r \nSet polarizes product of this Material (must has the ore property).\n §l○§r material – material.\n\n§larcSmeltInto§r: §o§narcSmeltInto(String materialName)§r \n\n§larcSmeltInto§r: §o§narcSmeltInto(Material material)§r \nSet arcSmelt product of this Material (must has the ore property).\n §l○§r material – material.\n\n§lmacerateInto§r: §o§nmacerateInto(String materialName)§r \n\n§lmacerateInto§r: §o§nmacerateInto(Material material)§r \nSet macerate product of this Material (must has the ore property).\n §l○§r material – material.\n\n§lingotSmeltInto§r: §o§ningotSmeltInto(String materialName)§r \n\n§lingotSmeltInto§r: §o§ningotSmeltInto(Material material)§r \nSet ingotSmelt product of this Material (must has the ore property).\n §l○§r material – material.\n\n§lfluidTemp§r: §o§nfluidTemp(int temp)§r \nSet the temperature of the fluid of this Material (must has the fluid property).\n §l○§r temp – temperature.\n\n§lcableProperties§r: §o§ncableProperties(long voltage, int amperage, int loss, @Optional boolean isSuperCon)§r \nAdd a cables and wires of this Material.\n §l○§r voltage – voltage.\n §l○§r amperage – amperage.\n §l○§r loss – loss.\n §l○§r isSuperCon – isSuperCon.\n\n§lfluidPipeProperties§r: §o§nfluidPipeProperties(int maxTemp, int throughput, boolean gasProof)§r \nAdd fluid pipes of this Material.\n §l○§r maxTemp – max acceptable temperature.\n §l○§r throughput – §l//TODO§r.\n §l○§r gasProof – §l//TODO§r.\n\n§litemPipeProperties§r: §o§nitemPipeProperties(int priority, float stacksPerSec)§r \nAdd item pipes of this Material.\n §l○§r priority – Items will try to take the path with the lowest priority.\n §l○§r stacksPerSec – rate in stacks per sec.\n\n§laddDefaultEnchant§r: §o§naddDefaultEnchant(IEnchantment enchantment)§r \nAdd Default Enchant of this Material.\n §l○§r enchantment – enchantment." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialRegistry§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0gold§r§5 §r§5\u003d§r§5 §r§0MaterialRegistry§r§5(§r§2\"gold\"§r§5)§r§5\n§r§9var§r§5 §r§0copper§r§5 §r§5\u003d§r§5 §r§0MaterialRegistry§r§5(§r§2\"copper\"§r§5)§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5 §r§8// name§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0color§r§5(§r§5-§r§c1§r§5)§r§5 §r§8// white§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0fluid§r§5(§r§2\"gas\"§r§5,§r§5 §r§cfalse§r§5)§r§5 §r§8// gas without block§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0dust§r§5(§r§5)§r§5 §r§8// has dust§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0ingot§r§5(§r§5)§r§5 §r§8// has ingot§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0toolStats§r§5(§r§c10§r§5,§r§5 §r§c3§r§5,§r§5 §r§c256§r§5,§r§5 §r§c21§r§5)§r§5 §r§8// tool stats§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0blastTemp§r§5(§r§c1000§r§5)§r§5 §r§8// EBF temperature§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0ore§r§5(§r§5)§r§5 §r§8// has ore blocks§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0addOreByproducts§r§5(§r§0gold§r§5,§r§5 §r§0copper§r§5)§r§5 §r§8// add byproducts§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0cableProperties§r§5(§r§c0§r§5,§r§5 §r§c2§r§5,§r§5 §r§c0§r§5,§r§5 §r§ctrue§r§5)§r§5 §r§8// add cables§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5.§r§0build§r§5(§r§5)§r§5;§r§5\n" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ico", - "content": [ - "§lMaterial IconSet" - ] - }, - { - "type": "textbox", - "content": [ - "§liconSet§r: §o§niconSet(String iconSet)§r \nSet the MaterialIconSet of this Material. Defaults vary depending on if the Material has a: \n §l○§r §nGemProperty§r, it will default to §l\"GEM_VERTICAL\"§r\n §l○§r §nIngotProperty§r or §nDustProperty§r, it will default to §l\"DULL\"§r\n §l○§r §nFluidProperty§r, it will default to either §l\"FLUID\"§r or §l\"GAS\"§r, depending on the FluidType\n §l○§r §nPlasmaProperty§r, it will default to §l\"FLUID\"§r\n\nDefault will be determined by first-found Property in this order, unless specified." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0iconSet§r§5(§r§2\"QUARTZ\"§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5\n§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "com", - "content": [ - "§lComponent" - ] - }, - { - "type": "textbox", - "content": [ - "The §lComponent§r refers to compositions of the material. \nFor example, the compositions of the §lSugar§r are §n2*Carbon§r, §n5*Water§r, and §n25*Oxygen§r. That would affect its chemical formula:" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/143438573-cd2e9078-744d-4861-a00c-1e9fc5ccd32a.png", - "width": 110, - "height": 50 - }, - { - "type": "textbox", - "content": [ - "§lcomponents§r: §o§ncomponents(MaterialStack[] components)§r \nSet the compositions of the material.\n §l○§r components - compositions." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialStack§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialRegistry§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0carbonMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialRegistry§r§5.§r§0get§r§5(§r§2\"carbon\"§r§5)§r§5;§r§5\n§r§9var§r§5 §r§0oxygenMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialRegistry§r§5.§r§0get§r§5(§r§2\"oxygen\"§r§5)§r§5;§r§5\n§r§5\n§r§0val§r§5 §r§0compositions§r§5 §r§0as§r§5 §r§0MaterialStack§r§5[§r§5]§r§5 §r§5\u003d§r§5 §r§5[§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§0carbonMaterial§r§5 §r§5*§r§5 §r§c2§r§5,§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§5 §r§0oxygenMaterial§r§5 §r§5*§r§5 §r§c3§r§5,§r§5\n§r§5 §r§5 §r§5 §r§5 §r§5]§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0components§r§5(§r§0compositions§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5\n§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "fla", - "content": [ - "§lMaterial Flag" - ] - }, - { - "type": "textbox", - "content": [ - "§lflags§r: §o§nflags(String... names)§r \nAdd MaterialFlags to this Material.\n §l○§r names - names of specific MaterialFlags." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0flags§r§5(§r§2\"generate_rod\"§r§5,§r§5 §r§2\"generate_foil\"§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5\n§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ele", - "content": [ - "§lElement" - ] - }, - { - "type": "textbox", - "content": [ - "§lelement§r: §o§nelement(String elementName)§r \nSet the element of this Material.\n §l○§r elementName - names of the element." - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialBuilder§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Elements§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0CEu§r§5 §r§5\u003d§r§5 §r§0Elements§r§5.§r§0add§r§5(§r§c999§r§5,§r§5 §r§c999§r§5,§r§5 §r§5-§r§c1§r§5,§r§5 §r§cnull§r§5,§r§5 §r§2\"GTCEu\"§r§5,§r§5 §r§2\"CEu\"§r§5,§r§5 §r§cfalse§r§5)§r§5;§r§5 §r§8// create a new element.§r§5\n§r§5\n§r§9var§r§5 §r§0myMaterial§r§5 §r§5\u003d§r§5 §r§0MaterialBuilder§r§5(§r§2\"my_material\"§r§5)§r§5.§r§0element§r§5(§r§2\"CEu\"§r§5)§r§5.§r§0build§r§5(§r§5)§r§5;§r§5 §r§8// register my element.§r§5\n§r" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/06_modify.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/06_modify.json deleted file mode 100644 index f9e1deeaf23..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/material/06_modify.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "section": "CraftTweaker/Material", - "title": "Modify Existing Materials", - "stream": [ - { - "type": "textbox", - "fontSize": 9, - "content": [ - "You can get Materials by the §lMaterialRegistry§r." - ] - }, - { - "type": "textbox", - "link": "element", - "content": [ - "1. §9Getters" - ] - }, - { - "type": "textbox", - "link": "ct", - "content": [ - "2. §9Setters" - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "element", - "content": [ - "§c§lGetters:" - ] - }, - { - "type": "textbox", - "content": [ - " §l○§r §o§nMaterialRegistry.get(String materialName)§r get §nMaterial§r by name.\n\n §l○§r §o§nMaterialRegistry.getAllMaterials()§r get §nMaterial§r List.\n\n §l○§r §o§ngetChemicalFormula()§r get default formula.\n\n §l○§r §o§nmaterialRGB§r get default materialRGB.\n\n §l○§r §o§nradioactive§r get default radioactive.\n\n §l○§r §o§nprotons§r get default protons.\n\n §l○§r §o§nneutrons§r get default neutrons.\n\n §l○§r §o§nmass§r get default mass.\n\n §l○§r §o§naverageProtons§r get default averageProtons.\n\n §l○§r §o§naverageNeutrons§r get default averageNeutrons.\n\n §l○§r §o§naverageMass§r get default averageMass.\n\n §l○§r §o§nblastTemperature§r get default blastTemperature.\n\n §l○§r §o§ncamelCaseName§r get default camelCaseName.\n\n §l○§r §o§nunlocalizedName§r get default unlocalizedName.\n\n §l○§r §o§nlocalizedName§r get default localizedName.\n\n §l○§r §o§nname§r get default name." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "ref": "ct", - "content": [ - "§c§lSetters:" - ] - }, - { - "type": "textbox", - "content": [ - " §l○§r §o§nsetFormula(String formula, @Optional boolean withFormatting)§r Set the formula of this Material.\n\n §l○§r §o§naddFlags(String... names)§r Add additional flags to this Material.\n\n §l○§r §o§nsetMaterialRGB(int materialRGB)§r Set the color of this Material.\n\n §l○§r §o§nsetFormula(String formula, @Optional boolean withFormatting)§r Set the formula of this Material." - ] - }, - { - "type": "textbox", - "content": [ - "\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d" - ] - }, - { - "type": "textbox", - "stroke": 687800320, - "stroke_width": 3, - "fill": 687800320, - "content": [ - "§5\n§r§8#loader gregtech§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0MaterialRegistry§r§5;§r§5\n§r§9import§r§5 §r§0mods§r§5.§r§0gregtech§r§5.§r§0material§r§5.§r§0Material§r§5;§r§5\n§r§5\n§r§9var§r§5 §r§0gold§r§5 §r§5\u003d§r§5 §r§0MaterialRegistry§r§5.§r§0get§r§5(§r§2\"gold\"§r§5)§r§5;§r§5\n§r§9var§r§5 §r§0name§r§5 §r§5\u003d§r§5 §r§0gold§r§5.§r§0name§r§5;§r§5 §r§8// \"gold\"§r§5\n§r§9var§r§5 §r§0color§r§5 §r§5\u003d§r§5 §r§0gold§r§5.§r§0materialRGB§r§5;§r§5 §r§8// 0xFFE650§r§5\n§r§0gold§r§5.§r§0setFormula§r§5(§r§2\"AggA\"§r§5)§r§5;§r§5 §r§8// set formula§r§5\n§r§9var§r§5 §r§0formula§r§5 §r§5\u003d§r§5 §r§0gold§r§5.§r§0getChemicalFormula§r§5(§r§5)§r§5;§r§5 §r§8// \"AggA\"§r§5\n§r§0gold§r§5.§r§0addFlag§r§5(§r§2\"generate_long_rod\"§r§5,§r§5 §r§2\"generate_gear\"§r§5)§r§5;§r§5 §r§8// add gold long rod, add gold gear§r§5\n§r" - ] - } - ], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/terminal/ct_terminal_01.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/terminal/ct_terminal_01.json deleted file mode 100644 index b1cdd3a9570..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/crafttweaker/terminal/ct_terminal_01.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "section": "CraftTweaker/Terminal", - "title": "CraftTweaker of Terminal", - "stream": [ - { - "type": "textbox", - "content": [ - "Content:" - ] - }, - { - "type": "textbox", - "content": [ - "§1§lURL:§r§n https://github.com/Gregicality/GregTech/wiki/CraftTweaker-of-Terminal" - ] - }, - { - "type": "textbox", - "ref": "api", - "isShadow": false, - "content": [ - "§4§lAPI:" - ] - }, - { - "type": "textbox", - "fontSize": 9, - "content": [ - "1. §1registerDevice(deviceItemStack, deviceName)§0:\nRegister the custon device.\n\n2. §1createAppRegistryBuilder(appName):\n§0Create the registryBuilder according to the app name (found in the store app).\n\n3. §1isDefaultApp(default):\n§0Make it as a default app.\n\n4. §1battery(euTier, cost):\n§0Set battery requirements for all tier.\n\n5. §1battery(appTier, euTier, cost):\n§0Set battery requirements for the specific tier.\n\n6. §1device(deviceName...):\n§0Set device requirements for all tier. (available by default: \"scanner\", \"wireless\", \"camera\", \"solar_lv\").\n\n7. §1device(appTier, device...):\n§0Set device requirements for the specific tier.\n\n8. §1upgrade(upgradeItemStack...):\n§0Set upgrade requirements for all tier.\n\n9. §1upgrade(appTier, upgradeItemStack...):\n§0Set upgrade requirements for the specific tier.\n\n10. §1build():\n§0finish and register." - ] - }, - { - "type": "textbox", - "ref": "demo", - "space": 1, - "content": [ - "\n§4§lZS Demo:" - ] - }, - { - "type": "textbox", - "fill": -912478525, - "fontSize": 9, - "content": [ - "import mods.gregtech.TerminalRegistry;\n\nTerminalRegistry.registerDevice(\u003core:ingotIron\u003e.firstItem, \"ingot_iron\");\n\nTerminalRegistry.createAppRegistryBuilder(\"ore_prospector\")\n .isDefaultApp(true)\n .battery(1, 500)\n .battery(3, 3, 1000)\n .device(\"camera\", \"wireless\")\n .device(4, \"ingot_iron\")\n .upgrade(\u003cminecraft:apple\u003e * 9)\n .upgrade(2, \u003cminecraft:apple\u003e * 9, \u003cminecraft:grass\u003e * 12)\n .build();" - ] - }, - { - "type": "textbox", - "fontSize": 9, - "content": [ - "§4§lResult:\n§rCustom Device" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280593-37922838-4a20-4e1b-9be9-73935c4c8c13.png", - "width": 190, - "height": 120 - }, - { - "type": "textbox", - "content": [ - "Register Battery, Device, and Upgrade" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280587-84dc8f67-6dde-472f-9ed8-6a4c5e71abc4.png", - "width": 190, - "height": 120 - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280590-d4700a88-5780-4e0f-95f8-130e82f4634a.png", - "width": 190, - "height": 120 - } - ], - "fixed": [ - { - "type": "textbox", - "x": 49, - "y": 40, - "width": 16, - "height": 10, - "link": "api", - "content": [ - "§9§napi" - ] - }, - { - "type": "textbox", - "x": 67, - "y": 40, - "width": 25, - "height": 10, - "link": "demo", - "content": [ - "§9§ndemo" - ] - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_0_guidepage.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_0_guidepage.json deleted file mode 100644 index 8fe3a94e403..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_0_guidepage.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "section": "Guide Widget Api", - "title": "Guide Page", - "stream": [ - { - "type": "textbox", - "content": [ - "In this page we'll learn how to write a guide page.", - "-------------------------------", - "Let's take a look at an example config file for a guide page.", - "§lJSON§r:", - "{", - " \"section\": \"section name here\",", - " \"title\": \"title here\",", - " \"stream\": [", - " {", - " \"type\": \"textbox\",", - " \"content\": [\"TextBox widget\"]", - " }", - " ],", - " \"fixed\": [", - " {", - " \"x\": 50,", - " \"y\": 100,", - " \"width\": 150,", - " \"height\": 40,", - " \"type\": 0,", - " \"content\": [\"TextBox widget\"]", - " }", - " ]", - "}", - "-------------------------------", - "§lContents§r" - ] - }, - { - "type": "textbox", - "link": "section", - "content": [ - " 1.§nsection§r" - ] - }, - { - "type": "textbox", - "link": "title", - "content": [ - " 2.§ntitle§r" - ] - }, - { - "type": "textbox", - "link": "stream", - "content": [ - " 3.§nstream§r" - ] - }, - { - "type": "textbox", - "link": "fixed", - "content": [ - " 4.§nfixed§r" - ] - }, - { - "type": "textbox", - "ref": "section", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nsection§r (§4required§r)", - "§ltype§r: String", - "§lillustrate§r: Specifies which section of the application the page belongs to.", - "The application automatically merges pages of the same section name and builds a directory tree." - ] - }, - { - "type": "textbox", - "ref": "title", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §ntitle§r (§4required§r)", - "§ltype§r: String", - "§lillustrate§r: The page title." - ] - }, - { - "type": "textbox", - "ref": "stream", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nstream§r (§4required§r)", - "§ltype§r: Array", - "§lillustrate§r: Widgets in streaming layout. You don't need to care the position and size of widgets in stream, all typography will be done automatically." - ] - }, - { - "type": "textbox", - "ref": "fixed", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nfixed§r (§4required§r)", - "§ltype§r: Array", - "§lillustrate§r: Widgets in fixed layout. You need to specify the position and size of each widget." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: fixed and stream" - ] - }, - { - "type": "textbox", - "isCenter": true, - "hover_text": ["stream widget"], - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [ - { - "type": "image", - "x": 30, - "y": 800, - "stroke": 4278190335, - "hover_text": ["fixed widget", "\"x\": 30","\"y\": 800","\"width\": 100","\"width\": 100"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_1_widget.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_1_widget.json deleted file mode 100644 index 7d8d23bea8c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_1_widget.json +++ /dev/null @@ -1,304 +0,0 @@ -{ - "section": "Guide Widget Api", - "title": "Guide Widget", - "stream": [ - { - "type": "textbox", - "content": [ - "In this page we'll learn what is §4§lGuide Widget§r, and its public attributes.", - "Widgets are rendered in the Guide Page, which is the basis for your custom pages. §nTextbox§r, §nImage§r, etc", - "To use it, just add the related JSON code under the §l\"fixed\"§r or §l\"stream\"§r.", - "There are some attributes effects (styles) that are valid for all widgets", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"type here\",", - " \"x\": 50,", - " \"y\": 100,", - " \"width\": 150,", - " \"height\": 40,", - " \"ref\": \"ref\",", - " \"stroke\": 0,", - " \"stroke_width\": 1,", - " \"fill\": 0,", - " \"link\": \"ref\"", - " \"hover_text\": [\"text here\"]", - "}", - "-------------------------------", - "§lContents§r" - ] - }, - { - "type": "textbox", - "link": "type", - "content": [ - " 1.§ntype§r" - ] - }, - { - "type": "textbox", - "link": "xywh", - "content": [ - " 2.§nx, y, width, height§r" - ] - }, - { - "type": "textbox", - "link": "ref", - "content": [ - " 3.§nref§r" - ] - }, - { - "type": "textbox", - "link": "fill", - "content": [ - " 4.§nfill§r" - ] - }, - { - "type": "textbox", - "link": "stroke", - "content": [ - " 5.§nstroke§r" - ] - }, - { - "type": "textbox", - "link": "stroke_width", - "content": [ - " 6.§nstroke_width§r" - ] - }, - { - "type": "textbox", - "link": "link", - "content": [ - " 7.§nlink§r" - ] - }, - { - "type": "textbox", - "link": "hover", - "content": [ - " 8.§nhover_text§r" - ] - }, - { - "type": "textbox", - "ref": "type", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §ntype§r (§4required§r)", - "§ltype§r: String", - "§lillustrate§r: This is the unique id of the widget. See the API documentation for each widget." - ] - }, - { - "type": "textbox", - "ref": "xywh", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nx, y, width, height§r (§4optional§r)", - "§ltype§r: Integer", - "§lillustrate§r: The position and size of the widget. In a stream layout, you usually don't need to set it (the image widget needs to set width and height). Under fixed layout you must set these four attributes." - ] - }, - { - "type": "textbox", - "ref": "ref", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nref§r (§4optional§r)", - "§ltype§r: String", - "§ldefault§r: null", - "§lillustrate§r: This is a tag of this widget. The ref should be unique on the same page." - ] - }, - { - "type": "textbox", - "ref": "fill", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nfill§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 0", - "§lillustrate§r: The background color." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: 4278190335 (0xFF0000FF)" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4278190335, - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "stroke", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nstroke§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 0", - "§lillustrate§r: The border color." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: 4278190335 (0xFF0000FF)" - ] - }, - { - "type": "image", - "form": "item", - "source": "minecraft:ender_pearl", - "stroke": 4278190335, - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "ref": "stroke_width", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nstroke_width§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 1", - "§lillustrate§r: The border width." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: 5" - ] - }, - { - "type": "image", - "form": "item", - "source": "minecraft:ender_pearl", - "stroke": 4278190335, - "stroke_width": 5, - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "ref": "link", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nlink§r (§6optional§r)", - "§ltype§r: String", - "§ldefault§r: null", - "§lillustrate§r: Click to jump to the specified location. Need to be used with ref, target is ref." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"P2\"" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4286430975, - "hover_text": ["\"ref\": \"P1\""], - "ref": "P1", - "link": "P2", - "content": ["Click Me!"] - }, - { - "type": "textbox", - "content": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"P1\"" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4286430975, - "hover_text": ["\"ref\": \"P2\""], - "ref": "P2", - "link": "P1", - "content": ["Click Me!"] - }, - { - "type": "textbox", - "ref": "hover", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nhover_text§r (§6optional§r)", - "§ltype§r: Array", - "§ldefault§r: null", - "§lillustrate§r: Displays text when the mouse is over the widget." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: [\"THIS IS\",\"GT ICON\"]" - ] - }, - { - "type": "image", - "hover_text": ["THIS IS","GT ICON"], - "form": "resource", - "source": "gregtech:textures/gui/icon/gregtech_logo.png", - "width": 100, - "height": 100 - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_2_textbox.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_2_textbox.json deleted file mode 100644 index f67b885350a..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_2_textbox.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "section": "Guide Widget Api", - "title": "1. TextBox Widget", - "stream": [ - { - "type": "textbox", - "content": [ - "In this page we'll learn how to use the powerful §4§lTextBox§r, which is the most commonly used. So you should read the API documentation carefully.", - "-------------------------------", - "§lWidget Type§r: §ntextbox§r", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"textbox\",", - " \"space\": 1,", - " \"fontSize\": 9,", - " \"fontColor\": 4278190080,", - " \"isCenter\": false,", - " \"isShadow\": false,", - " \"content\": [\"content here!\"]", - "}", - "-------------------------------", - "§lContents§r" - ] - }, - { - "type": "textbox", - "link": "content", - "content": [ - " 1.§ncontent§r" - ] - }, - { - "type": "textbox", - "link": "space", - "content": [ - " 2.§nspace§r" - ] - }, - { - "type": "textbox", - "link": "fontSize", - "content": [ - " 3.§nfontSize§r" - ] - }, - { - "type": "textbox", - "link": "fontColor", - "content": [ - " 4.§nfontColor§r" - ] - }, - { - "type": "textbox", - "link": "isCenter", - "content": [ - " 5.§nisCenter§r" - ] - }, - { - "type": "textbox", - "link": "isShadow", - "content": [ - " 6.§nisShadow§r" - ] - }, - { - "type": "textbox", - "ref": "content", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §ncontent§r (§4required§r)", - "§ltype§r: Array", - "§lillustrate§r: Text contents, each item will be a newline.Text that is too long will auto wrap itself. (Supporting Minecraft Formatting Code)" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "content": [ - "§lDemo§r: [...]", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "space", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nspace§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 1", - "§lillustrate§r: The spacing between lines of text." - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "space": 5, - "content": [ - "§lDemo§r: 5", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "fontSize", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nfontSize§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 9", - "§lillustrate§r: The font size. (Actually it's the height of the font)" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "fontSize": 5, - "content": [ - "§lDemo§r: 5", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "fontColor", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nfontColor§r (§6optional§r)", - "§ltype§r: Number", - "§ldefault§r: 4278190080", - "§lillustrate§r: The default color of the content. You can also set the colors with special symbols (provided by Minecraft).But maybe you need it sometimes." - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "fontColor": 5, - "content": [ - "§lDemo§r: 4294901760 (0xFFFF0000)", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "isCenter", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nisCenter§r (§6optional§r)", - "§ltype§r: Boolean", - "§ldefault§r: false", - "§lillustrate§r: Text-align center." - ] - }, - { - "type": "textbox", - "isCenter": false, - "stroke": 4294901760, - "content": [ - "§lDemo§r: false", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "isShadow", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nisShadow§r (§6optional§r)", - "§ltype§r: Boolean", - "§ldefault§r: false", - "§lillustrate§r: Render shadow." - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "isShadow": true, - "content": [ - "§lDemo§r: true", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_3_image.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_3_image.json deleted file mode 100644 index 39f6d14f5ad..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/guide_widget_api/api_3_image.json +++ /dev/null @@ -1,207 +0,0 @@ -{ - "section": "Guide Widget Api", - "title": "2. Image Widget", - "stream": [ - { - "type": "textbox", - "content": [ - "In this page we'll learn how to add an §4§lImage§r. There are three different forms of image supported here: §4Url§r, §4Item§r, and §4ResourceLocation§r. Don't worry, it's easy", - "-------------------------------", - "§lWidget Type§r: §nimage§r", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"image\",", - " \"form\": \"Item\",", - " \"source\": \"minecraft:ender_pearl\",", - " \"width\": 100,", - " \"height\": 100", - "}", - "-------------------------------", - "§lContents§r" - ] - }, - { - "type": "textbox", - "link": "form", - "content": [ - " 1.§nform§r" - ] - }, - { - "type": "textbox", - "link": "source", - "content": [ - " 2.§nsource§r" - ] - }, - { - "type": "textbox", - "link": "wh", - "content": [ - " 3.§nwidth, height§r" - ] - }, - { - "type": "textbox", - "ref": "form", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nform§r (§4required§r)", - "§ltype§r: String", - "§lillustrate§r: It can only be set one of §4Url§r, §4Item§r, or §4ResourceLocation§r.", - " \"url\" -- image url.", - " \"item\" -- The registered name of the Item in game.", - " \"resource\" -- The resource location." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"url\"" - ] - }, - { - "type": "image", - "hover_text": ["https://z3.ax1x.com/2021/07/29/Wb4Djs.gif"], - "form": "url", - "source": "https://z3.ax1x.com/2021/07/29/Wb4Djs.gif", - "stroke": 4278190080, - "stroke_width": 2, - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"item\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"resource\"" - ] - }, - { - "type": "image", - "hover_text": ["gregtech:textures/gui/icon/multiblock_category.png"], - "form": "resource", - "source": "gregtech:textures/gui/icon/multiblock_category.png", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "ref": "source", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nsource§r (§4required§r)", - "§ltype§r: String", - "§lillustrate§r: The source of the picture. The three images above correspond to the following sources:" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"https://z3.ax1x.com/2021/07/29/Wb4Djs.gif\"" - ] - }, - { - "type": "image", - "hover_text": ["https://z3.ax1x.com/2021/07/29/Wb4Djs.gif"], - "form": "url", - "source": "https://z3.ax1x.com/2021/07/29/Wb4Djs.gif", - "stroke": 4278190080, - "stroke_width": 2, - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"minecraft:ender_pearl\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"gregtech:textures/gui/icon/multiblock_category.png\"" - ] - }, - { - "type": "image", - "hover_text": ["gregtech:textures/gui/icon/multiblock_category.png"], - "form": "resource", - "source": "gregtech:textures/gui/icon/multiblock_category.png", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "ref": "wh", - "content": [ - "-------------------------------", - "", - "§lAttr§r: §nwidth, height§r (§4required§r)", - "§ltype§r: Integer", - "§lillustrate§r: The Size of the picture." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"50, 50\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§lDemo§r: \"100, 50\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 50 - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/important_concepts/machine_grid.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/important_concepts/machine_grid.json deleted file mode 100644 index 31aafa46b30..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/important_concepts/machine_grid.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "section": "Important Concepts", - "title": "Machine Grid", - "stream": [], - "fixed": [] -} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/forming_multiblocks.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/forming_multiblocks.json deleted file mode 100644 index e98245d48a4..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/forming_multiblocks.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "section": "Multiblocks", - "title": "Forming Multiblocks", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThis is a Guide to help you form Multiblocks and troubleshoot issues.§r\n\nThere are two really important factors to know when building Multiblocks.\n\n§lCheck the JEI preview:§r This one was probably obvious, but there\u0027s more than just a picture of how the Multiblock looks like! Use your mouse to §drotate§r the preview, §9hover over the parts§r to gain additional informations. The JEI page also contains the amount of blocks to build it. You can also §dright-click§r a block in the preview to get a display of all available blocks in that placement.\n\n\n§lThe JEI preview is a suggestion:§r There is no unique way to form the Multiblock. Most of the time, you have complete freedom for the §9tier of Buses/Hatches§r. And you also have the §dfreedom of placement§r.\n\nTaking the EBF as example, any tier of Energy/Bus/Hatch can be used, and they can be placed anywhere replacing a casing. Fluid Hatches are also optional, though you probably want them to handle recipes with fluid.\n\nAdditionally, you can §dsneak right-click§r the multiblock controller for an §6in-world preview§r, or use the §4Terminal§r\u0027s Multiblock Helper." - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/large_turbine_mechanics.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/large_turbine_mechanics.json deleted file mode 100644 index a96702086bc..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/large_turbine_mechanics.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "section": "Multiblocks", - "title": "Large Turbine Mechanics", - "stream": [ - { - "type": "textbox", - "content": [ - "§oThe Large Turbines are the most complex Multiblock Generators there exists in GTCEu in the present day.§r\n\nLet\u0027s start with the §4drawbacks§r of §3Large Turbines§r:\n§9-§r They work off §cInertia§r, which requires continuous running to achieve maximum Power.\n§9-§r Any excess unconsumed Energy produced will be §cvoided§r. So ideally you want to use large Energy buffers, and possibly control your Turbines with a redstone RS latch type of deal.\n§9-§r They require a §aRotor§r which loses durability over time and eventually §cbreak§r.\n§9-§r A little bit of Math is required to get the expected results.\n\n\nNow, with the §6upsides§r:\n§9-§r They can scale §9Power§r production substancially higher than the base output thanks to tiered §3Rotor Holders§r.\n§9-§r The §aRotor§r can give a huge boost to §dFuel efficiency§r, and §9Power§r production.\n§9-§r Self satisfaction for setting them up properly (yay!).\n\n\n§3Rotor Holders§r above the tier of the §3Large Turbine§r will §6double§r the production for every tier, multiplicatively.\n§3Rotor Holders§r above the tier of the §3Large Turbine§r will increase the efficiency by 10% for every tier, additively.\n\n§aRotors§r have a §9Power§r, §dEfficiency§r and §4Durability§r that are based on tool stats.\n§9Power§r multiplies the production of the §3Turbine§r. This stacks multiplicatively with the §3Rotor Holder§r.\n§dEfficiency§r reduces the fuel consumption. This stacks multiplicatively with the §3Rotor Holder§r.\n§4Durability§r is the lifetime of the §aRotor§r in seconds, when the §3Turbine§r is active.\n\n\n§2§lIn summary:§r\n\nThe §9Power§r output affects both the fuel consumption and the EU/t generation. It is calculated with the following formula:\n§cproduction \u003d baseEUt §l*§r rotorPower §l*§r 2^(rotorHolderTier - turbineTier)§r\n\nThe §dEfficiency§r reduces the fuel consumption, but does not alter the EU/t generation. It is calculated with the following formula:\n§cefficiency \u003d rotorEfficiency §l*§r (1 + 0.1 §l*§r (rotorHolderTier - turbineTier))§r\n\n\n§2§lSome examples:§r\n\nLarge Steam Turbine, with Ultimet Rotor and EV Rotor Holder:\nProduction \u003d 1024 §l*§r 1.60 §l*§r 2 \u003d 3276 EU/t\nEfficiency \u003d 1.30 §l*§r 1.10 \u003d 143%\n(Steam consumption \u003d 4582 L/t, this is above a Titanium Boiler, or a TungstenSteel Boiler with §m70% throttle)\n\nLarge Gas Turbine, with Chrome Rotor and EV Rotor Holder:\nProduction \u003d 4096 §l*§r 1.70 §l*§r 1 \u003d 5325 EU/t\nEfficiency \u003d 1.55 §l*§r 1.00 \u003d 155%\n(The same fuel consumption would produce 3435 EU/t using 6.7 Turbo Gas Turbines)\n\nLarge Plasma Turbine, with HSS-S Rotor and ZPM Rotor Holder:\nProduction \u003d 16834 §l*§r 2.50 §l*§r 4 \u003d 168340 EU/t\nEfficiency \u003d 1.80 §l*§r 1.20 \u003d 216%\n(This is more than a ZPM Amp!)" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/multibock_troubleshooting.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/multibock_troubleshooting.json deleted file mode 100644 index 096c157438a..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/multiblocks/multibock_troubleshooting.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "section": "Multiblocks", - "title": "Multiblock Troubleshooting", - "stream": [ - { - "type": "textbox", - "content": [ - "If a multiblock is formed, but you are having troubles figuring out why it does not run:\n§9-§r Check if the Multiblock is properly plugged in (we all make these mistakes!).\n\n§9-§r Do the initial Maintenance fix.\n\n§9-§r Verify the recipe usage, the max EU/t has to be greater than that of the recipe.\n\n§9- §rCheck the special requirements the recipe may have (JEI always has some kind of indication for it).\n\n§9-§r Make sure the recipe is properly input, this is less obvious than in a regular machine because you have to juggle between Input Bus and Input Hatch.\n\n§9-§r Make sure there is space for output. Maybe the multiblock formed but you forgot a Hatch. The other biggest offender is the Output Hatches being too low tier and having too little capacity!" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/resource_pack/emissive_texture.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/resource_pack/emissive_texture.json deleted file mode 100644 index 752ae4248f0..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/resource_pack/emissive_texture.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "section": "Resource Pack", - "title": "Custom Emissive Texture", - "stream": [ - { - "type": "textbox", - "content": [ - "Developers and resource pack authors can easily have emissive textures and set the bloom effect.\n\n§lContents:" - ] - }, - { - "type": "textbox", - "link": "emissive", - "content": [ - "1. §1Emissive Texture" - ] - }, - { - "type": "textbox", - "link": "bloom", - "content": [ - "2.§1 Bloom" - ] - }, - { - "type": "textbox", - "link": "demo", - "content": [ - "3. §1Demo" - ] - }, - { - "type": "textbox", - "ref": "emissive", - "content": [ - "§lEmissive Texture" - ] - }, - { - "type": "textbox", - "content": [ - "* For model-based blocks: Similar to §4CTM§r, you only need to set mcmeta file for the texture that you want to have the emissive effect." - ] - }, - { - "type": "card", - "fill": -3745585, - "width": 190, - "height": 100, - "isShadow": true - }, - { - "type": "textbox", - "content": [ - "§2light §rhere represents the default level of light it emit (from 0~15). Besides, you can also set sky and block separately as what CTM does." - ] - }, - { - "type": "textbox", - "content": [ - "* For CEu machines: They mostly are overlay textures under the assets/textures/blocks/machines and assets/textures/overlay/machines. You no need to set the mcmeta file for them. Just add a new texture file for the emissive part named \"XXX_emissive.png\"." - ] - }, - { - "type": "textbox", - "content": [ - "§lBloom" - ], - "ref": "bloom" - }, - { - "type": "textbox", - "content": [ - "* For CEu machines: You don\u0027t need to modify anything; all emissive textures have the bloom effect by default.\n\n* For model-based blocks: You just need to add an extra line to the mcmeta file. (§2\"layer\"§r: \"BLOOM\")" - ] - }, - { - "type": "card", - "fill": -3745585, - "width": 190, - "height": 110, - "isShadow": true - }, - { - "type": "textbox", - "ref": "demo", - "content": [ - "§lDemo" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/138578815-d2d4e357-8080-4d57-b8ac-61235eac8c2a.png", - "width": 190, - "height": 130 - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/138578838-b9e6a16d-e348-4fea-8ab4-8a940e1ecd0f.png", - "width": 190, - "height": 100 - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/138578853-9a2497f4-e1f5-45e9-ab64-26b5eb859139.png", - "width": 190, - "height": 110 - } - ], - "fixed": [ - { - "type": "textbox", - "x": 8, - "y": 206, - "width": 181, - "height": 90, - "content": [ - "{\n §2\"ctm\"§r: {\n §2\"ctm_version\"§r: 1,\n §2\"gregtech:§r true,\n §2\"extra\"§r: {\n §2\"light\"§r: 15\n }\n }\n}" - ] - }, - { - "type": "textbox", - "x": 8, - "y": 550, - "width": 181, - "height": 100, - "content": [ - "{\n §2\"ctm\"§r: {\n §2\"ctm_version\"§r: 1,\n §2\"layer\"§r: \"BLOOM\",\n §2\"gregtech\"§r true,\n §2\"extra\"§r: {\n §2\"light\"§r: 15\n }\n }\n}" - ] - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/terminal/terminal_hardware.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/terminal/terminal_hardware.json deleted file mode 100644 index 3a9c51f4a73..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/en_us/terminal/terminal_hardware.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "section": "Terminal", - "title": "Hardware", - "stream": [ - { - "type": "textbox", - "content": [ - "Current supported §4§lhardware§r:" - ] - }, - { - "type": "textbox", - "link": "battery", - "content": [ - " 1.§nBattery" - ] - }, - { - "type": "textbox", - "link": "device", - "content": [ - " 2.§nDevice" - ] - }, - { - "type": "textbox", - "isCenter": true, - "isShadow": false, - "content": [ - "§lBattery" - ], - "ref": "battery" - }, - { - "type": "card", - "fill": -2172721, - "width": 170, - "height": 90, - "isShadow": true - }, - { - "type": "textbox", - "ref": "device", - "isCenter": true, - "content": [ - "\n\n§lDevice" - ] - }, - { - "type": "card", - "fill": -2172721, - "width": 170, - "height": 133, - "isShadow": true - } - ], - "fixed": [ - { - "type": "textbox", - "x": 18, - "y": 92, - "width": 160, - "height": 30, - "content": [ - "All §4§lresuable§r batteries can be used as the §lBattery Hardware" - ] - }, - { - "type": "textbox", - "x": 53, - "y": 229, - "width": 102, - "height": 10, - "content": [ - "Wireless transmitter" - ] - }, - { - "type": "slots", - "x": 47, - "y": 136, - "width": 100, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 732, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 733, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 742, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 748, - "count": 1 - }, - { - "id": "gregtech:meta_item_1", - "damage": 753, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": -16, - "y": 224, - "width": 100, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 503, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": -16, - "y": 250, - "width": 100, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 466, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 52, - "y": 253, - "width": 100, - "height": 10, - "content": [ - "Prospector" - ] - }, - { - "type": "textbox", - "x": 52, - "y": 279, - "width": 100, - "height": 10, - "content": [ - "Solar" - ] - }, - { - "type": "slots", - "x": 10, - "y": 325, - "width": 48, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 467, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 12, - "y": 275, - "width": 45, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 333, - "count": 1 - } - ] - }, - { - "type": "slots", - "x": 22, - "y": 302, - "width": 25, - "height": 18, - "item_list": [ - { - "id": "gregtech:meta_item_1", - "damage": 504, - "count": 1 - } - ] - }, - { - "type": "textbox", - "x": 52, - "y": 306, - "width": 100, - "height": 10, - "content": [ - "Camera" - ] - }, - { - "type": "textbox", - "x": 51, - "y": 325, - "width": 100, - "height": 20, - "content": [ - "Advanced Prospector" - ] - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/crafttweaker/terminal/ct_terminal_01.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/crafttweaker/terminal/ct_terminal_01.json deleted file mode 100644 index d787b384e06..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/crafttweaker/terminal/ct_terminal_01.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "section": "CraftTweaker/终端", - "title": "终端的CT教程", - "stream": [ - { - "type": "textbox", - "content": [ - "目录:" - ] - }, - { - "type": "textbox", - "content": [ - "§1§lURL:§r§n https://github.com/Gregicality/GregTech/wiki/CraftTweaker-of-Terminal" - ] - }, - { - "type": "textbox", - "ref": "api", - "isShadow": false, - "content": [ - "§4§lAPI:" - ] - }, - { - "type": "textbox", - "fontSize": 9, - "content": [ - "1. §1registerDevice(deviceItemStack, deviceName)§0:\n注册自定义设备。\n\n2. §1createAppRegistryBuilder(appName):\n§0根据应用名称(可从商店获取)获得构造器。\n\n3. §1isDefaultApp(default):\n§0设置为默认应用。\n\n4. §1battery(euTier, cost):\n§0为所有层级设置相同的电池要求。\n\n5. §1battery(appTier, euTier, cost):\n§0为特定等级设置电池要求。\n\n6. §1device(deviceName...):\n§0为所有等级设置设备要求。 (默认可用设备: \"scanner\", \"wireless\", \"camera\", \"solar_lv\").\n\n7. §1device(appTier, device...):\n§0为特定等级设置设备要求。\n\n8. §1upgrade(upgradeItemStack...):\n§0设置所有等级的升级要求。\n\n9. §1upgrade(appTier, upgradeItemStack...):\n§0设置特定等级的升级和要求。\n\n10. §1build():\n§0完成并注册。" - ] - }, - { - "type": "textbox", - "ref": "demo", - "space": 1, - "content": [ - "\n§4§lZS Demo:" - ] - }, - { - "type": "textbox", - "fill": -912478525, - "fontSize": 9, - "content": [ - "import mods.gregtech.TerminalRegistry;\n\nTerminalRegistry.registerDevice(\u003core:ingotIron\u003e.firstItem, \"ingot_iron\");\n\nTerminalRegistry.createAppRegistryBuilder(\"ore_prospector\")\n .isDefaultApp(true)\n .battery(1, 500)\n .battery(3, 3, 1000)\n .device(\"camera\", \"wireless\")\n .device(4, \"ingot_iron\")\n .upgrade(\u003cminecraft:apple\u003e * 9)\n .upgrade(2, \u003cminecraft:apple\u003e * 9, \u003cminecraft:grass\u003e * 12)\n .build();" - ] - }, - { - "type": "textbox", - "fontSize": 9, - "content": [ - "§4§l结果:\n§r自定义设备" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280593-37922838-4a20-4e1b-9be9-73935c4c8c13.png", - "width": 190, - "height": 120 - }, - { - "type": "textbox", - "content": [ - "注册电池、设备、升级" - ] - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280587-84dc8f67-6dde-472f-9ed8-6a4c5e71abc4.png", - "width": 190, - "height": 120 - }, - { - "type": "image", - "form": "url", - "source": "https://user-images.githubusercontent.com/18493855/140280590-d4700a88-5780-4e0f-95f8-130e82f4634a.png", - "width": 190, - "height": 120 - } - ], - "fixed": [ - { - "type": "textbox", - "x": 27, - "y": 24, - "width": 16, - "height": 10, - "link": "api", - "content": [ - "§9§napi" - ] - }, - { - "type": "textbox", - "x": 41, - "y": 24, - "width": 25, - "height": 10, - "link": "demo", - "content": [ - "§9§ndemo" - ] - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_0_guidepage.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_0_guidepage.json deleted file mode 100644 index c501c92ca8c..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_0_guidepage.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "section": "指南页控件API", - "title": "指南页", - "stream": [ - { - "type": "textbox", - "content": [ - "这一页我们将学习如何编写指南页。", - "-------------------------------", - "先看一看一个简单里指南页示例。", - "§lJSON§r:", - "{", - " \"section\": \"section name here\",", - " \"title\": \"title here\",", - " \"stream\": [", - " {", - " \"type\": \"textbox\",", - " \"content\": [\"TextBox widget\"]", - " }", - " ],", - " \"fixed\": [", - " {", - " \"x\": 50,", - " \"y\": 100,", - " \"width\": 150,", - " \"height\": 40,", - " \"type\": 0,", - " \"content\": [\"TextBox widget\"]", - " }", - " ]", - "}", - "-------------------------------", - "§l目录§r" - ] - }, - { - "type": "textbox", - "link": "section", - "content": [ - " 1.§nsection§r" - ] - }, - { - "type": "textbox", - "link": "title", - "content": [ - " 2.§ntitle§r" - ] - }, - { - "type": "textbox", - "link": "stream", - "content": [ - " 3.§nstream§r" - ] - }, - { - "type": "textbox", - "link": "fixed", - "content": [ - " 4.§nfixed§r" - ] - }, - { - "type": "textbox", - "ref": "section", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nsection§r (§4必须§r)", - "§l类型§r: String", - "§l说明§r: 指定页面属于哪个章节。", - "指南App会自动合并具有相同节名的页面并构建目录树。" - ] - }, - { - "type": "textbox", - "ref": "title", - "content": [ - "-------------------------------", - "", - "§l属性§r: §ntitle§r (§4必须§r)", - "§l类型§r: String", - "§l说明§r: 页标题。" - ] - }, - { - "type": "textbox", - "ref": "stream", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nstream§r (§4必须§r)", - "§l类型§r: Array", - "§l说明§r: 属于流布局的控件。 你不需要关心控件在流中的位置和大小,所有的排版都会自动完成。" - ] - }, - { - "type": "textbox", - "ref": "fixed", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nfixed§r (§4必须§r)", - "§l类型§r: Array", - "§l说明§r: 属于固定布局的控件。 您需要指定每个控件的位置和大小。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: 固定布局和流布局" - ] - }, - { - "type": "textbox", - "isCenter": true, - "hover_text": ["流布局"], - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [ - { - "type": "image", - "x": 30, - "y": 800, - "stroke": 4278190335, - "hover_text": ["固定布局", "\"x\": 30","\"y\": 800","\"width\": 100","\"width\": 100"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - } - ] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_1_widget.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_1_widget.json deleted file mode 100644 index a1575f6685e..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_1_widget.json +++ /dev/null @@ -1,304 +0,0 @@ -{ - "section": "指南页控件API", - "title": "控件", - "stream": [ - { - "type": "textbox", - "content": [ - "这里我们将学习什么是 §4§l控件§r, 以及它的公共属性。", - "控件被渲染在指南页中,是一切的基础。 §n文本控件§r, §n图片控件§r, 等等", - "要使用控件,只需要将对应的控件配置写在 §l\"fixed\"§r 或者 §l\"stream\"§r下即可。", - "有一些公共属性、效果(样式)对所有控件都有效。", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"type here\",", - " \"x\": 50,", - " \"y\": 100,", - " \"width\": 150,", - " \"height\": 40,", - " \"ref\": \"ref\",", - " \"stroke\": 0,", - " \"stroke_width\": 1,", - " \"fill\": 0,", - " \"link\": \"ref\"", - " \"hover_text\": [\"text here\"]", - "}", - "-------------------------------", - "§l目录§r" - ] - }, - { - "type": "textbox", - "link": "type", - "content": [ - " 1.§ntype§r" - ] - }, - { - "type": "textbox", - "link": "xywh", - "content": [ - " 2.§nx, y, width, height§r" - ] - }, - { - "type": "textbox", - "link": "ref", - "content": [ - " 3.§nref§r" - ] - }, - { - "type": "textbox", - "link": "fill", - "content": [ - " 4.§nfill§r" - ] - }, - { - "type": "textbox", - "link": "stroke", - "content": [ - " 5.§nstroke§r" - ] - }, - { - "type": "textbox", - "link": "stroke_width", - "content": [ - " 6.§nstroke_width§r" - ] - }, - { - "type": "textbox", - "link": "link", - "content": [ - " 7.§nlink§r" - ] - }, - { - "type": "textbox", - "link": "hover", - "content": [ - " 8.§nhover_text§r" - ] - }, - { - "type": "textbox", - "ref": "type", - "content": [ - "-------------------------------", - "", - "§l属性§r: §ntype§r (§4必须§r)", - "§l类型§r: String", - "§l说明§r: 控件类型的唯一标识。通过api文档可以查看控件对应的控件类型标识。" - ] - }, - { - "type": "textbox", - "ref": "xywh", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nx, y, width, height§r (§4可选§r)", - "§l类型§r: Integer", - "§l说明§r: 控件的位置和大小。 在流布局中,通常不需要设置它(图片控件需要设置宽度和高度)。 在固定布局下,你必须设置这四个属性。" - ] - }, - { - "type": "textbox", - "ref": "ref", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nref§r (§4可选§r)", - "§l类型§r: String", - "§l缺省值§r: null", - "§l说明§r: 这是这个控件的一个引用标记。 同一页中的引用标记应该是唯一的。" - ] - }, - { - "type": "textbox", - "ref": "fill", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nfill§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 0", - "§l说明§r: 背景颜色。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: 4278190335 (0xFF0000FF)" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4278190335, - "content": [ - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "stroke", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nstroke§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 0", - "§l说明§r: 边框颜色" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: 4278190335 (0xFF0000FF)" - ] - }, - { - "type": "image", - "form": "item", - "source": "minecraft:ender_pearl", - "stroke": 4278190335, - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "ref": "stroke_width", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nstroke_width§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 1", - "§l说明§r: 边框宽度。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: 5" - ] - }, - { - "type": "image", - "form": "item", - "source": "minecraft:ender_pearl", - "stroke": 4278190335, - "stroke_width": 5, - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "ref": "link", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nlink§r (§6可选§r)", - "§l类型§r: String", - "§l缺省值§r: null", - "§l说明§r: 单击可跳转到指定引用的位置。需要与引用标记一起使用,目标是ref。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"P2\"" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4286430975, - "hover_text": ["\"ref\": \"P1\""], - "ref": "P1", - "link": "P2", - "content": ["点我!"] - }, - { - "type": "textbox", - "content": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"P1\"" - ] - }, - { - "type": "textbox", - "isCenter": true, - "fill": 4286430975, - "hover_text": ["\"ref\": \"P2\""], - "ref": "P2", - "link": "P1", - "content": ["点我!"] - }, - { - "type": "textbox", - "ref": "hover", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nhover_text§r (§6可选§r)", - "§l类型§r: Array", - "§l缺省值§r: null", - "§l说明§r: 鼠标悬停时的展示文本。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: [\"这是\",\"GT图标\"]" - ] - }, - { - "type": "image", - "hover_text": ["这是","GT图标"], - "form": "resource", - "source": "gregtech:textures/gui/icon/gregtech_logo.png", - "width": 100, - "height": 100 - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_2_textbox.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_2_textbox.json deleted file mode 100644 index 83c645bd0c2..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_2_textbox.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "section": "指南页控件API", - "title": "1. 文本控件", - "stream": [ - { - "type": "textbox", - "content": [ - "我们将学习指南中最常用的控件 §4§l文本控件§r。 因此,您应该仔细阅读API文档。", - "-------------------------------", - "§l控件类型标识§r: §ntextbox§r", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"textbox\",", - " \"space\": 1,", - " \"fontSize\": 9,", - " \"fontColor\": 4278190080,", - " \"isCenter\": false,", - " \"isShadow\": false,", - " \"content\": [\"content here!\"]", - "}", - "-------------------------------", - "§l目录§r" - ] - }, - { - "type": "textbox", - "link": "content", - "content": [ - " 1.§ncontent§r" - ] - }, - { - "type": "textbox", - "link": "space", - "content": [ - " 2.§nspace§r" - ] - }, - { - "type": "textbox", - "link": "fontSize", - "content": [ - " 3.§nfontSize§r" - ] - }, - { - "type": "textbox", - "link": "fontColor", - "content": [ - " 4.§nfontColor§r" - ] - }, - { - "type": "textbox", - "link": "isCenter", - "content": [ - " 5.§nisCenter§r" - ] - }, - { - "type": "textbox", - "link": "isShadow", - "content": [ - " 6.§nisShadow§r" - ] - }, - { - "type": "textbox", - "ref": "content", - "content": [ - "-------------------------------", - "", - "§l属性§r: §ncontent§r (§4必须§r)", - "§l类型§r: Array", - "§l说明§r: 文本内容数组,每一项都会换行。 文本太长会自动换行。 (支持Minecraft格式代码) " - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "content": [ - "§l示例§r: [...]", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "space", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nspace§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 1", - "§l说明§r: 文本行之间的间隔。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "space": 5, - "content": [ - "§l示例§r: 5", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "fontSize", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nfontSize§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 9", - "§l说明§r: 字体大小。(实际上是字体的高度)" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "fontSize": 5, - "content": [ - "§l示例§r: 5", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "fontColor", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nfontColor§r (§6可选§r)", - "§l类型§r: Number", - "§l缺省值§r: 4278190080", - "§l说明§r: 文本的默认颜色。你也可以用特殊的符号设置颜色(Minecraft提供的)。但也许有时候你需要它。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "fontColor": 5, - "content": [ - "§l示例§r: 4294901760 (0xFFFF0000)", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - }, - { - "type": "textbox", - "ref": "isCenter", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nisCenter§r (§6可选§r)", - "§l类型§r: Boolean", - "§l缺省值§r: false", - "§l说明§r: 文本水平居中。" - ] - }, - { - "type": "textbox", - "isCenter": false, - "stroke": 4294901760, - "content": [ - "§l示例§r: false", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - },{ - "type": "textbox", - "ref": "isShadow", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nisShadow§r (§6可选§r)", - "§l类型§r: Boolean", - "§l缺省值§r: false", - "§l说明§r: 渲染文本阴影。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "stroke": 4294901760, - "isShadow": true, - "content": [ - "§l示例§r: true", - "§nMinecraft Formatting", - "§r§00 §11 §22 §33", - "§44 §55 §66 §77", - "§88 §99 §aa §bb", - "§cc §dd §ee §ff", - "§r§0k §kMinecraft", - "§rl §lMinecraft", - "§rm §mMinecraft", - "§rn §nMinecraft", - "§ro §oMinecraft", - "§rr §rMinecraft" - ] - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_3_image.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_3_image.json deleted file mode 100644 index 9098438adb2..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/guide_widget_api/api_3_image.json +++ /dev/null @@ -1,207 +0,0 @@ -{ - "section": "指南页控件API", - "title": "2. 图片控件", - "stream": [ - { - "type": "textbox", - "content": [ - "我们将学习实用的§4§l图片控件§r。这里支持三种不同形式的图像:§4Url§r, §4Item§r, and §4ResourceLocation§r。别担心,一切都很容易。", - "-------------------------------", - "§l控件类型标识§r: §nimage§r", - "-------------------------------", - "§lJSON§r:", - "{", - " \"type\": \"image\",", - " \"form\": \"Item\",", - " \"source\": \"minecraft:ender_pearl\",", - " \"width\": 100,", - " \"height\": 100", - "}", - "-------------------------------", - "§l目录§r" - ] - }, - { - "type": "textbox", - "link": "form", - "content": [ - " 1.§nform§r" - ] - }, - { - "type": "textbox", - "link": "source", - "content": [ - " 2.§nsource§r" - ] - }, - { - "type": "textbox", - "link": "wh", - "content": [ - " 3.§nwidth, height§r" - ] - }, - { - "type": "textbox", - "ref": "form", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nform§r (§4必须§r)", - "§l类型§r: String", - "§l说明§r: 它只能是 §4Url§r, §4Item§r, 或 §4ResourceLocation§r中的一个。", - " \"url\" -- image url.", - " \"item\" -- The registered name of the Item in game.", - " \"resource\" -- The resource location." - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"url\"" - ] - }, - { - "type": "image", - "hover_text": ["https://z3.ax1x.com/2021/07/29/Wb4Djs.gif"], - "form": "url", - "source": "https://z3.ax1x.com/2021/07/29/Wb4Djs.gif", - "stroke": 4278190080, - "stroke_width": 2, - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"item\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"resource\"" - ] - }, - { - "type": "image", - "hover_text": ["gregtech:textures/gui/icon/coke_oven.png"], - "form": "resource", - "source": "gregtech:textures/gui/icon/coke_oven.png", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "ref": "source", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nsource§r (§4必须§r)", - "§l类型§r: String", - "§l说明§r: The source of the picture. The three images above correspond to the following sources:" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"https://z3.ax1x.com/2021/07/29/Wb4Djs.gif\"" - ] - }, - { - "type": "image", - "hover_text": ["https://z3.ax1x.com/2021/07/29/Wb4Djs.gif"], - "form": "url", - "source": "https://z3.ax1x.com/2021/07/29/Wb4Djs.gif", - "stroke": 4278190080, - "stroke_width": 2, - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"minecraft:ender_pearl\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"gregtech:textures/gui/icon/coke_oven.png\"" - ] - }, - { - "type": "image", - "hover_text": ["gregtech:textures/gui/icon/coke_oven.png"], - "form": "resource", - "source": "gregtech:textures/gui/icon/coke_oven.png", - "width": 100, - "height": 100 - }, - { - "type": "textbox", - "ref": "wh", - "content": [ - "-------------------------------", - "", - "§l属性§r: §nwidth, height§r (§4必须§r)", - "§l类型§r: Integer", - "§l说明§r: 图片尺寸。" - ] - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"50, 50\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 50, - "height": 50 - }, - { - "type": "textbox", - "isCenter": true, - "content": [ - "§l示例§r: \"100, 50\"" - ] - }, - { - "type": "image", - "hover_text": ["minecraft:ender_pearl"], - "form": "item", - "source": "minecraft:ender_pearl", - "width": 100, - "height": 50 - } - ], - "fixed": [] -} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/resource_pack/emissive_texture.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/resource_pack/emissive_texture.json deleted file mode 100644 index dfef1a0bd48..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/resource_pack/emissive_texture.json +++ /dev/null @@ -1 +0,0 @@ -{"section":"资源包","title":"自定义发光材质","stream":[{"type":"textbox","content":["开发人员和资源包作者可以很容易地有发光材质和设置泛光效果。\n\n§l目录:"]},{"type":"textbox","link":"emissive","content":["1. §1发光材质"]},{"type":"textbox","link":"bloom","content":["2.§1 泛光"]},{"type":"textbox","link":"demo","content":["3. §1示例"]},{"type":"textbox","ref":"emissive","content":["§l发光材质"]},{"type":"textbox","content":["* 对于常规模型: 与§4CTM§r相似,你只需要为你想要有发射效果的材质配置mcmeta文件即可。"]},{"type":"card","fill":-3745585,"width":190,"height":100,"isShadow":true},{"type":"textbox","content":["这里的§2light §r表示它发出的默认光级别(从0~15)。另外,你也可以像CTM一样把sky和block分开设置。"]},{"type":"textbox","content":["* 对于CEu机器: 他们材质大多数在 assets/textures/blocks/machines 和 assets/textures/overlay/machines下。 你不需要为他们设置mcmeta文件。只需为发光部分添加一个名为 \"XXX_emissive.png\"的材质即可。"]},{"type":"textbox","content":["§l泛光"],"ref":"bloom"},{"type":"textbox","content":["* 对于CEu机器: 你不需要修改任何东西,所有发光的材质都自带泛光。\n\n* 对于基本模型: 你只需要在mcmeta文件中添加额外的一行。 (§2\"layer\"§r: \"BLOOM\")"]},{"type":"card","fill":-3745585,"width":190,"height":110,"isShadow":true},{"type":"textbox","ref":"demo","content":["§l示例"]},{"type":"image","form":"url","source":"https://user-images.githubusercontent.com/18493855/138578815-d2d4e357-8080-4d57-b8ac-61235eac8c2a.png","width":190,"height":130},{"type":"image","form":"url","source":"https://user-images.githubusercontent.com/18493855/138578838-b9e6a16d-e348-4fea-8ab4-8a940e1ecd0f.png","width":190,"height":100},{"type":"image","form":"url","source":"https://user-images.githubusercontent.com/18493855/138578853-9a2497f4-e1f5-45e9-ab64-26b5eb859139.png","width":190,"height":110}],"fixed":[{"type":"textbox","x":8,"y":171,"width":181,"height":90,"content":["{\n §2\"ctm\"§r: {\n §2\"ctm_version\"§r: 1,\n §2\"gregtech:§r true,\n §2\"extra\"§r: {\n §2\"light\"§r: 15\n }\n }\n}"]},{"type":"textbox","x":7,"y":466,"width":181,"height":100,"content":["{\n §2\"ctm\"§r: {\n §2\"ctm_version\"§r: 1,\n §2\"layer\"§r: \"BLOOM\",\n §2\"gregtech\"§r true,\n §2\"extra\"§r: {\n §2\"light\"§r: 15\n }\n }\n}"]}]} diff --git a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/terminal/terminal_hardware.json b/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/terminal/terminal_hardware.json deleted file mode 100644 index ebfa5647886..00000000000 --- a/src/main/resources/assets/gregtech/terminal/guide/tutorials/zh_cn/terminal/terminal_hardware.json +++ /dev/null @@ -1 +0,0 @@ -{"section":"终端","title":"Hardware","stream":[{"type":"textbox","content":["Current supported §4§lhardware§r:"]},{"type":"textbox","link":"battery","content":[" 1.§nBattery"]},{"type":"textbox","link":"device","content":[" 2.§nDevice"]},{"type":"textbox","isCenter":true,"isShadow":false,"content":["§lBattery"],"ref":"battery"},{"type":"card","fill":-2172721,"width":170,"height":90,"isShadow":true},{"type":"textbox","ref":"device","isCenter":true,"content":["\n\n§lDevice"]},{"type":"card","fill":-2172721,"width":170,"height":113,"isShadow":true}],"fixed":[{"type":"textbox","x":18,"y":92,"width":160,"height":30,"content":["All §4§lresuable§r batteries could be used as the §lBattery Hardware"]},{"type":"textbox","x":53,"y":229,"width":102,"height":10,"content":["Wireless transmitter"]},{"type":"slots","x":47,"y":136,"width":100,"height":18,"item_list":[{"id":"gregtech:meta_item_1","damage":732,"count":1},{"id":"gregtech:meta_item_1","damage":733,"count":1},{"id":"gregtech:meta_item_1","damage":742,"count":1},{"id":"gregtech:meta_item_1","damage":748,"count":1},{"id":"gregtech:meta_item_1","damage":753,"count":1}]},{"type":"slots","x":-16,"y":224,"width":100,"height":18,"item_list":[{"id":"gregtech:meta_item_1","damage":468,"count":1}]},{"type":"slots","x":-16,"y":250,"width":100,"height":18,"item_list":[{"id":"gregtech:meta_item_1","damage":465,"count":1}]},{"type":"textbox","x":52,"y":253,"width":100,"height":10,"content":["Scanner"]},{"type":"textbox","x":52,"y":279,"width":100,"height":10,"content":["Solar"]},{"type":"slots","x":12,"y":275,"width":45,"height":18,"item_list":[{"id":"gregtech:meta_item_1","damage":333,"count":1}]},{"type":"slots","x":22,"y":302,"width":25,"height":18,"item_list":[{"id":"gregtech:meta_item_1","damage":469,"count":1}]},{"type":"textbox","x":52,"y":306,"width":100,"height":10,"content":["Camera"]}]} diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/console/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/console/icon.png deleted file mode 100644 index 1aa90b06a4b..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/console/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/fluid_prospector/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/fluid_prospector/icon.png deleted file mode 100644 index c9ef5ce0d7a..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/fluid_prospector/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_down.png b/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_down.png deleted file mode 100644 index 67e56db7dc7..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_down.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_up.png b/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_up.png deleted file mode 100644 index 9e7a2e0ff8d..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/frame_side_up.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/guide_editor/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/guide_editor/icon.png deleted file mode 100644 index d9f2047fd1a..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/guide_editor/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/hardware_manager/circuit.png b/src/main/resources/assets/gregtech/textures/gui/terminal/hardware_manager/circuit.png deleted file mode 100644 index 1d9e6095cab..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/hardware_manager/circuit.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/icon.png deleted file mode 100644 index 82a592d8ac6..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/profile.png b/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/profile.png deleted file mode 100644 index d7ad55895cb..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/multiblock_ar/profile.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/ore_prospector/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/ore_prospector/icon.png deleted file mode 100644 index 9aa927b81f8..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/ore_prospector/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_dialog.png b/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_dialog.png deleted file mode 100644 index d18efc6cbc1..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_dialog.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_frame.png b/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_frame.png deleted file mode 100644 index b557aef1cc1..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_frame.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_home.png b/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_home.png deleted file mode 100644 index 4d7bac24410..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/terminal_home.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/vtank_viewer/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/vtank_viewer/icon.png deleted file mode 100644 index d287058807f..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/vtank_viewer/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/icon.png b/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/icon.png deleted file mode 100644 index 32acbcd65c2..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/icon.png and /dev/null differ diff --git a/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/profile.png b/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/profile.png deleted file mode 100644 index 1575c67f60b..00000000000 Binary files a/src/main/resources/assets/gregtech/textures/gui/terminal/world_prospector/profile.png and /dev/null differ