├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── malilib │ ├── MaLiLib.java │ ├── MaLiLibActions.java │ ├── MaLiLibConfigInit.java │ ├── MaLiLibConfigScreen.java │ ├── MaLiLibConfigs.java │ ├── MaLiLibHotkeyProvider.java │ ├── MaLiLibInitHandler.java │ ├── MaLiLibReference.java │ ├── MinecraftClientAccessor.java │ ├── action │ ├── Action.java │ ├── ActionContext.java │ ├── ActionExecutionWidgetManager.java │ ├── ActionGroup.java │ ├── ActionList.java │ ├── ActionRegistry.java │ ├── ActionStorage.java │ ├── ActionType.java │ ├── AliasAction.java │ ├── MacroAction.java │ ├── NamedAction.java │ ├── ParameterizableNamedAction.java │ ├── ParameterizedAction.java │ ├── ParameterizedNamedAction.java │ ├── SimpleNamedAction.java │ ├── builtin │ │ ├── BaseBooleanConfigAction.java │ │ ├── BooleanDisableAction.java │ │ ├── BooleanEnableAction.java │ │ ├── BooleanToggleAction.java │ │ ├── ConfigActions.java │ │ ├── EventAction.java │ │ └── UtilityActions.java │ └── util │ │ └── ActionUtils.java │ ├── command │ └── ClientCommandHandler.java │ ├── compat │ └── modmenu │ │ └── ModMenuImpl.java │ ├── config │ ├── BaseModConfig.java │ ├── ConfigManager.java │ ├── ConfigManagerImpl.java │ ├── JsonModConfig.java │ ├── ModConfig.java │ ├── ValueChangeCallback.java │ ├── ValueLoadCallback.java │ ├── category │ │ ├── BaseConfigOptionCategory.java │ │ └── ConfigOptionCategory.java │ ├── group │ │ ├── BaseConfigGroup.java │ │ ├── ExpandableConfigGroup.java │ │ └── PopupConfigGroup.java │ ├── option │ │ ├── BaseBooleanAndNumberConfig.java │ │ ├── BaseConfig.java │ │ ├── BaseConfigOption.java │ │ ├── BaseDualValueConfig.java │ │ ├── BaseGenericConfig.java │ │ ├── BaseInfo.java │ │ ├── BaseSliderConfig.java │ │ ├── BooleanAndDoubleConfig.java │ │ ├── BooleanAndFileConfig.java │ │ ├── BooleanAndIntConfig.java │ │ ├── BooleanConfig.java │ │ ├── BooleanContainingConfig.java │ │ ├── ColorConfig.java │ │ ├── CommonDescription.java │ │ ├── ConfigInfo.java │ │ ├── ConfigOption.java │ │ ├── DirectoryConfig.java │ │ ├── DoubleConfig.java │ │ ├── DualColorConfig.java │ │ ├── FileConfig.java │ │ ├── GenericButtonConfig.java │ │ ├── HotkeyConfig.java │ │ ├── HotkeyedBooleanConfig.java │ │ ├── IntegerConfig.java │ │ ├── OptionListConfig.java │ │ ├── OverridableConfig.java │ │ ├── SliderConfig.java │ │ ├── StringConfig.java │ │ ├── Vec2dConfig.java │ │ ├── Vec2iConfig.java │ │ └── list │ │ │ ├── BlackWhiteListConfig.java │ │ │ ├── BlockListConfig.java │ │ │ ├── EquipmentSlotListConfig.java │ │ │ ├── IdentifierListConfig.java │ │ │ ├── ItemListConfig.java │ │ │ ├── StatusEffectListConfig.java │ │ │ ├── StringListConfig.java │ │ │ └── ValueListConfig.java │ ├── serialization │ │ ├── JsonConfigDeserializers.java │ │ ├── JsonConfigSerializerRegistry.java │ │ └── JsonConfigSerializers.java │ ├── util │ │ ├── ConfigLockHandler.java │ │ ├── ConfigLockUtils.java │ │ ├── ConfigUpdateUtils.java │ │ ├── ConfigUtils.java │ │ └── JsonConfigUtils.java │ └── value │ │ ├── ActiveMode.java │ │ ├── BaseOptionListConfigValue.java │ │ ├── BlackWhiteList.java │ │ ├── BlockSnap.java │ │ ├── FileBrowserColumns.java │ │ ├── FileWriteType.java │ │ ├── HorizontalAlignment.java │ │ ├── HudAlignment.java │ │ ├── KeybindDisplayMode.java │ │ ├── LayerMode.java │ │ ├── OptionListConfigValue.java │ │ ├── ScreenCorner.java │ │ ├── ScreenLocation.java │ │ ├── SortDirection.java │ │ └── VerticalAlignment.java │ ├── event │ ├── ClientTickHandler.java │ ├── ClientWorldChangeHandler.java │ ├── InitializationHandler.java │ ├── PostGameOverlayRenderer.java │ ├── PostItemTooltipRenderer.java │ ├── PostScreenRenderer.java │ ├── PostWorldRenderer.java │ ├── PrioritizedEventHandler.java │ └── dispatch │ │ ├── ClientWorldChangeEventDispatcher.java │ │ ├── ClientWorldChangeEventDispatcherImpl.java │ │ ├── InitializationDispatcher.java │ │ ├── InitializationDispatcherImpl.java │ │ ├── RenderEventDispatcher.java │ │ ├── RenderEventDispatcherImpl.java │ │ ├── TickEventDispatcher.java │ │ └── TickEventDispatcherImpl.java │ ├── gui │ ├── BaseConfirmActionScreen.java │ ├── BaseImportExportEntriesListScreen.java │ ├── BaseListScreen.java │ ├── BaseMultiListScreen.java │ ├── BaseScreen.java │ ├── BaseTabbedScreen.java │ ├── BaseTextInputScreen.java │ ├── ChooseActionScreen.java │ ├── ConfirmActionScreen.java │ ├── DirectorySelectorScreen.java │ ├── DualTextInputScreen.java │ ├── ExportEntriesListScreen.java │ ├── FileSelectorScreen.java │ ├── ImportEntriesListScreen.java │ ├── StringListSelectionScreen.java │ ├── TextInputScreen.java │ ├── action │ │ ├── ActionListScreen.java │ │ ├── ActionPromptScreen.java │ │ ├── ActionWidgetContainer.java │ │ ├── ActionWidgetScreen.java │ │ ├── ActionWidgetScreenData.java │ │ ├── AddActionExecutionWidgetScreen.java │ │ ├── BaseActionExecutionWidget.java │ │ ├── BaseActionListScreen.java │ │ ├── EditActionExecutionWidgetScreen.java │ │ ├── MacroActionEditScreen.java │ │ ├── RadialActionExecutionWidget.java │ │ └── RectangularActionExecutionWidget.java │ ├── callback │ │ ├── DoubleSliderCallback.java │ │ ├── FloatSliderCallback.java │ │ ├── IntegerSliderCallback.java │ │ ├── SliderCallback.java │ │ ├── SliderCallbackWithText.java │ │ └── SteppedSliderCallback.java │ ├── config │ │ ├── BaseConfigGroupEditScreen.java │ │ ├── BaseConfigScreen.java │ │ ├── BaseConfigTab.java │ │ ├── BaseValueListEditScreen.java │ │ ├── BlackWhiteListEditScreen.java │ │ ├── ConfigOptionWidgetFactory.java │ │ ├── ConfigSearchInfo.java │ │ ├── ConfigTab.java │ │ ├── ConfigWidgetContext.java │ │ ├── KeybindSettingsScreen.java │ │ ├── MissingConfigTypeFactory.java │ │ ├── indicator │ │ │ ├── BaseConfigStatusIndicatorEditScreen.java │ │ │ ├── BooleanConfigStatusIndicatorEditScreen.java │ │ │ ├── ConfigStatusIndicatorGroupAddConfigsScreen.java │ │ │ ├── ConfigStatusIndicatorGroupEditScreen.java │ │ │ ├── ConfigStatusWidgetFactory.java │ │ │ ├── ConfigStatusWidgetRegistry.java │ │ │ └── HotkeyedBooleanConfigStatusIndicatorEditScreen.java │ │ └── registry │ │ │ ├── ConfigScreenRegistry.java │ │ │ ├── ConfigTabExtensionRegistry.java │ │ │ ├── ConfigTabRegistry.java │ │ │ ├── ConfigTabRegistryImpl.java │ │ │ └── ConfigWidgetRegistry.java │ ├── edit │ │ ├── BaseLayerRangeEditScreen.java │ │ ├── ColorEditorScreenHsv.java │ │ ├── CustomHotkeyEditScreen.java │ │ ├── CustomHotkeysListScreen.java │ │ ├── CustomIconEditScreen.java │ │ ├── CustomIconListScreen.java │ │ ├── EdgeIntEditScreen.java │ │ ├── MessageRedirectListScreen.java │ │ ├── TranslationOverridesListScreen.java │ │ └── overlay │ │ │ ├── AllInfoWidgetsListScreen.java │ │ │ ├── ConfigStatusIndicatorWidgetListScreen.java │ │ │ ├── InfoRendererWidgetListScreen.java │ │ │ ├── MessageRendererWidgetEditScreen.java │ │ │ ├── StringListRendererWidgetEditScreen.java │ │ │ └── ToastRendererWidgetEditScreen.java │ ├── icon │ │ ├── BaseIcon.java │ │ ├── BaseIconProvider.java │ │ ├── DefaultFileBrowserIconProvider.java │ │ ├── DefaultIcons.java │ │ ├── FileBrowserIconProvider.java │ │ ├── Icon.java │ │ ├── IconProvider.java │ │ ├── IconRegistry.java │ │ ├── NamedBaseIcon.java │ │ ├── NamedIcon.java │ │ └── PositionedIcon.java │ ├── listener │ │ ├── DoubleModifierButtonListener.java │ │ ├── DoubleTextFieldListener.java │ │ ├── IntegerModifierButtonListener.java │ │ └── IntegerTextFieldListener.java │ ├── tab │ │ ├── BaseScreenTab.java │ │ ├── ScreenTab.java │ │ └── TabbedScreenState.java │ ├── util │ │ ├── BackgroundRenderer.java │ │ ├── BackgroundSettings.java │ │ ├── BorderRenderer.java │ │ ├── BorderSettings.java │ │ ├── DraggedCorner.java │ │ ├── ElementOffset.java │ │ ├── GeometryResizeNotifier.java │ │ ├── GuiUtils.java │ │ ├── ScreenContext.java │ │ └── TextRegion.java │ └── widget │ │ ├── BackgroundWidget.java │ │ ├── BaseDualNumberEditWidget.java │ │ ├── BaseLayerRangeEditWidget.java │ │ ├── BaseModelWidget.java │ │ ├── BaseNumberEditWidget.java │ │ ├── BaseSliderWidget.java │ │ ├── BaseTextFieldWidget.java │ │ ├── BaseTripleNumberEditWidget.java │ │ ├── BaseWidget.java │ │ ├── BlockModelWidget.java │ │ ├── BlockPosEditWidget.java │ │ ├── BooleanEditWidget.java │ │ ├── CheckBoxWidget.java │ │ ├── ColorEditorWidgetHsv.java │ │ ├── ColorIndicatorAndEditWidget.java │ │ ├── ColorIndicatorWidget.java │ │ ├── ContainerWidget.java │ │ ├── CyclableContainerWidget.java │ │ ├── DoubleEditWidget.java │ │ ├── DoubleTextFieldWidget.java │ │ ├── DropDownListWidget.java │ │ ├── EdgeIntEditWidget.java │ │ ├── FloatEditWidget.java │ │ ├── HorizontalColorSliderWidget.java │ │ ├── HorizontalHueSliderWidget.java │ │ ├── HorizontalSliderWidget.java │ │ ├── HoverInfoWidget.java │ │ ├── IconWidget.java │ │ ├── InfoIconWidget.java │ │ ├── IntegerEditWidget.java │ │ ├── IntegerTextFieldWidget.java │ │ ├── InteractableWidget.java │ │ ├── ItemStackWidget.java │ │ ├── KeybindSettingsWidget.java │ │ ├── LabelWidget.java │ │ ├── MenuEntryWidget.java │ │ ├── MenuWidget.java │ │ ├── QuadColorIndicatorWidget.java │ │ ├── RadioButtonWidget.java │ │ ├── ScrollBarWidget.java │ │ ├── Vec2dEditWidget.java │ │ ├── Vec2iEditWidget.java │ │ ├── Vec3dEditWidget.java │ │ ├── Vec3iEditWidget.java │ │ ├── VerticalHueSliderWidget.java │ │ ├── button │ │ ├── BaseValueListEditButton.java │ │ ├── BlackWhiteListEditButton.java │ │ ├── BooleanConfigButton.java │ │ ├── ButtonActionListener.java │ │ ├── GenericButton.java │ │ ├── KeyBindConfigButton.java │ │ ├── OnOffButton.java │ │ └── OptionListConfigButton.java │ │ ├── list │ │ ├── BaseFileBrowserWidget.java │ │ ├── BaseListWidget.java │ │ ├── ConfigOptionListWidget.java │ │ ├── DataListEntrySelectionHandler.java │ │ ├── DataListWidget.java │ │ ├── ListEntryWidgetFactory.java │ │ ├── ListEntryWidgetInitializer.java │ │ ├── SelectionListener.java │ │ ├── entry │ │ │ ├── BaseDataListEntryWidget.java │ │ │ ├── BaseInfoRendererWidgetEntryWidget.java │ │ │ ├── BaseListEntryWidget.java │ │ │ ├── BaseOrderableListEditEntryWidget.java │ │ │ ├── BaseStringListEditEntryWidget.java │ │ │ ├── BaseValueListEditEntryWidget.java │ │ │ ├── ConfigInfoEntryWidget.java │ │ │ ├── ConfigStatusIndicatorEntryWidget.java │ │ │ ├── CustomHotkeyDefinitionEntryWidget.java │ │ │ ├── DataListEntryWidgetData.java │ │ │ ├── DataListEntryWidgetFactory.java │ │ │ ├── DirectoryEntryWidget.java │ │ │ ├── GenericListEntryWidget.java │ │ │ ├── IconEntryWidget.java │ │ │ ├── IdentifierListEditEntryWidget.java │ │ │ ├── MessageRedirectEntryWidget.java │ │ │ ├── StringListEditEntryWidget.java │ │ │ ├── StringListEntryWidget.java │ │ │ ├── TranslationOverrideEntryWidget.java │ │ │ ├── action │ │ │ │ ├── ActionListBaseActionEntryWidget.java │ │ │ │ ├── ActionPromptEntryWidget.java │ │ │ │ └── ParameterizableActionEntryWidget.java │ │ │ └── config │ │ │ │ ├── BaseBooleanAndNumberConfigWidget.java │ │ │ │ ├── BaseConfigWidget.java │ │ │ │ ├── BaseDualNumberConfigWidget.java │ │ │ │ ├── BaseFileConfigWidget.java │ │ │ │ ├── BaseGenericConfigWidget.java │ │ │ │ ├── BaseHotkeyedBooleanConfigWidget.java │ │ │ │ ├── BaseKeyBindConfigWidget.java │ │ │ │ ├── BlackWhiteListConfigWidget.java │ │ │ │ ├── BooleanAndDoubleConfigWidget.java │ │ │ │ ├── BooleanAndFileConfigWidget.java │ │ │ │ ├── BooleanAndIntConfigWidget.java │ │ │ │ ├── BooleanConfigWidget.java │ │ │ │ ├── ColorConfigWidget.java │ │ │ │ ├── CustomHotkeyEntryWidget.java │ │ │ │ ├── DirectoryConfigWidget.java │ │ │ │ ├── DoubleConfigWidget.java │ │ │ │ ├── DualColorConfigWidget.java │ │ │ │ ├── ExpandableConfigGroupWidget.java │ │ │ │ ├── FileConfigWidget.java │ │ │ │ ├── GenericButtonConfigWidget.java │ │ │ │ ├── HotkeyConfigWidget.java │ │ │ │ ├── HotkeyedBooleanConfigWidget.java │ │ │ │ ├── IntegerConfigWidget.java │ │ │ │ ├── NumericConfigWidget.java │ │ │ │ ├── OptionListConfigWidget.java │ │ │ │ ├── PopupConfigGroupWidget.java │ │ │ │ ├── StringConfigWidget.java │ │ │ │ ├── Vec2dConfigWidget.java │ │ │ │ ├── Vec2iConfigWidget.java │ │ │ │ └── list │ │ │ │ ├── BaseValueListConfigWidget.java │ │ │ │ ├── BlockListConfigWidget.java │ │ │ │ ├── EquipmentSlotListConfigWidget.java │ │ │ │ ├── IdentifierListConfigWidget.java │ │ │ │ ├── ItemListConfigWidget.java │ │ │ │ ├── StatusEffectListConfigWidget.java │ │ │ │ └── StringListConfigWidget.java │ │ ├── header │ │ │ ├── BaseDataListEditHeaderWidget.java │ │ │ ├── ColumnizedDataListHeaderWidget.java │ │ │ ├── DataColumn.java │ │ │ ├── DataListHeaderWidget.java │ │ │ └── DirectoryNavigationWidget.java │ │ └── search │ │ │ ├── ConfigsSearchBarWidget.java │ │ │ └── SearchBarWidget.java │ │ └── util │ │ ├── DefaultWidgetPositioner.java │ │ ├── DirectoryCache.java │ │ ├── DirectoryNavigator.java │ │ ├── TextFieldValidator.java │ │ └── WidgetPositioner.java │ ├── input │ ├── ActionResult.java │ ├── CancelCondition.java │ ├── Context.java │ ├── CustomHotkeyDefinition.java │ ├── CustomHotkeyManager.java │ ├── Hotkey.java │ ├── HotkeyCategory.java │ ├── HotkeyManager.java │ ├── HotkeyManagerImpl.java │ ├── HotkeyProvider.java │ ├── InputDispatcher.java │ ├── InputDispatcherImpl.java │ ├── KeyAction.java │ ├── KeyBind.java │ ├── KeyBindImpl.java │ ├── KeyBindSettings.java │ ├── KeyBindSettingsConfigs.java │ ├── KeyUpdateResult.java │ ├── KeyboardInputHandler.java │ ├── Keys.java │ ├── MouseClickHandler.java │ ├── MouseMoveHandler.java │ ├── MouseScrollHandler.java │ ├── SimpleHotkeyProvider.java │ └── callback │ │ ├── ActionHotkeyCallback.java │ │ ├── AdjustableValueHotkeyCallback.java │ │ ├── HotkeyCallback.java │ │ ├── NamedActionHotkeyCallback.java │ │ ├── TimeIntervalValueScaler.java │ │ ├── ToggleBooleanKeyCallback.java │ │ └── ToggleBooleanWithMessageKeyCallback.java │ ├── interoperation │ ├── BlockPlacementPositionHandler.java │ └── BlockPlacementPositionProvider.java │ ├── listener │ ├── ConfirmationListener.java │ ├── EventListener.java │ ├── LayerRangeChangeListener.java │ └── TaskCompletionListener.java │ ├── mixin │ ├── access │ │ ├── AbstractHorseMixin.java │ │ ├── GuiContainerMixin.java │ │ ├── NBTBaseMixin.java │ │ └── NBTTagLongArrayMixin.java │ ├── command │ │ ├── GuiScreenMixin.java │ │ └── TabCompleterMixin.java │ ├── event │ │ └── MinecraftMixin.java │ ├── input │ │ ├── GuiScreenMixin.java │ │ └── MinecraftMixin.java │ ├── network │ │ └── MixinNetHandlerPlayClient.java │ └── render │ │ ├── EntityRendererMixin.java │ │ └── GuiScreenMixin.java │ ├── network │ ├── ClientPacketChannelHandler.java │ ├── ClientPacketChannelHandlerImpl.java │ ├── PacketSplitter.java │ ├── PacketUtils.java │ ├── PluginChannelHandler.java │ └── message │ │ ├── BasePacketHandler.java │ │ ├── ConfigLockPacketHandler.java │ │ └── MessagePacketHandler.java │ ├── overlay │ ├── InfoArea.java │ ├── InfoOverlay.java │ ├── InfoWidgetManager.java │ ├── InfoWidgetRegistry.java │ ├── message │ │ ├── DefaultMessageDispatchers.java │ │ ├── Message.java │ │ ├── MessageDispatcher.java │ │ ├── MessageHelpers.java │ │ ├── MessageOutput.java │ │ ├── MessageRedirectManager.java │ │ ├── MessageUtils.java │ │ └── NagHelper.java │ └── widget │ │ ├── BaseOverlayWidget.java │ │ ├── ConfigStatusIndicatorContainerWidget.java │ │ ├── InfoRendererWidget.java │ │ ├── MessageRendererWidget.java │ │ ├── StringListRendererWidget.java │ │ ├── ToastRendererWidget.java │ │ └── sub │ │ ├── BaseConfigStatusIndicatorWidget.java │ │ ├── BooleanConfigStatusWidget.java │ │ ├── DoubleConfigStatusWidget.java │ │ ├── HotkeyConfigStatusWidget.java │ │ ├── HotkeyedBooleanConfigStatusWidget.java │ │ ├── IntegerConfigStatusWidget.java │ │ ├── OptionListConfigStatusWidget.java │ │ ├── PlaceholderConfigStatusIndicatorWidget.java │ │ ├── StringConfigStatusWidget.java │ │ └── ToastWidget.java │ ├── registry │ └── Registry.java │ ├── render │ ├── BlockTargetingRenderUtils.java │ ├── Gradient.java │ ├── ItemRenderUtils.java │ ├── ModelRenderUtils.java │ ├── RectangleRenderer.java │ ├── RenderContext.java │ ├── RenderUtils.java │ ├── ShapeRenderUtils.java │ ├── TextRenderUtils.java │ ├── buffer │ │ ├── VanillaWrappingVertexBuilder.java │ │ ├── VertexBuffer.java │ │ ├── VertexBuilder.java │ │ ├── VertexBuilderState.java │ │ ├── VertexFormat.java │ │ └── VertexFormats.java │ ├── inventory │ │ ├── BuiltinInventoryRenderDefinitions.java │ │ ├── InventoryRange.java │ │ ├── InventoryRenderDefinition.java │ │ └── InventoryRenderUtils.java │ ├── overlay │ │ ├── BaseColoredQuadOverlayRenderer.java │ │ ├── BaseOverlayRenderer.java │ │ ├── BaseRenderObject.java │ │ ├── OverlayRendererContainer.java │ │ └── VboRenderObject.java │ ├── shader │ │ └── ShaderProgram.java │ └── text │ │ ├── Glyph.java │ │ ├── MultiLineTextRenderSettings.java │ │ ├── OrderedStringListFactory.java │ │ ├── SingleTextLineRenderer.java │ │ ├── StringListRenderer.java │ │ ├── StyledText.java │ │ ├── StyledTextBuilder.java │ │ ├── StyledTextLine.java │ │ ├── StyledTextParser.java │ │ ├── StyledTextSegment.java │ │ ├── StyledTextUtils.java │ │ ├── TextRenderFunction.java │ │ ├── TextRenderSettings.java │ │ ├── TextRenderer.java │ │ ├── TextRendererUtils.java │ │ └── TextStyle.java │ └── util │ ├── AlphaNumComparator.java │ ├── BackupUtils.java │ ├── DataIteratingTask.java │ ├── DirectoryCreator.java │ ├── FileNameUtils.java │ ├── FileUtils.java │ ├── HashUtils.java │ ├── HttpUtils.java │ ├── ListUtils.java │ ├── MathUtils.java │ ├── ProfilerSectionSupplierSupplier.java │ ├── StringReader.java │ ├── StringUtils.java │ ├── data │ ├── AppendOverwrite.java │ ├── BooleanConsumer.java │ ├── BooleanStorage.java │ ├── BooleanStorageWithDefault.java │ ├── Color4f.java │ ├── ConfigOnTab.java │ ├── Constants.java │ ├── DoubleStorage.java │ ├── DualDoubleConsumer.java │ ├── DualIntConsumer.java │ ├── DyeColorCode.java │ ├── EdgeInt.java │ ├── EnabledCondition.java │ ├── FloatConsumer.java │ ├── FloatStorage.java │ ├── FloatSupplier.java │ ├── FloatUnaryOperator.java │ ├── Identifier.java │ ├── Int2BooleanFunction.java │ ├── IntRange.java │ ├── IntegerStorage.java │ ├── ItemType.java │ ├── LeftRight.java │ ├── MarkerManager.java │ ├── ModInfo.java │ ├── NameIdentifiable.java │ ├── RangedDoubleStorage.java │ ├── RangedFloatStorage.java │ ├── RangedIntegerStorage.java │ ├── ResultingStringConsumer.java │ ├── RunStatus.java │ ├── SimpleBooleanStorage.java │ ├── SimpleBooleanStorageWithDefault.java │ ├── ToBooleanFunction.java │ ├── ToFloatFunction.java │ ├── WrapperDoubleStorage.java │ ├── WrapperFloatStorage.java │ ├── WrapperIntStorage.java │ ├── json │ │ ├── JsonDeserializers.java │ │ ├── JsonSerializers.java │ │ └── JsonUtils.java │ └── palette │ │ ├── HashMapPalette.java │ │ ├── LinearPalette.java │ │ ├── Palette.java │ │ └── PaletteResizeHandler.java │ ├── datadump │ ├── DataDump.java │ ├── Row.java │ ├── RowFormatterAsciiTable.java │ ├── RowFormatterBase.java │ ├── RowFormatterCompactTable.java │ ├── RowFormatterCsv.java │ └── RowFormatterSimpleText.java │ ├── game │ ├── BlockUtils.java │ ├── PlacementUtils.java │ ├── RayTraceUtils.java │ └── wrap │ │ ├── DefaultedList.java │ │ ├── EntityWrap.java │ │ ├── GameWrap.java │ │ ├── ItemWrap.java │ │ ├── NbtWrap.java │ │ ├── RegistryUtils.java │ │ ├── RenderWrap.java │ │ └── WorldWrap.java │ ├── inventory │ ├── ColoredVanillaInventoryView.java │ ├── CombinedInventoryView.java │ ├── EquipmentInventoryView.java │ ├── InventoryScreenUtils.java │ ├── InventoryUtils.java │ ├── InventoryView.java │ ├── ListBackedInventoryView.java │ ├── SlicedInventoryView.java │ ├── StorageItemInventoryUtils.java │ └── VanillaInventoryView.java │ ├── nbt │ ├── BaseNbtStringifier.java │ ├── NbtUtils.java │ ├── PrettyNbtStringifier.java │ └── SimpleNbtStringifier.java │ ├── position │ ├── BlockMirror.java │ ├── BlockPos.java │ ├── BlockRotation.java │ ├── ChunkPos.java │ ├── ChunkSectionPos.java │ ├── Coordinate.java │ ├── Direction.java │ ├── HitPosition.java │ ├── HitResult.java │ ├── IntBoundingBox.java │ ├── LayerRange.java │ ├── PositionUtils.java │ ├── Quadrant.java │ ├── SectorEdge.java │ ├── Vec2d.java │ ├── Vec2i.java │ ├── Vec3d.java │ ├── Vec3f.java │ └── Vec3i.java │ ├── restriction │ └── UsageRestriction.java │ └── text │ └── TranslationOverrideManager.java └── resources ├── assets └── malilib │ ├── icon.png │ ├── lang │ └── en_us.lang │ ├── shaders │ └── sv_selector.frag │ └── textures │ ├── gui │ ├── gui_widgets.png │ ├── inventory_background_empty_13x13.png │ ├── inventory_background_generic_54.png │ ├── inventory_background_misc.png │ └── toasts.png │ └── xcf │ ├── gui_widgets.xcf │ ├── inventory_backgrounds.xcf │ └── toasts.xcf ├── fabric.mod.json ├── mixins.malilib.json └── pack.mcmeta /.gitattributes: -------------------------------------------------------------------------------- 1 | # text stuff 2 | * text=auto 3 | *.bat text eol=crlf 4 | *.info text eol=lf 5 | *.java text eol=crlf 6 | *.json text eol=lf 7 | *.mcmeta text eol=lf 8 | *.md text eol=lf 9 | *.properties text eol=lf 10 | *.sh text eol=lf 11 | .gitattributes text eol=lf 12 | .gitignore text eol=lf 13 | build.gradle text eol=lf 14 | build.properties text eol=lf 15 | gradlew text eol=lf 16 | gradle/wrapper/gradle-wrapper.properties text eol=lf 17 | LICENSE.txt text eol=lf 18 | README.md text eol=lf 19 | 20 | #binary 21 | *.dat binary 22 | *.bin binary 23 | *.png binary 24 | *.exe binary 25 | *.dll binary 26 | *.zip binary 27 | *.jar binary 28 | *.7z binary 29 | *.db binary 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .settings 3 | bin/ 4 | build/ 5 | eclipse/ 6 | .classpath 7 | .project 8 | build.number 9 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs = -Xmx3G 2 | org.gradle.daemon = false 3 | org.gradle.cache.cleanup = false 4 | 5 | mod_id = malilib 6 | mod_name = MaLiLib 7 | mod_file_name = malilib-ornithe 8 | 9 | # Current mod version 10 | mod_version = 0.60.0-alpha.2 11 | 12 | # Minecraft, Fabric Loader, mappings and dependencies versions 13 | minecraft_version_out = 1.12.2 14 | minecraft_version = 1.12.2 15 | fabric_loader_version = 0.15.3 16 | osl_version = 0.11.3 17 | mod_menu_version = 0.1.1+mc1.12.2 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | maven { 8 | name = 'Ornithe Releases' 9 | url = 'https://maven.ornithemc.net/releases' 10 | } 11 | maven { 12 | name = 'Ornithe Snapshots' 13 | url = 'https://maven.ornithemc.net/snapshots' 14 | } 15 | gradlePluginPortal() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/MaLiLib.java: -------------------------------------------------------------------------------- 1 | package malilib; 2 | 3 | import net.ornithemc.osl.entrypoints.api.client.ClientModInitializer; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | public class MaLiLib implements ClientModInitializer 8 | { 9 | public static final Logger LOGGER = LogManager.getLogger(MaLiLibReference.MOD_ID); 10 | 11 | @Override 12 | public void initClient() 13 | { 14 | } 15 | 16 | public static boolean canShowCoordinates() 17 | { 18 | return MaLiLibConfigs.Generic.HIDE_ALL_COORDINATES.getBooleanValue() == false; 19 | } 20 | 21 | public static void debugLog(String str, Object... args) 22 | { 23 | if (MaLiLibConfigs.Debug.DEBUG_MESSAGES.getBooleanValue()) 24 | { 25 | LOGGER.info(str, args); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/MaLiLibHotkeyProvider.java: -------------------------------------------------------------------------------- 1 | package malilib; 2 | 3 | import java.util.List; 4 | import com.google.common.collect.ImmutableList; 5 | 6 | import malilib.input.Hotkey; 7 | import malilib.input.HotkeyCategory; 8 | import malilib.input.HotkeyProvider; 9 | import malilib.util.ListUtils; 10 | import malilib.util.data.ModInfo; 11 | 12 | public class MaLiLibHotkeyProvider implements HotkeyProvider 13 | { 14 | static final MaLiLibHotkeyProvider INSTANCE = new MaLiLibHotkeyProvider(); 15 | 16 | private MaLiLibHotkeyProvider() 17 | { 18 | } 19 | 20 | @Override 21 | public List getAllHotkeys() 22 | { 23 | return ListUtils.getAppendedList(MaLiLibConfigs.Hotkeys.FUNCTIONAL_HOTKEYS, 24 | MaLiLibConfigs.Debug.HOTKEYS); 25 | } 26 | 27 | @Override 28 | public List getHotkeysByCategories() 29 | { 30 | ModInfo modInfo = MaLiLibReference.MOD_INFO; 31 | 32 | return ImmutableList.of( 33 | new HotkeyCategory(modInfo, "malilib.hotkeys.category.debug_hotkeys" , MaLiLibConfigs.Debug.HOTKEYS), 34 | new HotkeyCategory(modInfo, "malilib.hotkeys.category.generic_hotkeys", MaLiLibConfigs.Hotkeys.FUNCTIONAL_HOTKEYS)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/malilib/MaLiLibInitHandler.java: -------------------------------------------------------------------------------- 1 | package malilib; 2 | 3 | import malilib.config.BaseModConfig; 4 | import malilib.input.CustomHotkeyManager; 5 | import malilib.network.message.ConfigLockPacketHandler; 6 | import malilib.overlay.widget.ConfigStatusIndicatorContainerWidget; 7 | import malilib.registry.Registry; 8 | 9 | public class MaLiLibInitHandler 10 | { 11 | public static void registerMalilibHandlers() 12 | { 13 | Registry.CONFIG_MANAGER.registerConfigHandler(BaseModConfig.createDefaultModConfig(MaLiLibReference.MOD_INFO, MaLiLibConfigs.CONFIG_VERSION, MaLiLibConfigs.CATEGORIES)); 14 | Registry.CONFIG_SCREEN.registerConfigScreenFactory(MaLiLibReference.MOD_INFO, MaLiLibConfigScreen::create); 15 | Registry.CONFIG_TAB.registerConfigTabSupplier(MaLiLibReference.MOD_INFO, MaLiLibConfigScreen::getConfigTabs); 16 | 17 | Registry.HOTKEY_MANAGER.registerHotkeyProvider(MaLiLibHotkeyProvider.INSTANCE); 18 | Registry.HOTKEY_MANAGER.registerHotkeyProvider(CustomHotkeyManager.INSTANCE); 19 | Registry.HOTKEY_MANAGER.registerHotkeyProvider(ConfigStatusIndicatorContainerWidget.getHotkeyProvider()); 20 | 21 | Registry.RENDER_EVENT_DISPATCHER.registerGameOverlayRenderer(Registry.INFO_OVERLAY); 22 | Registry.RENDER_EVENT_DISPATCHER.registerScreenPostRenderer(Registry.INFO_OVERLAY); 23 | Registry.TICK_EVENT_DISPATCHER.registerClientTickHandler(Registry.INFO_OVERLAY); 24 | 25 | MaLiLibConfigInit.init(); 26 | MaLiLibActions.init(); 27 | 28 | ConfigLockPacketHandler.updateRegistration(true); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/malilib/MaLiLibReference.java: -------------------------------------------------------------------------------- 1 | package malilib; 2 | 3 | import malilib.util.data.ModInfo; 4 | 5 | public class MaLiLibReference 6 | { 7 | public static final String MOD_ID = "malilib"; 8 | public static final String MOD_NAME = "MaLiLib"; 9 | public static final String MOD_VERSION = "@MOD_VERSION@"; 10 | 11 | public static final ModInfo MOD_INFO = new ModInfo(MOD_ID, MOD_NAME); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/MinecraftClientAccessor.java: -------------------------------------------------------------------------------- 1 | package malilib; 2 | 3 | public interface MinecraftClientAccessor 4 | { 5 | void setActionKeyF3(boolean value); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/malilib/action/Action.java: -------------------------------------------------------------------------------- 1 | package malilib.action; 2 | 3 | import malilib.input.ActionResult; 4 | 5 | public interface Action 6 | { 7 | /** 8 | * Runs the action/task code 9 | * @param ctx the common context data for the action 10 | * @return the result of running the action 11 | */ 12 | ActionResult execute(ActionContext ctx); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/action/ActionContext.java: -------------------------------------------------------------------------------- 1 | package malilib.action; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.entity.EntityPlayerSP; 7 | import net.minecraft.client.multiplayer.WorldClient; 8 | import net.minecraft.entity.Entity; 9 | 10 | import malilib.overlay.message.MessageOutput; 11 | import malilib.util.game.wrap.GameWrap; 12 | 13 | public class ActionContext 14 | { 15 | public static final ActionContext COMMON = new ActionContext(); 16 | 17 | @Nullable public final MessageOutput messageOutput; 18 | 19 | public ActionContext() 20 | { 21 | this(null); 22 | } 23 | 24 | public ActionContext(@Nullable MessageOutput messageOutput) 25 | { 26 | this.messageOutput = messageOutput; 27 | } 28 | 29 | public MessageOutput getMessageOutputOrDefault(MessageOutput defaultOutput) 30 | { 31 | return this.messageOutput != null ? this.messageOutput : defaultOutput; 32 | } 33 | 34 | public Minecraft getClient() 35 | { 36 | return GameWrap.getClient(); 37 | } 38 | 39 | @Nullable 40 | public WorldClient getWorld() 41 | { 42 | return GameWrap.getClientWorld(); 43 | } 44 | 45 | @Nullable 46 | public EntityPlayerSP getPlayer() 47 | { 48 | return GameWrap.getClientPlayer(); 49 | } 50 | 51 | @Nullable 52 | public Entity getCameraEntity() 53 | { 54 | return GameWrap.getCameraEntity(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/malilib/action/ParameterizedAction.java: -------------------------------------------------------------------------------- 1 | package malilib.action; 2 | 3 | import malilib.input.ActionResult; 4 | 5 | public interface ParameterizedAction 6 | { 7 | /** 8 | * Runs the action/task code 9 | * @param ctx the common context data for the action 10 | * @param arg the string argument for the action. 11 | * This may contain multiple different arguments 12 | * that the action will further parse and handle. 13 | * @return the result of running the action 14 | */ 15 | ActionResult executeWithArgument(ActionContext ctx, String arg); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/action/builtin/BooleanDisableAction.java: -------------------------------------------------------------------------------- 1 | package malilib.action.builtin; 2 | 3 | import java.util.function.Supplier; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.config.option.BooleanContainingConfig; 7 | import malilib.overlay.message.MessageHelpers.BooleanConfigMessageFactory; 8 | import malilib.overlay.message.MessageOutput; 9 | 10 | public class BooleanDisableAction extends BaseBooleanConfigAction 11 | { 12 | protected BooleanDisableAction(BooleanContainingConfig config, 13 | @Nullable BooleanConfigMessageFactory messageFactory, 14 | @Nullable Supplier messageTypeSupplier) 15 | { 16 | super(config, cfg -> cfg.setBooleanValue(false), messageFactory, messageTypeSupplier); 17 | } 18 | 19 | public static BooleanDisableAction of(BooleanContainingConfig config, 20 | @Nullable BooleanConfigMessageFactory messageFactory, 21 | @Nullable Supplier messageTypeSupplier) 22 | { 23 | return new BooleanDisableAction(config, messageFactory, messageTypeSupplier); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/malilib/action/builtin/BooleanEnableAction.java: -------------------------------------------------------------------------------- 1 | package malilib.action.builtin; 2 | 3 | import java.util.function.Supplier; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.config.option.BooleanContainingConfig; 7 | import malilib.overlay.message.MessageHelpers.BooleanConfigMessageFactory; 8 | import malilib.overlay.message.MessageOutput; 9 | 10 | public class BooleanEnableAction extends BaseBooleanConfigAction 11 | { 12 | protected BooleanEnableAction(BooleanContainingConfig config, 13 | @Nullable BooleanConfigMessageFactory messageFactory, 14 | @Nullable Supplier messageTypeSupplier) 15 | { 16 | super(config, cfg -> cfg.setBooleanValue(true), messageFactory, messageTypeSupplier); 17 | } 18 | 19 | public static BooleanEnableAction of(BooleanContainingConfig config, 20 | @Nullable BooleanConfigMessageFactory messageFactory, 21 | @Nullable Supplier messageTypeSupplier) 22 | { 23 | return new BooleanEnableAction(config, messageFactory, messageTypeSupplier); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/malilib/action/builtin/BooleanToggleAction.java: -------------------------------------------------------------------------------- 1 | package malilib.action.builtin; 2 | 3 | import java.util.function.Supplier; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.config.option.BooleanContainingConfig; 7 | import malilib.overlay.message.MessageHelpers.BooleanConfigMessageFactory; 8 | import malilib.overlay.message.MessageOutput; 9 | 10 | public class BooleanToggleAction extends BaseBooleanConfigAction 11 | { 12 | protected BooleanToggleAction(BooleanContainingConfig config, 13 | @Nullable BooleanConfigMessageFactory messageFactory, 14 | @Nullable Supplier messageTypeSupplier) 15 | { 16 | super(config, BooleanContainingConfig::toggleBooleanValue, messageFactory, messageTypeSupplier); 17 | } 18 | 19 | public static BooleanToggleAction of(BooleanContainingConfig config, 20 | @Nullable BooleanConfigMessageFactory messageFactory, 21 | @Nullable Supplier messageTypeSupplier) 22 | { 23 | return new BooleanToggleAction(config, messageFactory, messageTypeSupplier); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/malilib/action/builtin/EventAction.java: -------------------------------------------------------------------------------- 1 | package malilib.action.builtin; 2 | 3 | import malilib.action.Action; 4 | import malilib.action.ActionContext; 5 | import malilib.input.ActionResult; 6 | import malilib.listener.EventListener; 7 | 8 | public class EventAction implements Action 9 | { 10 | protected final EventListener listener; 11 | 12 | public EventAction(EventListener listener) 13 | { 14 | this.listener = listener; 15 | } 16 | 17 | @Override 18 | public ActionResult execute(ActionContext ctx) 19 | { 20 | this.listener.onEvent(); 21 | return ActionResult.SUCCESS; 22 | } 23 | 24 | public static EventAction of(EventListener listener) 25 | { 26 | return new EventAction(listener); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/compat/modmenu/ModMenuImpl.java: -------------------------------------------------------------------------------- 1 | package malilib.compat.modmenu; 2 | 3 | import com.terraformersmc.modmenu.api.ConfigScreenFactory; 4 | import com.terraformersmc.modmenu.api.ModMenuApi; 5 | 6 | import malilib.MaLiLibConfigScreen; 7 | import malilib.gui.BaseScreen; 8 | 9 | public class ModMenuImpl implements ModMenuApi 10 | { 11 | @Override 12 | public ConfigScreenFactory getModConfigScreenFactory() 13 | { 14 | return (currentScreen) -> { 15 | BaseScreen screen = MaLiLibConfigScreen.create(); 16 | screen.setParent(currentScreen); 17 | return screen; 18 | }; 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/malilib/config/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package malilib.config; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.util.data.ModInfo; 6 | 7 | public interface ConfigManager 8 | { 9 | /** 10 | * Registers a config handler 11 | * @param handler 12 | */ 13 | void registerConfigHandler(ModConfig handler); 14 | 15 | /** 16 | * Get the config handler for the given mod 17 | * @param modInfo 18 | * @return the config handler for the given mod, or null if there isn't one registered 19 | */ 20 | @Nullable 21 | ModConfig getConfigHandler(ModInfo modInfo); 22 | 23 | /** 24 | * Can be called to save the configs for the given mod, 25 | * if there are any configs that have changed since last saving (or being loaded). 26 | * @param modInfo 27 | * @return true if some setting were dirty and thus the configs got saved to file 28 | */ 29 | boolean saveConfigsIfChanged(ModInfo modInfo); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/ValueChangeCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.config; 2 | 3 | public interface ValueChangeCallback 4 | { 5 | /** 6 | * Called after a config's value changes 7 | * @param newValue the new value the config was set to 8 | * @param oldValue the old value before the value was changed 9 | */ 10 | void onValueChanged(T newValue, T oldValue); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/ValueLoadCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.config; 2 | 3 | public interface ValueLoadCallback 4 | { 5 | /** 6 | * Called after the config's value is loaded from file 7 | * @param newValue the new value the config was set to 8 | */ 9 | void onValueLoaded(T newValue); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/category/ConfigOptionCategory.java: -------------------------------------------------------------------------------- 1 | package malilib.config.category; 2 | 3 | import java.util.List; 4 | 5 | import malilib.config.option.ConfigOption; 6 | import malilib.util.data.ModInfo; 7 | import malilib.util.data.NameIdentifiable; 8 | 9 | public interface ConfigOptionCategory extends NameIdentifiable 10 | { 11 | /** 12 | * @return The ModInfo of the mod that this config category belongs to 13 | */ 14 | ModInfo getModInfo(); 15 | 16 | /** 17 | * @return Whether the configs in this category should be saved to file 18 | */ 19 | boolean shouldSaveToFile(); 20 | 21 | /** 22 | * @return The list of config options in this category. 23 | * This list is used in the config saving and loading methods, 24 | * and also for checking if some values are dirty and the config 25 | * should be saved to file again. 26 | */ 27 | List> getConfigOptions(); 28 | 29 | /** 30 | * Resets all the contained config options to their default values 31 | */ 32 | default void resetAllOptionsToDefaults() 33 | { 34 | for (ConfigOption config : this.getConfigOptions()) 35 | { 36 | config.resetToDefault(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/group/ExpandableConfigGroup.java: -------------------------------------------------------------------------------- 1 | package malilib.config.group; 2 | 3 | import java.util.List; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.config.option.ConfigInfo; 7 | import malilib.gui.config.ConfigTab; 8 | import malilib.util.data.ConfigOnTab; 9 | import malilib.util.data.ModInfo; 10 | 11 | public class ExpandableConfigGroup extends BaseConfigGroup 12 | { 13 | protected boolean isExpanded; 14 | 15 | public ExpandableConfigGroup(ModInfo modInfo, String name, List configs) 16 | { 17 | super(modInfo, name, configs); 18 | } 19 | 20 | public ExpandableConfigGroup(ModInfo modInfo, String name, String nameTranslationKey, 21 | @Nullable String commentTranslationKey, Object... commentArgs) 22 | { 23 | super(modInfo, name, nameTranslationKey, commentTranslationKey, commentArgs); 24 | } 25 | 26 | public boolean isExpanded() 27 | { 28 | return this.isExpanded; 29 | } 30 | 31 | public boolean toggleIsExpanded() 32 | { 33 | this.isExpanded = ! this.isExpanded; 34 | return this.isExpanded; 35 | } 36 | 37 | @Override 38 | public void addNestedOptionsToList(List list, ConfigTab tab, int nestingLevel, boolean expandAlways) 39 | { 40 | if (this.isExpanded || expandAlways) 41 | { 42 | for (ConfigInfo config : this.getConfigs()) 43 | { 44 | list.add(new ConfigOnTab(tab, config, nestingLevel)); 45 | config.addNestedOptionsToList(list, tab, nestingLevel + 1, expandAlways); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/group/PopupConfigGroup.java: -------------------------------------------------------------------------------- 1 | package malilib.config.group; 2 | 3 | import java.util.List; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.config.option.ConfigInfo; 7 | import malilib.util.data.ModInfo; 8 | 9 | public class PopupConfigGroup extends BaseConfigGroup 10 | { 11 | public PopupConfigGroup(ModInfo modInfo, String name, List configs) 12 | { 13 | super(modInfo, name, configs); 14 | } 15 | 16 | public PopupConfigGroup(ModInfo modInfo, String name, String nameTranslationKey, 17 | @Nullable String commentTranslationKey, Object... commentArgs) 18 | { 19 | super(modInfo, name, nameTranslationKey, commentTranslationKey, commentArgs); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/BaseDualValueConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import javax.annotation.Nullable; 4 | import org.apache.commons.lang3.tuple.Pair; 5 | 6 | public class BaseDualValueConfig extends BaseGenericConfig 7 | { 8 | @Nullable protected Pair labels; 9 | @Nullable protected Pair hoverTexts; 10 | 11 | public BaseDualValueConfig(String name, T defaultValue) 12 | { 13 | this(name, defaultValue, name); 14 | } 15 | 16 | public BaseDualValueConfig(String name, T defaultValue, @Nullable String commentTranslationKey, Object... commentArgs) 17 | { 18 | super(name, defaultValue, commentTranslationKey, commentArgs); 19 | } 20 | 21 | @Nullable 22 | public Pair getLabels() 23 | { 24 | return this.labels; 25 | } 26 | 27 | public void setLabels(@Nullable Pair labels) 28 | { 29 | this.labels = labels; 30 | } 31 | 32 | @Nullable 33 | public Pair getHoverTexts() 34 | { 35 | return this.hoverTexts; 36 | } 37 | 38 | public void setHoverTexts(@Nullable Pair hoverTexts) 39 | { 40 | this.hoverTexts = hoverTexts; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/BaseInfo.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import java.util.Optional; 4 | 5 | import malilib.util.data.ModInfo; 6 | 7 | public interface BaseInfo 8 | { 9 | /** 10 | * Returns the (internal) name of this object, used for example in the config files 11 | * @return the internal name of this config 12 | */ 13 | String getName(); 14 | 15 | /** 16 | * @return the display name used for this object, for example for config options on the config screens 17 | */ 18 | String getDisplayName(); 19 | 20 | /** 21 | * @return the ModInfo of the mod owning this object 22 | */ 23 | ModInfo getModInfo(); 24 | 25 | /** 26 | * Returns the comment or description for this object. It can be for example displayed 27 | * when hovering over the object's name or other related screen element on some screens. 28 | * Newlines can be added with "\n". Can be null if there is no comment for this object. 29 | * @return the (localized) comment, if one exists 30 | */ 31 | Optional getComment(); 32 | 33 | /** 34 | * Sets the ModInfo owning this config. 35 | * This is automatically called in {@link malilib.config.ConfigManager#registerConfigHandler(malilib.config.ModConfig)} 36 | * using the ModInfo from {@link malilib.config.ModConfig#getModInfo()}. 37 | * @param modInfo 38 | */ 39 | default void setModInfo(ModInfo modInfo) 40 | { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/BooleanContainingConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import malilib.util.data.BooleanStorageWithDefault; 4 | 5 | public interface BooleanContainingConfig extends BooleanStorageWithDefault, ConfigOption, OverridableConfig 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/ColorConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.util.data.Color4f; 6 | 7 | public class ColorConfig extends BaseGenericConfig 8 | { 9 | public ColorConfig(String name, String defaultValue) 10 | { 11 | this(name, defaultValue, name); 12 | } 13 | 14 | public ColorConfig(String name, String defaultValue, 15 | @Nullable String commentTranslationKey, Object... commentArgs) 16 | { 17 | super(name, Color4f.fromString(defaultValue), commentTranslationKey, commentArgs); 18 | } 19 | 20 | public Color4f getColor() 21 | { 22 | return this.value; 23 | } 24 | 25 | public int getIntegerValue() 26 | { 27 | return this.value.intValue; 28 | } 29 | 30 | public void setValueFromInt(int newValue) 31 | { 32 | this.setValue(Color4f.fromColor(newValue)); 33 | } 34 | 35 | public String getStringValue() 36 | { 37 | return Color4f.getHexColorString(this.effectiveValue.intValue); 38 | } 39 | 40 | public void setValueFromString(String value) 41 | { 42 | this.setValue(Color4f.fromString(value)); 43 | } 44 | 45 | public void loadColorValueFromString(String value) 46 | { 47 | this.value = Color4f.fromString(value); 48 | this.cacheSavedValue(); 49 | this.updateEffectiveValue(); 50 | this.onValueLoaded(this.effectiveValue); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/DirectoryConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import java.nio.file.Path; 4 | 5 | public class DirectoryConfig extends FileConfig 6 | { 7 | public DirectoryConfig(String name, Path defaultValue) 8 | { 9 | super(name, defaultValue, name); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/FileConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import java.nio.file.Path; 4 | import javax.annotation.Nullable; 5 | 6 | public class FileConfig extends BaseGenericConfig 7 | { 8 | public FileConfig(String name, Path defaultValue) 9 | { 10 | this(name, defaultValue, name); 11 | } 12 | 13 | public FileConfig(String name, Path defaultValue, @Nullable String commentTranslationKey, Object... commentArgs) 14 | { 15 | super(name, defaultValue, commentTranslationKey, commentArgs); 16 | } 17 | 18 | public String getStringValue() 19 | { 20 | return this.value.toAbsolutePath().toString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/OverridableConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public interface OverridableConfig 6 | { 7 | /** 8 | * @return true if this config currently has an active override 9 | */ 10 | boolean hasOverride(); 11 | 12 | /** 13 | * Enables an override for this config, using the provided override value 14 | * @param overrideValue the value to force the config's returned/visible value to 15 | */ 16 | void enableOverrideWithValue(T overrideValue); 17 | 18 | /** 19 | * Disables the override, restoring the normal value as the 20 | * returned/visible value of the config. 21 | */ 22 | void disableOverride(); 23 | 24 | /** 25 | * Sets the hover info message that will appear on the config screen 26 | * for any overridden/locked configs. 27 | */ 28 | void setOverrideMessage(@Nullable String translationKey); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/StringConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public class StringConfig extends BaseGenericConfig 6 | { 7 | public StringConfig(String name, String defaultValue) 8 | { 9 | this(name, defaultValue, name); 10 | } 11 | 12 | public StringConfig(String name, String defaultValue, 13 | @Nullable String commentTranslationKey, Object... commentArgs) 14 | { 15 | super(name, defaultValue, commentTranslationKey, commentArgs); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/list/BlackWhiteListConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option.list; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.config.option.BaseGenericConfig; 6 | import malilib.config.value.BlackWhiteList; 7 | 8 | public class BlackWhiteListConfig extends BaseGenericConfig> 9 | { 10 | public BlackWhiteListConfig(String name, BlackWhiteList defaultValue) 11 | { 12 | this(name, defaultValue, name); 13 | } 14 | 15 | public BlackWhiteListConfig(String name, BlackWhiteList defaultValue, 16 | @Nullable String commentTranslationKey, Object... commentArgs) 17 | { 18 | this(name, defaultValue, name, commentTranslationKey, commentArgs); 19 | } 20 | 21 | public BlackWhiteListConfig(String name, BlackWhiteList defaultValue, String prettyName, 22 | @Nullable String commentTranslationKey, Object... commentArgs) 23 | { 24 | super(name, defaultValue, name, prettyName, commentTranslationKey, commentArgs); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/option/list/StringListConfig.java: -------------------------------------------------------------------------------- 1 | package malilib.config.option.list; 2 | 3 | import javax.annotation.Nullable; 4 | import com.google.common.collect.ImmutableList; 5 | 6 | public class StringListConfig extends ValueListConfig 7 | { 8 | public StringListConfig(String name, ImmutableList defaultValue) 9 | { 10 | this(name, defaultValue, name); 11 | } 12 | 13 | public StringListConfig(String name, ImmutableList defaultValue, 14 | @Nullable String commentTranslationKey, Object... commentArgs) 15 | { 16 | super(name, defaultValue, (v) -> v, (s) -> s, commentTranslationKey, commentArgs); 17 | } 18 | 19 | @Override 20 | public StringListConfig copy() 21 | { 22 | StringListConfig config = new StringListConfig(this.name, this.defaultValue); 23 | config.copyValuesFrom(this); 24 | return config; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/util/ConfigLockUtils.java: -------------------------------------------------------------------------------- 1 | package malilib.config.util; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import malilib.action.ActionContext; 6 | import malilib.input.ActionResult; 7 | 8 | public class ConfigLockUtils 9 | { 10 | public static ActionResult resetConfigLocks() 11 | { 12 | return resetConfigLocks(ActionContext.COMMON); 13 | } 14 | 15 | public static ActionResult resetConfigLocks(ActionContext ctx) 16 | { 17 | ConfigLockHandler handler = new ConfigLockHandler(); 18 | handler.clearLocks(); 19 | return ActionResult.SUCCESS; 20 | } 21 | 22 | public static void applyConfigLocks() 23 | { 24 | ConfigLockHandler handler = new ConfigLockHandler(); 25 | handler.readAndApplyLocks(); 26 | } 27 | 28 | public static void applyConfigLocksFromServer(JsonObject obj) 29 | { 30 | ConfigLockHandler handler = new ConfigLockHandler(); 31 | handler.applyLocksFromServer(obj); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/ActiveMode.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class ActiveMode extends BaseOptionListConfigValue 6 | { 7 | public static final ActiveMode NEVER = new ActiveMode("never", "malilib.name.active_mode.never"); 8 | public static final ActiveMode WITH_KEY = new ActiveMode("with_key", "malilib.name.active_mode.with_key"); 9 | public static final ActiveMode ALWAYS = new ActiveMode("always", "malilib.name.active_mode.always"); 10 | 11 | public static final ImmutableList VALUES = ImmutableList.of(NEVER, WITH_KEY, ALWAYS); 12 | 13 | private ActiveMode(String name, String translationKey) 14 | { 15 | super(name, translationKey); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/BlockSnap.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class BlockSnap extends BaseOptionListConfigValue 6 | { 7 | public static final BlockSnap NONE = new BlockSnap("none", "malilib.name.block_snap.none"); 8 | public static final BlockSnap CENTER = new BlockSnap("center", "malilib.name.block_snap.center"); 9 | public static final BlockSnap CORNER = new BlockSnap("corner", "malilib.name.block_snap.corner"); 10 | 11 | public static final ImmutableList VALUES = ImmutableList.of(NONE, CENTER, CORNER); 12 | 13 | private BlockSnap(String name, String translationKey) 14 | { 15 | super(name, translationKey); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/FileBrowserColumns.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class FileBrowserColumns extends BaseOptionListConfigValue 6 | { 7 | public static final FileBrowserColumns NONE = new FileBrowserColumns("none", "malilib.name.file_browser_columns.none"); 8 | public static final FileBrowserColumns SIZE = new FileBrowserColumns("size", "malilib.name.file_browser_columns.size"); 9 | public static final FileBrowserColumns MTIME = new FileBrowserColumns("mtime", "malilib.name.file_browser_columns.mtime"); 10 | public static final FileBrowserColumns SIZE_MTIME = new FileBrowserColumns("size_mtime", "malilib.name.file_browser_columns.size_mtime"); 11 | 12 | public static final ImmutableList VALUES = ImmutableList.of(NONE, SIZE, MTIME, SIZE_MTIME); 13 | 14 | private FileBrowserColumns(String name, String translationKey) 15 | { 16 | super(name, translationKey); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/FileWriteType.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class FileWriteType extends BaseOptionListConfigValue 6 | { 7 | public static final FileWriteType NORMAL_WRITE = new FileWriteType("normal_write", "malilib.name.file_write_type.normal_write"); 8 | public static final FileWriteType TEMP_AND_RENAME = new FileWriteType("temp_and_rename", "malilib.name.file_write_type.temp_and_rename"); 9 | 10 | public static final ImmutableList VALUES = ImmutableList.of(NORMAL_WRITE, TEMP_AND_RENAME); 11 | 12 | private FileWriteType(String name, String translationKey) 13 | { 14 | super(name, translationKey); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/HudAlignment.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class HudAlignment extends BaseOptionListConfigValue 6 | { 7 | public static final HudAlignment TOP_LEFT = new HudAlignment("top_left", "malilib.name.screen_location.top_left"); 8 | public static final HudAlignment TOP_RIGHT = new HudAlignment("top_right", "malilib.name.screen_location.top_right"); 9 | public static final HudAlignment BOTTOM_LEFT = new HudAlignment("bottom_left", "malilib.name.screen_location.bottom_left"); 10 | public static final HudAlignment BOTTOM_RIGHT = new HudAlignment("bottom_right", "malilib.name.screen_location.bottom_right"); 11 | public static final HudAlignment CENTER = new HudAlignment("center", "malilib.name.screen_location.center"); 12 | 13 | public static final ImmutableList VALUES = ImmutableList.of(TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, CENTER); 14 | 15 | private HudAlignment(String name, String translationKey) 16 | { 17 | super(name, translationKey); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/KeybindDisplayMode.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class KeybindDisplayMode extends BaseOptionListConfigValue 6 | { 7 | public static final KeybindDisplayMode NONE = new KeybindDisplayMode("none", "malilib.name.keybind_display_mode.none"); 8 | public static final KeybindDisplayMode KEYS = new KeybindDisplayMode("keys", "malilib.name.keybind_display_mode.keys"); 9 | public static final KeybindDisplayMode ACTIONS = new KeybindDisplayMode("actions", "malilib.name.keybind_display_mode.actions"); 10 | public static final KeybindDisplayMode KEYS_ACTIONS = new KeybindDisplayMode("keys_and_actions", "malilib.name.keybind_display_mode.keys_and_actions"); 11 | 12 | public static final ImmutableList VALUES = ImmutableList.of(NONE, KEYS, ACTIONS, KEYS_ACTIONS); 13 | 14 | private KeybindDisplayMode(String name, String translationKey) 15 | { 16 | super(name, translationKey); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/LayerMode.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import malilib.util.StringUtils; 6 | 7 | public enum LayerMode implements OptionListConfigValue 8 | { 9 | ALL ("all", "malilib.name.layer_mode.all"), 10 | SINGLE_LAYER ("single_layer", "malilib.name.layer_mode.single_layer"), 11 | LAYER_RANGE ("layer_range", "malilib.name.layer_mode.layer_range"), 12 | ALL_BELOW ("all_below", "malilib.name.layer_mode.all_below"), 13 | ALL_ABOVE ("all_above", "malilib.name.layer_mode.all_above"); 14 | 15 | public static final ImmutableList VALUES = ImmutableList.copyOf(values()); 16 | 17 | private final String configString; 18 | private final String translationKey; 19 | 20 | LayerMode(String configString, String translationKey) 21 | { 22 | this.configString = configString; 23 | this.translationKey = translationKey; 24 | } 25 | 26 | @Override 27 | public String getName() 28 | { 29 | return this.configString; 30 | } 31 | 32 | @Override 33 | public String getDisplayName() 34 | { 35 | return StringUtils.translate(this.translationKey); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/OptionListConfigValue.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | public interface OptionListConfigValue 4 | { 5 | String getName(); 6 | 7 | String getDisplayName(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/ScreenCorner.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class ScreenCorner extends BaseOptionListConfigValue 6 | { 7 | public static final ScreenCorner TOP_LEFT = new ScreenCorner("top_left", "malilib.name.screen_location.top_left"); 8 | public static final ScreenCorner TOP_RIGHT = new ScreenCorner("top_right", "malilib.name.screen_location.top_right"); 9 | public static final ScreenCorner BOTTOM_LEFT = new ScreenCorner("bottom_left", "malilib.name.screen_location.bottom_left"); 10 | public static final ScreenCorner BOTTOM_RIGHT = new ScreenCorner("bottom_right", "malilib.name.screen_location.bottom_right"); 11 | 12 | public static final ImmutableList VALUES = ImmutableList.of(TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT); 13 | 14 | private ScreenCorner(String name, String translationKey) 15 | { 16 | super(name, translationKey); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/config/value/SortDirection.java: -------------------------------------------------------------------------------- 1 | package malilib.config.value; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public class SortDirection extends BaseOptionListConfigValue 6 | { 7 | public static final SortDirection NONE = new SortDirection("none", "malilib.name.sort_direction.none"); 8 | public static final SortDirection ASCENDING = new SortDirection("ascending", "malilib.name.sort_direction.ascending"); 9 | public static final SortDirection DESCENDING = new SortDirection("descending", "malilib.name.sort_direction.descending"); 10 | 11 | public static final ImmutableList VALUES_ALL = ImmutableList.of(NONE, ASCENDING, DESCENDING); 12 | public static final ImmutableList VALUES_ASC_DESC = ImmutableList.of(ASCENDING, DESCENDING); 13 | 14 | private SortDirection(String name, String translationKey) 15 | { 16 | super(name, translationKey); 17 | } 18 | 19 | public SortDirection getOpposite() 20 | { 21 | return (this == ASCENDING) ? DESCENDING : (this == DESCENDING ? ASCENDING : NONE); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/ClientTickHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import malilib.util.ProfilerSectionSupplierSupplier; 4 | 5 | public interface ClientTickHandler extends ProfilerSectionSupplierSupplier, PrioritizedEventHandler 6 | { 7 | /** 8 | * Called from the end of the client tick code (for world ticks, not the main game loop/rendering). 9 | *
br> 10 | * The classes implementing this method should be registered 11 | * to {@link malilib.event.dispatch.TickEventDispatcherImpl}. 12 | *

13 | * Note: The client world and the client player are checked 14 | * to not be null before this method is called. 15 | */ 16 | void onClientTick(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/ClientWorldChangeHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import net.minecraft.client.multiplayer.WorldClient; 6 | 7 | public interface ClientWorldChangeHandler extends PrioritizedEventHandler 8 | { 9 | /** 10 | * Called when the client world is going to be changed, 11 | * before the reference has been changed yet. 12 | *

13 | * The classes implementing this method should be registered to {@link malilib.event.dispatch.ClientWorldChangeEventDispatcherImpl} 14 | * @param worldBefore the old world reference, before the new one gets assigned 15 | * @param worldAfter the new world reference that is going to be assigned 16 | */ 17 | default void onPreClientWorldChange(@Nullable WorldClient worldBefore, @Nullable WorldClient worldAfter) {} 18 | 19 | /** 20 | * Called after the client world reference has been changed. 21 | *

22 | * The classes implementing this method should be registered to {@link malilib.event.dispatch.ClientWorldChangeEventDispatcherImpl} 23 | * @param worldBefore the old world reference, before the new one gets assigned 24 | * @param worldAfter the new world reference that is going to be assigned 25 | */ 26 | default void onPostClientWorldChange(@Nullable WorldClient worldBefore, @Nullable WorldClient worldAfter) {} 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/InitializationHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | public interface InitializationHandler extends PrioritizedEventHandler 4 | { 5 | /** 6 | * This method will be called for any registered {@link InitializationHandler} 7 | * when the game has been initialized and the mods can register their keybinds and configs 8 | * to malilib without causing class loading issues. 9 | *

10 | * So call all your (malilib-facing) mod init stuff inside this handler! 11 | *

12 | * The classes implementing this method should be registered to {@link malilib.event.dispatch.InitializationDispatcherImpl} 13 | */ 14 | void registerModHandlers(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/PostGameOverlayRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import malilib.render.RenderContext; 4 | import malilib.util.ProfilerSectionSupplierSupplier; 5 | 6 | public interface PostGameOverlayRenderer extends ProfilerSectionSupplierSupplier 7 | { 8 | /** 9 | * Called after the vanilla overlays have been rendered. 10 | *

11 | * The classes implementing this method should be registered 12 | * to {@link malilib.event.dispatch.RenderEventDispatcher}. 13 | *

14 | * Note: The client world and the client player are checked 15 | * to not be null before this method is called. 16 | */ 17 | void onPostGameOverlayRender(RenderContext ctx); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/PostItemTooltipRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | import malilib.render.RenderContext; 6 | import malilib.util.ProfilerSectionSupplierSupplier; 7 | 8 | public interface PostItemTooltipRenderer extends ProfilerSectionSupplierSupplier 9 | { 10 | /** 11 | * Called after the tooltip text of an item has been rendered 12 | *

13 | * The classes implementing this method should be registered to {@link malilib.event.dispatch.RenderEventDispatcherImpl} 14 | */ 15 | void onPostRenderItemTooltip(ItemStack stack, int x, int y, RenderContext ctx); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/PostScreenRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import malilib.gui.util.ScreenContext; 4 | import malilib.util.ProfilerSectionSupplierSupplier; 5 | 6 | public interface PostScreenRenderer extends ProfilerSectionSupplierSupplier 7 | { 8 | /** 9 | * Called after vanilla screen rendering 10 | *

11 | * The classes implementing this method should be registered 12 | * to {@link malilib.event.dispatch.RenderEventDispatcher}. 13 | *

14 | * Note: The client world and the client player are checked 15 | * to not be null before this method is called. 16 | */ 17 | void onPostScreenRender(ScreenContext ctx, float tickDelta); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/PostWorldRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | import malilib.render.RenderContext; 4 | import malilib.util.ProfilerSectionSupplierSupplier; 5 | 6 | public interface PostWorldRenderer extends ProfilerSectionSupplierSupplier 7 | { 8 | /** 9 | * Called after vanilla world rendering 10 | *

11 | * The classes implementing this method should be registered 12 | * to {@link malilib.event.dispatch.RenderEventDispatcher}. 13 | *

14 | * Note: The client world and the client player are checked 15 | * to not be null before this method is called. 16 | */ 17 | void onPostWorldRender(RenderContext ctx, float tickDelta); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/PrioritizedEventHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.event; 2 | 3 | public interface PrioritizedEventHandler 4 | { 5 | /** 6 | * Returns the priority of this event handler. 7 | * This is a simple numeric sort order against any other registered handlers, 8 | * so lower values come first in the list of registered handlers. 9 | * The handlers are called in the sorted order. 10 | * The default priority is 100. 11 | * @return the priority of this handler, lower values come first 12 | */ 13 | default int getPriority() 14 | { 15 | return 100; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/ClientWorldChangeEventDispatcher.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import malilib.event.ClientWorldChangeHandler; 4 | 5 | public interface ClientWorldChangeEventDispatcher 6 | { 7 | /** 8 | * Registers a handler for listening to client world changes. 9 | * @param listener 10 | */ 11 | void registerClientWorldChangeHandler(ClientWorldChangeHandler listener); 12 | 13 | /** 14 | * Un-registers a previously registered client world change handler. 15 | * @param listener 16 | */ 17 | void unregisterClientWorldChangeHandler(ClientWorldChangeHandler listener); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/InitializationDispatcher.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import malilib.event.InitializationHandler; 4 | 5 | public interface InitializationDispatcher 6 | { 7 | /** 8 | * Register an initialization handler, which will get called once the game has been initialized 9 | * and set up, and things are ready to be accessed and initialized by mods. 10 | * @param handler 11 | */ 12 | void registerInitializationHandler(InitializationHandler handler); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/InitializationDispatcherImpl.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.List; 6 | 7 | import malilib.MaLiLibInitHandler; 8 | import malilib.config.util.ConfigUtils; 9 | import malilib.event.InitializationHandler; 10 | 11 | public class InitializationDispatcherImpl implements InitializationDispatcher 12 | { 13 | protected final List handlers = new ArrayList<>(); 14 | 15 | public InitializationDispatcherImpl() 16 | { 17 | } 18 | 19 | @Override 20 | public void registerInitializationHandler(InitializationHandler handler) 21 | { 22 | if (this.handlers.contains(handler) == false) 23 | { 24 | this.handlers.add(handler); 25 | this.handlers.sort(Comparator.comparing(InitializationHandler::getPriority)); 26 | } 27 | } 28 | 29 | /** 30 | * NOT PUBLIC API - DO NOT CALL 31 | */ 32 | public void onGameInitDone() 33 | { 34 | MaLiLibInitHandler.registerMalilibHandlers(); 35 | 36 | if (this.handlers.isEmpty() == false) 37 | { 38 | for (InitializationHandler handler : this.handlers) 39 | { 40 | handler.registerModHandlers(); 41 | } 42 | } 43 | 44 | ConfigUtils.loadAllConfigsFromFile(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/RenderEventDispatcher.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import malilib.event.PostGameOverlayRenderer; 4 | import malilib.event.PostItemTooltipRenderer; 5 | import malilib.event.PostScreenRenderer; 6 | import malilib.event.PostWorldRenderer; 7 | 8 | public interface RenderEventDispatcher 9 | { 10 | /** 11 | * Registers a renderer which will have its {@link PostGameOverlayRenderer#onPostGameOverlayRender()} 12 | * method called after the vanilla game overlay rendering is done. 13 | * @param renderer 14 | */ 15 | void registerGameOverlayRenderer(PostGameOverlayRenderer renderer); 16 | 17 | /** 18 | * Registers a renderer which will have its {@link PostItemTooltipRenderer#onPostRenderItemTooltip(net.minecraft.item.ItemStack, int, int)} 19 | * method called after the vanilla ItemStack tooltip text has been rendered. 20 | * @param renderer 21 | */ 22 | void registerTooltipPostRenderer(PostItemTooltipRenderer renderer); 23 | 24 | /** 25 | * Registers a renderer which will have its {@link PostScreenRenderer#onPostScreenRender(float)} 26 | * method called after the vanilla screen rendering method has been called. 27 | * @param renderer 28 | */ 29 | void registerScreenPostRenderer(PostScreenRenderer renderer); 30 | 31 | /** 32 | * Registers a renderer which will have its {@link PostWorldRenderer#onPostWorldRender(float)} 33 | * method called after the vanilla world rendering is done. 34 | * @param renderer 35 | */ 36 | void registerWorldPostRenderer(PostWorldRenderer renderer); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/TickEventDispatcher.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import malilib.event.ClientTickHandler; 4 | 5 | public interface TickEventDispatcher 6 | { 7 | /** 8 | * Registers a client tick handler, which will have its {@link ClientTickHandler#onClientTick()} method 9 | * called at the end of the client world ticking phase. 10 | * @param handler 11 | */ 12 | void registerClientTickHandler(ClientTickHandler handler); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/event/dispatch/TickEventDispatcherImpl.java: -------------------------------------------------------------------------------- 1 | package malilib.event.dispatch; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.List; 6 | 7 | import malilib.event.ClientTickHandler; 8 | import malilib.util.game.wrap.GameWrap; 9 | 10 | public class TickEventDispatcherImpl implements TickEventDispatcher 11 | { 12 | protected final List clientTickHandlers = new ArrayList<>(); 13 | 14 | public TickEventDispatcherImpl() 15 | { 16 | } 17 | 18 | @Override 19 | public void registerClientTickHandler(ClientTickHandler handler) 20 | { 21 | if (this.clientTickHandlers.contains(handler) == false) 22 | { 23 | this.clientTickHandlers.add(handler); 24 | this.clientTickHandlers.sort(Comparator.comparing(ClientTickHandler::getPriority)); 25 | } 26 | } 27 | 28 | /** 29 | * NOT PUBLIC API - DO NOT CALL 30 | */ 31 | public void onClientTick() 32 | { 33 | if (this.clientTickHandlers.isEmpty() == false) 34 | { 35 | GameWrap.profilerPush("malilib_client_tick"); 36 | 37 | for (ClientTickHandler handler : this.clientTickHandlers) 38 | { 39 | GameWrap.profilerPush(handler.getProfilerSectionSupplier()); 40 | handler.onClientTick(); 41 | GameWrap.profilerPop(); 42 | } 43 | 44 | GameWrap.profilerPop(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/DirectorySelectorScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui; 2 | 3 | import java.nio.file.Path; 4 | 5 | import malilib.util.FileUtils; 6 | import malilib.util.data.ToBooleanFunction; 7 | 8 | public class DirectorySelectorScreen extends FileSelectorScreen 9 | { 10 | public DirectorySelectorScreen(Path currentDirectory, Path rootDirectory, ToBooleanFunction fileConsumer) 11 | { 12 | super(currentDirectory, rootDirectory, fileConsumer); 13 | 14 | this.fileFilter = FileUtils.ALWAYS_FALSE_FILEFILTER; 15 | this.setTitle("malilib.title.screen.directory_browser"); 16 | } 17 | 18 | @Override 19 | protected String getButtonLabel() 20 | { 21 | return "malilib.button.config.use_current_directory"; 22 | } 23 | 24 | @Override 25 | protected void onConfirm() 26 | { 27 | if (this.fileConsumer.applyAsBoolean(this.getListWidget().getCurrentDirectory())) 28 | { 29 | this.openParentScreen(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/TextInputScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui; 2 | 3 | import malilib.util.data.ResultingStringConsumer; 4 | 5 | public class TextInputScreen extends BaseTextInputScreen 6 | { 7 | protected final ResultingStringConsumer stringConsumer; 8 | 9 | public TextInputScreen(String titleKey, ResultingStringConsumer stringConsumer) 10 | { 11 | this(titleKey, "", stringConsumer); 12 | } 13 | 14 | public TextInputScreen(String titleKey, String defaultText, ResultingStringConsumer stringConsumer) 15 | { 16 | super(titleKey, defaultText); 17 | 18 | this.stringConsumer = stringConsumer; 19 | } 20 | 21 | @Override 22 | protected boolean applyValue() 23 | { 24 | return this.stringConsumer.consumeString(this.textField.getText()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/action/ActionWidgetContainer.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.action; 2 | 3 | public interface ActionWidgetContainer 4 | { 5 | /** 6 | * @return true if the widget edit mode is currently active 7 | */ 8 | boolean isEditMode(); 9 | 10 | /** 11 | * @return The current grid size in the edit mode. Returns -1 if the grid is disabled. 12 | */ 13 | int getGridSize(); 14 | 15 | /** 16 | * @return true if the current screen is configured to close when an action is triggered 17 | */ 18 | boolean shouldCloseScreenOnExecute(); 19 | 20 | /** 21 | * Can be called to notify that the internal state/settings of a widget were modified. 22 | * This can be used to detect when the screen state needs to be saved again. 23 | */ 24 | void notifyWidgetEdited(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/callback/SliderCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.callback; 2 | 3 | public interface SliderCallback 4 | { 5 | /** 6 | * Maximum number of values/steps the underlying data can have. 7 | * Return Integer.MAX_VALUE for unlimited/non-specified, like double data type ranges. 8 | */ 9 | int getMaxSteps(); 10 | 11 | /** 12 | * Returns the relative value within the min - max range, 13 | * so relativeValue = (value - minValue) / (maxValue - minValue) 14 | */ 15 | double getRelativeValue(); 16 | 17 | /** 18 | * Sets the value from the provided relative value (0.0 ... 1.0) 19 | */ 20 | void setRelativeValue(double relativeValue); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/callback/SliderCallbackWithText.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.callback; 2 | 3 | import malilib.render.text.StyledTextLine; 4 | 5 | public interface SliderCallbackWithText extends SliderCallback 6 | { 7 | /** 8 | * @return the formatted display text for the current value. This is used in the slider widget in the GUI. 9 | */ 10 | StyledTextLine getDisplayText(); 11 | 12 | /** 13 | * Updates the display text, if the value changes externally 14 | */ 15 | void updateDisplayText(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/callback/SteppedSliderCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.callback; 2 | 3 | public interface SteppedSliderCallback extends SliderCallback 4 | { 5 | /** 6 | * @return the step size the underlying config value should snap to 7 | */ 8 | double getStepSize(); 9 | 10 | /** 11 | * Sets the step size the underlying config value should snap to 12 | */ 13 | void setStepSize(double step); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/config/ConfigOptionWidgetFactory.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.config; 2 | 3 | import malilib.config.option.ConfigInfo; 4 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 5 | import malilib.gui.widget.list.entry.config.BaseConfigWidget; 6 | 7 | public interface ConfigOptionWidgetFactory 8 | { 9 | BaseConfigWidget create(CFG config, 10 | DataListEntryWidgetData constructData, 11 | ConfigWidgetContext ctx); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/config/ConfigWidgetContext.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.config; 2 | 3 | import malilib.gui.widget.list.ConfigOptionListWidget; 4 | import malilib.util.data.ConfigOnTab; 5 | 6 | public class ConfigWidgetContext 7 | { 8 | protected final ConfigOnTab configOnTab; 9 | protected final ConfigOptionListWidget listWidget; 10 | 11 | public ConfigWidgetContext(ConfigOnTab configOnTab, 12 | ConfigOptionListWidget listWidget) 13 | { 14 | this.configOnTab = configOnTab; 15 | this.listWidget = listWidget; 16 | } 17 | 18 | public ConfigOnTab getConfigOnTab() 19 | { 20 | return this.configOnTab; 21 | } 22 | 23 | public ConfigOptionListWidget getListWidget() 24 | { 25 | return this.listWidget; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/config/indicator/ConfigStatusWidgetFactory.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.config.indicator; 2 | 3 | import malilib.config.option.ConfigInfo; 4 | import malilib.overlay.widget.sub.BaseConfigStatusIndicatorWidget; 5 | import malilib.util.data.ConfigOnTab; 6 | 7 | public interface ConfigStatusWidgetFactory 8 | { 9 | BaseConfigStatusIndicatorWidget create(C config, ConfigOnTab configOnTab); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/config/registry/ConfigScreenRegistry.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.config.registry; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.function.Supplier; 8 | import javax.annotation.Nullable; 9 | import com.google.common.collect.ImmutableList; 10 | 11 | import malilib.gui.BaseScreen; 12 | import malilib.util.data.ModInfo; 13 | 14 | public class ConfigScreenRegistry 15 | { 16 | protected final Map> configScreenFactories = new HashMap<>(); 17 | protected ImmutableList mods = ImmutableList.of(); 18 | 19 | public ConfigScreenRegistry() 20 | { 21 | } 22 | 23 | public void registerConfigScreenFactory(ModInfo modInfo, Supplier screenFactory) 24 | { 25 | this.configScreenFactories.put(modInfo, screenFactory); 26 | 27 | ArrayList list = new ArrayList<>(this.configScreenFactories.keySet()); 28 | list.sort(Comparator.comparing(ModInfo::getModName)); 29 | this.mods = ImmutableList.copyOf(list); 30 | } 31 | 32 | @Nullable 33 | public Supplier getConfigScreenFactoryFor(ModInfo modInfo) 34 | { 35 | return this.configScreenFactories.get(modInfo); 36 | } 37 | 38 | public ImmutableList getAllModsWithConfigScreens() 39 | { 40 | return this.mods; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/config/registry/ConfigTabExtensionRegistry.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.config.registry; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.function.Supplier; 6 | import com.google.common.collect.ArrayListMultimap; 7 | 8 | import malilib.config.option.ConfigInfo; 9 | import malilib.gui.config.ConfigTab; 10 | 11 | public class ConfigTabExtensionRegistry 12 | { 13 | protected final ArrayListMultimap>> configTabExtensions = ArrayListMultimap.create(); 14 | 15 | public void registerConfigTabExtension(ConfigTab tab, 16 | Supplier> customOptionSupplier) 17 | { 18 | this.configTabExtensions.put(tab, customOptionSupplier); 19 | } 20 | 21 | public List getExtensionConfigsForTab(ConfigTab tab) 22 | { 23 | List list = new ArrayList<>(); 24 | 25 | for (Supplier> extension : this.configTabExtensions.get(tab)) 26 | { 27 | list.addAll(extension.get()); 28 | } 29 | 30 | return list; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/edit/BaseLayerRangeEditScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.edit; 2 | 3 | import java.util.List; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.gui.BaseTabbedScreen; 7 | import malilib.gui.tab.ScreenTab; 8 | import malilib.gui.widget.BaseLayerRangeEditWidget; 9 | import malilib.util.position.LayerRange; 10 | 11 | public abstract class BaseLayerRangeEditScreen extends BaseTabbedScreen 12 | { 13 | protected final BaseLayerRangeEditWidget editWidget; 14 | 15 | public BaseLayerRangeEditScreen(String screenId, 16 | List screenTabs, 17 | @Nullable ScreenTab defaultTab, 18 | LayerRange range) 19 | { 20 | super(screenId, screenTabs, defaultTab); 21 | 22 | this.editWidget = new BaseLayerRangeEditWidget(-1, -1, range); 23 | } 24 | 25 | @Override 26 | protected void reAddActiveWidgets() 27 | { 28 | super.reAddActiveWidgets(); 29 | 30 | this.addWidget(this.editWidget); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/edit/ColorEditorScreenHsv.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.edit; 2 | 3 | import java.util.function.IntConsumer; 4 | 5 | import malilib.gui.BaseScreen; 6 | import malilib.gui.widget.ColorEditorWidgetHsv; 7 | 8 | public class ColorEditorScreenHsv extends BaseScreen 9 | { 10 | protected final ColorEditorWidgetHsv colorEditorWidget; 11 | 12 | public ColorEditorScreenHsv(int colorIn, IntConsumer colorConsumer) 13 | { 14 | this.backgroundColor = 0xFF000000; 15 | this.renderBorder = true; 16 | this.useTitleHierarchy = false; 17 | 18 | this.colorEditorWidget = new ColorEditorWidgetHsv(colorIn, colorConsumer); 19 | 20 | this.setTitle("malilib.title.screen.color_editor"); 21 | this.setScreenWidthAndHeight(300, 180); 22 | this.centerOnScreen(); 23 | } 24 | 25 | @Override 26 | protected void reAddActiveWidgets() 27 | { 28 | super.reAddActiveWidgets(); 29 | 30 | this.addWidget(this.colorEditorWidget); 31 | } 32 | 33 | @Override 34 | protected void updateWidgetPositions() 35 | { 36 | super.updateWidgetPositions(); 37 | 38 | this.colorEditorWidget.setPosition(this.x + 4, this.y + 18); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/edit/EdgeIntEditScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.edit; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.gui.BaseScreen; 6 | import malilib.gui.widget.EdgeIntEditWidget; 7 | import malilib.util.data.EdgeInt; 8 | 9 | public class EdgeIntEditScreen extends BaseScreen 10 | { 11 | protected final EdgeIntEditWidget editWidget; 12 | 13 | public EdgeIntEditScreen(EdgeInt value, boolean isColor, String titleKey, @Nullable String centerText) 14 | { 15 | this.useTitleHierarchy = false; 16 | this.backgroundColor = 0xFF000000; 17 | this.renderBorder = true; 18 | this.setTitle(titleKey); 19 | 20 | this.editWidget = new EdgeIntEditWidget(300, 100, value, isColor, centerText); 21 | 22 | this.setScreenWidthAndHeight(320, 130); 23 | this.centerOnScreen(); 24 | } 25 | 26 | @Override 27 | protected void reAddActiveWidgets() 28 | { 29 | super.reAddActiveWidgets(); 30 | 31 | this.addWidget(this.editWidget); 32 | } 33 | 34 | @Override 35 | protected void updateWidgetPositions() 36 | { 37 | super.updateWidgetPositions(); 38 | 39 | this.editWidget.setPosition(this.x + 10, this.y + 26); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/edit/overlay/AllInfoWidgetsListScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.edit.overlay; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.gui.widget.list.entry.BaseInfoRendererWidgetEntryWidget; 5 | import malilib.overlay.widget.InfoRendererWidget; 6 | 7 | public class AllInfoWidgetsListScreen extends InfoRendererWidgetListScreen 8 | { 9 | public AllInfoWidgetsListScreen() 10 | { 11 | super(InfoRendererWidgetListScreen.createSupplierFromInfoManagerForSubtypes(InfoRendererWidget.class), 12 | null, 13 | BaseInfoRendererWidgetEntryWidget::new); 14 | 15 | this.setTitle("malilib.title.screen.configs.info_renderer_widgets", MaLiLibReference.MOD_VERSION); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/edit/overlay/ConfigStatusIndicatorWidgetListScreen.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.edit.overlay; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.gui.widget.list.entry.BaseInfoRendererWidgetEntryWidget; 5 | import malilib.overlay.widget.ConfigStatusIndicatorContainerWidget; 6 | import malilib.registry.Registry; 7 | 8 | public class ConfigStatusIndicatorWidgetListScreen extends InfoRendererWidgetListScreen 9 | { 10 | public ConfigStatusIndicatorWidgetListScreen() 11 | { 12 | super(InfoRendererWidgetListScreen.createSupplierFromInfoManagerForExactType(ConfigStatusIndicatorContainerWidget.class), 13 | ConfigStatusIndicatorContainerWidget::new, 14 | BaseInfoRendererWidgetEntryWidget::new); 15 | 16 | this.setTitle("malilib.title.screen.configs.config_status_indicator_configuration", MaLiLibReference.MOD_VERSION); 17 | this.canCreateNewWidgets = true; 18 | } 19 | 20 | @Override 21 | protected void importOverwriteRemoveOldWidgets() 22 | { 23 | Registry.INFO_WIDGET_MANAGER.removeMatchingWidgets(w -> w.getClass() == ConfigStatusIndicatorContainerWidget.class); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/icon/BaseIconProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.icon; 2 | 3 | import javax.annotation.Nullable; 4 | import com.google.common.collect.ImmutableMap; 5 | 6 | public class BaseIconProvider implements IconProvider 7 | { 8 | protected final int expectedWidth; 9 | protected final ImmutableMap icons; 10 | 11 | public BaseIconProvider(int expectedWidth, ImmutableMap icons) 12 | { 13 | this.expectedWidth = expectedWidth; 14 | this.icons = icons; 15 | } 16 | 17 | @Override 18 | public int getExpectedWidth() 19 | { 20 | return this.expectedWidth; 21 | } 22 | 23 | @Nullable 24 | @Override 25 | public Icon getIconFor(T entry) 26 | { 27 | return this.icons.get(entry); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/icon/DefaultFileBrowserIconProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.icon; 2 | 3 | public class DefaultFileBrowserIconProvider implements FileBrowserIconProvider 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/icon/IconProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.icon; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public interface IconProvider 6 | { 7 | /** 8 | * @return the expected width of the icons for nice alignment, 9 | * in case some entries return null icons 10 | */ 11 | int getExpectedWidth(); 12 | 13 | /** 14 | * @return the icon to use for the given value 15 | */ 16 | @Nullable 17 | Icon getIconFor(T entry); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/icon/NamedIcon.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.icon; 2 | 3 | public interface NamedIcon extends Icon 4 | { 5 | /** 6 | * @return the name of the icon 7 | */ 8 | String getName(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/icon/PositionedIcon.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.icon; 2 | 3 | import malilib.util.position.Vec2i; 4 | 5 | public class PositionedIcon 6 | { 7 | public final Vec2i pos; 8 | public final Icon icon; 9 | 10 | public PositionedIcon(Vec2i pos, Icon icon) 11 | { 12 | this.pos = pos; 13 | this.icon = icon; 14 | } 15 | 16 | public static PositionedIcon of(Vec2i pos, Icon icon) 17 | { 18 | return new PositionedIcon(pos, icon); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/listener/DoubleModifierButtonListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.listener; 2 | 3 | import java.util.function.DoubleConsumer; 4 | import java.util.function.DoubleSupplier; 5 | 6 | import malilib.gui.BaseScreen; 7 | import malilib.util.data.Int2BooleanFunction; 8 | 9 | public class DoubleModifierButtonListener implements Int2BooleanFunction 10 | { 11 | protected final DoubleSupplier supplier; 12 | protected final DoubleConsumer consumer; 13 | protected final int modifierShift; 14 | protected final int modifierControl; 15 | protected final int modifierAlt; 16 | 17 | public DoubleModifierButtonListener(DoubleSupplier supplier, DoubleConsumer consumer) 18 | { 19 | this(supplier, consumer, 8, 1, 4); 20 | } 21 | 22 | public DoubleModifierButtonListener(DoubleSupplier supplier, DoubleConsumer consumer, int modifierShift, int modifierControl, int modifierAlt) 23 | { 24 | this.supplier = supplier; 25 | this.consumer = consumer; 26 | this.modifierShift = modifierShift; 27 | this.modifierControl = modifierControl; 28 | this.modifierAlt = modifierAlt; 29 | } 30 | 31 | @Override 32 | public boolean apply(int mouseButton) 33 | { 34 | int amount = mouseButton == 1 ? -1 : 1; 35 | 36 | if (BaseScreen.isShiftDown()) { amount *= this.modifierShift; } 37 | if (BaseScreen.isCtrlDown()) { amount *= this.modifierControl; } 38 | if (BaseScreen.isAltDown()) { amount *= this.modifierAlt; } 39 | 40 | this.consumer.accept(this.supplier.getAsDouble() + amount); 41 | 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/listener/DoubleTextFieldListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.listener; 2 | 3 | import java.util.function.Consumer; 4 | import java.util.function.DoubleConsumer; 5 | 6 | public class DoubleTextFieldListener implements Consumer 7 | { 8 | protected final DoubleConsumer consumer; 9 | 10 | public DoubleTextFieldListener(DoubleConsumer consumer) 11 | { 12 | this.consumer = consumer; 13 | } 14 | 15 | @Override 16 | public void accept(String newText) 17 | { 18 | try 19 | { 20 | this.consumer.accept(Double.parseDouble(newText)); 21 | } 22 | catch (Exception ignore) {} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/listener/IntegerModifierButtonListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.listener; 2 | 3 | import java.util.function.IntConsumer; 4 | import java.util.function.IntSupplier; 5 | 6 | import malilib.gui.BaseScreen; 7 | import malilib.util.data.Int2BooleanFunction; 8 | 9 | public class IntegerModifierButtonListener implements Int2BooleanFunction 10 | { 11 | protected final IntSupplier supplier; 12 | protected final IntConsumer consumer; 13 | protected final int modifierShift; 14 | protected final int modifierControl; 15 | protected final int modifierAlt; 16 | 17 | public IntegerModifierButtonListener(IntSupplier supplier, IntConsumer consumer) 18 | { 19 | this(supplier, consumer, 8, 1, 4); 20 | } 21 | 22 | public IntegerModifierButtonListener(IntSupplier supplier, IntConsumer consumer, int modifierShift, int modifierControl, int modifierAlt) 23 | { 24 | this.supplier = supplier; 25 | this.consumer = consumer; 26 | this.modifierShift = modifierShift; 27 | this.modifierControl = modifierControl; 28 | this.modifierAlt = modifierAlt; 29 | } 30 | 31 | @Override 32 | public boolean apply(int mouseButton) 33 | { 34 | int amount = mouseButton == 1 ? -1 : 1; 35 | 36 | if (BaseScreen.isShiftDown()) { amount *= this.modifierShift; } 37 | if (BaseScreen.isCtrlDown()) { amount *= this.modifierControl; } 38 | if (BaseScreen.isAltDown()) { amount *= this.modifierAlt; } 39 | 40 | this.consumer.accept(this.supplier.getAsInt() + amount); 41 | 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/listener/IntegerTextFieldListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.listener; 2 | 3 | import java.util.function.Consumer; 4 | import java.util.function.IntConsumer; 5 | 6 | public class IntegerTextFieldListener implements Consumer 7 | { 8 | protected final IntConsumer consumer; 9 | 10 | public IntegerTextFieldListener(IntConsumer consumer) 11 | { 12 | this.consumer = consumer; 13 | } 14 | 15 | @Override 16 | public void accept(String newText) 17 | { 18 | try 19 | { 20 | this.consumer.accept(Integer.parseInt(newText)); 21 | } 22 | catch (Exception ignore) {} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/tab/TabbedScreenState.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.tab; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public class TabbedScreenState 6 | { 7 | @Nullable public ScreenTab currentTab; 8 | public int visibleTabsStartIndex; 9 | 10 | public TabbedScreenState(@Nullable ScreenTab currentTab) 11 | { 12 | this.currentTab = currentTab; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/util/BackgroundRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.util; 2 | 3 | import malilib.render.ShapeRenderUtils; 4 | 5 | public class BackgroundRenderer 6 | { 7 | protected BackgroundSettings normalSettings = new BackgroundSettings(0xFF101010); 8 | protected BackgroundSettings hoverSettings = new BackgroundSettings(0x50FFFFFF); 9 | 10 | public BackgroundSettings getNormalSettings() 11 | { 12 | return this.normalSettings; 13 | } 14 | 15 | public BackgroundSettings getHoverSettings() 16 | { 17 | return this.hoverSettings; 18 | } 19 | 20 | public BackgroundSettings getActiveSettings(boolean hovered) 21 | { 22 | return hovered && this.hoverSettings.isEnabled() ? this.hoverSettings : this.normalSettings; 23 | } 24 | 25 | public void renderBackgroundIfEnabled(int x, int y, float z, int width, int height, 26 | BackgroundSettings settings, ScreenContext ctx) 27 | { 28 | if (settings.isEnabled()) 29 | { 30 | this.renderBackground(x, y, z, width, height, settings, ctx); 31 | } 32 | } 33 | 34 | public void renderBackground(int x, int y, float z, int width, int height, 35 | BackgroundSettings settings, ScreenContext ctx) 36 | { 37 | ShapeRenderUtils.renderRectangle(x, y, z, width, height, settings.getColor(), ctx); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/util/BorderRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.util; 2 | 3 | import malilib.render.ShapeRenderUtils; 4 | import malilib.util.data.EdgeInt; 5 | 6 | public class BorderRenderer 7 | { 8 | protected final BorderSettings normalSettings = new BorderSettings(0xFFC0C0C0); 9 | protected final BorderSettings hoverSettings = new BorderSettings(0xFFFFFFFF); 10 | 11 | public BorderSettings getNormalSettings() 12 | { 13 | return this.normalSettings; 14 | } 15 | 16 | public BorderSettings getHoverSettings() 17 | { 18 | return this.hoverSettings; 19 | } 20 | 21 | public BorderSettings getActiveSettings(boolean hovered) 22 | { 23 | return hovered && this.hoverSettings.isEnabled() ? this.hoverSettings : this.normalSettings; 24 | } 25 | 26 | public void renderBorderIfEnabled(int x, int y, float z, 27 | int width, int height, 28 | BorderSettings settings, ScreenContext ctx) 29 | { 30 | if (settings.isEnabled()) 31 | { 32 | this.renderBorder(x, y, z, width, height, settings, ctx); 33 | } 34 | } 35 | 36 | public void renderBorder(int x, int y, float z, 37 | int width, int height, 38 | BorderSettings settings, ScreenContext ctx) 39 | { 40 | EdgeInt color = settings.getColor(); 41 | int borderWidth = settings.getActiveBorderWidth(); 42 | ShapeRenderUtils.renderOutline(x, y, z, width, height, borderWidth, color, ctx); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/util/ScreenContext.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.util; 2 | 3 | import malilib.MaLiLibConfigs; 4 | import malilib.render.RenderContext; 5 | 6 | public class ScreenContext extends RenderContext 7 | { 8 | public static final ScreenContext DUMMY = new ScreenContext(0, 0, -1, true); 9 | 10 | public final int mouseX; 11 | public final int mouseY; 12 | public final int hoveredWidgetId; 13 | public final boolean isActiveScreen; 14 | 15 | public ScreenContext(int mouseX, int mouseY, int hoveredWidgetId, boolean isActiveScreen) 16 | { 17 | this.mouseX = mouseX; 18 | this.mouseY = mouseY; 19 | this.hoveredWidgetId = hoveredWidgetId; 20 | this.isActiveScreen = isActiveScreen; 21 | } 22 | 23 | public boolean getRenderDebug() 24 | { 25 | return MaLiLibConfigs.Debug.GUI_DEBUG.getBooleanValue() && 26 | MaLiLibConfigs.Debug.GUI_DEBUG_KEY.isHeld(); 27 | } 28 | 29 | public boolean getDebugRenderAll() 30 | { 31 | return MaLiLibConfigs.Debug.GUI_DEBUG_ALL.getBooleanValue(); 32 | } 33 | 34 | public boolean getDebugInfoAlways() 35 | { 36 | return MaLiLibConfigs.Debug.GUI_DEBUG_INFO_ALWAYS.getBooleanValue(); 37 | } 38 | 39 | public boolean matches(int mouseX, int mouseY, boolean isActiveScreen, int hoveredWidgetId) 40 | { 41 | return this.isActiveScreen == isActiveScreen && 42 | this.hoveredWidgetId == hoveredWidgetId && 43 | this.mouseX == mouseX && 44 | this.mouseY == mouseY; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/HoverInfoWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | public class HoverInfoWidget extends InteractableWidget 4 | { 5 | public HoverInfoWidget(int width, int height, String key, Object... args) 6 | { 7 | super(width, height); 8 | 9 | this.translateAndAddHoverString(key, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/InfoIconWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | import malilib.gui.icon.Icon; 4 | import malilib.gui.util.ScreenContext; 5 | 6 | public class InfoIconWidget extends HoverInfoWidget 7 | { 8 | protected final Icon icon; 9 | 10 | public InfoIconWidget(Icon icon, String key, Object... args) 11 | { 12 | super(icon.getWidth(), icon.getHeight(), key, args); 13 | 14 | this.icon = icon; 15 | } 16 | 17 | @Override 18 | public void renderAt(int x, int y, float z, ScreenContext ctx) 19 | { 20 | this.icon.renderAt(x, y, z + 0.1f, IconWidget.getVariantIndex(true, this.isHoveredForRender(ctx)), ctx); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/ItemStackWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | import net.minecraft.item.Item; 4 | import net.minecraft.item.ItemStack; 5 | 6 | import malilib.gui.util.ScreenContext; 7 | import malilib.render.ItemRenderUtils; 8 | import malilib.util.game.wrap.ItemWrap; 9 | 10 | public class ItemStackWidget extends BaseModelWidget 11 | { 12 | protected ItemStack stack; 13 | 14 | public ItemStackWidget(ItemStack stack) 15 | { 16 | this(16, stack); 17 | } 18 | 19 | public ItemStackWidget(int dimensions, ItemStack stack) 20 | { 21 | super(dimensions); 22 | 23 | this.setStack(stack); 24 | } 25 | 26 | public ItemStackWidget setStack(ItemStack stack) 27 | { 28 | this.stack = stack; 29 | 30 | this.updateSize(); 31 | 32 | return this; 33 | } 34 | 35 | @Override 36 | protected void renderModel(int x, int y, float z, float scale, ScreenContext ctx) 37 | { 38 | if (ItemWrap.notEmpty(this.stack)) 39 | { 40 | ItemRenderUtils.renderStackAt(this.stack, x, y, z, this.scale, ctx); 41 | } 42 | } 43 | 44 | public static ItemStackWidget createItemWidget(Item item) 45 | { 46 | ItemStackWidget widget = new ItemStackWidget(16, new ItemStack(item)); 47 | widget.getBackgroundRenderer().getNormalSettings().setEnabledAndColor(true, 0xFF505050); 48 | widget.getBackgroundRenderer().getHoverSettings().setEnabledAndColor(true, 0xFF505050); 49 | return widget; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/MenuEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | import malilib.render.text.StyledTextLine; 4 | 5 | public class MenuEntryWidget extends InteractableWidget 6 | { 7 | protected final Runnable action; 8 | 9 | public MenuEntryWidget(StyledTextLine text, Runnable action) 10 | { 11 | this(text, action, true); 12 | } 13 | 14 | public MenuEntryWidget(StyledTextLine text, Runnable action, boolean enabled) 15 | { 16 | this(10, 12, text, action); 17 | 18 | this.setEnabled(enabled); 19 | } 20 | 21 | public MenuEntryWidget(int width, int height, StyledTextLine text, Runnable action) 22 | { 23 | super(width, height); 24 | 25 | this.canReceiveMouseClicks = true; 26 | this.action = action; 27 | this.setText(text); 28 | this.setWidth(this.text.renderWidth + 10); 29 | } 30 | 31 | @Override 32 | protected void onEnabledStateChanged(boolean isEnabled) 33 | { 34 | int color = isEnabled ? 0xFFFFFFFF : 0xFF808080; 35 | this.getTextSettings().setTextColor(color); 36 | } 37 | 38 | /** 39 | * Handle the mouse click.
40 | * Note: MenuEntryWidget should return false, if it wants the MenuWidget to close the menu, 41 | * or return true if it wants the menu to stay open. 42 | */ 43 | @Override 44 | protected boolean onMouseClicked(int mouseX, int mouseY, int mouseButton) 45 | { 46 | if (this.isEnabled() && mouseButton == 0) 47 | { 48 | this.action.run(); 49 | return false; 50 | } 51 | 52 | return true; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/Vec2dEditWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import malilib.util.position.Coordinate; 6 | import malilib.util.position.Vec2d; 7 | 8 | public class Vec2dEditWidget extends BaseDualNumberEditWidget 9 | { 10 | public Vec2dEditWidget(int width, int height, 11 | int gap, boolean vertical, 12 | Vec2d initialValue, 13 | Consumer valueConsumer) 14 | { 15 | super(width, height, gap, vertical, initialValue, valueConsumer); 16 | } 17 | 18 | @Override 19 | public void updateWidgetState() 20 | { 21 | this.xCoordinateWidget.setDoubleValue(this.pos.x); 22 | this.yCoordinateWidget.setDoubleValue(this.pos.y); 23 | } 24 | 25 | @Override 26 | protected DoubleEditWidget createNumberEditWidget(int width, int height, Vec2d initialPos, Coordinate coord) 27 | { 28 | return new DoubleEditWidget(width, height, 29 | coord.asDouble(initialPos), 30 | -31000000.0, 31000000.0, 31 | (val) -> this.setValue(val, coord)); 32 | } 33 | 34 | public void setValidRange(double minX, double minY, double maxX, double maxY) 35 | { 36 | this.xCoordinateWidget.setValidRange(minX, maxX); 37 | this.yCoordinateWidget.setValidRange(minY, maxY); 38 | } 39 | 40 | protected void setValue(double newVal, Coordinate coordinate) 41 | { 42 | this.setValue(coordinate.modifyVec2d(newVal, this.pos)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/Vec2iEditWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import malilib.util.position.Coordinate; 6 | import malilib.util.position.Vec2i; 7 | 8 | public class Vec2iEditWidget extends BaseDualNumberEditWidget 9 | { 10 | public Vec2iEditWidget(int width, int height, 11 | int gap, boolean vertical, 12 | Vec2i initialValue, 13 | Consumer valueConsumer) 14 | { 15 | super(width, height, gap, vertical, initialValue, valueConsumer); 16 | } 17 | 18 | @Override 19 | public void updateWidgetState() 20 | { 21 | this.xCoordinateWidget.setIntegerValue(this.pos.getX()); 22 | this.yCoordinateWidget.setIntegerValue(this.pos.getY()); 23 | } 24 | 25 | @Override 26 | protected IntegerEditWidget createNumberEditWidget(int width, int height, Vec2i initialPos, Coordinate coord) 27 | { 28 | return new IntegerEditWidget(width, height, initialPos.getX(), (val) -> this.setValue(val, coord)); 29 | } 30 | 31 | public void setValidRange(int minX, int minY, int maxX, int maxY) 32 | { 33 | this.xCoordinateWidget.setValidRange(minX, maxX); 34 | this.yCoordinateWidget.setValidRange(minY, maxY); 35 | } 36 | 37 | protected void setValue(int newVal, Coordinate coordinate) 38 | { 39 | this.setValue(coordinate.modifyVec2i(newVal, this.pos)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/button/BooleanConfigButton.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.button; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.util.data.BooleanStorage; 6 | 7 | public class BooleanConfigButton extends OnOffButton 8 | { 9 | public BooleanConfigButton(int width, int height, BooleanStorage config) 10 | { 11 | this(width, height, config, OnOffStyle.SLIDER_ON_OFF, null); 12 | } 13 | 14 | public BooleanConfigButton(int width, int height, BooleanStorage config, OnOffStyle style, @Nullable String translationKey) 15 | { 16 | super(width, height, style, config::getBooleanValue, translationKey); 17 | 18 | this.setActionListener(config::toggleBooleanValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/button/ButtonActionListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.button; 2 | 3 | public interface ButtonActionListener 4 | { 5 | /** 6 | * Called when a button is clicked with the mouse 7 | * @param mouseButton the mouse button that was clicked. 0 = left click, 1 = right click, 2 = middle click 8 | * @param buttonWidget the button widget this listener is tied to 9 | * @return true if the action was successful 10 | */ 11 | boolean actionPerformedWithButton(int mouseButton, GenericButton buttonWidget); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/ListEntryWidgetInitializer.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list; 2 | 3 | public interface ListEntryWidgetInitializer 4 | { 5 | void onListContentsRefreshed(DataListWidget dataListWidget, int entryWidgetWidth); 6 | 7 | void applyToEntryWidgets(DataListWidget dataListWidget); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/SelectionListener.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public interface SelectionListener 6 | { 7 | void onSelectionChange(@Nullable T entry); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/ConfigInfoEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | import malilib.config.option.ConfigInfo; 4 | import malilib.render.text.StyledTextLine; 5 | import malilib.util.data.ConfigOnTab; 6 | 7 | public class ConfigInfoEntryWidget extends BaseDataListEntryWidget 8 | { 9 | public ConfigInfoEntryWidget(ConfigOnTab data, DataListEntryWidgetData constructData) 10 | { 11 | super(data, constructData); 12 | 13 | ConfigInfo config = data.getConfig(); 14 | this.translateAndAddHoverString("malilib.hover.config.info_entry_widget", 15 | config.getDisplayName(), config.getName(), 16 | config.getClass().getSimpleName()); 17 | 18 | this.setText(StyledTextLine.parseFirstLine(config.getDisplayName())); 19 | 20 | int bgColor = this.isOdd ? 0x30FFFFFF : 0x20FFFFFF; 21 | this.getBackgroundRenderer().getNormalSettings().setEnabledAndColor(true, bgColor); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/DataListEntryWidgetData.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | import malilib.gui.widget.list.DataListWidget; 4 | 5 | public class DataListEntryWidgetData 6 | { 7 | public int x; 8 | public int y; 9 | public int width; 10 | public int height; 11 | public int listIndex; 12 | public int originalListIndex; 13 | public DataListWidget listWidget; 14 | 15 | public DataListEntryWidgetData(int x, int y, int width, int height, 16 | int listIndex, int originalListIndex, 17 | DataListWidget listWidget) 18 | { 19 | this.x = x; 20 | this.y = y; 21 | this.width = width; 22 | this.height = height; 23 | this.listIndex = listIndex; 24 | this.originalListIndex = originalListIndex; 25 | this.listWidget = listWidget; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/DataListEntryWidgetFactory.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public interface DataListEntryWidgetFactory 6 | { 7 | /** 8 | * Creates the list entry widget for the given data entry and list index 9 | */ 10 | @Nullable 11 | BaseListEntryWidget createWidget(DATATYPE data, DataListEntryWidgetData constructData); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/IdentifierListEditEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | import malilib.util.data.Identifier; 4 | 5 | public class IdentifierListEditEntryWidget extends BaseStringListEditEntryWidget 6 | { 7 | public IdentifierListEditEntryWidget(Identifier data, 8 | DataListEntryWidgetData constructData, 9 | Identifier defaultValue) 10 | { 11 | super(data, constructData, defaultValue, Identifier::toString, Identifier::new); 12 | this.newEntryFactory = () -> new Identifier("minecraft:foo"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/StringListEditEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | public class StringListEditEntryWidget extends BaseStringListEditEntryWidget 4 | { 5 | public StringListEditEntryWidget(String data, 6 | DataListEntryWidgetData constructData, 7 | String defaultValue) 8 | { 9 | super(data, constructData, defaultValue, (v) -> v, (s) -> s); 10 | 11 | this.newEntryFactory = () -> ""; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/StringListEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry; 2 | 3 | import malilib.render.text.StyledTextLine; 4 | 5 | public class StringListEntryWidget extends BaseDataListEntryWidget 6 | { 7 | public StringListEntryWidget(String data, DataListEntryWidgetData constructData) 8 | { 9 | super(data, constructData); 10 | 11 | this.setText(StyledTextLine.unParsed(data)); 12 | this.getBackgroundRenderer().getNormalSettings().setColor(this.isOdd ? 0xA0101010 : 0xA0303030); 13 | this.getBackgroundRenderer().getHoverSettings().setColor(0xA0707070); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/BaseGenericConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.BaseGenericConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 6 | 7 | public class BaseGenericConfigWidget> extends BaseConfigWidget 8 | { 9 | protected final TYPE initialValue; 10 | 11 | public BaseGenericConfigWidget(CFG config, 12 | DataListEntryWidgetData constructData, 13 | ConfigWidgetContext ctx) 14 | { 15 | super(config, constructData, ctx); 16 | 17 | this.initialValue = config.getValueForSerialization(); 18 | } 19 | 20 | @Override 21 | public boolean wasModified() 22 | { 23 | return this.config.getValueForSerialization().equals(this.initialValue) == false; 24 | } 25 | 26 | @Override 27 | protected boolean isResetEnabled() 28 | { 29 | return this.config.isModified() && this.config.isLocked() == false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/CustomHotkeyEntryWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.gui.config.ConfigWidgetContext; 4 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 5 | import malilib.input.CustomHotkeyDefinition; 6 | 7 | /** 8 | * This class is used when the custom hotkeys get pulled to the config search results. 9 | * This is not used on the Custom Hotkeys config screen, 10 | * see {@link malilib.gui.widget.list.entry.CustomHotkeyDefinitionEntryWidget} for that. 11 | */ 12 | public class CustomHotkeyEntryWidget extends BaseKeyBindConfigWidget 13 | { 14 | public CustomHotkeyEntryWidget(CustomHotkeyDefinition config, 15 | DataListEntryWidgetData constructData, 16 | ConfigWidgetContext ctx) 17 | { 18 | super(config, constructData, ctx, config.getKeyBind()); 19 | 20 | this.keybindButton.setEnabled(config.isLocked() == false); 21 | 22 | if (config.isLocked()) 23 | { 24 | this.keybindButton.setHoverInfoRequiresShift(false); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/DirectoryConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import java.nio.file.Path; 4 | 5 | import malilib.config.option.DirectoryConfig; 6 | import malilib.gui.config.ConfigWidgetContext; 7 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 8 | 9 | public class DirectoryConfigWidget extends BaseFileConfigWidget 10 | { 11 | public DirectoryConfigWidget(DirectoryConfig config, 12 | DataListEntryWidgetData constructData, 13 | ConfigWidgetContext ctx) 14 | { 15 | super(config, constructData, ctx); 16 | } 17 | 18 | @Override 19 | protected Path getFileFromConfig() 20 | { 21 | return this.config.getValue(); 22 | } 23 | 24 | @Override 25 | protected void setFileToConfig(Path file) 26 | { 27 | this.config.setValue(file); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/FileConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import java.nio.file.Path; 4 | 5 | import malilib.config.option.FileConfig; 6 | import malilib.gui.BaseScreen; 7 | import malilib.gui.FileSelectorScreen; 8 | import malilib.gui.config.ConfigWidgetContext; 9 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 10 | 11 | public class FileConfigWidget extends BaseFileConfigWidget 12 | { 13 | public FileConfigWidget(FileConfig config, 14 | DataListEntryWidgetData constructData, 15 | ConfigWidgetContext ctx) 16 | { 17 | super(config, constructData, ctx); 18 | } 19 | 20 | @Override 21 | protected Path getFileFromConfig() 22 | { 23 | return this.config.getValue(); 24 | } 25 | 26 | @Override 27 | protected void setFileToConfig(Path file) 28 | { 29 | this.config.setValue(file); 30 | } 31 | 32 | @Override 33 | protected BaseScreen createScreen(Path currentDir, Path rootDir) 34 | { 35 | return new FileSelectorScreen(currentDir, rootDir, this::onPathSelected); 36 | } 37 | 38 | @Override 39 | protected String getButtonLabelKey() 40 | { 41 | return "malilib.button.config.select_file"; 42 | } 43 | 44 | @Override 45 | protected String getButtonHoverTextKey() 46 | { 47 | return "malilib.hover.button.config.selected_file"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/GenericButtonConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.GenericButtonConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.button.GenericButton; 6 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 7 | 8 | public class GenericButtonConfigWidget extends BaseConfigWidget 9 | { 10 | protected final GenericButton button; 11 | 12 | public GenericButtonConfigWidget(GenericButtonConfig config, 13 | DataListEntryWidgetData constructData, 14 | ConfigWidgetContext ctx) 15 | { 16 | super(config, constructData, ctx); 17 | 18 | this.button = GenericButton.create(config.getButtonTextTranslationKey()); 19 | this.button.setActionListener(config.getButtonActionListener()); 20 | } 21 | 22 | @Override 23 | public void reAddSubWidgets() 24 | { 25 | super.reAddSubWidgets(); 26 | this.addWidget(this.button); 27 | } 28 | 29 | @Override 30 | public void updateSubWidgetPositions() 31 | { 32 | super.updateSubWidgetPositions(); 33 | this.button.setPosition(this.getElementsStartPosition(), this.getY() + 1); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/HotkeyConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.HotkeyConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 6 | 7 | public class HotkeyConfigWidget extends BaseKeyBindConfigWidget 8 | { 9 | public HotkeyConfigWidget(HotkeyConfig config, 10 | DataListEntryWidgetData constructData, 11 | ConfigWidgetContext ctx) 12 | { 13 | super(config, constructData, ctx, config.getKeyBind()); 14 | 15 | this.keybindButton.setHoverStringProvider("locked", config::getLockAndOverrideMessages); 16 | this.keybindButton.setEnabled(config.isLocked() == false); 17 | 18 | if (config.isLocked()) 19 | { 20 | this.keybindButton.setHoverInfoRequiresShift(false); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/HotkeyedBooleanConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.HotkeyedBooleanConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 6 | 7 | public class HotkeyedBooleanConfigWidget extends BaseHotkeyedBooleanConfigWidget 8 | { 9 | public HotkeyedBooleanConfigWidget(HotkeyedBooleanConfig config, 10 | DataListEntryWidgetData constructData, 11 | ConfigWidgetContext ctx) 12 | { 13 | super(config, config, config.getKeyBind(), constructData, ctx); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/Vec2dConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.Vec2dConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.BaseDualNumberEditWidget; 6 | import malilib.gui.widget.DoubleEditWidget; 7 | import malilib.gui.widget.Vec2dEditWidget; 8 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 9 | import malilib.util.position.Vec2d; 10 | 11 | public class Vec2dConfigWidget extends BaseDualNumberConfigWidget 12 | { 13 | public Vec2dConfigWidget(Vec2dConfig config, 14 | DataListEntryWidgetData constructData, 15 | ConfigWidgetContext ctx) 16 | { 17 | super(config, constructData, ctx); 18 | } 19 | 20 | @Override 21 | protected BaseDualNumberEditWidget createEditWidget(Vec2dConfig config) 22 | { 23 | Vec2dEditWidget widget = new Vec2dEditWidget(120, 18, 6, false, config.getValue(), this.config::setValue); 24 | double minValue = config.getMinValue(); 25 | double maxValue = config.getMaxValue(); 26 | widget.setValidRange(minValue, minValue, maxValue, maxValue); 27 | return widget; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/Vec2iConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config; 2 | 3 | import malilib.config.option.Vec2iConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.BaseDualNumberEditWidget; 6 | import malilib.gui.widget.IntegerEditWidget; 7 | import malilib.gui.widget.Vec2iEditWidget; 8 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 9 | import malilib.util.position.Vec2i; 10 | 11 | public class Vec2iConfigWidget extends BaseDualNumberConfigWidget 12 | { 13 | public Vec2iConfigWidget(Vec2iConfig config, 14 | DataListEntryWidgetData constructData, 15 | ConfigWidgetContext ctx) 16 | { 17 | super(config, constructData, ctx); 18 | } 19 | 20 | @Override 21 | protected BaseDualNumberEditWidget createEditWidget(Vec2iConfig config) 22 | { 23 | Vec2iEditWidget widget = new Vec2iEditWidget(120, 18, 6, false, config.getValue(), this.config::setValue); 24 | int minValue = config.getMinValue(); 25 | int maxValue = config.getMaxValue(); 26 | widget.setValidRange(minValue, minValue, maxValue, maxValue); 27 | return widget; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/entry/config/list/StringListConfigWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.entry.config.list; 2 | 3 | import malilib.config.option.list.StringListConfig; 4 | import malilib.gui.config.ConfigWidgetContext; 5 | import malilib.gui.widget.button.BaseValueListEditButton; 6 | import malilib.gui.widget.button.GenericButton; 7 | import malilib.gui.widget.list.entry.DataListEntryWidgetData; 8 | import malilib.gui.widget.list.entry.StringListEditEntryWidget; 9 | import malilib.util.StringUtils; 10 | 11 | public class StringListConfigWidget extends BaseValueListConfigWidget 12 | { 13 | public StringListConfigWidget(StringListConfig config, 14 | DataListEntryWidgetData constructData, 15 | ConfigWidgetContext ctx) 16 | { 17 | super(config, constructData, ctx); 18 | } 19 | 20 | @Override 21 | protected GenericButton createButton(int width, int height, StringListConfig config, ConfigWidgetContext ctx) 22 | { 23 | String title = StringUtils.translate("malilib.title.screen.string_list_edit", this.config.getDisplayName()); 24 | 25 | return new BaseValueListEditButton<>(width, height, config, this::updateWidgetState, 26 | () -> "", StringListEditEntryWidget::new, title); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/list/header/DataListHeaderWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.list.header; 2 | 3 | import malilib.gui.widget.ContainerWidget; 4 | import malilib.gui.widget.list.DataListWidget; 5 | 6 | public class DataListHeaderWidget extends ContainerWidget 7 | { 8 | protected final DataListWidget listWidget; 9 | 10 | public DataListHeaderWidget(int width, int height, DataListWidget listWidget) 11 | { 12 | super(width, height); 13 | 14 | this.listWidget = listWidget; 15 | } 16 | 17 | public void setHeaderWidgetSize(int width, int height) 18 | { 19 | width = width > 0 ? width : this.getWidth(); 20 | height = height > 0 ? height : this.getHeight(); 21 | 22 | this.setSize(width, height); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/util/DefaultWidgetPositioner.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.util; 2 | 3 | import malilib.gui.widget.InteractableWidget; 4 | import malilib.util.data.EdgeInt; 5 | 6 | public class DefaultWidgetPositioner implements WidgetPositioner 7 | { 8 | @Override 9 | public void positionWidget(InteractableWidget widget, int defaultX, int defaultY, int defaultWidth) 10 | { 11 | EdgeInt margin = widget.getMargin(); 12 | int x = defaultX + margin.getLeft(); 13 | int y = defaultY + margin.getTop(); 14 | 15 | widget.setPosition(x, y); 16 | widget.setWidth(defaultWidth); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/util/DirectoryCache.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.util; 2 | 3 | import java.nio.file.Path; 4 | import javax.annotation.Nullable; 5 | 6 | public interface DirectoryCache 7 | { 8 | @Nullable 9 | Path getCurrentDirectoryForContext(String context); 10 | 11 | void setCurrentDirectoryForContext(String context, Path dir); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/util/DirectoryNavigator.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.util; 2 | 3 | import java.nio.file.Path; 4 | 5 | public interface DirectoryNavigator 6 | { 7 | Path getCurrentDirectory(); 8 | 9 | void switchToDirectory(Path dir); 10 | 11 | void switchToParentDirectory(); 12 | 13 | void switchToRootDirectory(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/util/TextFieldValidator.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.util; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | public interface TextFieldValidator 6 | { 7 | /** 8 | * Checks if the given string is a valid input for this input type. 9 | * @param text 10 | * @return 11 | */ 12 | boolean isValidInput(String text); 13 | 14 | /** 15 | * Returns an optional error message to be displayed when 16 | * the given input is not a valid value. 17 | * @return The optional localized error message to be displayed. 18 | */ 19 | @Nullable default String getErrorMessage(String text) 20 | { 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/gui/widget/util/WidgetPositioner.java: -------------------------------------------------------------------------------- 1 | package malilib.gui.widget.util; 2 | 3 | import malilib.gui.widget.InteractableWidget; 4 | 5 | public interface WidgetPositioner 6 | { 7 | void positionWidget(InteractableWidget widget, int defaultX, int defaultY, int defaultWidth); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/ActionResult.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | public enum ActionResult 4 | { 5 | SUCCESS, 6 | FAIL, 7 | PASS 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/CancelCondition.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import malilib.config.value.BaseOptionListConfigValue; 6 | 7 | public class CancelCondition extends BaseOptionListConfigValue 8 | { 9 | public static final CancelCondition NEVER = new CancelCondition("never", "malilib.name.cancel_condition.never"); 10 | public static final CancelCondition ALWAYS = new CancelCondition("always", "malilib.name.cancel_condition.always"); 11 | public static final CancelCondition ON_SUCCESS = new CancelCondition("on_success", "malilib.name.cancel_condition.on_success"); 12 | public static final CancelCondition ON_FAILURE = new CancelCondition("on_failure", "malilib.name.cancel_condition.on_failure"); 13 | 14 | public static final ImmutableList VALUES = ImmutableList.of(NEVER, ALWAYS, ON_SUCCESS, ON_FAILURE); 15 | 16 | public CancelCondition(String name, String translationKey) 17 | { 18 | super(name, translationKey); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/Context.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import malilib.config.value.BaseOptionListConfigValue; 6 | 7 | public class Context extends BaseOptionListConfigValue 8 | { 9 | public static final Context INGAME = new Context("ingame", "malilib.name.key_context.ingame", 0); 10 | public static final Context GUI = new Context("gui", "malilib.name.key_context.gui", 1); 11 | public static final Context ANY = new Context("any", "malilib.name.key_context.any", 2); 12 | 13 | public static final ImmutableList VALUES = ImmutableList.of(INGAME, GUI, ANY); 14 | 15 | protected final int iconIndex; 16 | 17 | private Context(String name, String translationKey, int iconIndex) 18 | { 19 | super(name, translationKey); 20 | 21 | this.iconIndex = iconIndex; 22 | } 23 | 24 | public int getIconIndex() 25 | { 26 | return this.iconIndex; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/HotkeyManager.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | public interface HotkeyManager 6 | { 7 | /** 8 | * Registers a hotkey provider, which will want to register 9 | * some hotkeys whenever the key -> keybinds maps need to be rebuilt.
10 | * Any malilib-based hotkeys should be registered via this method! 11 | */ 12 | void registerHotkeyProvider(HotkeyProvider provider); 13 | 14 | /** 15 | * Un-registers a previously registered hotkey provider 16 | */ 17 | void unregisterHotkeyProvider(HotkeyProvider provider); 18 | 19 | /** 20 | * Returns a list of all the currently registered hotkeys, grouped by categories 21 | */ 22 | ImmutableList getHotkeyCategories(); 23 | 24 | /** 25 | * Causes the key -> keybinds map to be rebuilt for all registered hotkeys. 26 | */ 27 | void updateUsedKeys(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/HotkeyProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import java.util.List; 4 | 5 | public interface HotkeyProvider 6 | { 7 | /** 8 | * Returns a list of all hotkeys that should be registered. 9 | * This is called when the master hotkey list in malilib is being rebuilt, 10 | * Any hotkeys not on the returned list will not function! 11 | */ 12 | List getAllHotkeys(); 13 | 14 | /** 15 | * Returns a list of all the hotkeys, grouped in categories. 16 | * This is mostly just used for the keybind overlap info hover text. 17 | */ 18 | List getHotkeysByCategories(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/InputDispatcher.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | public interface InputDispatcher 4 | { 5 | /** 6 | * Registers a keyboard input handler, which will receive 7 | * the raw key presses. 8 | * @param handler 9 | */ 10 | void registerKeyboardInputHandler(KeyboardInputHandler handler); 11 | 12 | /** 13 | * Un-registers a previously registered keyboard input handler 14 | * @param handler 15 | */ 16 | void unregisterKeyboardInputHandler(KeyboardInputHandler handler); 17 | 18 | /** 19 | * Registers a mouse click input handler, which will receive 20 | * all mouse key presses. 21 | */ 22 | void registerMouseClickHandler(MouseClickHandler handler); 23 | 24 | /** 25 | * Registers a mouse scroll input handler, which will receive 26 | * all mouse wheel events. 27 | */ 28 | void registerMouseScrollHandler(MouseScrollHandler handler); 29 | 30 | /** 31 | * Registers a mouse move input handler, which will receive 32 | * mouse move notifications. 33 | */ 34 | void registerMouseMoveHandler(MouseMoveHandler handler); 35 | 36 | /** 37 | * Un-registers a previously registered mouse click input handler 38 | */ 39 | void unregisterMouseClickHandler(MouseClickHandler handler); 40 | 41 | /** 42 | * Un-registers a previously registered mouse click input handler 43 | */ 44 | void unregisterMouseScrollHandler(MouseScrollHandler handler); 45 | 46 | /** 47 | * Un-registers a previously registered mouse click input handler 48 | */ 49 | void unregisterMouseMoveHandler(MouseMoveHandler handler); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/KeyAction.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import malilib.config.value.BaseOptionListConfigValue; 6 | 7 | public class KeyAction extends BaseOptionListConfigValue 8 | { 9 | public static final KeyAction PRESS = new KeyAction("press", "malilib.name.key_action.press", 0); 10 | public static final KeyAction RELEASE = new KeyAction("release", "malilib.name.key_action.release", 1); 11 | public static final KeyAction BOTH = new KeyAction("both", "malilib.name.key_action.both", 2); 12 | 13 | public static final ImmutableList VALUES = ImmutableList.of(PRESS, RELEASE, BOTH); 14 | 15 | protected final int iconIndex; 16 | 17 | public KeyAction(String name, String translationKey, int iconIndex) 18 | { 19 | super(name, translationKey); 20 | 21 | this.iconIndex = iconIndex; 22 | } 23 | 24 | public int getIconIndex() 25 | { 26 | return this.iconIndex; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/KeyUpdateResult.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | public class KeyUpdateResult 4 | { 5 | public final boolean cancel; 6 | public final boolean triggered; 7 | 8 | public KeyUpdateResult(boolean cancel, boolean triggered) 9 | { 10 | this.cancel = cancel; 11 | this.triggered = triggered; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/KeyboardInputHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import malilib.event.PrioritizedEventHandler; 4 | 5 | public interface KeyboardInputHandler extends PrioritizedEventHandler 6 | { 7 | /** 8 | * Called on keyboard events with the key and whether the key was pressed or released. 9 | * @param keyCode 10 | * @param scanCode 11 | * @param modifiers 12 | * @param keyState 13 | * @return true if further processing of this key event should be cancelled 14 | */ 15 | boolean onKeyInput(int keyCode, int scanCode, int modifiers, boolean keyState); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/MouseClickHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import malilib.event.PrioritizedEventHandler; 4 | 5 | public interface MouseClickHandler extends PrioritizedEventHandler 6 | { 7 | /** 8 | * Called on mouse events with the key or wheel value and whether the key was pressed or released. 9 | * @param mouseButton the button that was pressed or released 10 | * @param buttonState the new state of the button 11 | * @return true if further processing of this event should be cancelled 12 | */ 13 | boolean onMouseClick(int mouseX, int mouseY, int mouseButton, boolean buttonState); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/MouseMoveHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import malilib.event.PrioritizedEventHandler; 4 | 5 | public interface MouseMoveHandler extends PrioritizedEventHandler 6 | { 7 | /** 8 | * Called when the mouse is moved 9 | */ 10 | void onMouseMove(int mouseX, int mouseY); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/MouseScrollHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import malilib.event.PrioritizedEventHandler; 4 | 5 | public interface MouseScrollHandler extends PrioritizedEventHandler 6 | { 7 | /** 8 | * Called when the mouse wheel is scrolled 9 | * @param mouseX the x-position of the mouse cursor 10 | * @param mouseY the y-position of the mouse cursor 11 | * @param deltaX the horizontal scroll amount 12 | * @param deltaY the vertical scroll amount 13 | * @return true if further processing of this event should be cancelled 14 | */ 15 | boolean onMouseScroll(int mouseX, int mouseY, double deltaX, double deltaY); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/SimpleHotkeyProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.input; 2 | 3 | import java.util.List; 4 | import java.util.function.Supplier; 5 | import com.google.common.collect.ImmutableList; 6 | 7 | import malilib.util.data.ModInfo; 8 | 9 | public class SimpleHotkeyProvider implements HotkeyProvider 10 | { 11 | protected final ModInfo modInfo; 12 | protected final String categoryName; 13 | protected final Supplier> hotkeySupplier; 14 | 15 | public SimpleHotkeyProvider(ModInfo modInfo, String categoryName, Supplier> hotkeySupplier) 16 | { 17 | this.modInfo = modInfo; 18 | this.categoryName = categoryName; 19 | this.hotkeySupplier = hotkeySupplier; 20 | } 21 | 22 | @Override 23 | public List getAllHotkeys() 24 | { 25 | return this.hotkeySupplier.get(); 26 | } 27 | 28 | @Override 29 | public List getHotkeysByCategories() 30 | { 31 | return ImmutableList.of(new HotkeyCategory(this.modInfo, this.categoryName , this.hotkeySupplier)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/callback/ActionHotkeyCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.input.callback; 2 | 3 | import malilib.action.Action; 4 | import malilib.action.ActionContext; 5 | import malilib.input.ActionResult; 6 | import malilib.input.KeyAction; 7 | import malilib.input.KeyBind; 8 | 9 | public class ActionHotkeyCallback implements HotkeyCallback 10 | { 11 | protected final Action action; 12 | 13 | public ActionHotkeyCallback(Action action) 14 | { 15 | this.action = action; 16 | } 17 | 18 | @Override 19 | public ActionResult onKeyAction(KeyAction action, KeyBind key) 20 | { 21 | return this.action.execute(ActionContext.COMMON); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/callback/HotkeyCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.input.callback; 2 | 3 | import malilib.action.Action; 4 | import malilib.action.NamedAction; 5 | import malilib.input.ActionResult; 6 | import malilib.input.KeyAction; 7 | import malilib.input.KeyBind; 8 | 9 | public interface HotkeyCallback 10 | { 11 | /** 12 | * Called when a hotkey is triggered. 13 | * @param action the key action this callback is being called for (either press or release) 14 | * @param key the keybind that this callback is being called for, 15 | * in case the same callback instance is used for multiple different hotkeys 16 | * @return the action result of executing the callback 17 | */ 18 | ActionResult onKeyAction(KeyAction action, KeyBind key); 19 | 20 | /** 21 | * Wraps an Action as a HotkeyCallback 22 | */ 23 | static HotkeyCallback of(Action action) 24 | { 25 | return new ActionHotkeyCallback(action); 26 | } 27 | 28 | /** 29 | * Wraps an NamedAction as a HotkeyCallback 30 | */ 31 | static HotkeyCallback of(NamedAction action) 32 | { 33 | return new NamedActionHotkeyCallback(action); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/callback/NamedActionHotkeyCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.input.callback; 2 | 3 | import malilib.action.NamedAction; 4 | import malilib.input.ActionResult; 5 | import malilib.input.KeyAction; 6 | import malilib.input.KeyBind; 7 | 8 | public class NamedActionHotkeyCallback implements HotkeyCallback 9 | { 10 | protected final NamedAction action; 11 | 12 | public NamedActionHotkeyCallback(NamedAction action) 13 | { 14 | this.action = action; 15 | } 16 | 17 | @Override 18 | public ActionResult onKeyAction(KeyAction action, KeyBind key) 19 | { 20 | return this.action.execute(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/callback/TimeIntervalValueScaler.java: -------------------------------------------------------------------------------- 1 | package malilib.input.callback; 2 | 3 | public class TimeIntervalValueScaler 4 | { 5 | protected final long intervalMs; 6 | protected final int multiplier; 7 | protected long lastTime; 8 | 9 | public TimeIntervalValueScaler(long intervalMs, int multiplier) 10 | { 11 | this.intervalMs = intervalMs; 12 | this.multiplier = multiplier; 13 | this.lastTime = System.nanoTime() / 1000000L; 14 | } 15 | 16 | public int getScaledValue(int value) 17 | { 18 | long currentTime = System.nanoTime() / 1000000L; 19 | 20 | if (currentTime - this.lastTime <= this.intervalMs) 21 | { 22 | value *= this.multiplier; 23 | } 24 | 25 | this.lastTime = currentTime; 26 | 27 | return value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/input/callback/ToggleBooleanKeyCallback.java: -------------------------------------------------------------------------------- 1 | package malilib.input.callback; 2 | 3 | import malilib.input.ActionResult; 4 | import malilib.input.KeyAction; 5 | import malilib.input.KeyBind; 6 | import malilib.util.data.BooleanStorage; 7 | 8 | public class ToggleBooleanKeyCallback implements HotkeyCallback 9 | { 10 | protected final BooleanStorage config; 11 | 12 | public ToggleBooleanKeyCallback(BooleanStorage config) 13 | { 14 | this.config = config; 15 | } 16 | 17 | @Override 18 | public ActionResult onKeyAction(KeyAction action, KeyBind key) 19 | { 20 | this.config.toggleBooleanValue(); 21 | return ActionResult.SUCCESS; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/interoperation/BlockPlacementPositionHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.interoperation; 2 | 3 | import java.util.ArrayList; 4 | import javax.annotation.Nullable; 5 | 6 | import malilib.util.position.BlockPos; 7 | 8 | public class BlockPlacementPositionHandler 9 | { 10 | protected final ArrayList providers = new ArrayList<>(); 11 | 12 | public BlockPlacementPositionHandler() 13 | { 14 | } 15 | 16 | public void registerPositionProvider(BlockPlacementPositionProvider provider) 17 | { 18 | if (this.providers.contains(provider) == false) 19 | { 20 | this.providers.add(provider); 21 | } 22 | } 23 | 24 | public void unregisterPositionProvider(BlockPlacementPositionProvider provider) 25 | { 26 | this.providers.remove(provider); 27 | } 28 | 29 | /** 30 | * Returns the current overridden block placement position, if any. 31 | * If no providers currently want to override the position, then 32 | * null is returned. 33 | * @return the current overridden block placement position, or null for no changes from vanilla 34 | */ 35 | @Nullable 36 | public BlockPos getCurrentPlacementPosition() 37 | { 38 | if (this.providers.isEmpty() == false) 39 | { 40 | for (BlockPlacementPositionProvider provider : this.providers) 41 | { 42 | BlockPos pos = provider.getPlacementPosition(); 43 | 44 | if (pos != null) 45 | { 46 | return pos; 47 | } 48 | } 49 | } 50 | 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/malilib/interoperation/BlockPlacementPositionProvider.java: -------------------------------------------------------------------------------- 1 | package malilib.interoperation; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import malilib.util.position.BlockPos; 6 | 7 | public interface BlockPlacementPositionProvider 8 | { 9 | /** 10 | * Returns the block placement position that should be used 11 | * for the current situation. 12 | * This allows mods that want to modify the normal vanilla block placement 13 | * position to indicate that change to other mods that want to do something 14 | * with the placement position. 15 | * If the implementer does not currently want to modify the normal placement 16 | * position, then it should return null. 17 | * @return The overridden block placement position, or null if no changes should occur at the moment 18 | */ 19 | @Nullable 20 | BlockPos getPlacementPosition(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/malilib/listener/ConfirmationListener.java: -------------------------------------------------------------------------------- 1 | package malilib.listener; 2 | 3 | public interface ConfirmationListener 4 | { 5 | /** 6 | * Called when a task requiring confirmation is confirmed by the user 7 | * @return true on success, false on failure 8 | */ 9 | boolean onActionConfirmed(); 10 | 11 | /** 12 | * Called when a task requiring confirmation is cancelled by the user 13 | * @return true on success, false on failure 14 | */ 15 | default boolean onActionCancelled() 16 | { 17 | return false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/malilib/listener/EventListener.java: -------------------------------------------------------------------------------- 1 | package malilib.listener; 2 | 3 | public interface EventListener 4 | { 5 | /** 6 | * Called when the event happens/triggers 7 | */ 8 | void onEvent(); 9 | 10 | /** 11 | * Creates a new chained EventListener, where this listener 12 | * runs first and the provided other listener runs after. 13 | * @param other the listener to chain after this listener 14 | * @return the new chained listener 15 | */ 16 | default EventListener chain(EventListener other) 17 | { 18 | return () -> { 19 | this.onEvent(); 20 | other.onEvent(); 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/listener/LayerRangeChangeListener.java: -------------------------------------------------------------------------------- 1 | package malilib.listener; 2 | 3 | public interface LayerRangeChangeListener 4 | { 5 | /** 6 | * This method is called when the range changes such that a global/entire update should be performed 7 | */ 8 | void updateAll(); 9 | 10 | /** 11 | * This method is called when the range changes such that an update 12 | * only between the given X coordinate range is sufficient 13 | */ 14 | void updateBetweenX(int minX, int maxX); 15 | 16 | /** 17 | * This method is called when the range changes such that an update 18 | * only between the given Y coordinate range is sufficient 19 | */ 20 | void updateBetweenY(int minY, int maxY); 21 | 22 | /** 23 | * This method is called when the range changes such that an update 24 | * only between the given Z coordinate range is sufficient 25 | */ 26 | void updateBetweenZ(int minZ, int maxZ); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/malilib/listener/TaskCompletionListener.java: -------------------------------------------------------------------------------- 1 | package malilib.listener; 2 | 3 | public interface TaskCompletionListener 4 | { 5 | /** 6 | * Called when a task wants to inform a listener about the task being completed 7 | */ 8 | void onTaskCompleted(); 9 | 10 | /** 11 | * Called when a task wants to inform a listener about the task being aborted before completion 12 | */ 13 | default void onTaskAborted() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/access/AbstractHorseMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.access; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import net.minecraft.entity.passive.AbstractHorse; 7 | import net.minecraft.inventory.ContainerHorseChest; 8 | 9 | @Mixin(AbstractHorse.class) 10 | public interface AbstractHorseMixin 11 | { 12 | @Accessor("horseChest") 13 | ContainerHorseChest malilib_getHorseChest(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/access/GuiContainerMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.access; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | @Mixin(net.minecraft.client.gui.inventory.GuiContainer.class) 7 | public interface GuiContainerMixin 8 | { 9 | @Accessor("hoveredSlot") 10 | net.minecraft.inventory.Slot getHoveredSlot(); 11 | 12 | @Accessor("guiLeft") 13 | int getGuiPosX(); 14 | 15 | @Accessor("guiTop") 16 | int getGuiPosY(); 17 | 18 | @Accessor("xSize") 19 | int getGuiSizeX(); 20 | 21 | @Accessor("ySize") 22 | int getGuiSizeY(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/access/NBTBaseMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.access; 2 | 3 | import java.io.DataOutput; 4 | import java.io.IOException; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | import net.minecraft.nbt.NBTBase; 9 | 10 | @Mixin(NBTBase.class) 11 | public interface NBTBaseMixin 12 | { 13 | @Invoker("write") 14 | void invokeWrite(DataOutput output) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/access/NBTTagLongArrayMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.access; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import net.minecraft.nbt.NBTTagLongArray; 7 | 8 | @Mixin(NBTTagLongArray.class) 9 | public interface NBTTagLongArrayMixin 10 | { 11 | @Accessor("data") 12 | long[] getArray(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/command/GuiScreenMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.command; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.Shadow; 5 | import org.spongepowered.asm.mixin.injection.At; 6 | import org.spongepowered.asm.mixin.injection.Inject; 7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 8 | 9 | import net.minecraft.client.Minecraft; 10 | import net.minecraft.client.gui.Gui; 11 | import net.minecraft.client.gui.GuiScreen; 12 | 13 | import malilib.registry.Registry; 14 | 15 | @Mixin(GuiScreen.class) 16 | public abstract class GuiScreenMixin extends Gui 17 | { 18 | @Shadow protected Minecraft mc; 19 | 20 | @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At( 21 | value = "INVOKE", 22 | target = "Lnet/minecraft/client/entity/EntityPlayerSP;sendChatMessage(Ljava/lang/String;)V"), 23 | cancellable = true) 24 | private void onSendMessage(String msg, boolean addToChat, CallbackInfo ci) 25 | { 26 | if (Registry.CLIENT_COMMAND_HANDLER.executeCommand(this.mc.player, msg) != 0) 27 | { 28 | ci.cancel(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/network/MixinNetHandlerPlayClient.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.network; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 7 | 8 | import net.minecraft.client.network.NetHandlerPlayClient; 9 | import net.minecraft.network.play.server.SPacketCustomPayload; 10 | 11 | import malilib.network.ClientPacketChannelHandlerImpl; 12 | import malilib.registry.Registry; 13 | 14 | @Mixin(NetHandlerPlayClient.class) 15 | public abstract class MixinNetHandlerPlayClient 16 | { 17 | @Inject(method = "handleCustomPayload", at = @At("RETURN")) 18 | private void onCustomPayload(SPacketCustomPayload packet, CallbackInfo ci) 19 | { 20 | NetHandlerPlayClient handler = (NetHandlerPlayClient) (Object) this; 21 | ((ClientPacketChannelHandlerImpl) Registry.CLIENT_PACKET_CHANNEL_HANDLER).processPacketFromServer(packet, handler); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/mixin/render/GuiScreenMixin.java: -------------------------------------------------------------------------------- 1 | package malilib.mixin.render; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Inject; 6 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 7 | 8 | import net.minecraft.client.gui.Gui; 9 | import net.minecraft.client.gui.GuiScreen; 10 | import net.minecraft.item.ItemStack; 11 | 12 | import malilib.event.dispatch.RenderEventDispatcherImpl; 13 | import malilib.registry.Registry; 14 | 15 | @Mixin(GuiScreen.class) 16 | public abstract class GuiScreenMixin extends Gui 17 | { 18 | @Inject(method = "renderToolTip", at = @At("RETURN")) 19 | private void onRenderToolTip(ItemStack stack, int x, int y, CallbackInfo ci) 20 | { 21 | ((RenderEventDispatcherImpl) Registry.RENDER_EVENT_DISPATCHER).onRenderTooltipPost(stack, x, y); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/malilib/network/ClientPacketChannelHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.network; 2 | 3 | public interface ClientPacketChannelHandler 4 | { 5 | void registerClientChannelHandler(PluginChannelHandler handler); 6 | 7 | void unregisterClientChannelHandler(PluginChannelHandler handler); 8 | } -------------------------------------------------------------------------------- /src/main/java/malilib/network/PluginChannelHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.network; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.network.PacketBuffer; 6 | import net.minecraft.util.ResourceLocation; 7 | 8 | public interface PluginChannelHandler 9 | { 10 | /** 11 | * @return true if this packet should be registered to the other end of 12 | * the connection via a 'minecraft:register' packet. 13 | */ 14 | boolean registerToServer(); 15 | 16 | /** 17 | * @return true if this packet should be put through the PacketSplitter system, 18 | * which allows receiving much larger packets, as they will automatically get 19 | * split to the maximum custom payload packet size. 20 | * If false, then the packet is received directly as-is. 21 | */ 22 | boolean usePacketSplitter(); 23 | 24 | /** 25 | * @return a list of message channels this handler can handle 26 | */ 27 | List getChannels(); 28 | 29 | /** 30 | * Called when the packet is received from the other end of the connection 31 | */ 32 | void onPacketReceived(PacketBuffer buf); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/malilib/network/message/BasePacketHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.network.message; 2 | 3 | import malilib.network.PluginChannelHandler; 4 | 5 | public abstract class BasePacketHandler implements PluginChannelHandler 6 | { 7 | protected boolean registerToServer; 8 | protected boolean usePacketSplitter; 9 | 10 | @Override 11 | public boolean usePacketSplitter() 12 | { 13 | return this.usePacketSplitter; 14 | } 15 | 16 | @Override 17 | public boolean registerToServer() 18 | { 19 | return this.registerToServer; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/DoubleConfigStatusWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.config.option.DoubleConfig; 5 | import malilib.render.text.StyledTextLine; 6 | import malilib.util.data.ConfigOnTab; 7 | 8 | public class DoubleConfigStatusWidget extends BaseConfigStatusIndicatorWidget 9 | { 10 | protected double lastValue; 11 | 12 | public DoubleConfigStatusWidget(DoubleConfig config, ConfigOnTab configOnTab) 13 | { 14 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_double"); 15 | } 16 | 17 | public DoubleConfigStatusWidget(DoubleConfig config, ConfigOnTab configOnTab, String widgetTypeId) 18 | { 19 | super(config, configOnTab, widgetTypeId); 20 | } 21 | 22 | @Override 23 | public void updateState(boolean force) 24 | { 25 | if (force || this.lastValue != this.config.getDoubleValue()) 26 | { 27 | this.updateValue(); 28 | } 29 | } 30 | 31 | protected void updateValue() 32 | { 33 | this.lastValue = this.config.getDoubleValue(); 34 | this.valueDisplayText = StyledTextLine.parseFirstLine(String.valueOf(this.lastValue)); 35 | this.valueRenderWidth = this.valueDisplayText.renderWidth; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/HotkeyConfigStatusWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import it.unimi.dsi.fastutil.ints.IntArrayList; 4 | 5 | import malilib.MaLiLibReference; 6 | import malilib.config.option.HotkeyConfig; 7 | import malilib.render.text.StyledTextLine; 8 | import malilib.render.text.TextStyle; 9 | import malilib.util.data.ConfigOnTab; 10 | 11 | public class HotkeyConfigStatusWidget extends BaseConfigStatusIndicatorWidget 12 | { 13 | protected final TextStyle style = TextStyle.builder().withColor(0xFFFFA000).build(); 14 | protected final IntArrayList lastValue = new IntArrayList(); 15 | 16 | public HotkeyConfigStatusWidget(HotkeyConfig config, ConfigOnTab configOnTab) 17 | { 18 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_hotkey"); 19 | } 20 | 21 | public HotkeyConfigStatusWidget(HotkeyConfig config, ConfigOnTab configOnTab, String widgetTypeId) 22 | { 23 | super(config, configOnTab, widgetTypeId); 24 | } 25 | 26 | @Override 27 | public void updateState(boolean force) 28 | { 29 | if (force || this.config.getValue().matches(this.lastValue) == false) 30 | { 31 | this.updateValue(); 32 | } 33 | } 34 | 35 | protected void updateValue() 36 | { 37 | this.lastValue.clear(); 38 | this.config.getValue().getKeysToList(this.lastValue); 39 | this.valueDisplayText = StyledTextLine.parseFirstLine(this.config.getValue().getKeysDisplayString(), this.style); 40 | this.valueRenderWidth = this.valueDisplayText.renderWidth; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/IntegerConfigStatusWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.config.option.IntegerConfig; 5 | import malilib.render.text.StyledTextLine; 6 | import malilib.util.data.ConfigOnTab; 7 | 8 | public class IntegerConfigStatusWidget extends BaseConfigStatusIndicatorWidget 9 | { 10 | protected int lastValue; 11 | 12 | public IntegerConfigStatusWidget(IntegerConfig config, ConfigOnTab configOnTab) 13 | { 14 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_integer"); 15 | } 16 | 17 | public IntegerConfigStatusWidget(IntegerConfig config, ConfigOnTab configOnTab, String widgetTypeId) 18 | { 19 | super(config, configOnTab, widgetTypeId); 20 | } 21 | 22 | @Override 23 | public void updateState(boolean force) 24 | { 25 | if (force || this.lastValue != this.config.getIntegerValue()) 26 | { 27 | this.updateValue(); 28 | } 29 | } 30 | 31 | protected void updateValue() 32 | { 33 | this.lastValue = this.config.getIntegerValue(); 34 | this.valueDisplayText = StyledTextLine.parseFirstLine(String.valueOf(this.lastValue)); 35 | this.valueRenderWidth = this.valueDisplayText.renderWidth; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/OptionListConfigStatusWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.config.option.OptionListConfig; 5 | import malilib.config.value.OptionListConfigValue; 6 | import malilib.render.text.StyledTextLine; 7 | import malilib.util.data.ConfigOnTab; 8 | 9 | public class OptionListConfigStatusWidget extends BaseConfigStatusIndicatorWidget> 10 | { 11 | protected OptionListConfigValue lastValue; 12 | 13 | public OptionListConfigStatusWidget(OptionListConfig config, ConfigOnTab configOnTab) 14 | { 15 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_option_list"); 16 | } 17 | 18 | public OptionListConfigStatusWidget(OptionListConfig config, 19 | ConfigOnTab configOnTab, String widgetTypeId) 20 | { 21 | super(config, configOnTab, widgetTypeId); 22 | 23 | this.valueColor = 0xFFFFA000; 24 | } 25 | 26 | @Override 27 | public void updateState(boolean force) 28 | { 29 | if (force || this.lastValue != this.config.getValue()) 30 | { 31 | this.updateValue(); 32 | } 33 | } 34 | 35 | protected void updateValue() 36 | { 37 | this.lastValue = this.config.getValue(); 38 | this.valueDisplayText = StyledTextLine.parseFirstLine(this.lastValue.getDisplayName()); 39 | this.valueRenderWidth = this.valueDisplayText.renderWidth; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/PlaceholderConfigStatusIndicatorWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | import malilib.MaLiLibReference; 6 | import malilib.config.option.BooleanConfig; 7 | import malilib.config.option.ConfigInfo; 8 | import malilib.util.data.ConfigOnTab; 9 | 10 | public class PlaceholderConfigStatusIndicatorWidget extends BaseConfigStatusIndicatorWidget 11 | { 12 | public static final BooleanConfig DUMMY_CONFIG = new BooleanConfig("?", false); 13 | 14 | protected JsonObject data = new JsonObject(); 15 | 16 | public PlaceholderConfigStatusIndicatorWidget(ConfigInfo config, ConfigOnTab configOnTab) 17 | { 18 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_placeholder"); 19 | } 20 | 21 | public PlaceholderConfigStatusIndicatorWidget(ConfigInfo config, ConfigOnTab configOnTab, String widgetTypeId) 22 | { 23 | super(config, configOnTab, widgetTypeId); 24 | } 25 | 26 | @Override 27 | public void updateState(boolean force) 28 | { 29 | } 30 | 31 | @Override 32 | public void fromJson(JsonObject obj) 33 | { 34 | this.data = obj; 35 | } 36 | 37 | @Override 38 | public JsonObject toJson() 39 | { 40 | return this.data; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/malilib/overlay/widget/sub/StringConfigStatusWidget.java: -------------------------------------------------------------------------------- 1 | package malilib.overlay.widget.sub; 2 | 3 | import malilib.MaLiLibReference; 4 | import malilib.config.option.StringConfig; 5 | import malilib.render.text.StyledTextLine; 6 | import malilib.render.text.TextStyle; 7 | import malilib.util.data.ConfigOnTab; 8 | 9 | public class StringConfigStatusWidget extends BaseConfigStatusIndicatorWidget 10 | { 11 | protected TextStyle style = TextStyle.builder().withColor(0xFF00FFFF).build(); 12 | protected String lastValue = ""; 13 | 14 | public StringConfigStatusWidget(StringConfig config, ConfigOnTab configOnTab) 15 | { 16 | this(config, configOnTab, MaLiLibReference.MOD_ID + ":csi_value_string"); 17 | } 18 | 19 | public StringConfigStatusWidget(StringConfig config, ConfigOnTab configOnTab, String widgetTypeId) 20 | { 21 | super(config, configOnTab, widgetTypeId); 22 | } 23 | 24 | @Override 25 | public void updateState(boolean force) 26 | { 27 | if (force || this.config.getValue().equals(this.lastValue) == false) 28 | { 29 | this.updateValue(); 30 | } 31 | } 32 | 33 | protected void updateValue() 34 | { 35 | this.lastValue = this.config.getValue(); 36 | this.valueDisplayText = StyledTextLine.parseJoin(this.lastValue, this.style); 37 | this.valueRenderWidth = this.valueDisplayText.renderWidth; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/RectangleRenderer.java: -------------------------------------------------------------------------------- 1 | package malilib.render; 2 | 3 | public interface RectangleRenderer 4 | { 5 | /** 6 | * Renders something at the provided coordinates/area. 7 | * In malilib this is used for customizing the hover text background. 8 | */ 9 | void render(int x, int y, float z, int width, int height, RenderContext ctx); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/RenderContext.java: -------------------------------------------------------------------------------- 1 | package malilib.render; 2 | 3 | public class RenderContext 4 | { 5 | public static final RenderContext DUMMY = new RenderContext(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/buffer/VertexBuffer.java: -------------------------------------------------------------------------------- 1 | package malilib.render.buffer; 2 | 3 | import java.nio.ByteBuffer; 4 | import org.lwjgl.opengl.GL15; 5 | 6 | import malilib.util.game.wrap.RenderWrap; 7 | 8 | public class VertexBuffer 9 | { 10 | private final VertexFormat vertexFormat; 11 | private int glBufferId; 12 | private int vertexCount; 13 | 14 | public VertexBuffer(VertexFormat vertexFormat) 15 | { 16 | this.vertexFormat = vertexFormat; 17 | this.glBufferId = RenderWrap.glGenBuffers(); 18 | } 19 | 20 | public void bindBuffer() 21 | { 22 | RenderWrap.bindBuffer(RenderWrap.GL_ARRAY_BUFFER, this.glBufferId); 23 | } 24 | 25 | public void unbindBuffer() 26 | { 27 | RenderWrap.bindBuffer(RenderWrap.GL_ARRAY_BUFFER, 0); 28 | } 29 | 30 | public void bufferData(ByteBuffer data) 31 | { 32 | this.bindBuffer(); 33 | RenderWrap.bufferData(RenderWrap.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW); 34 | this.unbindBuffer(); 35 | this.vertexCount = data.limit() / this.vertexFormat.getSize(); 36 | } 37 | 38 | public void drawArrays(int mode) 39 | { 40 | RenderWrap.glDrawArrays(mode, 0, this.vertexCount); 41 | } 42 | 43 | public void deleteGlBuffers() 44 | { 45 | if (this.glBufferId >= 0) 46 | { 47 | RenderWrap.glDeleteBuffers(this.glBufferId); 48 | this.glBufferId = -1; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/buffer/VertexBuilderState.java: -------------------------------------------------------------------------------- 1 | package malilib.render.buffer; 2 | 3 | public class VertexBuilderState 4 | { 5 | public final VertexFormat vertexFormat; 6 | public final int[] vertexData; 7 | public final int vertexCount; 8 | 9 | public VertexBuilderState(VertexFormat vertexFormat, int[] vertexData) 10 | { 11 | this.vertexFormat = vertexFormat; 12 | this.vertexData = vertexData; 13 | this.vertexCount = vertexData.length / (vertexFormat.getSize() >> 2); 14 | } 15 | 16 | public VertexFormat getVertexFormat() 17 | { 18 | return this.vertexFormat; 19 | } 20 | 21 | public int getVertexCount() 22 | { 23 | return this.vertexCount; 24 | } 25 | 26 | public int[] getVertexData() 27 | { 28 | return this.vertexData; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/buffer/VertexFormats.java: -------------------------------------------------------------------------------- 1 | package malilib.render.buffer; 2 | 3 | public class VertexFormats 4 | { 5 | public static final VertexFormat POSITION = new VertexFormat(0, -1, -1, -1, 0); 6 | public static final VertexFormat POSITION_COLOR = new VertexFormat(0, -1, 12, -1, 0); 7 | public static final VertexFormat POSITION_TEX = new VertexFormat(0, 12, -1, -1, 0); 8 | /* 9 | public static final VertexFormat POSITION_NORMAL = new VertexFormat(); 10 | */ 11 | public static final VertexFormat POSITION_TEX_COLOR = new VertexFormat(0, 12, 20, -1, 0); 12 | /* 13 | public static final VertexFormat POSITION_TEX_NORMAL = new VertexFormat(); 14 | public static final VertexFormat POSITION_TEX_LMAP_COLOR = new VertexFormat(); 15 | public static final VertexFormat POSITION_TEX_COLOR_NORMAL = new VertexFormat(); 16 | */ 17 | 18 | public static final VertexFormat BLOCK = new VertexFormat(0, 16, 12, -1, 24, 0); 19 | public static final VertexFormat ITEM = new VertexFormat(0, 16, 12, 24, 1); 20 | /* 21 | public static final VertexFormat OLDMODEL_POSITION_TEX_NORMAL = new VertexFormat(); 22 | public static final VertexFormat PARTICLE_POSITION_TEX_COLOR_LMAP = new VertexFormat(); 23 | */ 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/inventory/InventoryRange.java: -------------------------------------------------------------------------------- 1 | package malilib.render.inventory; 2 | 3 | import java.util.function.IntUnaryOperator; 4 | 5 | import malilib.util.position.Vec2i; 6 | 7 | public class InventoryRange 8 | { 9 | public final IntUnaryOperator slotsPerRowFunction; 10 | public final Vec2i startPos; 11 | public final boolean renderSlotBackgrounds; 12 | public final int startSlot; 13 | public final int slotCount; 14 | 15 | public InventoryRange(int startSlot, int slotCount, boolean renderSlotBackgrounds, 16 | Vec2i startPos, IntUnaryOperator slotsPerRowFunction) 17 | { 18 | this.startSlot = startSlot; 19 | this.slotCount = slotCount; 20 | this.renderSlotBackgrounds = renderSlotBackgrounds; 21 | this.startPos = startPos; 22 | this.slotsPerRowFunction = slotsPerRowFunction; 23 | } 24 | 25 | public static InventoryRange of(int startSlot, int slotCount, boolean renderSlots, 26 | Vec2i startPos, IntUnaryOperator slotsPerRowFunction) 27 | { 28 | return new InventoryRange(startSlot, slotCount, renderSlots, startPos, slotsPerRowFunction); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/overlay/BaseRenderObject.java: -------------------------------------------------------------------------------- 1 | package malilib.render.overlay; 2 | 3 | import malilib.render.buffer.VertexBuilder; 4 | import malilib.render.buffer.VertexFormat; 5 | 6 | public abstract class BaseRenderObject 7 | { 8 | protected final VertexFormat vertexFormat; 9 | protected final boolean hasTexture; 10 | protected final int glMode; 11 | 12 | public BaseRenderObject(int glMode, VertexFormat vertexFormat) 13 | { 14 | this.glMode = glMode; 15 | this.vertexFormat = vertexFormat; 16 | this.hasTexture = this.vertexFormat.hasTexture(); 17 | } 18 | 19 | public BaseRenderObject(int glMode, VertexFormat vertexFormat, boolean usesTexture) 20 | { 21 | this.glMode = glMode; 22 | this.vertexFormat = vertexFormat; 23 | this.hasTexture = usesTexture; 24 | } 25 | 26 | public int getGlMode() 27 | { 28 | return this.glMode; 29 | } 30 | 31 | public VertexFormat getVertexFormat() 32 | { 33 | return this.vertexFormat; 34 | } 35 | 36 | /** 37 | * Uploads the given VertexBuilder to the VBO or Render List 38 | * @param builder the VertexBuilder to upload 39 | */ 40 | public abstract void uploadData(VertexBuilder builder); 41 | 42 | /** 43 | * Draws the VBO or Render List to the screen 44 | */ 45 | public abstract void draw(); 46 | 47 | /** 48 | * De-allocates the VBO or Render List 49 | */ 50 | public abstract void deleteGlResources(); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/malilib/render/text/TextRenderFunction.java: -------------------------------------------------------------------------------- 1 | package malilib.render.text; 2 | 3 | public interface TextRenderFunction 4 | { 5 | /** 6 | * Renders the given string at the given location using the provided color. 7 | * Whether or not the text is line broken in any way depends on the implementation. 8 | */ 9 | void renderText(int x, int y, float z, int color, String text); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/HashUtils.java: -------------------------------------------------------------------------------- 1 | package malilib.util; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Path; 5 | import java.security.DigestInputStream; 6 | import java.security.MessageDigest; 7 | 8 | import malilib.MaLiLib; 9 | 10 | public class HashUtils 11 | { 12 | public static String getHashAsHexString(Path file, MessageDigest digest) 13 | { 14 | StringBuilder sb = new StringBuilder(64); 15 | digest.reset(); 16 | 17 | try (DigestInputStream din = new DigestInputStream(Files.newInputStream(file),digest)) 18 | { 19 | byte[] buf = new byte[4096]; 20 | 21 | while (din.read(buf) != -1) 22 | { 23 | } 24 | 25 | byte[] raw = digest.digest(); 26 | 27 | for (byte b : raw) 28 | { 29 | sb.append(String.format("%02X", b)); 30 | } 31 | } 32 | catch (Exception e) 33 | { 34 | MaLiLib.LOGGER.warn("Exception while hashing file '{}': {}", file.toAbsolutePath(), e.getMessage()); 35 | } 36 | 37 | return sb.toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/ProfilerSectionSupplierSupplier.java: -------------------------------------------------------------------------------- 1 | package malilib.util; 2 | 3 | import java.util.function.Supplier; 4 | 5 | public interface ProfilerSectionSupplierSupplier 6 | { 7 | /** 8 | * Returns a supplier for the profiler section name that should be used 9 | * @return 10 | */ 11 | default Supplier getProfilerSectionSupplier() 12 | { 13 | return () -> this.getClass().getName().replace(".", "_"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/AppendOverwrite.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import malilib.util.StringUtils; 6 | 7 | public enum AppendOverwrite 8 | { 9 | APPEND ("malilib.name.append_overwrite.append"), 10 | OVERWRITE("malilib.name.append_overwrite.overwrite"); 11 | 12 | public static final ImmutableList VALUES = ImmutableList.copyOf(values()); 13 | 14 | private final String translationKey; 15 | 16 | AppendOverwrite(String translationKey) 17 | { 18 | this.translationKey = translationKey; 19 | } 20 | 21 | public String getDisplayName() 22 | { 23 | return StringUtils.translate(this.translationKey); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/BooleanConsumer.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface BooleanConsumer 5 | { 6 | void accept(boolean value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/BooleanStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface BooleanStorage 4 | { 5 | /** 6 | * @return the current value 7 | */ 8 | boolean getBooleanValue(); 9 | 10 | /** 11 | * Sets the value. 12 | * @param value the new value 13 | * @return true if the value changed (NOT the new value!) 14 | */ 15 | boolean setBooleanValue(boolean value); 16 | 17 | /** 18 | * Toggles the value to the opposite value 19 | * @return true if the value changed (which in this case is always, 20 | * unless the config is locked or overridden!) 21 | */ 22 | default boolean toggleBooleanValue() 23 | { 24 | return this.setBooleanValue(! this.getBooleanValue()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/BooleanStorageWithDefault.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface BooleanStorageWithDefault extends BooleanStorage 4 | { 5 | boolean getDefaultBooleanValue(); 6 | 7 | boolean isModified(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/Constants.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public class Constants 4 | { 5 | public static class NBT 6 | { 7 | public static final int TAG_END = 0; 8 | public static final int TAG_BYTE = 1; 9 | public static final int TAG_SHORT = 2; 10 | public static final int TAG_INT = 3; 11 | public static final int TAG_LONG = 4; 12 | public static final int TAG_FLOAT = 5; 13 | public static final int TAG_DOUBLE = 6; 14 | public static final int TAG_BYTE_ARRAY = 7; 15 | public static final int TAG_STRING = 8; 16 | public static final int TAG_LIST = 9; 17 | public static final int TAG_COMPOUND = 10; 18 | public static final int TAG_INT_ARRAY = 11; 19 | public static final int TAG_LONG_ARRAY = 12; 20 | public static final int TAG_ANY_NUMERIC = 99; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/DoubleStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface DoubleStorage 4 | { 5 | double getDoubleValue(); 6 | 7 | boolean setDoubleValue(double newValue); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/DualDoubleConsumer.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import java.util.function.DoubleConsumer; 4 | 5 | public class DualDoubleConsumer implements DoubleConsumer 6 | { 7 | protected final DoubleConsumer consumerOne; 8 | protected final DoubleConsumer consumerTwo; 9 | 10 | public DualDoubleConsumer(DoubleConsumer consumerOne, DoubleConsumer consumerTwo) 11 | { 12 | this.consumerOne = consumerOne; 13 | this.consumerTwo = consumerTwo; 14 | } 15 | 16 | @Override 17 | public void accept(double value) 18 | { 19 | this.consumerOne.accept(value); 20 | this.consumerTwo.accept(value); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/DualIntConsumer.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import java.util.function.IntConsumer; 4 | 5 | public class DualIntConsumer implements IntConsumer 6 | { 7 | protected final IntConsumer consumerOne; 8 | protected final IntConsumer consumerTwo; 9 | 10 | public DualIntConsumer(IntConsumer consumerOne, IntConsumer consumerTwo) 11 | { 12 | this.consumerOne = consumerOne; 13 | this.consumerTwo = consumerTwo; 14 | } 15 | 16 | @Override 17 | public void accept(int value) 18 | { 19 | this.consumerOne.accept(value); 20 | this.consumerTwo.accept(value); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/EnabledCondition.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public enum EnabledCondition 4 | { 5 | ANY, 6 | ENABLED, 7 | DISABLED 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/FloatConsumer.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface FloatConsumer 5 | { 6 | void accept(float value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/FloatStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface FloatStorage 4 | { 5 | float getFloatValue(); 6 | 7 | boolean setFloatValue(float newValue); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/FloatSupplier.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface FloatSupplier 5 | { 6 | float getAsFloat(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/FloatUnaryOperator.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface FloatUnaryOperator 5 | { 6 | float apply(float value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/Identifier.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | 5 | /** 6 | * This is a simple dummy "wrapper" class that just extends the vanilla ResourceLocation/Identifier class. 7 | * The sole purpose of this class is to hide that mapping difference from lots of the places in 8 | * the mods' code, where an identifier is needed. 9 | */ 10 | public class Identifier extends ResourceLocation 11 | { 12 | public Identifier(ResourceLocation resourceLocation) 13 | { 14 | this(resourceLocation.getNamespace(), resourceLocation.getPath()); 15 | } 16 | 17 | public Identifier(String resourceName) 18 | { 19 | super(resourceName); 20 | } 21 | 22 | public Identifier(String namespaceIn, String pathIn) 23 | { 24 | super(namespaceIn, pathIn); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/Int2BooleanFunction.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface Int2BooleanFunction 5 | { 6 | boolean apply(int value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/IntRange.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public class IntRange 4 | { 5 | protected final int first; 6 | protected final int last; 7 | protected final int length; 8 | 9 | public IntRange(int start, int length) 10 | { 11 | this.first = start; 12 | this.length = length; 13 | this.last = start + length - 1; 14 | } 15 | 16 | public int getFirst() 17 | { 18 | return this.first; 19 | } 20 | 21 | public int getLast() 22 | { 23 | return this.last; 24 | } 25 | 26 | public int getLength() 27 | { 28 | return this.length; 29 | } 30 | 31 | public boolean contains(int value) 32 | { 33 | return value >= this.first && value <= this.last; 34 | } 35 | 36 | @Override 37 | public String toString() 38 | { 39 | return String.format("IntRange:{first:%d,last:%d,length:%d}", this.first, this.last, this.length); 40 | } 41 | 42 | public static IntRange of(int start, int length) 43 | { 44 | return new IntRange(start, length); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/IntegerStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface IntegerStorage 4 | { 5 | int getIntegerValue(); 6 | 7 | boolean setIntegerValue(int newValue); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/LeftRight.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public enum LeftRight 4 | { 5 | LEFT, 6 | RIGHT; 7 | 8 | public LeftRight getOpposite() 9 | { 10 | return this == LEFT ? RIGHT : LEFT; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/ModInfo.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public class ModInfo 4 | { 5 | public static final ModInfo NO_MOD = new ModInfo("-", "-"); 6 | 7 | protected final String modId; 8 | protected final String modName; 9 | 10 | public ModInfo(String modId, String modName) 11 | { 12 | this.modId = modId; 13 | this.modName = modName; 14 | } 15 | 16 | /** 17 | * @return the mod ID of this mod 18 | */ 19 | public String getModId() 20 | { 21 | return this.modId; 22 | } 23 | 24 | /** 25 | * @return the human-friendly mod name of this mod 26 | */ 27 | public String getModName() 28 | { 29 | return this.modName; 30 | } 31 | 32 | @Override 33 | public String toString() 34 | { 35 | return "ModInfo{modId='" + this.modId + "', modName='" + this.modName + "'}"; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) 40 | { 41 | if (this == o) { return true; } 42 | if (o == null || this.getClass() != o.getClass()) { return false; } 43 | 44 | ModInfo modInfo = (ModInfo) o; 45 | 46 | if (!this.modId.equals(modInfo.modId)) { return false; } 47 | return this.modName.equals(modInfo.modName); 48 | } 49 | 50 | @Override 51 | public int hashCode() 52 | { 53 | int result = this.modId.hashCode(); 54 | result = 31 * result + this.modName.hashCode(); 55 | return result; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/NameIdentifiable.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface NameIdentifiable 4 | { 5 | /** 6 | * @return the internal (config-savable) name of this object. 7 | */ 8 | String getName(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/RangedDoubleStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface RangedDoubleStorage extends DoubleStorage 4 | { 5 | double getMinDoubleValue(); 6 | 7 | double getMaxDoubleValue(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/RangedFloatStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface RangedFloatStorage extends FloatStorage 4 | { 5 | float getMinFloatValue(); 6 | 7 | float getMaxFloatValue(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/RangedIntegerStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public interface RangedIntegerStorage extends IntegerStorage 4 | { 5 | int getMinIntegerValue(); 6 | 7 | int getMaxIntegerValue(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/ResultingStringConsumer.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface ResultingStringConsumer 5 | { 6 | /** 7 | * Consumes the provided string, and returns true on success, or false on failure 8 | * @param string the input string argument 9 | * @return true if the operation succeeded, false if it failed 10 | */ 11 | boolean consumeString(String string); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/RunStatus.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import malilib.util.StringUtils; 4 | 5 | public enum RunStatus 6 | { 7 | STOPPED ("malilib.name.run_status.stopped", "malilib.name.run_status.stopped.colored"), 8 | PAUSED ("malilib.name.run_status.paused", "malilib.name.run_status.paused.colored"), 9 | RUNNING ("malilib.name.run_status.running", "malilib.name.run_status.running.colored"), 10 | FINISHED ("malilib.name.run_status.finished", "malilib.name.run_status.finished.colored"), 11 | ABORTED ("malilib.name.run_status.aborted", "malilib.name.run_status.aborted.colored"); 12 | 13 | private final String translationKey; 14 | private final String coloredTranslationKey; 15 | 16 | RunStatus(String translationKey, String coloredTranslationKey) 17 | { 18 | this.translationKey = translationKey; 19 | this.coloredTranslationKey = coloredTranslationKey; 20 | } 21 | 22 | public String getDisplayName() 23 | { 24 | return StringUtils.translate(this.translationKey); 25 | } 26 | 27 | public String getColoredDisplayName() 28 | { 29 | return StringUtils.translate(this.coloredTranslationKey); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/SimpleBooleanStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public class SimpleBooleanStorage implements BooleanStorage 4 | { 5 | protected boolean value; 6 | 7 | public SimpleBooleanStorage() 8 | { 9 | } 10 | 11 | public SimpleBooleanStorage(boolean value) 12 | { 13 | this.value = value; 14 | } 15 | 16 | @Override 17 | public boolean getBooleanValue() 18 | { 19 | return this.value; 20 | } 21 | 22 | @Override 23 | public boolean setBooleanValue(boolean value) 24 | { 25 | if (this.value != value) 26 | { 27 | this.value = value; 28 | return true; 29 | } 30 | 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/SimpleBooleanStorageWithDefault.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | public class SimpleBooleanStorageWithDefault extends SimpleBooleanStorage implements BooleanStorageWithDefault 4 | { 5 | protected final boolean defaultValue; 6 | 7 | public SimpleBooleanStorageWithDefault() 8 | { 9 | this(false); 10 | } 11 | 12 | public SimpleBooleanStorageWithDefault(boolean value) 13 | { 14 | super(value); 15 | 16 | this.defaultValue = value; 17 | } 18 | 19 | @Override 20 | public boolean getDefaultBooleanValue() 21 | { 22 | return this.defaultValue; 23 | } 24 | 25 | @Override 26 | public boolean isModified() 27 | { 28 | return this.defaultValue != this.value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/ToBooleanFunction.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface ToBooleanFunction 5 | { 6 | boolean applyAsBoolean(T value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/ToFloatFunction.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | @FunctionalInterface 4 | public interface ToFloatFunction 5 | { 6 | float applyAsFloat(T value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/WrapperDoubleStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import java.util.function.DoubleConsumer; 4 | import java.util.function.DoubleSupplier; 5 | 6 | import malilib.util.MathUtils; 7 | 8 | public class WrapperDoubleStorage implements RangedDoubleStorage 9 | { 10 | protected final DoubleSupplier valueSupplier; 11 | protected final DoubleConsumer valueConsumer; 12 | protected double minValue; 13 | protected double maxValue; 14 | 15 | public WrapperDoubleStorage(double minValue, double maxValue, DoubleSupplier valueSupplier, DoubleConsumer valueConsumer) 16 | { 17 | this.minValue = minValue; 18 | this.maxValue = maxValue; 19 | this.valueSupplier = valueSupplier; 20 | this.valueConsumer = valueConsumer; 21 | } 22 | 23 | @Override 24 | public double getMinDoubleValue() 25 | { 26 | return this.minValue; 27 | } 28 | 29 | @Override 30 | public double getMaxDoubleValue() 31 | { 32 | return this.maxValue; 33 | } 34 | 35 | @Override 36 | public double getDoubleValue() 37 | { 38 | return this.valueSupplier.getAsDouble(); 39 | } 40 | 41 | @Override 42 | public boolean setDoubleValue(double newValue) 43 | { 44 | this.valueConsumer.accept(MathUtils.clamp(newValue, this.minValue, this.maxValue)); 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/WrapperFloatStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import malilib.util.MathUtils; 4 | 5 | public class WrapperFloatStorage implements RangedFloatStorage 6 | { 7 | protected final FloatSupplier valueSupplier; 8 | protected final FloatConsumer valueConsumer; 9 | protected float minValue; 10 | protected float maxValue; 11 | 12 | public WrapperFloatStorage(float minValue, float maxValue, FloatSupplier valueSupplier, FloatConsumer valueConsumer) 13 | { 14 | this.minValue = minValue; 15 | this.maxValue = maxValue; 16 | this.valueSupplier = valueSupplier; 17 | this.valueConsumer = valueConsumer; 18 | } 19 | 20 | @Override 21 | public float getMinFloatValue() 22 | { 23 | return this.minValue; 24 | } 25 | 26 | @Override 27 | public float getMaxFloatValue() 28 | { 29 | return this.maxValue; 30 | } 31 | 32 | @Override 33 | public float getFloatValue() 34 | { 35 | return this.valueSupplier.getAsFloat(); 36 | } 37 | 38 | @Override 39 | public boolean setFloatValue(float newValue) 40 | { 41 | this.valueConsumer.accept(MathUtils.clamp(newValue, this.minValue, this.maxValue)); 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/WrapperIntStorage.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data; 2 | 3 | import java.util.function.IntConsumer; 4 | import java.util.function.IntSupplier; 5 | 6 | import malilib.util.MathUtils; 7 | 8 | public class WrapperIntStorage implements RangedIntegerStorage 9 | { 10 | protected final IntSupplier valueSupplier; 11 | protected final IntConsumer valueConsumer; 12 | protected int minValue; 13 | protected int maxValue; 14 | 15 | public WrapperIntStorage(int minValue, int maxValue, IntSupplier valueSupplier, IntConsumer valueConsumer) 16 | { 17 | this.minValue = minValue; 18 | this.maxValue = maxValue; 19 | this.valueSupplier = valueSupplier; 20 | this.valueConsumer = valueConsumer; 21 | } 22 | 23 | @Override 24 | public int getMinIntegerValue() 25 | { 26 | return this.minValue; 27 | } 28 | 29 | @Override 30 | public int getMaxIntegerValue() 31 | { 32 | return this.maxValue; 33 | } 34 | 35 | @Override 36 | public int getIntegerValue() 37 | { 38 | return this.valueSupplier.getAsInt(); 39 | } 40 | 41 | @Override 42 | public boolean setIntegerValue(int newValue) 43 | { 44 | this.valueConsumer.accept(MathUtils.clamp(newValue, this.minValue, this.maxValue)); 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/palette/Palette.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data.palette; 2 | 3 | import java.util.List; 4 | import javax.annotation.Nullable; 5 | 6 | public interface Palette 7 | { 8 | /** 9 | * @return the current number of entries in this palette 10 | */ 11 | int getSize(); 12 | 13 | /** 14 | * @return the maximum size of the palette 15 | */ 16 | int getMaxSize(); 17 | 18 | /** 19 | * @return the palette ID for the given value (and add 20 | * the value to the palette if it doesn't exist there yet) 21 | */ 22 | int idFor(T value); 23 | 24 | /** 25 | * @return the value corresponding to the given palette ID, if the ID exists in the palette 26 | */ 27 | @Nullable 28 | T getValue(int id); 29 | 30 | /** 31 | * @return the current full mappings of IDs to values. 32 | * The ID is the position in the returned list. 33 | */ 34 | List getMapping(); 35 | 36 | /** 37 | * Sets the current ID to value mapping of the palette. 38 | * This is meant for reading the palette from file. 39 | * @return true if the mapping was set successfully, false if it failed 40 | */ 41 | boolean setMapping(List list); 42 | 43 | /** 44 | * Overrides the mapping for the given ID. 45 | * @return true if the ID was found in the palette and thus was possible to override 46 | */ 47 | boolean overrideMapping(int id, T value); 48 | 49 | /** 50 | * Creates a copy of this palette, using the provided resize handler 51 | */ 52 | Palette copy(PaletteResizeHandler resizeHandler); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/data/palette/PaletteResizeHandler.java: -------------------------------------------------------------------------------- 1 | package malilib.util.data.palette; 2 | 3 | public interface PaletteResizeHandler 4 | { 5 | /** 6 | * Called when a palette runs out of IDs in the current entry width, 7 | * and the underlying container needs to be resized for the new entry bit width. 8 | * @return the ID for the new value being added when the resize happens 9 | */ 10 | int onResize(int newSizeBits, T valueBeingAdded, Palette oldPalette); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/datadump/RowFormatterCompactTable.java: -------------------------------------------------------------------------------- 1 | package malilib.util.datadump; 2 | 3 | public class RowFormatterCompactTable extends RowFormatterBase 4 | { 5 | public RowFormatterCompactTable(DataDump dump) 6 | { 7 | super(dump); 8 | 9 | String colSep = dump.useColumnSeparator ? "|" : " "; 10 | String lineColSep = dump.useColumnSeparator ? "+" : "-"; 11 | StringBuilder sbColumns = new StringBuilder(128); 12 | StringBuilder sbSeparator = new StringBuilder(256); 13 | 14 | String[] title = dump.title.getValues(); 15 | int titleLength = dump.columns * 3 + 1 - 2; 16 | 17 | sbColumns.append(colSep); 18 | 19 | for (int i = 0; i < dump.columns; ++i) 20 | { 21 | sbColumns.append(" %s ").append(colSep); 22 | titleLength += title[i].length(); 23 | } 24 | 25 | // Generate the separator after the title line, like: +--------+ 26 | sbSeparator.append(lineColSep); 27 | 28 | for (int i = 0; i < titleLength; ++i) 29 | { 30 | sbSeparator.append("-"); 31 | } 32 | 33 | sbSeparator.append(lineColSep); 34 | 35 | this.formatStringColumns = sbColumns.toString(); 36 | this.lineSeparator = sbSeparator.toString(); 37 | } 38 | 39 | @Override 40 | protected String getFormattedHeaderOrFooter(String header) 41 | { 42 | String colSep = this.dump.useColumnSeparator ? "|" : ""; 43 | return colSep + " " + header + " " + colSep; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/datadump/RowFormatterSimpleText.java: -------------------------------------------------------------------------------- 1 | package malilib.util.datadump; 2 | 3 | public class RowFormatterSimpleText extends RowFormatterBase 4 | { 5 | public RowFormatterSimpleText(DataDump dump) 6 | { 7 | super(dump); 8 | 9 | StringBuilder sbColumns = new StringBuilder(128); 10 | StringBuilder sbSeparator = new StringBuilder(256); 11 | 12 | String[] title = dump.title.getValues(); 13 | int titleLength = (dump.columns - 1) * 2; 14 | 15 | for (int i = 0; i < dump.columns; ++i) 16 | { 17 | if (i < (dump.columns - 1)) 18 | { 19 | sbColumns.append("%s, "); 20 | } 21 | else 22 | { 23 | sbColumns.append("%s"); 24 | } 25 | 26 | titleLength += title[i].length(); 27 | } 28 | 29 | // Generate the separator after the title line, like: -------- 30 | 31 | for (int i = 0; i < titleLength; ++i) 32 | { 33 | sbSeparator.append("-"); 34 | } 35 | 36 | this.formatStringColumns = sbColumns.toString(); 37 | this.lineSeparator = sbSeparator.toString(); 38 | } 39 | 40 | @Override 41 | protected String getFormattedHeaderOrFooter(String header) 42 | { 43 | return header; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/game/wrap/DefaultedList.java: -------------------------------------------------------------------------------- 1 | package malilib.util.game.wrap; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import javax.annotation.Nullable; 7 | import org.apache.commons.lang3.Validate; 8 | 9 | import net.minecraft.util.NonNullList; 10 | 11 | public class DefaultedList extends NonNullList 12 | { 13 | protected DefaultedList() 14 | { 15 | this(new ArrayList<>(), null); 16 | } 17 | 18 | protected DefaultedList(List delegate, @Nullable E defaultValue) 19 | { 20 | super(delegate, defaultValue); 21 | } 22 | 23 | public static DefaultedList empty() 24 | { 25 | return new DefaultedList<>(); 26 | } 27 | 28 | /** 29 | * Creates a new NonNullList with fixed size, and filled with the object passed. 30 | */ 31 | @SuppressWarnings("unchecked") 32 | public static DefaultedList ofSize(int size, E defaultValue) 33 | { 34 | Validate.notNull(defaultValue); 35 | Object[] arr = new Object[size]; 36 | Arrays.fill(arr, defaultValue); 37 | 38 | return new DefaultedList<>(Arrays.asList((E[]) arr), defaultValue); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/game/wrap/ItemWrap.java: -------------------------------------------------------------------------------- 1 | package malilib.util.game.wrap; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.nbt.NBTTagCompound; 7 | 8 | public class ItemWrap 9 | { 10 | @Nullable 11 | public static NBTTagCompound getTag(ItemStack stack) 12 | { 13 | return stack.getTagCompound(); 14 | } 15 | 16 | public static void setTag(ItemStack stack, @Nullable NBTTagCompound tag) 17 | { 18 | stack.setTagCompound(tag); 19 | } 20 | 21 | public static ItemStack fromTag(NBTTagCompound tag) 22 | { 23 | return new ItemStack(tag); 24 | } 25 | 26 | public static boolean isEmpty(ItemStack stack) 27 | { 28 | return stack.isEmpty(); 29 | } 30 | 31 | public static boolean notEmpty(ItemStack stack) 32 | { 33 | return stack.isEmpty() == false; 34 | } 35 | 36 | public static String getStackString(ItemStack stack) 37 | { 38 | if (ItemWrap.notEmpty(stack)) 39 | { 40 | String id = RegistryUtils.getItemIdStr(stack.getItem()); 41 | NBTTagCompound tag = ItemWrap.getTag(stack); 42 | 43 | return String.format("[%s @ %d - display: %s - NBT: %s] (%s)", 44 | id != null ? id : "null", stack.getMetadata(), stack.getDisplayName(), 45 | tag != null ? tag.toString() : "", stack); 46 | } 47 | 48 | return ""; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/ColoredVanillaInventoryView.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.inventory.IInventory; 4 | 5 | public class ColoredVanillaInventoryView extends VanillaInventoryView 6 | { 7 | protected final int backgroundTintColor; 8 | 9 | public ColoredVanillaInventoryView(IInventory inv, int backgroundTintColor) 10 | { 11 | super(inv); 12 | 13 | this.backgroundTintColor = backgroundTintColor; 14 | } 15 | 16 | public int getBackgroundTintColor() 17 | { 18 | return this.backgroundTintColor; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/CombinedInventoryView.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | public class CombinedInventoryView implements InventoryView 6 | { 7 | protected final InventoryView inventory1; 8 | protected final InventoryView inventory2; 9 | 10 | public CombinedInventoryView(InventoryView inventory1, InventoryView inventory2) 11 | { 12 | this.inventory1 = inventory1; 13 | this.inventory2 = inventory2; 14 | } 15 | 16 | @Override 17 | public int getSize() 18 | { 19 | return this.inventory1.getSize() + this.inventory2.getSize(); 20 | } 21 | 22 | @Override 23 | public ItemStack getStack(int slot) 24 | { 25 | final int firstInvSize = this.inventory1.getSize(); 26 | 27 | if (slot < firstInvSize) 28 | { 29 | return this.inventory1.getStack(slot); 30 | } 31 | 32 | return this.inventory2.getStack(slot - firstInvSize); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/InventoryScreenUtils.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.client.gui.inventory.GuiContainer; 4 | import net.minecraft.inventory.Slot; 5 | 6 | import malilib.mixin.access.GuiContainerMixin; 7 | 8 | public class InventoryScreenUtils 9 | { 10 | public static int getGuiPosX(GuiContainer gui) 11 | { 12 | return ((GuiContainerMixin) gui).getGuiPosX(); 13 | } 14 | 15 | public static int getGuiPosY(GuiContainer gui) 16 | { 17 | return ((GuiContainerMixin) gui).getGuiPosY(); 18 | } 19 | 20 | public static int getGuiSizeX(GuiContainer gui) 21 | { 22 | return ((GuiContainerMixin) gui).getGuiSizeX(); 23 | } 24 | 25 | public static int getGuiSizeY(GuiContainer gui) 26 | { 27 | return ((GuiContainerMixin) gui).getGuiSizeY(); 28 | } 29 | 30 | public static Slot getSlotUnderMouse(GuiContainer gui) 31 | { 32 | return ((GuiContainerMixin) gui).getHoveredSlot(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/InventoryView.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | public interface InventoryView 6 | { 7 | /** 8 | * @return the total number of slots in this inventory 9 | */ 10 | int getSize(); 11 | 12 | /** 13 | * @param slot the slot number 14 | * @return the ItemStack from the requested slot number 15 | */ 16 | ItemStack getStack(int slot); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/SlicedInventoryView.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | public class SlicedInventoryView implements InventoryView 6 | { 7 | protected final InventoryView baseInventory; 8 | protected final int startSlot; 9 | protected final int slotCount; 10 | 11 | public SlicedInventoryView(InventoryView baseInventory, int startSlot, int slotCount) 12 | { 13 | this.baseInventory = baseInventory; 14 | this.startSlot = startSlot; 15 | this.slotCount = Math.max(Math.min(slotCount, baseInventory.getSize() - startSlot), 0); 16 | } 17 | 18 | @Override 19 | public int getSize() 20 | { 21 | return this.slotCount; 22 | } 23 | 24 | @Override 25 | public ItemStack getStack(int slot) 26 | { 27 | return this.baseInventory.getStack(slot + this.startSlot); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/inventory/VanillaInventoryView.java: -------------------------------------------------------------------------------- 1 | package malilib.util.inventory; 2 | 3 | import net.minecraft.inventory.IInventory; 4 | import net.minecraft.item.ItemStack; 5 | 6 | public class VanillaInventoryView implements InventoryView 7 | { 8 | protected final IInventory inv; 9 | 10 | public VanillaInventoryView(IInventory inv) 11 | { 12 | this.inv = inv; 13 | } 14 | 15 | @Override 16 | public int getSize() 17 | { 18 | return this.inv.getSizeInventory(); 19 | } 20 | 21 | @Override 22 | public ItemStack getStack(int slot) 23 | { 24 | return this.inv.getStackInSlot(slot); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/ChunkPos.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public class ChunkPos extends net.minecraft.util.math.ChunkPos 4 | { 5 | public ChunkPos(int x, int z) 6 | { 7 | super(x, z); 8 | } 9 | 10 | public int getX() 11 | { 12 | return this.x; 13 | } 14 | 15 | public int getZ() 16 | { 17 | return this.z; 18 | } 19 | 20 | @Override 21 | public String toString() 22 | { 23 | return "ChunkPos{x=" + this.x + ", z=" + this.z + "}"; 24 | } 25 | 26 | public static long asLong(int chunkX, int chunkZ) 27 | { 28 | return ((long) chunkZ << 32) | (long) chunkX; 29 | } 30 | 31 | public static ChunkPos of(net.minecraft.util.math.ChunkPos pos) 32 | { 33 | return new ChunkPos(pos.x, pos.z); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/ChunkSectionPos.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | import java.util.Comparator; 4 | 5 | public class ChunkSectionPos extends Vec3i 6 | { 7 | public ChunkSectionPos(BlockPos pos) 8 | { 9 | this(pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4); 10 | } 11 | 12 | public ChunkSectionPos(int x, int y, int z) 13 | { 14 | super(x, y, z); 15 | } 16 | 17 | @Override 18 | public String toString() 19 | { 20 | return "ChunkSectionPos{x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + "}"; 21 | } 22 | 23 | public static ChunkSectionPos ofBlockPos(net.minecraft.util.math.Vec3i blockPos) 24 | { 25 | return new ChunkSectionPos(blockPos.getX() >> 4, blockPos.getY() >> 4, blockPos.getZ() >> 4); 26 | } 27 | 28 | public static class DistanceComparator implements Comparator 29 | { 30 | private final ChunkSectionPos referencePosition; 31 | 32 | public DistanceComparator(ChunkSectionPos referencePosition) 33 | { 34 | this.referencePosition = referencePosition; 35 | } 36 | 37 | @Override 38 | public int compare(ChunkSectionPos pos1, ChunkSectionPos pos2) 39 | { 40 | double dist1 = pos1.squareDistanceTo(this.referencePosition); 41 | double dist2 = pos2.squareDistanceTo(this.referencePosition); 42 | 43 | return Double.compare(dist1, dist2); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/HitPosition.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public class HitPosition 4 | { 5 | protected final BlockPos blockPos; 6 | protected final Vec3d exactPos; 7 | protected final Direction direction; 8 | 9 | public HitPosition(BlockPos blockPos, Vec3d exactPos, Direction direction) 10 | { 11 | this.blockPos = blockPos; 12 | this.exactPos = exactPos; 13 | this.direction = direction; 14 | } 15 | 16 | public BlockPos getBlockPos() 17 | { 18 | return this.blockPos; 19 | } 20 | 21 | public Vec3d getExactPos() 22 | { 23 | return this.exactPos; 24 | } 25 | 26 | public Direction getSide() 27 | { 28 | return this.direction; 29 | } 30 | 31 | @Override 32 | public String toString() 33 | { 34 | return "HitPosition{blockPos=" + this.blockPos + ", exactPos=" + this.exactPos + ", direction=" + this.direction + "}"; 35 | } 36 | 37 | public static HitPosition of(BlockPos blockPos, Vec3d exactPos, Direction direction) 38 | { 39 | return new HitPosition(blockPos, exactPos, direction); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/Quadrant.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public enum Quadrant 4 | { 5 | NORTH_WEST, 6 | NORTH_EAST, 7 | SOUTH_WEST, 8 | SOUTH_EAST; 9 | 10 | public static Quadrant getQuadrant(BlockPos pos, Vec3d center) 11 | { 12 | return getQuadrant(pos.getX(), pos.getZ(), center); 13 | } 14 | 15 | public static Quadrant getQuadrant(int x, int z, Vec3d center) 16 | { 17 | return getQuadrant((double) x, (double) z, center); 18 | } 19 | 20 | public static Quadrant getQuadrant(double x, double z, Vec3d center) 21 | { 22 | // West 23 | if (x <= center.x) 24 | { 25 | // North 26 | if (z <= center.z) 27 | { 28 | return NORTH_WEST; 29 | } 30 | // South 31 | else 32 | { 33 | return SOUTH_WEST; 34 | } 35 | } 36 | // East 37 | else 38 | { 39 | // North 40 | if (z <= center.z) 41 | { 42 | return NORTH_EAST; 43 | } 44 | // South 45 | else 46 | { 47 | return SOUTH_EAST; 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/Vec2i.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public class Vec2i 4 | { 5 | public static final Vec2i ZERO = new Vec2i(0, 0); 6 | 7 | public final int x; 8 | public final int y; 9 | 10 | public Vec2i(int x, int y) 11 | { 12 | this.x = x; 13 | this.y = y; 14 | } 15 | 16 | public int getX() 17 | { 18 | return this.x; 19 | } 20 | 21 | public int getY() 22 | { 23 | return this.y; 24 | } 25 | 26 | public double getSquaredDistance(int x, int y) 27 | { 28 | double diffX = (double) x - (double) this.x; 29 | double diffY = (double) y - (double) this.y; 30 | 31 | return diffX * diffX + diffY * diffY; 32 | } 33 | 34 | public double getDistance(int x, int y) 35 | { 36 | return Math.sqrt(this.getSquaredDistance(x, y)); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o) 41 | { 42 | if (this == o) { return true; } 43 | if (o == null || this.getClass() != o.getClass()) { return false; } 44 | 45 | Vec2i vec2i = (Vec2i) o; 46 | 47 | if (this.x != vec2i.x) { return false; } 48 | return this.y == vec2i.y; 49 | } 50 | 51 | @Override 52 | public int hashCode() 53 | { 54 | int result = this.x; 55 | result = 31 * result + this.y; 56 | return result; 57 | } 58 | 59 | @Override 60 | public String toString() 61 | { 62 | return "Vec2i{x=" + this.x + ", y=" + this.y + "}"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/Vec3f.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public class Vec3f 4 | { 5 | public static final Vec3f ZERO = new Vec3f(0.0F, 0.0F, 0.0F); 6 | 7 | public final float x; 8 | public final float y; 9 | public final float z; 10 | 11 | public Vec3f(double x, double y, double z) 12 | { 13 | this((float) x, (float) y, (float) z); 14 | } 15 | 16 | public Vec3f(float x, float y, float z) 17 | { 18 | this.x = x; 19 | this.y = y; 20 | this.z = z; 21 | } 22 | 23 | public float getX() 24 | { 25 | return this.x; 26 | } 27 | 28 | public float getY() 29 | { 30 | return this.y; 31 | } 32 | 33 | public float getZ() 34 | { 35 | return this.z; 36 | } 37 | 38 | public Vec3f normalize() 39 | { 40 | return normalized(this.x, this.y, this.z); 41 | } 42 | 43 | public static Vec3f normalized(float x, float y, float z) 44 | { 45 | double d = Math.sqrt(x * x + y * y + z * z); 46 | return d < 1.0E-4 ? ZERO : new Vec3f(x / d, y / d, z / d); 47 | } 48 | 49 | @Override 50 | public String toString() 51 | { 52 | return "Vec3f{x=" + this.x + ", y=" + this.y + ", z=" + this.z + "}"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/malilib/util/position/Vec3i.java: -------------------------------------------------------------------------------- 1 | package malilib.util.position; 2 | 3 | public class Vec3i extends net.minecraft.util.math.BlockPos 4 | { 5 | public static final Vec3i ZERO = new Vec3i(0, 0, 0); 6 | 7 | /* 8 | public final int x; 9 | public final int y; 10 | public final int z; 11 | */ 12 | 13 | public Vec3i(int x, int y, int z) 14 | { 15 | super(x, y, z); 16 | /* 17 | this.x = x; 18 | this.y = y; 19 | this.z = z; 20 | */ 21 | } 22 | 23 | /* 24 | public int getX() 25 | { 26 | return this.x; 27 | } 28 | 29 | public int getY() 30 | { 31 | return this.y; 32 | } 33 | 34 | public int getZ() 35 | { 36 | return this.z; 37 | } 38 | */ 39 | 40 | public long squareDistanceTo(Vec3i other) 41 | { 42 | return this.squareDistanceTo(other.getX(), other.getY(), other.getZ()); 43 | } 44 | 45 | public long squareDistanceTo(int x, int y, int z) 46 | { 47 | return (long) this.getX() * x + (long) this.getY() * y + (long) this.getZ() * z; 48 | } 49 | 50 | public double squareDistanceOfCenterTo(Vec3d pos) 51 | { 52 | return (this.getX() + 0.5) * pos.x + (this.getY() + 0.5) * pos.y + (this.getZ() + 0.5) * pos.z; 53 | } 54 | 55 | @Override 56 | public String toString() 57 | { 58 | return "Vec3i{x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + "}"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/icon.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/shaders/sv_selector.frag: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Made by skyrising 4 | 5 | uniform float hue_value; 6 | 7 | vec3 hue2rgb(float h) 8 | { 9 | float r = abs(h * 6.0 - 3.0) - 1.0; 10 | float g = 2.0 - abs(h * 6.0 - 2.0); 11 | float b = 2.0 - abs(h * 6.0 - 4.0); 12 | return clamp(vec3(r, g, b), 0.0, 1.0); 13 | } 14 | 15 | vec3 hsv2rgb(vec3 hsv) 16 | { 17 | vec3 rgb = hue2rgb(hsv.x); 18 | return ((rgb - 1.0) * hsv.y + 1.0) * hsv.z; 19 | } 20 | 21 | void main() 22 | { 23 | gl_FragColor = vec4(hsv2rgb(vec3(mod(hue_value, 1.0), gl_TexCoord[0].xy)), 1.0); 24 | } -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/gui/gui_widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/gui/gui_widgets.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/gui/inventory_background_empty_13x13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/gui/inventory_background_empty_13x13.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/gui/inventory_background_generic_54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/gui/inventory_background_generic_54.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/gui/inventory_background_misc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/gui/inventory_background_misc.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/gui/toasts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/gui/toasts.png -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/xcf/gui_widgets.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/xcf/gui_widgets.xcf -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/xcf/inventory_backgrounds.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/xcf/inventory_backgrounds.xcf -------------------------------------------------------------------------------- /src/main/resources/assets/malilib/textures/xcf/toasts.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maruohon/malilib/fa3e7aeb222a66affcc6cc0a24a75c5b3160467c/src/main/resources/assets/malilib/textures/xcf/toasts.xcf -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "malilib", 4 | "name": "MaLiLib", 5 | "version": "${mod_version}", 6 | 7 | "description": "A library mod for (masa's) client-side mods", 8 | "license": "LGPLv3", 9 | "authors": [ "masa" ], 10 | "contact": { 11 | "homepage": "https://www.curseforge.com/minecraft/mc-mods/malilib", 12 | "issues": "https://github.com/maruohon/malilib/issues", 13 | "sources": "https://github.com/maruohon/malilib", 14 | "discord": "https://discordapp.com/channels/211786369951989762/453662800460644354/" 15 | }, 16 | 17 | "icon": "assets/malilib/icon.png", 18 | "environment": "client", 19 | "entrypoints": { 20 | "client-init": [ 21 | "malilib.MaLiLib" 22 | ], 23 | "modmenu": [ 24 | "malilib.compat.modmenu.ModMenuImpl" 25 | ] 26 | }, 27 | 28 | "mixins": [ 29 | { 30 | "config": "mixins.malilib.json", 31 | "environment": "client" 32 | } 33 | ], 34 | 35 | "depends": { 36 | "minecraft": "1.12.x", 37 | "osl-entrypoints": "*", 38 | "osl-resource-loader": "*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/mixins.malilib.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "malilib.mixin", 4 | "compatibilityLevel": "JAVA_8", 5 | "minVersion": "0.8", 6 | "client": [ 7 | "access.AbstractHorseMixin", 8 | "access.GuiContainerMixin", 9 | "access.NBTBaseMixin", 10 | "access.NBTTagLongArrayMixin", 11 | "command.GuiScreenMixin", 12 | "command.TabCompleterMixin", 13 | "event.MinecraftMixin", 14 | "input.GuiScreenMixin", 15 | "input.MinecraftMixin", 16 | "network.MixinNetHandlerPlayClient", 17 | "render.EntityRendererMixin", 18 | "render.GuiScreenMixin" 19 | ], 20 | "injectors": { 21 | "defaultRequire": 1 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 3, 4 | "description": "MaLiLib resources" 5 | } 6 | } --------------------------------------------------------------------------------