├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ └── feature-request.yml └── workflows │ ├── gradle-publish.yml │ └── gradle.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── build.gradle ├── buildSrc ├── build.gradle └── src │ └── main │ └── groovy │ └── kasuga │ └── builder │ └── PackerPlugin.groovy ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── javascript └── build.ts ├── package.json ├── settings.gradle ├── src ├── generated │ └── resources │ │ ├── assets │ │ └── kasuga_lib │ │ │ ├── anim_model_preload.json │ │ │ ├── animations │ │ │ └── model.animation.json │ │ │ ├── blockstates │ │ │ └── test │ │ │ │ ├── example_fluid.json │ │ │ │ ├── green_apple.json │ │ │ │ ├── rotation_test.json │ │ │ │ └── salt_ore.json │ │ │ ├── guis.json │ │ │ ├── guis │ │ │ └── screen.xml │ │ │ ├── js │ │ │ ├── .gitignore │ │ │ └── modules │ │ │ │ └── .gitignore │ │ │ ├── lang │ │ │ ├── en_us.json │ │ │ └── zh_cn.json │ │ │ ├── models │ │ │ ├── block │ │ │ │ └── test │ │ │ │ │ ├── blockbench │ │ │ │ │ ├── bb_model_test.json │ │ │ │ │ ├── df11g_head.bbmodel │ │ │ │ │ └── qj_bogey_main.bbmodel │ │ │ │ │ ├── c70.geo.json │ │ │ │ │ ├── c70.json │ │ │ │ │ ├── green_apple.json │ │ │ │ │ ├── rotation_test_model.geo.json │ │ │ │ │ ├── rotation_test_model.json │ │ │ │ │ ├── salt_ore.json │ │ │ │ │ ├── test_model_complicate.geo.json │ │ │ │ │ ├── test_model_complicate.json │ │ │ │ │ ├── test_model_rotation.geo.json │ │ │ │ │ ├── test_model_simple.geo.json │ │ │ │ │ ├── test_model_simple_2.geo.json │ │ │ │ │ └── wheel_test.geo.json │ │ │ ├── default │ │ │ │ ├── missing_model.geo.json │ │ │ │ └── missing_model.json │ │ │ ├── entity │ │ │ │ └── test │ │ │ │ │ └── wuling │ │ │ │ │ ├── jsons │ │ │ │ │ ├── door │ │ │ │ │ │ ├── back_door_left.json │ │ │ │ │ │ ├── back_door_right.json │ │ │ │ │ │ ├── front_door_left.json │ │ │ │ │ │ ├── front_door_right.json │ │ │ │ │ │ └── large_back_door.json │ │ │ │ │ ├── frame.json │ │ │ │ │ ├── tie.json │ │ │ │ │ └── wheel │ │ │ │ │ │ ├── left_wheel.json │ │ │ │ │ │ └── right_wheel.json │ │ │ │ │ ├── objs │ │ │ │ │ ├── door │ │ │ │ │ │ ├── wuling_back_door_left.mtl │ │ │ │ │ │ ├── wuling_back_door_left.obj │ │ │ │ │ │ ├── wuling_back_door_right.mtl │ │ │ │ │ │ ├── wuling_back_door_right.obj │ │ │ │ │ │ ├── wuling_front_door_left.mtl │ │ │ │ │ │ ├── wuling_front_door_left.obj │ │ │ │ │ │ ├── wuling_front_door_right.mtl │ │ │ │ │ │ ├── wuling_front_door_right.obj │ │ │ │ │ │ ├── wuling_large_back_door.mtl │ │ │ │ │ │ └── wuling_large_back_door.obj │ │ │ │ │ ├── wheel │ │ │ │ │ │ ├── wuling_left_wheel.mtl │ │ │ │ │ │ ├── wuling_left_wheel.obj │ │ │ │ │ │ ├── wuling_right_wheel.mtl │ │ │ │ │ │ └── wuling_right_wheel.obj │ │ │ │ │ ├── wuling_frame.mtl │ │ │ │ │ ├── wuling_frame.obj │ │ │ │ │ ├── wuling_tie.mtl │ │ │ │ │ └── wuling_tie.obj │ │ │ │ │ ├── wuling_anim.json │ │ │ │ │ ├── wuling_base.json │ │ │ │ │ └── wuling_frame.json │ │ │ ├── item │ │ │ │ ├── example_fluid_bucket.json │ │ │ │ └── salt_ore.json │ │ │ └── panel │ │ │ │ ├── arrow.geo.json │ │ │ │ ├── arrow.json │ │ │ │ ├── arrow_2.geo.json │ │ │ │ ├── arrow_2.json │ │ │ │ ├── panel.geo.json │ │ │ │ └── panel.json │ │ │ └── textures │ │ │ ├── block │ │ │ ├── fluid │ │ │ │ ├── water_flow.png │ │ │ │ ├── water_flow.png.mcmeta │ │ │ │ ├── water_overlay.png │ │ │ │ ├── water_still.png │ │ │ │ └── water_still.png.mcmeta │ │ │ └── test │ │ │ │ ├── c70.png │ │ │ │ ├── rotation_test_model.png │ │ │ │ └── salt_ore.png │ │ │ ├── common │ │ │ └── test │ │ │ │ ├── green_apple.png │ │ │ │ ├── green_apple_bubble.png │ │ │ │ ├── test_model_complicate.png │ │ │ │ ├── test_model_rotation.png │ │ │ │ ├── test_model_simple.png │ │ │ │ └── test_model_simple_2.png │ │ │ ├── default │ │ │ ├── missing_model.png │ │ │ └── particle.png │ │ │ ├── entity │ │ │ └── wuling_texture.png │ │ │ ├── gui │ │ │ ├── editor.png │ │ │ ├── no_img.png │ │ │ └── pixel.png │ │ │ ├── item │ │ │ └── example_fluid_bucket.png │ │ │ ├── panel │ │ │ ├── arrow_texture.png │ │ │ └── panel_texture.png │ │ │ └── particles │ │ │ └── green_particle.png │ │ ├── data │ │ ├── forge │ │ │ └── tags │ │ │ │ └── fluids │ │ │ │ └── example_fluid.json │ │ └── kasuga_lib │ │ │ ├── forge │ │ │ └── biome_modifier │ │ │ │ └── salt_ore.json.disabled │ │ │ └── worldgen │ │ │ ├── configured_feature │ │ │ └── salt_ore.json.disabled │ │ │ └── placed_feature │ │ │ └── salt_ore_placed.json.disabled │ │ ├── kasuga.mixins.json │ │ ├── kasuga_lib.png │ │ └── libraries │ │ └── lwjgl-yoga-3.3.1 │ │ └── windows │ │ ├── x64 │ │ └── org │ │ │ └── lwjgl │ │ │ └── yoga │ │ │ └── lwjgl_yoga.dll │ │ └── x86 │ │ └── org │ │ └── lwjgl │ │ └── yoga │ │ └── lwjgl_yoga.dll └── main │ ├── java │ └── kasuga │ │ └── lib │ │ ├── KasugaLib.java │ │ ├── KasugaLibConfig.java │ │ ├── core │ │ ├── KasugaLibClient.java │ │ ├── KasugaLibStacks.java │ │ ├── addons │ │ │ ├── minecraft │ │ │ │ ├── ClientAddon.java │ │ │ │ ├── ClientReloadManager.java │ │ │ │ └── ServerAddon.java │ │ │ ├── node │ │ │ │ ├── AssetReader.java │ │ │ │ ├── EntryType.java │ │ │ │ ├── NodePackage.java │ │ │ │ ├── NodePackageLoader.java │ │ │ │ ├── PackageMinecraftField.java │ │ │ │ ├── PackageReader.java │ │ │ │ └── PackageScanner.java │ │ │ └── resource │ │ │ │ ├── FlatFilesystem.java │ │ │ │ ├── HierarchicalFilesystem.java │ │ │ │ ├── ResourceAdapter.java │ │ │ │ ├── ResourceManagerPackageProvider.java │ │ │ │ ├── ResourceProvider.java │ │ │ │ ├── VanillaFileResourcePackProvider.java │ │ │ │ ├── VanillaFolderResourcePackProvider.java │ │ │ │ └── VanillaPathResourcePackProvider.java │ │ ├── annos │ │ │ ├── Beta.java │ │ │ ├── Inner.java │ │ │ ├── Mandatory.java │ │ │ ├── Optional.java │ │ │ └── Util.java │ │ ├── base │ │ │ ├── BucketItem.java │ │ │ ├── CustomBlockRenderer.java │ │ │ ├── CustomRenderedItem.java │ │ │ ├── NbtSerializable.java │ │ │ ├── Saved.java │ │ │ ├── SimpleCreativeTab.java │ │ │ ├── TickingBlockEntity.java │ │ │ ├── UnModeledBlockProperty.java │ │ │ ├── commands │ │ │ │ ├── ArgumentTypes │ │ │ │ │ ├── BaseArgument.java │ │ │ │ │ └── BaseArgumentInfo.java │ │ │ │ ├── CommandHandler.java │ │ │ │ ├── CommandNode.java │ │ │ │ └── CommandTree.java │ │ │ └── item_helper │ │ │ │ ├── ExternalProperties.java │ │ │ │ ├── ExternalRemainderBlockItem.java │ │ │ │ └── ExternalRemainderItem.java │ │ ├── channel │ │ │ ├── ChannelNetworkManager.java │ │ │ ├── NetworkSwitcher.java │ │ │ ├── address │ │ │ │ ├── ChannelPort.java │ │ │ │ ├── ConnectionInfo.java │ │ │ │ ├── FeatureChannelPort.java │ │ │ │ ├── Label.java │ │ │ │ ├── LabelType.java │ │ │ │ ├── LabelTypeRegistry.java │ │ │ │ └── UUIDChannelPort.java │ │ │ ├── network │ │ │ │ ├── NetworkChannelSocket.java │ │ │ │ ├── NetworkDuplexer.java │ │ │ │ ├── NetworkManager.java │ │ │ │ ├── NetworkSeriaizableType.java │ │ │ │ ├── NetworkSerializable.java │ │ │ │ ├── NetworkSerializableRegistry.java │ │ │ │ ├── NetworkServerManager.java │ │ │ │ └── address │ │ │ │ │ ├── MinecraftClientPlayerAddress.java │ │ │ │ │ ├── MinecraftServerAddress.java │ │ │ │ │ ├── NetworkAddressTypes.java │ │ │ │ │ └── PlainStringAddress.java │ │ │ ├── packets │ │ │ │ ├── C2SChannelConnectionPacket.java │ │ │ │ ├── C2SChannelMessagePacket.java │ │ │ │ ├── C2SChannelStateChangePacket.java │ │ │ │ ├── ChannelNetworkPacket.java │ │ │ │ ├── S2CChannelConnectionPacket.java │ │ │ │ ├── S2CChannelMessagePacket.java │ │ │ │ └── S2CChannelStateChangePacket.java │ │ │ ├── peer │ │ │ │ ├── Channel.java │ │ │ │ ├── ChannelCloseListener.java │ │ │ │ ├── ChannelHandle.java │ │ │ │ ├── ChannelHandler.java │ │ │ │ ├── ChannelMultiplexer.java │ │ │ │ ├── ChannelPeer.java │ │ │ │ ├── ChannelPeerSocketClient.java │ │ │ │ ├── ChannelPeerSocketServer.java │ │ │ │ ├── ChannelReciever.java │ │ │ │ ├── ChannelSocket.java │ │ │ │ ├── ChannelStatus.java │ │ │ │ └── FeaturedChannelPeer.java │ │ │ ├── route │ │ │ │ ├── DropRouteTarget.java │ │ │ │ ├── ForwardAndTransformAddressTarget.java │ │ │ │ ├── ForwardRouteTarget.java │ │ │ │ ├── PlayerLabelMatchRule.java │ │ │ │ ├── RouteRule.java │ │ │ │ ├── RouteRuleManager.java │ │ │ │ ├── RouteTarget.java │ │ │ │ ├── RouteTargets.java │ │ │ │ ├── SimpleRouter.java │ │ │ │ └── TargetLabelMatchRule.java │ │ │ └── test │ │ │ │ └── ChannelTest.java │ │ ├── client │ │ │ ├── ModelMappings.java │ │ │ ├── animation │ │ │ │ ├── Constants.java │ │ │ │ ├── data │ │ │ │ │ ├── Animation.java │ │ │ │ │ ├── anchor │ │ │ │ │ │ ├── Anchor.java │ │ │ │ │ │ └── AnchorsGroup.java │ │ │ │ │ ├── bones │ │ │ │ │ │ ├── BoneMovement.java │ │ │ │ │ │ └── BonesGroup.java │ │ │ │ │ ├── timer │ │ │ │ │ │ ├── TimeLine.java │ │ │ │ │ │ └── TimeLineGroup.java │ │ │ │ │ └── trigger │ │ │ │ │ │ ├── Trigger.java │ │ │ │ │ │ └── TriggerGroup.java │ │ │ │ ├── infrastructure │ │ │ │ │ ├── AnimAssignable.java │ │ │ │ │ ├── AnimationElement.java │ │ │ │ │ ├── Condition.java │ │ │ │ │ ├── IAnchor.java │ │ │ │ │ └── MappingLayer.java │ │ │ │ └── neo_neo │ │ │ │ │ ├── Animation.java │ │ │ │ │ ├── InterpolationUtil.java │ │ │ │ │ ├── StateHolder.java │ │ │ │ │ ├── StaticPose.java │ │ │ │ │ ├── VectorIOUtil.java │ │ │ │ │ ├── VectorUtil.java │ │ │ │ │ ├── base │ │ │ │ │ ├── IBezier.java │ │ │ │ │ ├── ICustom.java │ │ │ │ │ └── Movement.java │ │ │ │ │ ├── key_frame │ │ │ │ │ ├── KeyFrame.java │ │ │ │ │ └── KeyFrameHolder.java │ │ │ │ │ ├── point │ │ │ │ │ ├── PivotPoint.java │ │ │ │ │ └── Point.java │ │ │ │ │ ├── rotation │ │ │ │ │ ├── BezierRotation.java │ │ │ │ │ ├── CustomRotation.java │ │ │ │ │ ├── LinearRotation.java │ │ │ │ │ └── Rotation.java │ │ │ │ │ ├── scaling │ │ │ │ │ ├── BezierScaling.java │ │ │ │ │ ├── CustomScaling.java │ │ │ │ │ ├── LinearScaling.java │ │ │ │ │ └── Scaling.java │ │ │ │ │ └── translation │ │ │ │ │ ├── BezierTranslation.java │ │ │ │ │ ├── CustomTranslation.java │ │ │ │ │ ├── LinearTranslation.java │ │ │ │ │ └── Translation.java │ │ │ ├── block_bench_model │ │ │ │ ├── BlockBenchModelLoader.java │ │ │ │ ├── anim │ │ │ │ │ ├── Animation.java │ │ │ │ │ ├── Animator.java │ │ │ │ │ ├── Channel.java │ │ │ │ │ ├── KeyFrame.java │ │ │ │ │ ├── LoopMode.java │ │ │ │ │ ├── instance │ │ │ │ │ │ ├── AnimationController.java │ │ │ │ │ │ ├── AnimationInstance.java │ │ │ │ │ │ ├── AnimatorInstance.java │ │ │ │ │ │ └── Ticker.java │ │ │ │ │ └── interpolation │ │ │ │ │ │ ├── Bezier.java │ │ │ │ │ │ ├── CatmullRom.java │ │ │ │ │ │ ├── Interpolation.java │ │ │ │ │ │ ├── InterpolationType.java │ │ │ │ │ │ ├── Linear.java │ │ │ │ │ │ └── Step.java │ │ │ │ ├── anim_model │ │ │ │ │ ├── AnimBlockBenchElement.java │ │ │ │ │ ├── AnimBlockBenchGroup.java │ │ │ │ │ ├── AnimBlockBenchModel.java │ │ │ │ │ ├── AnimElement.java │ │ │ │ │ ├── AnimFunctions.java │ │ │ │ │ ├── ElementCollection.java │ │ │ │ │ ├── ModelTransform.java │ │ │ │ │ └── Renderable.java │ │ │ │ ├── json_data │ │ │ │ │ ├── BlockBenchFile.java │ │ │ │ │ ├── BlockBenchMeta.java │ │ │ │ │ ├── Element.java │ │ │ │ │ ├── Face.java │ │ │ │ │ ├── Group.java │ │ │ │ │ ├── IElement.java │ │ │ │ │ ├── Outline.java │ │ │ │ │ ├── Texture.java │ │ │ │ │ └── TextureSource.java │ │ │ │ └── model │ │ │ │ │ ├── BlockBenchElement.java │ │ │ │ │ ├── BlockBenchFace.java │ │ │ │ │ ├── BlockBenchGroup.java │ │ │ │ │ ├── BlockBenchModel.java │ │ │ │ │ ├── ModelElement.java │ │ │ │ │ └── TransformContext.java │ │ │ ├── frontend │ │ │ │ ├── assets │ │ │ │ │ └── TextureAssetProvider.java │ │ │ │ ├── commands │ │ │ │ │ ├── FrontendCommands.java │ │ │ │ │ ├── GuiScreenHelper.java │ │ │ │ │ ├── MetroLoaderModule.java │ │ │ │ │ ├── MetroModuleInfo.java │ │ │ │ │ ├── MetroModuleLoader.java │ │ │ │ │ └── MetroServerResourceProvider.java │ │ │ │ ├── common │ │ │ │ │ ├── event │ │ │ │ │ │ ├── DomEvent.java │ │ │ │ │ │ ├── Event.java │ │ │ │ │ │ └── MessageEvent.java │ │ │ │ │ ├── interaction │ │ │ │ │ │ ├── MouseContext.java │ │ │ │ │ │ └── PlaneMouseContext.java │ │ │ │ │ ├── layouting │ │ │ │ │ │ ├── LayoutBox.java │ │ │ │ │ │ ├── LayoutBoxI.java │ │ │ │ │ │ ├── LayoutCache.java │ │ │ │ │ │ ├── LayoutContext.java │ │ │ │ │ │ ├── LayoutEngine.java │ │ │ │ │ │ └── LayoutNode.java │ │ │ │ │ └── style │ │ │ │ │ │ ├── ResourceStyle.java │ │ │ │ │ │ ├── Style.java │ │ │ │ │ │ ├── StyleAttributeProxy.java │ │ │ │ │ │ ├── StyleList.java │ │ │ │ │ │ ├── StyleRegistry.java │ │ │ │ │ │ ├── StyleStates.java │ │ │ │ │ │ ├── StyleTarget.java │ │ │ │ │ │ └── StyleType.java │ │ │ │ ├── dom │ │ │ │ │ ├── DomContext.java │ │ │ │ │ ├── attribute │ │ │ │ │ │ ├── AttributeMap.java │ │ │ │ │ │ └── AttributeProxy.java │ │ │ │ │ ├── event │ │ │ │ │ │ └── EventEmitter.java │ │ │ │ │ ├── nodes │ │ │ │ │ │ ├── DomNode.java │ │ │ │ │ │ └── NodeTypeRegistry.java │ │ │ │ │ └── registration │ │ │ │ │ │ ├── DOMPriorityRegistry.java │ │ │ │ │ │ ├── DOMRegistryItem.java │ │ │ │ │ │ └── DOMRegistryItemDynamicProxy.java │ │ │ │ ├── font │ │ │ │ │ ├── ExtendableProperty.java │ │ │ │ │ └── FontHelper.java │ │ │ │ ├── gui │ │ │ │ │ ├── GuiAttachTarget.java │ │ │ │ │ ├── GuiContext.java │ │ │ │ │ ├── GuiEngine.java │ │ │ │ │ ├── GuiInstance.java │ │ │ │ │ ├── GuiScreen.java │ │ │ │ │ ├── SourceInfo.java │ │ │ │ │ ├── canvas │ │ │ │ │ │ ├── CanvasManager.java │ │ │ │ │ │ ├── CanvasRenderingContext2D.java │ │ │ │ │ │ ├── DrawTool.java │ │ │ │ │ │ ├── Path2D.java │ │ │ │ │ │ ├── Point2D.java │ │ │ │ │ │ └── glfw │ │ │ │ │ │ │ ├── CanvasRenderType.java │ │ │ │ │ │ │ ├── CanvasRenderer.java │ │ │ │ │ │ │ └── CanvasTextureState.java │ │ │ │ │ ├── events │ │ │ │ │ │ ├── UIEvent.java │ │ │ │ │ │ └── mouse │ │ │ │ │ │ │ ├── MouseClickEvent.java │ │ │ │ │ │ │ ├── MouseDownEvent.java │ │ │ │ │ │ │ ├── MouseEvent.java │ │ │ │ │ │ │ ├── MouseMoveEvent.java │ │ │ │ │ │ │ └── MouseUpEvent.java │ │ │ │ │ ├── layout │ │ │ │ │ │ ├── EdgeSize2D.java │ │ │ │ │ │ ├── LayoutEngineType.java │ │ │ │ │ │ ├── LayoutEngines.java │ │ │ │ │ │ ├── LayoutNodeContext.java │ │ │ │ │ │ ├── vanilla │ │ │ │ │ │ │ ├── VanillaLayoutEngine.java │ │ │ │ │ │ │ ├── VanillaLayoutHandlers.java │ │ │ │ │ │ │ └── VanillaLayoutNode.java │ │ │ │ │ │ └── yoga │ │ │ │ │ │ │ ├── MayMeasurable.java │ │ │ │ │ │ │ ├── YogaLayoutEngine.java │ │ │ │ │ │ │ ├── YogaLayoutNode.java │ │ │ │ │ │ │ ├── YogaStyleHandlers.java │ │ │ │ │ │ │ ├── api │ │ │ │ │ │ │ ├── YogaAlign.java │ │ │ │ │ │ │ ├── YogaDirection.java │ │ │ │ │ │ │ ├── YogaDisplay.java │ │ │ │ │ │ │ ├── YogaEdge.java │ │ │ │ │ │ │ ├── YogaExample.java │ │ │ │ │ │ │ ├── YogaFileExtractor.java │ │ │ │ │ │ │ ├── YogaFileLocator.java │ │ │ │ │ │ │ ├── YogaFlexDirection.java │ │ │ │ │ │ │ ├── YogaJustify.java │ │ │ │ │ │ │ ├── YogaMeasureFunction.java │ │ │ │ │ │ │ ├── YogaMeasureFunctionTransformer.java │ │ │ │ │ │ │ ├── YogaMeasureMode.java │ │ │ │ │ │ │ ├── YogaMeasureOutput.java │ │ │ │ │ │ │ ├── YogaNode.java │ │ │ │ │ │ │ ├── YogaNodeType.java │ │ │ │ │ │ │ ├── YogaOverflow.java │ │ │ │ │ │ │ ├── YogaPositionType.java │ │ │ │ │ │ │ └── YogaWrap.java │ │ │ │ │ │ │ └── value │ │ │ │ │ │ │ └── ValueMapperBuilder.java │ │ │ │ │ ├── nodes │ │ │ │ │ │ ├── AllGuiNodes.java │ │ │ │ │ │ ├── GuiCanvasNode.java │ │ │ │ │ │ ├── GuiDomNode.java │ │ │ │ │ │ ├── GuiDomRoot.java │ │ │ │ │ │ ├── GuiTextNode.java │ │ │ │ │ │ └── GuiViewNode.java │ │ │ │ │ └── styles │ │ │ │ │ │ ├── AllGuiStyles.java │ │ │ │ │ │ ├── GuiStyleRegistry.java │ │ │ │ │ │ ├── LayoutApplierRegistry.java │ │ │ │ │ │ ├── PixelUnit.java │ │ │ │ │ │ ├── layout │ │ │ │ │ │ ├── AlignType.java │ │ │ │ │ │ ├── BorderStyle.java │ │ │ │ │ │ ├── DisplayType.java │ │ │ │ │ │ ├── EnumStyle.java │ │ │ │ │ │ ├── FlexDirection.java │ │ │ │ │ │ ├── JustifyType.java │ │ │ │ │ │ ├── LayoutStyle.java │ │ │ │ │ │ ├── PositionStyle.java │ │ │ │ │ │ ├── PositionType.java │ │ │ │ │ │ ├── SizeStyle.java │ │ │ │ │ │ └── ZIndexStyle.java │ │ │ │ │ │ └── node │ │ │ │ │ │ ├── BackgroundFilterColor.java │ │ │ │ │ │ ├── BackgroundImageStyle.java │ │ │ │ │ │ ├── BackgroundNineSliceParam.java │ │ │ │ │ │ ├── BackgroundRenderTypeStyle.java │ │ │ │ │ │ ├── BackgroundUVStyle.java │ │ │ │ │ │ ├── FontSizeStyle.java │ │ │ │ │ │ └── SimpleNodeStyleType.java │ │ │ │ └── rendering │ │ │ │ │ ├── AssetImageProvider.java │ │ │ │ │ ├── BackgroundRenderer.java │ │ │ │ │ ├── ImageProvider.java │ │ │ │ │ ├── ImageProviders.java │ │ │ │ │ ├── RenderContext.java │ │ │ │ │ ├── ResourceImageProvider.java │ │ │ │ │ └── VertexBufferCache.java │ │ │ ├── interaction │ │ │ │ └── GuiOperatingPerspectiveScreen.java │ │ │ ├── model │ │ │ │ ├── AnimModelLoader.java │ │ │ │ ├── BedrockModelLoader.java │ │ │ │ ├── BedrockRenderable.java │ │ │ │ ├── ItemTransformMapping.java │ │ │ │ ├── ItemTransformProvider.java │ │ │ │ ├── ModelPreloadManager.java │ │ │ │ ├── Rotationable.java │ │ │ │ ├── anim_instance │ │ │ │ │ ├── AnimCacheManager.java │ │ │ │ │ ├── AnimateTicker.java │ │ │ │ │ ├── AnimateTickerManager.java │ │ │ │ │ ├── AnimationInstance.java │ │ │ │ │ ├── InstanceOf.java │ │ │ │ │ ├── KeyFrameInstance.java │ │ │ │ │ ├── MultiAnimateTicker.java │ │ │ │ │ └── Ticker.java │ │ │ │ ├── anim_json │ │ │ │ │ ├── Animation.java │ │ │ │ │ ├── AnimationFile.java │ │ │ │ │ ├── CatmullRomUtils.java │ │ │ │ │ ├── KeyFrame.java │ │ │ │ │ ├── LoopMode.java │ │ │ │ │ └── Pose.java │ │ │ │ ├── anim_model │ │ │ │ │ ├── AnimBone.java │ │ │ │ │ ├── AnimCube.java │ │ │ │ │ ├── AnimModel.java │ │ │ │ │ └── Animable.java │ │ │ │ └── model_json │ │ │ │ │ ├── BedrockModel.java │ │ │ │ │ ├── Bone.java │ │ │ │ │ ├── BoxLayerProcessor.java │ │ │ │ │ ├── Cube.java │ │ │ │ │ ├── ForAnimModel.java │ │ │ │ │ ├── Geometry.java │ │ │ │ │ ├── GeometryDescription.java │ │ │ │ │ ├── Locator.java │ │ │ │ │ ├── Quad.java │ │ │ │ │ ├── UVCorner.java │ │ │ │ │ ├── UnbakedUV.java │ │ │ │ │ └── Vertex.java │ │ │ └── render │ │ │ │ ├── PoseContext.java │ │ │ │ ├── RenderableItem.java │ │ │ │ ├── RendererUtil.java │ │ │ │ ├── SimpleColor.java │ │ │ │ ├── curve │ │ │ │ ├── CatmullromCurveTemplate.java │ │ │ │ ├── CurveTemplate.java │ │ │ │ └── FunctionCurveTemplate.java │ │ │ │ ├── font │ │ │ │ ├── Font.java │ │ │ │ ├── PivotPosition.java │ │ │ │ └── TextContext.java │ │ │ │ ├── model │ │ │ │ ├── CustomRenderedItemModel.java │ │ │ │ ├── MultiPartModel.java │ │ │ │ └── SimpleModel.java │ │ │ │ └── texture │ │ │ │ ├── GraphicsImage.java │ │ │ │ ├── ImageMask.java │ │ │ │ ├── Matrix.java │ │ │ │ ├── NineSlicedImageMask.java │ │ │ │ ├── RenderTypeBuilder.java │ │ │ │ ├── StaticImage.java │ │ │ │ ├── StaticImageHolder.java │ │ │ │ ├── Texture.java │ │ │ │ ├── Vec2f.java │ │ │ │ └── old │ │ │ │ ├── SimpleTexture.java │ │ │ │ └── WorldTexture.java │ │ ├── config │ │ │ └── SimpleConfig.java │ │ ├── events │ │ │ ├── both │ │ │ │ ├── BothSetupEvent.java │ │ │ │ ├── CommandEvent.java │ │ │ │ ├── EntityAttributeEvent.java │ │ │ │ └── ResourcePackEvent.java │ │ │ ├── client │ │ │ │ ├── AnimationModelRegistryEvent.java │ │ │ │ ├── ClientConnection.java │ │ │ │ ├── ClientSetupEvent.java │ │ │ │ ├── ClientTickEvent.java │ │ │ │ ├── GeometryEvent.java │ │ │ │ ├── InteractionFovEvent.java │ │ │ │ ├── ModelRegistryEvent.java │ │ │ │ ├── PacketEvent.java │ │ │ │ ├── PlayLogEvent.java │ │ │ │ ├── ReloadEvent.java │ │ │ │ ├── RenderTickEvent.java │ │ │ │ └── TextureRegistryEvent.java │ │ │ └── server │ │ │ │ ├── ServerConnectionListeners.java │ │ │ │ ├── ServerLevelEvents.java │ │ │ │ ├── ServerResourceListener.java │ │ │ │ ├── ServerStartingEvents.java │ │ │ │ └── ServerTickEvent.java │ │ ├── javascript │ │ │ ├── Asset.java │ │ │ ├── CompoundTagWrapper.java │ │ │ ├── ContextModuleLoader.java │ │ │ ├── JavascriptApi.java │ │ │ ├── JavascriptContext.java │ │ │ ├── JavascriptThread.java │ │ │ ├── JavascriptThreadGroup.java │ │ │ ├── SideEffectContext.java │ │ │ ├── SynchronizedThread.java │ │ │ ├── Tickable.java │ │ │ ├── commands │ │ │ │ └── JavascriptModuleCommands.java │ │ │ ├── engine │ │ │ │ ├── AbstractJavascriptEngineModule.java │ │ │ │ ├── JavascriptEngineContext.java │ │ │ │ ├── JavascriptEngineModule.java │ │ │ │ ├── JavascriptModuleLoader.java │ │ │ │ ├── JavascriptModuleScope.java │ │ │ │ ├── JavascriptValue.java │ │ │ │ ├── ScriptEngine.java │ │ │ │ ├── ScriptEngines.java │ │ │ │ ├── annotations │ │ │ │ │ ├── HostAccess.java │ │ │ │ │ └── Optimization.java │ │ │ │ └── javet │ │ │ │ │ ├── JavetClassConverter.java │ │ │ │ │ ├── JavetContext.java │ │ │ │ │ ├── JavetJavascriptModule.java │ │ │ │ │ ├── JavetJavascriptValue.java │ │ │ │ │ ├── JavetKasugaConverter.java │ │ │ │ │ ├── JavetModuleAPI.java │ │ │ │ │ ├── JavetScriptEngine.java │ │ │ │ │ ├── JavetValue.java │ │ │ │ │ ├── KasugaJavetConsoleInterceptor.java │ │ │ │ │ ├── RequireFunction.java │ │ │ │ │ └── converter │ │ │ │ │ ├── ClassAccessor.java │ │ │ │ │ ├── FastJavetClassConverter.java │ │ │ │ │ ├── INativeClassProvider.java │ │ │ │ │ ├── MethodOverrideMap.java │ │ │ │ │ └── NativeProxyAccessor.java │ │ │ ├── ffi │ │ │ │ └── ResourceLocationFFIHelper.java │ │ │ ├── module │ │ │ │ ├── JSModuleLoader.java │ │ │ │ └── NodeModuleResolver.java │ │ │ ├── prebuilt │ │ │ │ ├── PrebuiltModule.java │ │ │ │ ├── PrebuiltModuleLoader.java │ │ │ │ ├── nbt │ │ │ │ │ └── NBTModule.java │ │ │ │ ├── process │ │ │ │ │ └── ProcessModule.java │ │ │ │ ├── registry │ │ │ │ │ ├── RegistryPrebuiltModule.java │ │ │ │ │ └── RegistryProxy.java │ │ │ │ ├── timer │ │ │ │ │ ├── KasugaTimer.java │ │ │ │ │ └── TimerPrebuiltModule.java │ │ │ │ └── websocket │ │ │ │ │ ├── WebSocketPrebuiltModule.java │ │ │ │ │ ├── WebsocketEvent.java │ │ │ │ │ ├── WebsocketHandler.java │ │ │ │ │ └── WebsocketInterface.java │ │ │ └── registration │ │ │ │ ├── JavascriptPriorityRegistry.java │ │ │ │ ├── RegistrationRegistry.java │ │ │ │ └── RegistrySet.java │ │ ├── menu │ │ │ ├── GuiMenuManager.java │ │ │ ├── IBlockEntityMenuHolder.java │ │ │ ├── api │ │ │ │ ├── ChannelHandlerProxy.java │ │ │ │ ├── ChannelProxy.java │ │ │ │ ├── GuiMenuOperateProxy.java │ │ │ │ └── GuiMenuUtils.java │ │ │ ├── base │ │ │ │ ├── BindingClient.java │ │ │ │ ├── GuiBinding.java │ │ │ │ ├── GuiBindingTarget.java │ │ │ │ ├── GuiContainerMenu.java │ │ │ │ ├── GuiMenu.java │ │ │ │ ├── GuiMenuRegistry.java │ │ │ │ └── GuiMenuType.java │ │ │ ├── design.md │ │ │ ├── javascript │ │ │ │ ├── JavascriptMenu.java │ │ │ │ ├── JavascriptMenuHandle.java │ │ │ │ ├── JavascriptMenuHandler.java │ │ │ │ └── JavascriptMenuRegistry.java │ │ │ ├── locator │ │ │ │ ├── AbstractChunkBasedLocator.java │ │ │ │ ├── AbstractDynamicChunkBasedLocator.java │ │ │ │ ├── BlockMenuLocator.java │ │ │ │ ├── EntityMenuLocator.java │ │ │ │ ├── GuiMenuHolder.java │ │ │ │ ├── IChunkBasedLocator.java │ │ │ │ ├── LocatedMenuManager.java │ │ │ │ ├── MenuLocator.java │ │ │ │ ├── MenuLocatorRegistry.java │ │ │ │ ├── MenuLocatorType.java │ │ │ │ ├── MenuLocatorTypes.java │ │ │ │ └── ServerChunkMenuLocatorManager.java │ │ │ ├── network │ │ │ │ ├── BlockEntityMenuIdSyncHandler.java │ │ │ │ ├── BlockEntityMenuIdSyncPacket.java │ │ │ │ ├── GuiClientMenuAddress.java │ │ │ │ ├── GuiMenuNetworking.java │ │ │ │ ├── GuiServerMenuAddress.java │ │ │ │ ├── MenuAddressTypes.java │ │ │ │ └── ServerLocatorChangePacket.java │ │ │ └── targets │ │ │ │ ├── ClientScreenTarget.java │ │ │ │ ├── ClientTextureTarget.java │ │ │ │ ├── Target.java │ │ │ │ ├── TargetsClient.java │ │ │ │ └── WorldRendererTarget.java │ │ ├── network │ │ │ ├── C2SPacket.java │ │ │ ├── Packet.java │ │ │ ├── PacketPair.java │ │ │ └── S2CPacket.java │ │ ├── packets │ │ │ └── AllPackets.java │ │ ├── resource │ │ │ ├── CustomResourceReloadListener.java │ │ │ ├── KasugaPackFinder.java │ │ │ ├── KasugaPackResource.java │ │ │ ├── PackBuilder.java │ │ │ ├── RegisterCustomPackEvent.java │ │ │ └── Resources.java │ │ ├── sync │ │ │ ├── ChannelDataSynchronizer.java │ │ │ ├── DataState.java │ │ │ └── DataSynchronizer.java │ │ ├── util │ │ │ ├── Callback.java │ │ │ ├── ComponentHelper.java │ │ │ ├── DevelopEnvFileContainer.java │ │ │ ├── Envs.java │ │ │ ├── LazyRecomputable.java │ │ │ ├── MultipleReader.java │ │ │ ├── SortedArrayList.java │ │ │ ├── Start.java │ │ │ ├── WeakCache.java │ │ │ ├── data_type │ │ │ │ ├── Pair.java │ │ │ │ ├── PrioritizedItem.java │ │ │ │ └── Vec2i.java │ │ │ ├── glob │ │ │ │ ├── GlobFilterNode.java │ │ │ │ ├── GlobMatcher.java │ │ │ │ └── GlobTreeNode.java │ │ │ ├── nbt_json │ │ │ │ ├── AllConversionPairs.java │ │ │ │ ├── CompoundPair.java │ │ │ │ ├── ConversionPair.java │ │ │ │ ├── Converter.java │ │ │ │ ├── ListIsEmptyException.java │ │ │ │ ├── NoAvailableConversionException.java │ │ │ │ ├── TemplateConverter.java │ │ │ │ ├── collection │ │ │ │ │ ├── ByteArrayPair.java │ │ │ │ │ ├── CollectionPair.java │ │ │ │ │ ├── IntArrayPair.java │ │ │ │ │ ├── ListPair.java │ │ │ │ │ └── LongArrayPair.java │ │ │ │ └── primitive │ │ │ │ │ ├── BooleanPair.java │ │ │ │ │ ├── PrimitivePair.java │ │ │ │ │ ├── StringPair.java │ │ │ │ │ └── numeric │ │ │ │ │ ├── BytePair.java │ │ │ │ │ ├── DoublePair.java │ │ │ │ │ ├── FloatPair.java │ │ │ │ │ ├── IntPair.java │ │ │ │ │ ├── LongPair.java │ │ │ │ │ ├── NumericPair.java │ │ │ │ │ └── ShortPair.java │ │ │ └── projectile │ │ │ │ ├── CameraTracker.java │ │ │ │ ├── Grid.java │ │ │ │ ├── MatrixResolveUtil.java │ │ │ │ ├── Panel.java │ │ │ │ ├── PanelRenderer.java │ │ │ │ ├── Ray.java │ │ │ │ └── RayRenderer.java │ │ └── xml │ │ │ ├── IXmlObject.java │ │ │ ├── JsonConvertor.java │ │ │ ├── XmlCompound.java │ │ │ ├── XmlNumber.java │ │ │ ├── XmlProcessor.java │ │ │ └── XmlString.java │ │ ├── example_env │ │ ├── AllClient.java │ │ ├── AllExampleElements.java │ │ ├── OperateScreenCommand.java │ │ ├── block │ │ │ ├── RotationTestBlock.java │ │ │ ├── fluid │ │ │ │ ├── ExampleFluid.java │ │ │ │ └── ExampleFluidBlock.java │ │ │ ├── green_apple │ │ │ │ ├── GreenAppleBlock.java │ │ │ │ ├── GreenAppleItem.java │ │ │ │ └── GreenAppleTile.java │ │ │ └── gui │ │ │ │ ├── GuiExampleBlock.java │ │ │ │ ├── GuiExampleBlockApi.java │ │ │ │ ├── GuiExampleBlockEntity.java │ │ │ │ ├── GuiExampleBlockRenderer.java │ │ │ │ └── GuiExampleMenu.java │ │ ├── client │ │ │ ├── block_entity │ │ │ │ └── renderer │ │ │ │ │ └── GreenAppleTileRenderer.java │ │ │ ├── entity │ │ │ │ └── renderer │ │ │ │ │ └── WuLingRenderer.java │ │ │ ├── item │ │ │ │ └── renderer │ │ │ │ │ └── GreenAppleItemRenderer.java │ │ │ └── screens │ │ │ │ ├── GreenAppleMenu.java │ │ │ │ └── GreenAppleScreen.java │ │ ├── engine │ │ │ ├── Benchmarker.java │ │ │ └── ClassBenchmarker.java │ │ ├── entity │ │ │ ├── DoorControl.java │ │ │ └── WuLingEntity.java │ │ └── network │ │ │ ├── ExampleC2SPacket.java │ │ │ └── ExampleS2CPacket.java │ │ ├── mixins │ │ └── mixin │ │ │ ├── MixinNbtUtils.java │ │ │ ├── MultiPackResourceManagerAccessor.java │ │ │ ├── ReloadableResourceManagerAccessor.java │ │ │ ├── client │ │ │ ├── MixinBlockModel$Deserializer.java │ │ │ ├── MixinBlockModelBinding.java │ │ │ ├── MixinBlockModelShaper.java │ │ │ ├── MixinBlockRenderDispatcher.java │ │ │ ├── MixinModelBakery.java │ │ │ └── MixinTextureManager.java │ │ │ └── resources │ │ │ ├── DelegatingPackResourcesMixin.java │ │ │ ├── FilePackResourceMixin.java │ │ │ └── PathPackResourceMixin.java │ │ └── registrations │ │ ├── BlockEntityRendererBuilder.java │ │ ├── BundledReg.java │ │ ├── EntityRendererBuilder.java │ │ ├── Reg.java │ │ ├── TagReg.java │ │ ├── builders │ │ └── SelfReferenceItemBuilder.java │ │ ├── client │ │ ├── AnimReg.java │ │ ├── KeyBindingReg.java │ │ └── ModelReg.java │ │ ├── common │ │ ├── ArgumentTypeReg.java │ │ ├── BlockEntityReg.java │ │ ├── BlockReg.java │ │ ├── BlockTagReg.java │ │ ├── BucketItemReg.java │ │ ├── ChannelReg.java │ │ ├── CommandReg.java │ │ ├── ConfiguredFeatureReg.java │ │ ├── CreativeTabReg.java │ │ ├── EffectReg.java │ │ ├── EntityReg.java │ │ ├── FluidBlockReg.java │ │ ├── FluidReg.java │ │ ├── FluidTagReg.java │ │ ├── ItemReg.java │ │ ├── ItemTagReg.java │ │ ├── MenuReg.java │ │ ├── OreReg.java │ │ ├── PlacedFeatureReg.java │ │ ├── RecipeReg.java │ │ └── SoundReg.java │ │ ├── exception │ │ └── RegistryElementNotPresentException.java │ │ └── registry │ │ ├── FontRegistry.java │ │ ├── ModelRegistry.java │ │ ├── SimpleRegistry.java │ │ └── TextureRegistry.java │ └── resources │ ├── META-INF │ └── mods.toml │ └── pack.mcmeta └── translation ├── kasugalib.marks.docx └── kasugalib.marks.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Disable autocrlf on generated files, they always generate with LF 2 | # Add any extra files or paths here to make git stop saying they 3 | # are changed when only line endings change. 4 | src/generated/**/.cache/cache text eol=lf 5 | src/generated/**/*.json text eol=lf 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: 提交功能请求 3 | title: "Feature: " 4 | labels: 5 | - feature 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: Describe the problem related to the feature request 10 | description: 请简要地说明是什么问题导致你想要一个新特性。 11 | validations: 12 | required: true 13 | - type: textarea 14 | attributes: 15 | label: Describe the solution you'd like 16 | description: 请说明你希望使用什么样的方法 (比如增加什么功能) 解决上述问题。 17 | validations: 18 | required: true 19 | - type: textarea 20 | attributes: 21 | label: Describe alternatives you've considered 22 | description: 除了上述方法以外,你还考虑过哪些其他的实现方式? 23 | - type: textarea 24 | attributes: 25 | label: Additional context 26 | description: 请描述其他想要补充的信息。 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | 24 | # Files from Forge MDK 25 | forge*changelog.txt 26 | 27 | node_modules 28 | yarn.lock 29 | package-lock.json 30 | 31 | # Javascript Build 32 | javascript/**/lib -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "javascript/core"] 2 | path = javascript/core 3 | url = https://github.com/KasugaLibGroup/KasugaJavascript.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 MegumiKasuga 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | } 3 | 4 | 5 | group = 'kasuga.build' 6 | 7 | repositories { 8 | mavenCentral() 9 | jcenter {} 10 | gradlePluginPortal() 11 | } 12 | 13 | dependencies { 14 | implementation localGroovy() 15 | implementation gradleApi() 16 | implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.1+") 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx7G -Dhttp.readTimeout\=300000 -Dhttp.connectionTimeout\=300000 -Dhttp.socketTimeout\=300000 -Dorg.gradle.internal.http.socketTimeout\=300000 -Dorg.gradle.internal.http.connectionTimeout\=300000 -Dorg.gradle.internal.http.readTimeout\=300000 4 | org.gradle.daemon=false 5 | 6 | curios_version =1.19.2-5.1.1.0 7 | jei_minecraft_version=1.19.2 8 | mixin_version=0.8.5 9 | mixingradle_version = 0.7.+ 10 | jei_version=11.2.0.246 11 | mc_version=1.19.2 12 | 13 | mod_version = 1.19.2-0.21.3 14 | jarVersion = 1.19.2-0.21.3 15 | 16 | registrate_version = MC1.19-1.1.5 17 | 18 | javetLibraryExcluding = false 19 | compileTarget = normal -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/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-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "kasugalib", 4 | "version": "0.1.0", 5 | "description": "The javascript part of KasugaLib", 6 | "main": "index.js", 7 | "repository": "https://github.com/KasugaLibGroup/KasugaLib", 8 | "author": "TimeBather ", 9 | "license": "MIT", 10 | "devDependencies": { 11 | "@types/node": "^22.9.3", 12 | "esbuild": "^0.24.0", 13 | "execa": "^5.1.1", 14 | "glob": "^11.0.0", 15 | "tsx": "^4.19.2" 16 | }, 17 | "scripts": { 18 | "build": "tsx javascript/build.ts" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | } 5 | } 6 | rootProject.name = 'KasugaLib' -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/anim_model_preload.json: -------------------------------------------------------------------------------- 1 | { 2 | "animation": [ 3 | "kasuga_lib:model" 4 | ], 5 | "model": [ 6 | "kasuga_lib:block/test/test_model_complicate", 7 | "kasuga_lib:panel/arrow", 8 | "kasuga_lib:panel/panel", 9 | "kasuga_lib:panel/arrow_2" 10 | ] 11 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/blockstates/test/green_apple.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | 4 | }, 5 | "": { 6 | "model": "kasuga_lib:block/test/blockbench/bb_model_test" 7 | } 8 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/blockstates/test/rotation_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "kasuga_lib:block/test/c70" 5 | }, 6 | "facing=south": { 7 | "model": "kasuga_lib:block/test/c70", 8 | "y": 180 9 | }, 10 | "facing=east": { 11 | "model": "kasuga_lib:block/test/c70", 12 | "y": 270 13 | }, 14 | "facing=west": { 15 | "model": "kasuga_lib:block/test/c70", 16 | "y": 90 17 | } 18 | }, 19 | "model": "kasuga_lib:block/test/rotation_test_model" 20 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/blockstates/test/salt_ore.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "": { 4 | "model": "kasuga_lib:block/test/salt_ore" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/guis.json: -------------------------------------------------------------------------------- 1 | { 2 | "entry": "kasuga_lib:guis/index.js" 3 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/guis/screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0, 2.0 6 | MegumiKasuga 7 | 1.0 8 | an example screen 9 | 10 | 11 | 12 | 13 | 14 | example.text 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/js/.gitignore: -------------------------------------------------------------------------------- 1 | *.js -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/js/modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.js -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "tips.block": "--------------------------------------=== all blocks ===--------------------------------------", 3 | "block.kasuga_lib.green_apple": "Green Apple", 4 | "item.kasuga_lib.example_fluid_bucket": "Example Fluid Bucket", 5 | "internal.kasuga_lib.texture_pack": "Kasuga Lib Internal Texture Pack", 6 | "internal.kasuga_lib.texture_pack.desc": "Internal Texture Pack for kasuga lib's blockbench model loader." 7 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "tips.block": "--------------------------------------=== 方块 ===--------------------------------------", 3 | "block.kasuga_lib.green_apple": "绿色林檎", 4 | "item.kasuga_lib.example_fluid_bucket": "范例液体桶", 5 | "internal.kasuga_lib.texture_pack": "Kasuga Lib 内置纹理包", 6 | "internal.kasuga_lib.texture_pack.desc": "服务于Kasuga Lib内置BlockBench模型加载器的内置纹理包。" 7 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/block/test/blockbench/bb_model_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:blockbench_model", 3 | "model": "kasuga_lib:block/test/blockbench/qj_bogey_main", 4 | "identifier": "bb_test_model" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/block/test/c70.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_model", 3 | "model": "kasuga_lib:block/test/c70", 4 | "texture": "kasuga_lib:block/test/c70", 5 | "identifier": "kasuga_lib:c70", 6 | "render_type": "solid" 7 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/block/test/rotation_test_model.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_model", 3 | "model": "kasuga_lib:block/test/rotation_test_model", 4 | "texture": "kasuga_lib:block/test/rotation_test_model", 5 | "identifier": "kasuga_lib:rotation_test_model", 6 | "render_type": "solid" 7 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/block/test/salt_ore.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "block/cube_all", 3 | "textures": { 4 | "all": "kasuga_lib:block/test/salt_ore" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/block/test/test_model_complicate.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_animated", 3 | "model": "kasuga_lib:block/test/test_model_complicate", 4 | "texture": "kasuga_lib:common/test/test_model_complicate", 5 | "render_type": "translucent", 6 | "geometry": "geometry.unknown", 7 | "identifier": "kasuga_lib:test_model_complicate" 8 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/default/missing_model.geo.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.12.0", 3 | "minecraft:geometry": [ 4 | { 5 | "description": { 6 | "identifier": "geometry.unknown", 7 | "texture_width": 64, 8 | "texture_height": 64, 9 | "visible_bounds_width": 2, 10 | "visible_bounds_height": 2.5, 11 | "visible_bounds_offset": [0, 0.75, 0] 12 | }, 13 | "bones": [ 14 | { 15 | "name": "bb_main", 16 | "pivot": [0, 0, 0], 17 | "cubes": [ 18 | { 19 | "origin": [-8, 0, -8], 20 | "size": [16, 16, 16], 21 | "uv": { 22 | "north": {"uv": [0, 0], "uv_size": [16, 16]}, 23 | "east": {"uv": [0, 16], "uv_size": [16, 16]}, 24 | "south": {"uv": [16, 0], "uv_size": [16, 16]}, 25 | "west": {"uv": [16, 16], "uv_size": [16, 16]}, 26 | "up": {"uv": [0, 32], "uv_size": [16, 16]}, 27 | "down": {"uv": [32, 16], "uv_size": [16, -16]} 28 | } 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/default/missing_model.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_model", 3 | "model": "kasuga_lib:default/missing_model", 4 | "texture": "kasuga_lib:default/missing_model", 5 | "particle": "kasuga_lib:default/particle" 6 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/door/back_door_left.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/door/wuling_back_door_left.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/door/back_door_right.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/door/wuling_back_door_right.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/door/front_door_left.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/door/wuling_front_door_left.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/door/front_door_right.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/door/wuling_front_door_right.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/door/large_back_door.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/door/wuling_large_back_door.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/frame.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/wuling_frame.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/tie.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/wuling_tie.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/wheel/left_wheel.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/wheel/wuling_left_wheel.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/jsons/wheel/right_wheel.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "forge:obj", 3 | "flip_v": true, 4 | "model": "kasuga_lib:models/entity/test/wuling/objs/wheel/wuling_right_wheel.obj" 5 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/door/wuling_back_door_left.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_d6472561-2507-4e59-cb30-6daa7ac9366d 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/door/wuling_back_door_right.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_714d1e78-e1fc-df37-c978-092d62050d93 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/door/wuling_front_door_left.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_65ccf344-c30a-f1db-c5d4-9b3e8c0ba198 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/door/wuling_front_door_right.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_8573418f-5d4d-53a4-631b-ce27ae6a5793 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/door/wuling_large_back_door.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_385bb753-a795-537e-9a7d-9664a172a6dd 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/wheel/wuling_left_wheel.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_fdfaf3e0-f2c6-bf5f-926d-917a4c7bef3c 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/wheel/wuling_right_wheel.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_537c14c7-5846-a7e0-a53c-17839b0c9844 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/wuling_frame.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_2c93d129-cabd-1419-b15f-a11dc3399c39 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/objs/wuling_tie.mtl: -------------------------------------------------------------------------------- 1 | # Made in Blockbench 4.9.4 2 | newmtl m_fca1ff5f-28eb-8d0c-220a-b72e26840033 3 | map_Kd kasuga_lib:entity/wuling_texture 4 | newmtl none -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/wuling_base.json: -------------------------------------------------------------------------------- 1 | { 2 | "multi_part": { 3 | "left_wheel": "kasuga_lib:entity/test/wuling/jsons/wheel/left_wheel", 4 | "left_wheel_2": "kasuga_lib:entity/test/wuling/jsons/wheel/left_wheel", 5 | "right_wheel": "kasuga_lib:entity/test/wuling/jsons/wheel/right_wheel", 6 | "right_wheel_2": "kasuga_lib:entity/test/wuling/jsons/wheel/right_wheel", 7 | "wuling_car": "kasuga_lib:entity/test/wuling/wuling_frame" 8 | } 9 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/entity/test/wuling/wuling_frame.json: -------------------------------------------------------------------------------- 1 | { 2 | "multi_part": { 3 | "frame": "kasuga_lib:entity/test/wuling/jsons/frame", 4 | "tie": "kasuga_lib:entity/test/wuling/jsons/tie", 5 | "front_door_left": "kasuga_lib:entity/test/wuling/jsons/door/front_door_left", 6 | "front_door_right": "kasuga_lib:entity/test/wuling/jsons/door/front_door_right", 7 | "back_door_left": "kasuga_lib:entity/test/wuling/jsons/door/back_door_left", 8 | "back_door_right": "kasuga_lib:entity/test/wuling/jsons/door/back_door_right", 9 | "large_back_door": "kasuga_lib:entity/test/wuling/jsons/door/large_back_door" 10 | } 11 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/item/example_fluid_bucket.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "kasuga_lib:item/example_fluid_bucket" 5 | } 6 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/item/salt_ore.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "kasuga_lib:block/test/salt_ore" 3 | } 4 | -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/panel/arrow.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_animated", 3 | "model": "kasuga_lib:panel/arrow", 4 | "texture": "kasuga_lib:panel/arrow_texture", 5 | "geometry": "geometry.unknown", 6 | "render_type": "translucent", 7 | "identifier": "kasuga_lib:arrow" 8 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/panel/arrow_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_animated", 3 | "model": "kasuga_lib:panel/arrow_2", 4 | "texture": "kasuga_lib:panel/arrow_texture", 5 | "geometry": "geometry.unknown", 6 | "render_type": "translucent", 7 | "identifier": "kasuga_lib:arrow_2" 8 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/panel/panel.geo.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.12.0", 3 | "minecraft:geometry": [ 4 | { 5 | "description": { 6 | "identifier": "geometry.unknown", 7 | "texture_width": 128, 8 | "texture_height": 128, 9 | "visible_bounds_width": 3, 10 | "visible_bounds_height": 1.5, 11 | "visible_bounds_offset": [0, 0.25, 0] 12 | }, 13 | "bones": [ 14 | { 15 | "name": "bb_main", 16 | "pivot": [0, 0, 0], 17 | "cubes": [ 18 | { 19 | "origin": [-11, 0, -14], 20 | "size": [22, 0, 28], 21 | "uv": { 22 | "north": {"uv": [28, 28], "uv_size": [22, 0]}, 23 | "east": {"uv": [0, 28], "uv_size": [28, 0]}, 24 | "south": {"uv": [78, 28], "uv_size": [22, 0]}, 25 | "west": {"uv": [50, 28], "uv_size": [28, 0]}, 26 | "up": {"uv": [28, 0], "uv_size": [22, 28]}, 27 | "down": {"uv": [28, 28], "uv_size": [22, -28]} 28 | } 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/models/panel/panel.json: -------------------------------------------------------------------------------- 1 | { 2 | "loader": "kasuga_lib:bedrock_animated", 3 | "model": "kasuga_lib:panel/panel", 4 | "texture": "kasuga_lib:panel/panel_texture", 5 | "render_type": "translucent", 6 | "geometry": "geometry.unknown", 7 | "identifier": "kasuga_lib:panel" 8 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_flow.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_flow.png.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "animation": {} 3 | } -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_overlay.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_still.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_still.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/fluid/water_still.png.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "animation": { 3 | "frametime": 2 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/test/c70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/test/c70.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/test/rotation_test_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/test/rotation_test_model.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/block/test/salt_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/block/test/salt_ore.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/green_apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/green_apple.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/green_apple_bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/green_apple_bubble.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_complicate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_complicate.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_rotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_rotation.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_simple.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_simple_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/common/test/test_model_simple_2.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/default/missing_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/default/missing_model.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/default/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/default/particle.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/entity/wuling_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/entity/wuling_texture.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/gui/editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/gui/editor.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/gui/no_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/gui/no_img.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/gui/pixel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/gui/pixel.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/item/example_fluid_bucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/item/example_fluid_bucket.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/panel/arrow_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/panel/arrow_texture.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/panel/panel_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/panel/panel_texture.png -------------------------------------------------------------------------------- /src/generated/resources/assets/kasuga_lib/textures/particles/green_particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/assets/kasuga_lib/textures/particles/green_particle.png -------------------------------------------------------------------------------- /src/generated/resources/data/forge/tags/fluids/example_fluid.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "kasuga_lib:example_fluid_still", 4 | "kasuga_lib:example_fluid_flow" 5 | ] 6 | } -------------------------------------------------------------------------------- /src/generated/resources/data/kasuga_lib/forge/biome_modifier/salt_ore.json.disabled: -------------------------------------------------------------------------------- 1 | { 2 | "type": "forge:add_features", 3 | "biomes": "#minecraft:is_overworld", 4 | "features": "kasuga_lib:salt_ore", 5 | "step": "underground_ores" 6 | } 7 | -------------------------------------------------------------------------------- /src/generated/resources/data/kasuga_lib/worldgen/configured_feature/salt_ore.json.disabled: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:ore", 3 | "config": { 4 | "discard_chance_on_air_exposure": 0.0, 5 | "size": 12, 6 | "targets": [ 7 | { 8 | "state": { 9 | "Name": "kasuga_lib:salt_ore" 10 | }, 11 | "target": { 12 | "predicate_type": "minecraft:tag_match", 13 | "tag": "minecraft:stone_ore_replaceables" 14 | } 15 | }, 16 | { 17 | "state": { 18 | "Name": "kasuga_lib:deepslate_salt_ore" 19 | }, 20 | "target": { 21 | "predicate_type": "minecraft:tag_match", 22 | "tag": "minecraft:deepslate_ore_replaceables" 23 | } 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /src/generated/resources/data/kasuga_lib/worldgen/placed_feature/salt_ore_placed.json.disabled: -------------------------------------------------------------------------------- 1 | { 2 | "feature": "kasuga_lib:salt_ore", 3 | "placement": [ 4 | { 5 | "type": "minecraft:count", 6 | "count": 9 7 | }, 8 | { 9 | "type": "minecraft:in_square" 10 | }, 11 | { 12 | "type": "minecraft:height_range", 13 | "height": { 14 | "type": "minecraft:uniform", 15 | "max_inclusive": { 16 | "absolute": 80 17 | }, 18 | "min_inclusive": { 19 | "absolute": -80 20 | } 21 | } 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /src/generated/resources/kasuga.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "priority": 65535, 4 | "package": "kasuga.lib.mixins.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "refmap": "kasuga.refmap.json", 7 | "mixins": [ 8 | "MixinNbtUtils", 9 | "MultiPackResourceManagerAccessor", 10 | "ReloadableResourceManagerAccessor", 11 | "resources.DelegatingPackResourcesMixin", 12 | "resources.FilePackResourceMixin", 13 | "resources.PathPackResourceMixin" 14 | ], 15 | "client": [ 16 | "client.MixinBlockModel$Deserializer", 17 | "client.MixinBlockModelBinding", 18 | "client.MixinBlockModelShaper", 19 | "client.MixinModelBakery", 20 | "client.MixinTextureManager" 21 | ], 22 | "minVersion": "0.8" 23 | } 24 | -------------------------------------------------------------------------------- /src/generated/resources/kasuga_lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/kasuga_lib.png -------------------------------------------------------------------------------- /src/generated/resources/libraries/lwjgl-yoga-3.3.1/windows/x64/org/lwjgl/yoga/lwjgl_yoga.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/libraries/lwjgl-yoga-3.3.1/windows/x64/org/lwjgl/yoga/lwjgl_yoga.dll -------------------------------------------------------------------------------- /src/generated/resources/libraries/lwjgl-yoga-3.3.1/windows/x86/org/lwjgl/yoga/lwjgl_yoga.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/src/generated/resources/libraries/lwjgl-yoga-3.3.1/windows/x86/org/lwjgl/yoga/lwjgl_yoga.dll -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/KasugaLibConfig.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib; 2 | 3 | import kasuga.lib.core.config.SimpleConfig; 4 | 5 | public class KasugaLibConfig { 6 | 7 | public static final SimpleConfig CONFIG = new SimpleConfig() 8 | .client("client_side_settings") 9 | .boolConfig("enable_animation_cache", false) 10 | .registerConfigs(); 11 | 12 | public static void invoke(){} 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/minecraft/ClientAddon.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.minecraft; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.addons.resource.ResourceManagerPackageProvider; 5 | import net.minecraft.client.Minecraft; 6 | 7 | public class ClientAddon { 8 | public static ResourceManagerPackageProvider provider = null; 9 | 10 | public static void init(){ 11 | load(); 12 | } 13 | public static void load(){ 14 | provider = new ResourceManagerPackageProvider( 15 | Minecraft.getInstance().getResourceManager() 16 | ); 17 | 18 | provider.register(KasugaLib.STACKS.JAVASCRIPT.CLIENT_LOADER); 19 | } 20 | 21 | public static void unload(){ 22 | if(provider == null) 23 | return; 24 | provider.unregister(KasugaLib.STACKS.JAVASCRIPT.CLIENT_LOADER); 25 | } 26 | 27 | public static void reload(){ 28 | unload(); 29 | load(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/minecraft/ClientReloadManager.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.minecraft; 2 | 3 | import net.minecraft.server.packs.resources.ResourceManager; 4 | import net.minecraft.server.packs.resources.ResourceManagerReloadListener; 5 | 6 | public class ClientReloadManager implements ResourceManagerReloadListener { 7 | @Override 8 | public void onResourceManagerReload(ResourceManager resourceManager) { 9 | ClientAddon.reload(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/minecraft/ServerAddon.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.minecraft; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.addons.resource.ResourceManagerPackageProvider; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.server.MinecraftServer; 7 | 8 | public class ServerAddon { 9 | public static ResourceManagerPackageProvider provider = null; 10 | public static void init(MinecraftServer server){ 11 | load(server); 12 | } 13 | 14 | public static void load(MinecraftServer server){ 15 | provider = new ResourceManagerPackageProvider( 16 | server.getResourceManager() 17 | ); 18 | 19 | provider.register(KasugaLib.STACKS.JAVASCRIPT.SERVER_LOADER); 20 | } 21 | 22 | public static void unload(){ 23 | if(provider == null) 24 | return; 25 | provider.unregister(KasugaLib.STACKS.JAVASCRIPT.SERVER_LOADER); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/node/EntryType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.node; 2 | 3 | public enum EntryType { 4 | SERVER, 5 | CLIENT, 6 | INITIALIZATION 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/resource/FlatFilesystem.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.resource; 2 | 3 | import java.util.stream.Stream; 4 | 5 | public interface FlatFilesystem extends ResourceProvider{ 6 | public Stream listEntries(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/resource/HierarchicalFilesystem.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.resource; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | public interface HierarchicalFilesystem extends ResourceProvider{ 7 | public List list(String path) throws IOException; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/addons/resource/ResourceProvider.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.addons.resource; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.nio.file.Path; 6 | 7 | public interface ResourceProvider { 8 | public static Path safeResolve(Path first, String ...paths){ 9 | Path iter = first; 10 | for(String path : paths){ 11 | while(path.startsWith("/")) 12 | path = path.substring(1); 13 | iter = iter.resolve(path); 14 | } 15 | if(!first.relativize(iter).startsWith("..")) 16 | return iter; 17 | else 18 | throw new IllegalArgumentException("Path is not safe(relative to the first path)"); 19 | } 20 | public static String firstSplash(String path){ 21 | while(path.startsWith("/")) 22 | path = path.substring(1); 23 | return path; 24 | } 25 | public InputStream open(String path) throws IOException; 26 | public boolean exists(String path); 27 | public boolean isRegularFile(String path); 28 | 29 | public boolean isDirectory(String path); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/annos/Beta.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.annos; 2 | 3 | /** 4 | * This Annotation means the marked element is still under construction 5 | * or still without sufficient verification. 6 | * So these elements would be changed between lib versions. 7 | * Please try not to use these class or methods. 8 | */ 9 | public @interface Beta {} 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/annos/Inner.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.annos; 2 | 3 | /** 4 | * This annotation means that the marked element (class or method) is only for the quaternions lib usage. 5 | * Don't use them in your codes. So as not to cause mistakes or other adverse consequences. 6 | */ 7 | public @interface Inner {} 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/annos/Mandatory.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.annos; 2 | 3 | /** 4 | * This annotation means you should use this method at least once in your registration or other code. 5 | * It's very important for your registration. Your code would not work properly without them. 6 | */ 7 | public @interface Mandatory { } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/annos/Optional.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.annos; 2 | 3 | /** 4 | * This annotation means that the marked method is not necessary for your registration. Your registration could 5 | * run well without them. Only use them if you need their functions. 6 | */ 7 | public @interface Optional {} 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/annos/Util.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.annos; 2 | 3 | /** 4 | * This annotation marks a utility. Any marked element could be used as util and you could use them to boost your coding. 5 | */ 6 | public @interface Util { } 7 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/CustomBlockRenderer.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import com.mojang.blaze3d.vertex.VertexConsumer; 5 | import net.minecraft.client.renderer.RenderType; 6 | import net.minecraft.core.BlockPos; 7 | import net.minecraft.world.level.BlockAndTintGetter; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | import org.openjdk.nashorn.internal.ir.Block; 10 | 11 | import java.util.function.Supplier; 12 | 13 | public abstract class CustomBlockRenderer { 14 | private final Supplier block; 15 | public CustomBlockRenderer(Supplier blockSupplier) { 16 | this.block = blockSupplier; 17 | } 18 | public abstract void render(BlockState state, BlockPos pos, BlockAndTintGetter level 19 | , PoseStack stack, VertexConsumer consumer, RenderType type, int light); 20 | 21 | public T getBlock() { 22 | return block.get(); 23 | } 24 | 25 | public boolean shouldRender(BlockState state, BlockPos pos, BlockAndTintGetter level, RenderType type) { 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/NbtSerializable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public interface NbtSerializable { 6 | void write(CompoundTag nbt); 7 | void read(CompoundTag nbt); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/SimpleCreativeTab.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base; 2 | 3 | import net.minecraft.world.item.CreativeModeTab; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | import javax.annotation.Nonnull; 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * This class is for CreativeModeTab functioning. Without this class we have to override the {@link CreativeModeTab#makeIcon()} 11 | * method over and over again only for apply our icons, which makes no scene. 12 | */ 13 | public class SimpleCreativeTab extends CreativeModeTab { 14 | public final Supplier icon; 15 | 16 | /** 17 | * Use this to get a SimpleCreativeTab 18 | * @param label the name of your tab, usually a translation key. 19 | * @param icon the icon supplier. We would use this to get the icon automatically. 20 | */ 21 | public SimpleCreativeTab(String label, @Nonnull Supplier icon) { 22 | super(label); 23 | this.icon = icon; 24 | } 25 | 26 | @Override 27 | public ItemStack makeIcon() { 28 | return icon.get(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/TickingBlockEntity.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base; 2 | 3 | import kasuga.lib.core.annos.Beta; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.world.level.block.entity.BlockEntity; 6 | import net.minecraft.world.level.block.entity.BlockEntityType; 7 | import net.minecraft.world.level.block.state.BlockState; 8 | 9 | /** 10 | * Don't use. 11 | */ 12 | @Beta 13 | public abstract class TickingBlockEntity extends BlockEntity { 14 | public TickingBlockEntity(BlockEntityType pType, BlockPos pPos, BlockState pBlockState) { 15 | super(pType, pPos, pBlockState); 16 | } 17 | 18 | public abstract void tick(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/commands/CommandHandler.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base.commands; 2 | 3 | import com.mojang.brigadier.context.CommandContext; 4 | import kasuga.lib.registrations.common.ArgumentTypeReg; 5 | import net.minecraft.commands.CommandSourceStack; 6 | 7 | import static kasuga.lib.KasugaLib.MAIN_LOGGER; 8 | 9 | /** 10 | * Extend this class to create your command handler(Use CommandReg.INSTANCE.new) 11 | */ 12 | public abstract class CommandHandler { 13 | protected CommandContext ctx; 14 | 15 | public CommandHandler() { 16 | } 17 | 18 | public T getParameter(String name, Class type){ 19 | String base = ctx.getArgument(name, String.class); 20 | return ArgumentTypeReg.INSTANCE.parse(base, type); 21 | } 22 | 23 | public int executeWithContext(CommandContext ctx){ 24 | this.ctx = ctx; 25 | try { 26 | run(); 27 | } catch (Exception e) { 28 | MAIN_LOGGER.error("Error during command: ", e); 29 | return -1; 30 | } 31 | return 1; 32 | } 33 | 34 | public abstract void run(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/base/item_helper/ExternalProperties.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.base.item_helper; 2 | 3 | import net.minecraft.world.item.Item; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.function.Supplier; 7 | 8 | public class ExternalProperties extends Item.Properties { 9 | 10 | @Nonnull 11 | Supplier craftingRemainderItem = () -> null; 12 | 13 | public ExternalProperties craftRemainder(Supplier craftingReminderItem) { 14 | this.craftingRemainderItem = craftingReminderItem; 15 | return this; 16 | } 17 | 18 | /** 19 | * Don't use, use {@link ExternalProperties#craftRemainder(Supplier)} instead. 20 | * @param pCraftingRemainingItem Don't use. 21 | * @return self. 22 | */ 23 | @Deprecated 24 | @Override 25 | public Item.Properties craftRemainder(Item pCraftingRemainingItem) { 26 | return super.craftRemainder(pCraftingRemainingItem); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/address/ChannelPort.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.address; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | 5 | public abstract class ChannelPort { 6 | public abstract void write(FriendlyByteBuf byteBuf); 7 | public static ChannelPort read(FriendlyByteBuf byteBuf){ 8 | byte type = byteBuf.readByte(); 9 | switch (type){ 10 | case 0: 11 | return FeatureChannelPort.read(byteBuf); 12 | case 1: 13 | return UUIDChannelPort.read(byteBuf); 14 | default: 15 | throw new IllegalArgumentException("Unknown ChannelPort type: " + type); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/address/Label.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.address; 2 | 3 | import kasuga.lib.core.channel.network.NetworkSeriaizableType; 4 | import kasuga.lib.core.channel.network.NetworkSerializable; 5 | 6 | public abstract class Label implements NetworkSerializable { 7 | private final NetworkSeriaizableType type; 8 | 9 | protected Label(NetworkSeriaizableType type) { 10 | this.type = type; 11 | } 12 | @Override 13 | public NetworkSeriaizableType getType() { 14 | return type; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/address/LabelType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.address; 2 | 3 | import kasuga.lib.core.channel.network.NetworkSeriaizableType; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | 6 | import java.util.function.Function; 7 | 8 | public class LabelType extends NetworkSeriaizableType { 9 | public LabelType(Function deserializer) { 10 | super(deserializer); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/address/LabelTypeRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.address; 2 | 3 | import kasuga.lib.core.channel.network.NetworkSerializableRegistry; 4 | 5 | public class LabelTypeRegistry extends NetworkSerializableRegistry> { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/network/NetworkSerializable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | 5 | public interface NetworkSerializable { 6 | public void write(FriendlyByteBuf byteBuf); 7 | public NetworkSeriaizableType getType(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/network/address/MinecraftClientPlayerAddress.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.network.address; 2 | 3 | import kasuga.lib.core.channel.address.Label; 4 | import kasuga.lib.core.channel.network.NetworkSeriaizableType; 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraft.server.level.ServerPlayer; 7 | 8 | public class MinecraftClientPlayerAddress extends Label { 9 | private ServerPlayer player; 10 | 11 | public MinecraftClientPlayerAddress(ServerPlayer player){ 12 | this(); 13 | this.player = player; 14 | } 15 | 16 | public MinecraftClientPlayerAddress(FriendlyByteBuf byteBuf) { 17 | this(); 18 | throw new UnsupportedOperationException(); 19 | } 20 | 21 | public MinecraftClientPlayerAddress() { 22 | super(NetworkAddressTypes.PLAYER_ADDRESS); 23 | } 24 | 25 | @Override 26 | public void write(FriendlyByteBuf byteBuf) { 27 | throw new UnsupportedOperationException(); 28 | } 29 | 30 | public ServerPlayer getPlayer() { 31 | return player; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/network/address/MinecraftServerAddress.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.network.address; 2 | 3 | import kasuga.lib.core.channel.address.Label; 4 | import kasuga.lib.core.channel.network.NetworkSeriaizableType; 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraftforge.common.util.Lazy; 7 | 8 | import java.util.Objects; 9 | 10 | public class MinecraftServerAddress extends Label { 11 | int x; 12 | public static final Lazy INSTANCE = Lazy.of(()->new MinecraftServerAddress()); 13 | protected MinecraftServerAddress() { 14 | super(NetworkAddressTypes.SERVER); 15 | } 16 | 17 | public MinecraftServerAddress(FriendlyByteBuf byteBuf) { 18 | this(); 19 | } 20 | 21 | @Override 22 | public void write(FriendlyByteBuf byteBuf) {} 23 | 24 | @Override 25 | public boolean equals(Object object) { 26 | if (this == object) return true; 27 | return object != null && getClass() == object.getClass(); 28 | } 29 | 30 | @Override 31 | public int hashCode() { 32 | return 25565; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/packets/ChannelNetworkPacket.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.packets; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.KasugaLibStacks; 5 | import kasuga.lib.registrations.common.ChannelReg; 6 | 7 | public class ChannelNetworkPacket { 8 | public final ChannelReg channelReg = new ChannelReg("channel") 9 | .brand("1.0") 10 | .loadPacket(C2SChannelConnectionPacket.class, C2SChannelConnectionPacket::new) 11 | .loadPacket(S2CChannelConnectionPacket.class, S2CChannelConnectionPacket::new) 12 | .loadPacket(C2SChannelMessagePacket.class, C2SChannelMessagePacket::new) 13 | .loadPacket(S2CChannelMessagePacket.class, S2CChannelMessagePacket::new) 14 | .loadPacket(C2SChannelStateChangePacket.class, C2SChannelStateChangePacket::new) 15 | .loadPacket(S2CChannelStateChangePacket.class, S2CChannelStateChangePacket::new) 16 | .submit(KasugaLib.STACKS.REGISTRY); 17 | 18 | public static void invoke(){} 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/packets/S2CChannelMessagePacket.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.packets; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.network.S2CPacket; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.nbt.CompoundTag; 7 | import net.minecraft.network.FriendlyByteBuf; 8 | 9 | public class S2CChannelMessagePacket extends S2CPacket { 10 | long networkId; 11 | CompoundTag message; 12 | boolean isConnectionSender; 13 | 14 | public S2CChannelMessagePacket(long channelId, CompoundTag message, boolean isConnectionSender) { 15 | this.networkId = channelId; 16 | this.message = message; 17 | this.isConnectionSender = isConnectionSender; 18 | } 19 | 20 | public S2CChannelMessagePacket(FriendlyByteBuf buf) { 21 | this.networkId = buf.readLong(); 22 | this.message = buf.readNbt(); 23 | } 24 | 25 | @Override 26 | public void handle(Minecraft minecraft) { 27 | KasugaLib.STACKS.CHANNEL.client().onMessage(networkId, message, isConnectionSender); 28 | } 29 | 30 | @Override 31 | public void encode(FriendlyByteBuf buf) { 32 | buf.writeLong(networkId); 33 | buf.writeNbt(message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelCloseListener.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | public interface ChannelCloseListener { 4 | public void onClose(Channel channel); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelHandle.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public interface ChannelHandle { 6 | void setHandler(ChannelHandler newHandler); 7 | void sendMessage(CompoundTag message); 8 | void close(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelHandler.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public interface ChannelHandler { 6 | default void onChannelEstabilished(ChannelHandle channel){}; 7 | default void onChannelMessage(ChannelHandle channel, CompoundTag payload){} 8 | default void onChannelClose(ChannelHandle channel){} 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelReciever.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | public interface ChannelReciever { 4 | public void $onConnect(Channel channel); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelSocket.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public interface ChannelSocket { 6 | public void onMessage(CompoundTag message); 7 | public void onEstablished(); 8 | public void onClose(); 9 | 10 | void setChannel(Channel channel); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/ChannelStatus.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | public enum ChannelStatus { 4 | PENDING(0x00), 5 | ESTABLISHED(0x01), 6 | CLOSED(0x02); 7 | private final int index; 8 | ChannelStatus(int index){ 9 | this.index = index; 10 | } 11 | 12 | public static ChannelStatus fromInt(int i) { 13 | switch (i) { 14 | case 0x00: 15 | return PENDING; 16 | case 0x01: 17 | return ESTABLISHED; 18 | case 0x02: 19 | return CLOSED; 20 | default: 21 | return null; 22 | } 23 | } 24 | 25 | public int toInt() { 26 | return index; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/peer/FeaturedChannelPeer.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.peer; 2 | 3 | import kasuga.lib.core.channel.address.ChannelPort; 4 | import kasuga.lib.core.channel.address.Label; 5 | 6 | import java.util.HashMap; 7 | import java.util.function.Function; 8 | 9 | public class FeaturedChannelPeer extends ChannelPeer { 10 | public FeaturedChannelPeer(Label address) { 11 | super(address); 12 | } 13 | 14 | HashMap> openedPorts = new HashMap<>(); 15 | 16 | public void openPort(ChannelPort port, Function handler){ 17 | openedPorts.put(port, handler); 18 | } 19 | 20 | public void closePort(ChannelPort port){ 21 | openedPorts.remove(port); 22 | } 23 | 24 | @Override 25 | protected boolean onConnect(ChannelPeerSocketServer server) { 26 | ChannelPort port = server.getChannel().destination().getPort(); 27 | if(openedPorts.containsKey(port)){ 28 | server.setHandler(openedPorts.get(port).apply(server)); 29 | return true; 30 | } 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/DropRouteTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.peer.Channel; 4 | 5 | public class DropRouteTarget implements RouteTarget { 6 | public static DropRouteTarget instance = new DropRouteTarget(); 7 | 8 | @Override 9 | public void distribute(Channel channel, RouteRuleManager manager) { 10 | channel.close(); 11 | return; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/ForwardRouteTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.peer.Channel; 4 | import kasuga.lib.core.channel.peer.ChannelReciever; 5 | 6 | public class ForwardRouteTarget implements RouteTarget { 7 | private final ChannelReciever reciever; 8 | 9 | public ForwardRouteTarget(ChannelReciever reciever) { 10 | this.reciever = reciever; 11 | } 12 | 13 | @Override 14 | public void distribute(Channel channel, RouteRuleManager manager) { 15 | reciever.$onConnect(channel); 16 | } 17 | 18 | public static ForwardRouteTarget create(ChannelReciever reciever) { 19 | return new ForwardRouteTarget(reciever); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/RouteRule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.address.LabelType; 4 | import kasuga.lib.core.channel.peer.Channel; 5 | 6 | import java.util.Optional; 7 | 8 | public interface RouteRule { 9 | public Optional route(Channel channel); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/RouteRuleManager.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.peer.Channel; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | public class RouteRuleManager { 10 | List rules = new ArrayList<>(); 11 | public void sendPacket(Channel channel) { 12 | for (RouteRule rule : rules) { 13 | Optional target = rule.route(channel); 14 | if(target.isPresent()){ 15 | target.get().distribute(channel, this); 16 | return; 17 | } 18 | } 19 | } 20 | 21 | public void addRule(RouteRule rule) { 22 | rules.add(rule); 23 | } 24 | 25 | public void removeRule(RouteRule rule) { 26 | rules.remove(rule); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/RouteTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.peer.Channel; 4 | 5 | public interface RouteTarget { 6 | public void distribute(Channel channel, RouteRuleManager manager); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/RouteTargets.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.address.Label; 4 | import kasuga.lib.core.channel.peer.Channel; 5 | import kasuga.lib.core.channel.peer.ChannelReciever; 6 | 7 | import java.util.function.Function; 8 | 9 | public class RouteTargets { 10 | public static final DropRouteTarget DROP = DropRouteTarget.instance; 11 | 12 | public ForwardRouteTarget to(ChannelReciever receiver) { 13 | return new ForwardRouteTarget(receiver); 14 | } 15 | 16 | public ForwardAndTransformAddressTarget to(ChannelReciever receiver, Function transferFunction) { 17 | return new ForwardAndTransformAddressTarget(receiver, transferFunction); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/channel/route/TargetLabelMatchRule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.channel.route; 2 | 3 | import kasuga.lib.core.channel.address.LabelType; 4 | import kasuga.lib.core.channel.peer.Channel; 5 | 6 | import java.util.Optional; 7 | 8 | public class TargetLabelMatchRule implements RouteRule{ 9 | RouteTarget target; 10 | LabelType type; 11 | @Override 12 | public Optional route(Channel channel) { 13 | if(channel.destination().address().getType() == type) 14 | return Optional.of(target); 15 | return Optional.empty(); 16 | } 17 | 18 | public TargetLabelMatchRule(RouteTarget target, LabelType type) { 19 | this.target = target; 20 | this.type = type; 21 | } 22 | 23 | public static TargetLabelMatchRule create(LabelType type, RouteTarget target) { 24 | return new TargetLabelMatchRule(target, type); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/infrastructure/AnimAssignable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.infrastructure; 2 | 3 | import interpreter.compute.data.Namespace; 4 | 5 | import java.util.Map; 6 | 7 | public interface AnimAssignable { 8 | void assign(String codec, float value); 9 | boolean isAssignable(); 10 | Namespace getNamespace(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/infrastructure/AnimationElement.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.infrastructure; 2 | 3 | import java.util.function.Predicate; 4 | 5 | public abstract class AnimationElement { 6 | private final String key; 7 | public AnimationElement(String key) { 8 | this.key = key; 9 | } 10 | 11 | public String key(){return key;} 12 | public abstract boolean isAssignable(); 13 | public abstract boolean isValid(); 14 | public abstract void assign(String codec, float value); 15 | public abstract void init(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/neo_neo/rotation/LinearRotation.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.neo_neo.rotation; 2 | 3 | import kasuga.lib.core.client.animation.neo_neo.InterpolationUtil; 4 | import net.minecraft.world.phys.Vec3; 5 | 6 | public class LinearRotation extends Rotation { 7 | public LinearRotation(Vec3 data, float startTime, float endTime, boolean degree) { 8 | super(data, startTime, endTime, degree); 9 | } 10 | 11 | @Override 12 | public Vec3 getPercentage(float percentage) { 13 | return InterpolationUtil.linear(this.data, percentage); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/neo_neo/scaling/LinearScaling.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.neo_neo.scaling; 2 | 3 | import net.minecraft.world.phys.Vec3; 4 | 5 | public class LinearScaling extends Scaling { 6 | 7 | public LinearScaling(Vec3 data, float startTime, float endTime) { 8 | super(data, startTime, endTime); 9 | } 10 | 11 | public void setScale(Vec3 scale) { 12 | super.setData(scale); 13 | } 14 | 15 | public Vec3 getScale() { 16 | return getData(); 17 | } 18 | 19 | public void scale(Vec3 scale) { 20 | this.setScale(getScale().multiply(scale)); 21 | } 22 | 23 | @Override 24 | public Vec3 getPercentage(float percentage) { 25 | return STARTER.add(STARTER.subtract(getData()).scale(percentage)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/neo_neo/scaling/Scaling.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.neo_neo.scaling; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import kasuga.lib.core.client.animation.neo_neo.VectorUtil; 5 | import kasuga.lib.core.client.animation.neo_neo.base.Movement; 6 | import kasuga.lib.core.client.animation.neo_neo.point.PivotPoint; 7 | import kasuga.lib.core.client.animation.neo_neo.point.Point; 8 | import net.minecraft.world.phys.Vec3; 9 | 10 | public abstract class Scaling extends Movement { 11 | public static final Vec3 STARTER = new Vec3(1, 1, 1); 12 | 13 | public Scaling(Vec3 data, float startTime, float endTime) { 14 | super(data, startTime, endTime); 15 | } 16 | 17 | @Override 18 | public void move(float time, PoseStack pose) { 19 | VectorUtil.scale(pose, getPercentage(calculateTime(time))); 20 | } 21 | 22 | @Override 23 | public void apply(PivotPoint point, float time) { 24 | if (point instanceof Point p) 25 | p.scale(getPercentage(calculateTime(time))); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/neo_neo/translation/LinearTranslation.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.neo_neo.translation; 2 | 3 | import net.minecraft.world.phys.Vec3; 4 | 5 | public class LinearTranslation extends Translation { 6 | public LinearTranslation(Vec3 data, float startTime, float endTime) { 7 | super(data, startTime, endTime); 8 | } 9 | 10 | @Override 11 | public Vec3 getPercentage(float percentage) { 12 | return data.scale(percentage); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/animation/neo_neo/translation/Translation.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.animation.neo_neo.translation; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import kasuga.lib.core.client.animation.neo_neo.VectorUtil; 5 | import kasuga.lib.core.client.animation.neo_neo.base.Movement; 6 | import kasuga.lib.core.client.animation.neo_neo.point.PivotPoint; 7 | import net.minecraft.world.phys.Vec3; 8 | 9 | public abstract class Translation extends Movement { 10 | public Translation(Vec3 data, float startTime, float endTime) { 11 | super(data, startTime, endTime); 12 | } 13 | 14 | @Override 15 | public void move(float time, PoseStack pose) { 16 | VectorUtil.translate(pose, getPercentage(calculateTime(time))); 17 | } 18 | 19 | public void translate(Vec3 vec3) { 20 | this.data = this.data.add(vec3); 21 | } 22 | 23 | public void translate(double x, double y, double z) { 24 | this.data = this.data.add(x, y, z); 25 | } 26 | 27 | @Override 28 | public void apply(PivotPoint point, float time) { 29 | point.translate(getPercentage(calculateTime(time))); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim/Channel.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | public enum Channel { 6 | 7 | ROTATION("rotation"), 8 | POSITION("position"), 9 | SCALE("scale"); 10 | 11 | public final String name; 12 | 13 | Channel(String name) { 14 | this.name = name; 15 | } 16 | 17 | public static @Nullable Channel get(String name) { 18 | for (Channel c : Channel.values()) { 19 | if (c.name.equals(name)) 20 | return c; 21 | } 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim/LoopMode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim; 2 | 3 | public enum LoopMode { 4 | 5 | ONCE("once", 0, false, false), 6 | HOLD("hold", 1, true, false), 7 | LOOP("loop", 2, false, true); 8 | 9 | public final String name; 10 | public final int index; 11 | public final boolean stayAtLast, continueAnimate; 12 | 13 | LoopMode(String name, int index, boolean stayAtLast, boolean continueAnimate) { 14 | this.name = name; 15 | this.index = index; 16 | this.stayAtLast = stayAtLast; 17 | this.continueAnimate = continueAnimate; 18 | } 19 | 20 | public static LoopMode get(String name) { 21 | for (LoopMode loopMode : LoopMode.values()) { 22 | if (loopMode.name.equals(name)) { 23 | return loopMode; 24 | } 25 | } 26 | return ONCE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim/interpolation/InterpolationType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim.interpolation; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum InterpolationType { 7 | 8 | LINEAR(50, new Linear()), 9 | BEZIER(25, new Bezier()), 10 | CRS(0, new CatmullRom()), 11 | STEP(75, new Step()); 12 | 13 | private final Interpolation interpolation; 14 | private final String name; 15 | private final int priority; 16 | 17 | InterpolationType(int priority, Interpolation interpolation) { 18 | this.interpolation = interpolation; 19 | this.name = interpolation.getName(); 20 | this.priority = priority; 21 | } 22 | 23 | public static InterpolationType get(String name) { 24 | for (InterpolationType type : InterpolationType.values()) { 25 | if (type.name.equals(name)) { 26 | return type; 27 | } 28 | } 29 | return STEP; 30 | } 31 | 32 | public static InterpolationType getMinPriority(InterpolationType left, InterpolationType right) { 33 | return left.getPriority() <= right.getPriority() ? left : right; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim/interpolation/Step.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim.interpolation; 2 | 3 | import com.mojang.math.Vector3f; 4 | import kasuga.lib.core.client.block_bench_model.anim.Animator; 5 | import kasuga.lib.core.client.block_bench_model.anim.KeyFrame; 6 | 7 | public class Step extends Interpolation { 8 | 9 | public Step() { 10 | super("step"); 11 | } 12 | 13 | @Override 14 | public Vector3f interpolate(Animator animator, KeyFrame pre, KeyFrame next, float time) { 15 | Vector3f result = stepOnKeyFrame(pre, next, time); 16 | if (result != null) return result; 17 | return pre.getPostDataPoint(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim_model/ElementCollection.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim_model; 2 | 3 | import net.minecraftforge.api.distmarker.Dist; 4 | import net.minecraftforge.api.distmarker.OnlyIn; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.HashMap; 9 | import java.util.UUID; 10 | 11 | @OnlyIn(Dist.CLIENT) 12 | public interface ElementCollection { 13 | 14 | HashMap getChildren(); 15 | 16 | default @Nullable AnimElement getChild(@NotNull UUID uuid) { 17 | return getChildren().getOrDefault(uuid, null); 18 | } 19 | 20 | default boolean hasChild(@NotNull UUID uuid) { 21 | return getChildren().containsKey(uuid); 22 | } 23 | 24 | default void addChild(@NotNull UUID uuid, @NotNull AnimElement child) { 25 | getChildren().put(uuid, child); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/anim_model/Renderable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.anim_model; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import com.mojang.blaze3d.vertex.VertexConsumer; 5 | import kasuga.lib.core.client.render.SimpleColor; 6 | import net.minecraft.client.renderer.MultiBufferSource; 7 | import net.minecraftforge.api.distmarker.Dist; 8 | import net.minecraftforge.api.distmarker.OnlyIn; 9 | 10 | @OnlyIn(Dist.CLIENT) 11 | public interface Renderable { 12 | 13 | void render(PoseStack pose, VertexConsumer consumer, SimpleColor color, int light, int overlay); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/json_data/BlockBenchMeta.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.json_data; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | import org.openjdk.nashorn.internal.objects.annotations.Getter; 7 | 8 | @OnlyIn(Dist.CLIENT) 9 | public class BlockBenchMeta { 10 | 11 | private final String formatVersion, modelFormat; 12 | private final boolean boxUV; 13 | 14 | public BlockBenchMeta(JsonObject json) { 15 | this.formatVersion = json.get("format_version").getAsString(); 16 | this.modelFormat = json.get("model_format").getAsString(); 17 | this.boxUV = json.get("box_uv").getAsBoolean(); 18 | } 19 | 20 | public String getFormatVersion() { 21 | return formatVersion; 22 | } 23 | 24 | public String getModelFormat() { 25 | return modelFormat; 26 | } 27 | 28 | public boolean isBoxUV() { 29 | return boxUV; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/json_data/IElement.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.json_data; 2 | 3 | import com.mojang.math.Vector3f; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | import java.util.UUID; 8 | 9 | @OnlyIn(Dist.CLIENT) 10 | public interface IElement { 11 | 12 | String getName(); 13 | Vector3f getPivot(); 14 | int getPreviewColorType(); 15 | UUID getId(); 16 | boolean isExport(); 17 | boolean isLocked(); 18 | boolean isVisibility(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/block_bench_model/model/ModelElement.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.block_bench_model.model; 2 | 3 | import com.mojang.math.Vector3f; 4 | import kasuga.lib.core.client.render.texture.Vec2f; 5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 6 | import net.minecraft.client.resources.model.Material; 7 | import net.minecraft.client.resources.model.ModelState; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | import net.minecraftforge.client.model.IModelBuilder; 11 | 12 | import java.util.UUID; 13 | import java.util.function.Function; 14 | 15 | @OnlyIn(Dist.CLIENT) 16 | public interface ModelElement { 17 | 18 | UUID getId(); 19 | String getName(); 20 | Vector3f getPivot(); 21 | Vector3f getRotation(); 22 | boolean isRender(); 23 | 24 | default TransformContext transform(TransformContext fromParent) { 25 | return fromParent.transform(getRotation(), getPivot()); 26 | } 27 | 28 | void addQuads(IModelBuilder modelBuilder, ModelState modelTransform, 29 | TransformContext transform, Vec2f resolution, 30 | Function spriteGetter); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/commands/GuiScreenHelper.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.commands; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import kasuga.lib.KasugaLib; 5 | import kasuga.lib.core.client.frontend.gui.GuiInstance; 6 | import kasuga.lib.core.client.frontend.gui.GuiScreen; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.resources.ResourceLocation; 9 | 10 | import java.util.UUID; 11 | 12 | public class GuiScreenHelper { 13 | public static void attach(UUID instanceId){ 14 | GuiInstance instance = KasugaLib.STACKS.GUI.orElseThrow().getInstanceById(instanceId).get(); 15 | if(instance == null) 16 | return; 17 | RenderSystem.recordRenderCall(()->{ 18 | Minecraft.getInstance().setScreen(new GuiScreen(instance)); 19 | }); 20 | } 21 | 22 | public static void createAndAttach(ResourceLocation location){ 23 | RenderSystem.recordRenderCall(()->{ 24 | Minecraft.getInstance().setScreen(KasugaLib.STACKS.GUI.get().create(location).createScreen()); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/commands/MetroLoaderModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.commands; 2 | 3 | import kasuga.lib.core.addons.node.AssetReader; 4 | import kasuga.lib.core.addons.node.NodePackage; 5 | import kasuga.lib.core.javascript.engine.AbstractJavascriptEngineModule; 6 | import kasuga.lib.core.javascript.engine.JavascriptEngineModule; 7 | 8 | public class MetroLoaderModule extends AbstractJavascriptEngineModule { 9 | private MetroModuleInfo metroInfo; 10 | MetroLoaderModule(MetroModuleInfo info){ 11 | metroInfo = info; 12 | } 13 | 14 | @Override 15 | public Object getFeature(String name) { 16 | if(name == "metro"){ 17 | return metroInfo; 18 | } 19 | return super.getFeature(name); 20 | } 21 | 22 | @Override 23 | public void setAssetReader(AssetReader reader) {} 24 | 25 | @Override 26 | public String getAbsoultePath() { 27 | return ""; 28 | } 29 | 30 | @Override 31 | public NodePackage getPackage() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public String getDirectoryName() { 37 | return ""; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/commands/MetroModuleInfo.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.commands; 2 | 3 | public class MetroModuleInfo { 4 | 5 | private final String serverAddress; 6 | private final MetroServerResourceProvider provider; 7 | 8 | public MetroModuleInfo( 9 | String serverAddress, 10 | MetroServerResourceProvider provider 11 | ){ 12 | this.serverAddress = serverAddress; 13 | this.provider = provider; 14 | } 15 | 16 | public String getServerAddress() { 17 | return serverAddress; 18 | } 19 | 20 | public MetroServerResourceProvider getProvider() { 21 | return provider; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/event/DomEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.event; 2 | 3 | import kasuga.lib.core.client.frontend.dom.nodes.DomNode; 4 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 5 | 6 | public abstract class DomEvent extends Event{ 7 | protected final DomNode currentTarget; 8 | protected final DomNode target; 9 | protected boolean propagationStopped = false; 10 | protected DomEvent(DomNode currentTarget, DomNode target, boolean trusted) { 11 | super(trusted); 12 | this.currentTarget = currentTarget; 13 | this.target = target; 14 | } 15 | @HostAccess.Export 16 | public void stopPropagation(){ 17 | this.propagationStopped = true; 18 | } 19 | 20 | @HostAccess.Export 21 | public boolean isPropagationStopped(){ 22 | return propagationStopped; 23 | } 24 | @HostAccess.Export 25 | public DomNode getCurrentTarget(){ 26 | return currentTarget; 27 | } 28 | 29 | @HostAccess.Export 30 | public DomNode getTarget(){ 31 | return target; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/event/Event.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.event; 2 | 3 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 4 | 5 | public abstract class Event { 6 | 7 | protected final boolean trusted; 8 | protected boolean defaultPrevented; 9 | 10 | public Event(boolean trusted){ 11 | this.trusted = trusted; 12 | } 13 | 14 | @HostAccess.Export 15 | public boolean isBubbles(){ 16 | return false; 17 | } 18 | 19 | @HostAccess.Export 20 | public boolean isCancelable(){ 21 | return true; 22 | } 23 | 24 | 25 | @HostAccess.Export 26 | public boolean getDefaultPrevented(){ 27 | return this.defaultPrevented; 28 | } 29 | 30 | @HostAccess.Export 31 | public boolean isTrusted(){ 32 | return trusted; 33 | } 34 | 35 | 36 | @HostAccess.Export 37 | public abstract String getType(); 38 | 39 | 40 | @HostAccess.Export 41 | public void preventDefault(){ 42 | this.defaultPrevented = true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/event/MessageEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.event; 2 | 3 | import com.caoccao.javet.annotations.V8Allow; 4 | import com.caoccao.javet.annotations.V8Convert; 5 | import com.caoccao.javet.enums.V8ConversionMode; 6 | import kasuga.lib.core.javascript.CompoundTagWrapper; 7 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 8 | import net.minecraft.nbt.CompoundTag; 9 | 10 | @V8Convert(mode = V8ConversionMode.AllowOnly) 11 | public class MessageEvent extends Event{ 12 | 13 | private CompoundTag data; 14 | 15 | public MessageEvent(boolean trusted, CompoundTag data) { 16 | super(trusted); 17 | this.data = data; 18 | } 19 | 20 | @HostAccess.Export 21 | @V8Allow 22 | public CompoundTagWrapper getValue(){ 23 | return new CompoundTagWrapper(this.data); 24 | } 25 | 26 | @HostAccess.Export 27 | @V8Allow 28 | @Override 29 | public String getType() { 30 | return "message"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/interaction/MouseContext.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.interaction; 2 | 3 | public interface MouseContext { 4 | int x(); 5 | int y(); 6 | 7 | public static class EmptyMouseContext implements MouseContext{ 8 | 9 | @Override 10 | public int x() { 11 | return 0; 12 | } 13 | 14 | @Override 15 | public int y() { 16 | return 0; 17 | } 18 | } 19 | 20 | public static EmptyMouseContext EMPTY = new EmptyMouseContext(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/interaction/PlaneMouseContext.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.interaction; 2 | 3 | public class PlaneMouseContext implements MouseContext{ 4 | private final int x; 5 | private final int y; 6 | 7 | public PlaneMouseContext(int x, int y) { 8 | this.x = x; 9 | this.y = y; 10 | } 11 | 12 | @Override 13 | public int x() { 14 | return x; 15 | } 16 | 17 | @Override 18 | public int y() { 19 | return y; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/layouting/LayoutEngine.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.layouting; 2 | 3 | import kasuga.lib.core.client.frontend.dom.nodes.DomNode; 4 | import kasuga.lib.core.client.frontend.gui.layout.LayoutEngineType; 5 | 6 | public interface LayoutEngine { 7 | public void init(); 8 | public T createNode(N node,Object source); 9 | public LayoutEngineType getType(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/layouting/LayoutNode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.layouting; 2 | 3 | import kasuga.lib.core.client.frontend.common.style.Style; 4 | import kasuga.lib.core.client.frontend.gui.layout.EdgeSize2D; 5 | 6 | public interface LayoutNode { 7 | public boolean applyChanges(); 8 | public boolean update(); 9 | public void calculate(); 10 | public LayoutBox getPosition(); 11 | public void markDirty(); 12 | public void addChild(int index,LayoutNode node); 13 | 14 | public void removeChild(int index); 15 | 16 | public void removeChild(LayoutNode node); 17 | public void close(); 18 | 19 | EdgeSize2D getBorder(); 20 | 21 | LayoutBox getRelative(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/style/Style.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.style; 2 | 3 | import java.util.Map; 4 | 5 | public abstract class Style { 6 | 7 | public abstract boolean isValid(Map, Style> origin); 8 | 9 | public abstract StyleType getType(); 10 | 11 | public abstract R getTarget(); 12 | 13 | public abstract String getValueString(); 14 | 15 | public abstract P getValue(); 16 | 17 | public String toString(){ 18 | return super.toString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/style/StyleAttributeProxy.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.style; 2 | 3 | import kasuga.lib.core.client.frontend.dom.attribute.AttributeProxy; 4 | 5 | public class StyleAttributeProxy implements AttributeProxy { 6 | private final StyleList list; 7 | 8 | public StyleAttributeProxy(StyleList list){ 9 | this.list = list; 10 | } 11 | @Override 12 | public String get() { 13 | return list.toString(); 14 | } 15 | 16 | @Override 17 | public String set(String value) { 18 | list.clear(); 19 | list.decode(value); 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/style/StyleRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.style; 2 | 3 | 4 | import java.util.HashMap; 5 | 6 | public class StyleRegistry { 7 | 8 | public HashMap> registry = new HashMap<>(); 9 | public HashMap,String> reversal = new HashMap<>(); 10 | 11 | public StyleType getStyle(String name){ 12 | return registry.get(name); 13 | } 14 | 15 | public String getStyleName(StyleType styleType){ 16 | return reversal.get(styleType); 17 | } 18 | 19 | public > T register(String name, T styleType){ 20 | if(registry.containsKey(name)) 21 | throw new IllegalArgumentException("Style already registered"); 22 | registry.put(name,styleType); 23 | reversal.put(styleType,name); 24 | return styleType; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/style/StyleStates.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.style; 2 | 3 | public class StyleStates { 4 | public enum ReadState{ 5 | ROOT, 6 | PARAMETER, 7 | STRING, 8 | ESCAPE 9 | } 10 | 11 | public enum PartState{ 12 | ATTRIBUTE, 13 | VALUE 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/common/style/StyleType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.common.style; 2 | 3 | import java.util.function.Function; 4 | 5 | public interface StyleType,R> { 6 | public T getDefault(); 7 | public T create(String string); 8 | 9 | public static ,R> StyleType of(Function creator, String defaultValue){ 10 | T defaultStyle = creator.apply(defaultValue); 11 | return new StyleType() { 12 | @Override 13 | public T getDefault() { 14 | return defaultStyle; 15 | } 16 | 17 | @Override 18 | public T create(String string) { 19 | return creator.apply(string); 20 | } 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/dom/attribute/AttributeProxy.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.dom.attribute; 2 | 3 | public interface AttributeProxy { 4 | public String get(); 5 | 6 | public String set(String value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/dom/nodes/NodeTypeRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.dom.nodes; 2 | 3 | import kasuga.lib.core.client.frontend.gui.GuiContext; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.function.Function; 8 | 9 | public class NodeTypeRegistry { 10 | Map> registry = new HashMap<>(); 11 | 12 | public void register(String name, Function constructor){ 13 | registry.put(name,constructor); 14 | } 15 | 16 | public T create(String name,GuiContext context){ 17 | if(!registry.containsKey(name)) 18 | throw new IllegalArgumentException("Registry error"); 19 | return registry.get(name).apply(context); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/font/ExtendableProperty.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.font; 2 | 3 | import kasuga.lib.core.util.Callback; 4 | import kasuga.lib.core.util.LazyRecomputable; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public class ExtendableProperty { 9 | 10 | public T thisValue = null; 11 | 12 | public Supplier parentSupplier; 13 | 14 | public Callback updateNotifier; 15 | 16 | public ExtendableProperty(Supplier parentSupplier, Callback updateNotifier){ 17 | this.parentSupplier = parentSupplier; 18 | this.updateNotifier = updateNotifier; 19 | } 20 | 21 | public LazyRecomputable cached = LazyRecomputable.of( 22 | ()-> thisValue == null ? parentSupplier.get() : thisValue 23 | ); 24 | 25 | public void setSize(T value){ 26 | thisValue = value; 27 | cached.clear(); 28 | this.updateNotifier.execute(); 29 | } 30 | 31 | public void notifyUpdate(){ 32 | cached.clear(); 33 | this.updateNotifier.execute(); 34 | } 35 | 36 | public T get(){ 37 | return cached.get(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/SourceInfo.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutBox; 4 | 5 | public class SourceInfo { 6 | public SourceInfo(LayoutBox size){ 7 | this.size = size; 8 | } 9 | public LayoutBox size; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/canvas/CanvasManager.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.canvas; 2 | 3 | import kasuga.lib.core.client.frontend.gui.canvas.glfw.CanvasRenderer; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class CanvasManager { 8 | ArrayList canvasList = new ArrayList<>(); 9 | 10 | public void add(CanvasRenderer canvas){ 11 | this.canvasList.add(canvas); 12 | } 13 | 14 | public void remove(CanvasRenderer canvas){ 15 | this.canvasList.remove(canvas); 16 | } 17 | 18 | public CanvasRenderer create(int width, int height){ 19 | CanvasRenderer renderer = new CanvasRenderer(this, width, height); 20 | this.add(renderer); 21 | return renderer; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/canvas/Path2D.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.canvas; 2 | 3 | public class Path2D { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/canvas/Point2D.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.canvas; 2 | 3 | public record Point2D(float x, float y) { 4 | 5 | public static Point2D ZERO = new Point2D(0, 0); 6 | 7 | @Override 8 | public boolean equals(Object object) { 9 | if (this == object) return true; 10 | if (object == null || getClass() != object.getClass()) return false; 11 | Point2D point2D = (Point2D) object; 12 | return Float.compare(x, point2D.x) == 0 && Float.compare(y, point2D.y) == 0; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/events/UIEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.events; 2 | 3 | import kasuga.lib.core.client.frontend.common.event.DomEvent; 4 | import kasuga.lib.core.client.frontend.dom.nodes.DomNode; 5 | 6 | public abstract class UIEvent extends DomEvent { 7 | protected UIEvent(DomNode currentTarget, DomNode target, boolean trusted) { 8 | super(currentTarget, target, trusted); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/LayoutEngineType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutEngine; 4 | import net.minecraftforge.common.util.Lazy; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public class LayoutEngineType { 9 | private final Lazy factory; 10 | 11 | public LayoutEngineType(Supplier> factory) { 12 | this.factory = Lazy.concurrentOf(()->factory.get().get()); 13 | } 14 | 15 | public T create() { 16 | return factory.get(); 17 | } 18 | 19 | public static LayoutEngineType of(Supplier> factory) { 20 | return new LayoutEngineType<>(factory); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/LayoutEngines.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout; 2 | 3 | import kasuga.lib.core.client.frontend.gui.layout.vanilla.VanillaLayoutEngine; 4 | import kasuga.lib.core.client.frontend.gui.layout.yoga.YogaLayoutEngine; 5 | 6 | public class LayoutEngines { 7 | public static LayoutEngineType YOGA = LayoutEngineType.of(()->YogaLayoutEngine::new); 8 | public static LayoutEngineType VANILLA = LayoutEngineType.of(()-> VanillaLayoutEngine::new); 9 | public static LayoutEngineType DEFAULT = VANILLA; 10 | public static void init(){ 11 | DEFAULT.create().init(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/LayoutNodeContext.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutEngine; 4 | import kasuga.lib.core.client.frontend.common.layouting.LayoutNode; 5 | import kasuga.lib.core.client.frontend.gui.GuiEngine; 6 | import kasuga.lib.core.client.frontend.gui.nodes.GuiDomNode; 7 | 8 | import java.util.Optional; 9 | 10 | public record LayoutNodeContext( 11 | LayoutEngine engine, 12 | GuiDomNode domNode, 13 | T layoutNode 14 | ) { 15 | public Optional cast(Class classType){ 16 | if(classType.isAssignableFrom(layoutNode.getClass())) { 17 | return Optional.of(classType.cast(layoutNode)); 18 | } else { 19 | return Optional.empty(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/vanilla/VanillaLayoutEngine.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.vanilla; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutEngine; 4 | import kasuga.lib.core.client.frontend.common.layouting.LayoutNode; 5 | import kasuga.lib.core.client.frontend.dom.nodes.DomNode; 6 | import kasuga.lib.core.client.frontend.gui.GuiEngine; 7 | import kasuga.lib.core.client.frontend.gui.layout.LayoutEngineType; 8 | import kasuga.lib.core.client.frontend.gui.layout.LayoutEngines; 9 | import kasuga.lib.core.client.frontend.gui.nodes.GuiDomNode; 10 | 11 | public class VanillaLayoutEngine implements LayoutEngine { 12 | @Override 13 | public void init() { 14 | VanillaLayoutHandlers.init(); 15 | } 16 | 17 | @Override 18 | public VanillaLayoutNode createNode(GuiDomNode node, Object source) { 19 | return new VanillaLayoutNode(this, node, source); 20 | } 21 | 22 | @Override 23 | public LayoutEngineType getType() { 24 | return LayoutEngines.VANILLA; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/MayMeasurable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga; 2 | 3 | import kasuga.lib.core.client.frontend.gui.layout.yoga.api.YogaMeasureFunction; 4 | 5 | import java.util.Optional; 6 | 7 | public interface MayMeasurable { 8 | public Optional measure(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/YogaLayoutEngine.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutEngine; 4 | import kasuga.lib.core.client.frontend.gui.layout.LayoutEngineType; 5 | import kasuga.lib.core.client.frontend.gui.layout.LayoutEngines; 6 | import kasuga.lib.core.client.frontend.gui.layout.yoga.api.YogaFileLocator; 7 | import kasuga.lib.core.client.frontend.gui.nodes.GuiDomNode; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.fml.DistExecutor; 10 | 11 | public class YogaLayoutEngine implements LayoutEngine { 12 | 13 | @Override 14 | public YogaLayoutNode createNode(GuiDomNode node, Object source) { 15 | return new YogaLayoutNode(this, node,source); 16 | } 17 | 18 | @Override 19 | public LayoutEngineType getType() { 20 | return LayoutEngines.YOGA; 21 | } 22 | 23 | @Override 24 | public void init() { 25 | YogaStyleHandlers.init(); 26 | DistExecutor.unsafeRunWhenOn(Dist.CLIENT,()-> YogaFileLocator::configureLWJGLPath); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaAlign.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | import static org.lwjgl.util.yoga.Yoga.*; 3 | 4 | public enum YogaAlign { 5 | 6 | AUTO(YGAlignAuto), 7 | FLEX_START(YGAlignFlexStart), 8 | CENTER(YGAlignCenter), 9 | FLEX_END(YGAlignFlexEnd), 10 | STRETCH(YGAlignStretch), 11 | BASELINE(YGAlignBaseline), 12 | SPACE_BETWEEN(YGAlignSpaceBetween), 13 | SPACE_AROUND(YGAlignSpaceAround) 14 | ; 15 | private final int value; 16 | 17 | YogaAlign(int value) { 18 | this.value = value; 19 | } 20 | 21 | public int getValue(){ 22 | return value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaDirection.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import static org.lwjgl.util.yoga.Yoga.*; 4 | 5 | public enum YogaDirection { 6 | LTR(YGDirectionLTR), 7 | RTL(YGDirectionRTL), 8 | INHERIT(YGDirectionInherit) 9 | ; 10 | 11 | private final int value; 12 | 13 | YogaDirection(int value) { 14 | this.value = value; 15 | } 16 | 17 | int getValue(){ 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaDisplay.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import static org.lwjgl.util.yoga.Yoga.YGDisplayFlex; 4 | import static org.lwjgl.util.yoga.Yoga.YGDisplayNone; 5 | 6 | public enum YogaDisplay { 7 | NONE(YGDisplayNone), 8 | FLEX(YGDisplayFlex) 9 | ; 10 | 11 | private final int value; 12 | 13 | YogaDisplay(int value) { 14 | this.value = value; 15 | } 16 | 17 | public int getValue(){ 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaEdge.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import static org.lwjgl.util.yoga.Yoga.*; 4 | 5 | public enum YogaEdge { 6 | LEFT(YGEdgeLeft), 7 | TOP(YGEdgeTop), 8 | RIGHT(YGEdgeRight), 9 | BOTTOM(YGEdgeBottom), 10 | START(YGEdgeStart), 11 | END(YGEdgeEnd), 12 | HORIZONTAL(YGEdgeHorizontal), 13 | VERTICAL(YGEdgeVertical), 14 | ALL(YGEdgeAll) 15 | ; 16 | 17 | private final int value; 18 | 19 | YogaEdge(int value) { 20 | this.value = value; 21 | } 22 | 23 | int getValue(){ 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaFileLocator.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import kasuga.lib.core.util.Envs; 4 | import net.minecraft.CrashReport; 5 | import net.minecraft.client.Minecraft; 6 | import org.lwjgl.system.Configuration; 7 | 8 | import java.io.File; 9 | 10 | public class YogaFileLocator { 11 | 12 | public static void configureLWJGLPath(){ 13 | Configuration.LIBRARY_PATH.set(Configuration.LIBRARY_PATH.get() + File.pathSeparator + YogaFileLocator.getYogaAssemblyDirectory()); 14 | } 15 | 16 | public static String getYogaAssemblyDirectory(){ 17 | if(Envs.isClient()){ 18 | try{ 19 | return YogaFileExtractor.extract() + File.separatorChar + "lwjgl-yoga-3.3.1" + File.separatorChar; 20 | }catch (Exception e){ 21 | Minecraft.crash(CrashReport.forThrowable(e, "Failed to load yoga assembly")); 22 | } 23 | } 24 | throw new IllegalStateException("Illegal environment"); 25 | } 26 | 27 | public static String getDevelopmentLibrariesDirectory(){ 28 | return "../src/generated/resources/libraries/"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaFlexDirection.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import static org.lwjgl.util.yoga.Yoga.*; 4 | 5 | public enum YogaFlexDirection { 6 | COLUMN(YGFlexDirectionColumn), 7 | ROW(YGFlexDirectionRow), 8 | COLUMN_REVERSE(YGFlexDirectionColumnReverse), 9 | ROW_REVERSE(YGFlexDirectionRowReverse), 10 | ; 11 | private final int value; 12 | 13 | YogaFlexDirection(int value) { 14 | this.value = value; 15 | } 16 | 17 | int getValue(){ 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaJustify.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | import static org.lwjgl.util.yoga.Yoga.*; 3 | 4 | public enum YogaJustify { 5 | FLEX_START(YGJustifyFlexStart), 6 | CENTER(YGJustifyCenter), 7 | FLEX_END(YGJustifyFlexEnd), 8 | SPACE_BETWEEN(YGJustifySpaceBetween), 9 | SPACE_AROUND(YGJustifySpaceAround), 10 | SPACE_EVENLY(YGJustifySpaceEvenly) 11 | ; 12 | private final int value; 13 | 14 | YogaJustify(int value) { 15 | this.value = value; 16 | } 17 | 18 | public int getValue(){ 19 | return value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaMeasureFunction.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | public interface YogaMeasureFunction { 4 | /** 5 | * Return a value created by YogaMeasureOutput.make(width, height); 6 | */ 7 | long measure( 8 | YogaNode node, 9 | float width, 10 | YogaMeasureMode widthMode, 11 | float height, 12 | YogaMeasureMode heightMode); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaMeasureFunctionTransformer.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import org.lwjgl.util.yoga.YGMeasureFunc; 4 | import org.lwjgl.util.yoga.YGMeasureFuncI; 5 | 6 | public class YogaMeasureFunctionTransformer { 7 | public static YGMeasureFuncI transform(YogaMeasureFunction function){ 8 | if(function == null){ 9 | throw new NullPointerException("Measure function cannot be null"); 10 | } 11 | return YGMeasureFunc.create((YGMeasureFuncI) (nodePointer,width,widthMode,height,heightMode,size)->{ 12 | long returnVal = function.measure(YogaNode.fromPointer(nodePointer),width,YogaMeasureMode.fromInt(widthMode),height,YogaMeasureMode.fromInt(heightMode)); 13 | size.set(YogaMeasureOutput.getWidth(returnVal),YogaMeasureOutput.getHeight(returnVal)); 14 | }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaMeasureMode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | public enum YogaMeasureMode { 4 | UNDEFINED(0), 5 | EXACTLY(1), 6 | AT_MOST(2); 7 | 8 | private final int mIntValue; 9 | 10 | YogaMeasureMode(int intValue) { 11 | mIntValue = intValue; 12 | } 13 | 14 | public int getValue() { 15 | return mIntValue; 16 | } 17 | 18 | public static YogaMeasureMode fromInt(int value) { 19 | switch (value) { 20 | case 0: return UNDEFINED; 21 | case 1: return EXACTLY; 22 | case 2: return AT_MOST; 23 | default: throw new IllegalArgumentException("Unknown enum value: " + value); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaMeasureOutput.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | public class YogaMeasureOutput { 4 | 5 | public static long make(float width, float height) { 6 | final int wBits = Float.floatToRawIntBits(width); 7 | final int hBits = Float.floatToRawIntBits(height); 8 | return ((long) wBits) << 32 | ((long) hBits); 9 | } 10 | 11 | public static long make(int width, int height) { 12 | return make((float) width, (float) height); 13 | } 14 | 15 | public static float getWidth(long measureOutput) { 16 | return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32))); 17 | } 18 | 19 | public static float getHeight(long measureOutput) { 20 | return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput)); 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaNodeType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | import static org.lwjgl.util.yoga.Yoga.YGNodeTypeDefault; 4 | import static org.lwjgl.util.yoga.Yoga.YGNodeTypeText; 5 | 6 | public enum YogaNodeType { 7 | DEFAULT(YGNodeTypeDefault), 8 | TEXT(YGNodeTypeText) 9 | ; 10 | 11 | private final int value; 12 | 13 | YogaNodeType(int value) { 14 | this.value = value; 15 | } 16 | 17 | int getValue(){ 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaOverflow.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | 3 | 4 | import static org.lwjgl.util.yoga.Yoga.*; 5 | 6 | public enum YogaOverflow { 7 | HIDDEN(YGOverflowHidden), 8 | SCROLL(YGOverflowScroll), 9 | VISIBLE(YGOverflowVisible) 10 | ; 11 | 12 | private final int value; 13 | 14 | YogaOverflow(int value) { 15 | this.value = value; 16 | } 17 | 18 | int getValue(){ 19 | return value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaPositionType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | import static org.lwjgl.util.yoga.Yoga.*; 3 | 4 | public enum YogaPositionType { 5 | STATIC(YGPositionTypeStatic), 6 | ABSOLUTE(YGPositionTypeAbsolute), 7 | RELATIVE(YGPositionTypeRelative), 8 | ; 9 | 10 | private final int value; 11 | 12 | YogaPositionType(int value) { 13 | this.value = value; 14 | } 15 | 16 | 17 | public int getValue(){ 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/layout/yoga/api/YogaWrap.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.layout.yoga.api; 2 | import static org.lwjgl.util.yoga.Yoga.*; 3 | 4 | public enum YogaWrap { 5 | NO_WRAP(YGWrapNoWrap), 6 | WRAP(YGWrapWrap), 7 | REVERSE(YGWrapReverse), 8 | ; 9 | 10 | private final int value; 11 | 12 | YogaWrap(int value) { 13 | this.value = value; 14 | } 15 | 16 | int getValue(){ 17 | return value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/nodes/AllGuiNodes.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.nodes; 2 | 3 | import kasuga.lib.core.client.frontend.dom.nodes.NodeTypeRegistry; 4 | 5 | public class AllGuiNodes { 6 | public static void register(NodeTypeRegistry nodeTypeRegistry) { 7 | nodeTypeRegistry.register("view",GuiViewNode::new); 8 | nodeTypeRegistry.register("text",GuiTextNode::new); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/nodes/GuiDomRoot.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.nodes; 2 | 3 | import com.caoccao.javet.annotations.V8Convert; 4 | import kasuga.lib.core.client.frontend.gui.GuiContext; 5 | 6 | @V8Convert() 7 | public class GuiDomRoot extends GuiDomNode { 8 | public GuiDomRoot(GuiContext context) { 9 | super(context); 10 | this.styles.decode("height:100%;width:100%"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/nodes/GuiViewNode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.nodes; 2 | 3 | import com.caoccao.javet.annotations.V8Convert; 4 | import kasuga.lib.core.client.frontend.gui.GuiContext; 5 | import kasuga.lib.core.client.frontend.rendering.RenderContext; 6 | 7 | @V8Convert() 8 | public class GuiViewNode extends GuiDomNode{ 9 | public GuiViewNode(GuiContext context) { 10 | super(context); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/GuiStyleRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles; 2 | 3 | import kasuga.lib.core.client.frontend.common.style.StyleRegistry; 4 | import kasuga.lib.core.client.frontend.common.style.StyleTarget; 5 | 6 | public class GuiStyleRegistry extends StyleRegistry { 7 | public GuiStyleRegistry(){ 8 | super(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/layout/DisplayType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles.layout; 2 | 3 | 4 | public enum DisplayType { 5 | FLEX("flex"), 6 | UNSET("unset"), 7 | INVALID("invalid") 8 | ; 9 | 10 | DisplayType(String type) {} 11 | 12 | public static DisplayType fromString(String positionType){ 13 | return switch (positionType.toLowerCase()){ 14 | case "flex"->FLEX; 15 | case "unset"->UNSET; 16 | default -> INVALID; 17 | }; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return switch (this){ 23 | case FLEX -> "flex"; 24 | case UNSET -> "unset"; 25 | case INVALID -> "invalid"; 26 | }; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/layout/FlexDirection.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles.layout; 2 | 3 | 4 | public enum FlexDirection { 5 | ROW("row"), 6 | COLUMN("column"), 7 | 8 | ROW_REVERSE("row_reverse"), 9 | COLUMN_REVERSE("column_reverse"), 10 | INVALID("column") 11 | ; 12 | 13 | 14 | FlexDirection(String type) {} 15 | 16 | public static FlexDirection fromString(String flexDirection){ 17 | return switch (flexDirection.toLowerCase()){ 18 | case "row" -> ROW; 19 | case "column" -> COLUMN; 20 | case "row_reverse" -> ROW_REVERSE; 21 | case "column_reverse" -> COLUMN_REVERSE; 22 | default -> INVALID; 23 | }; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return switch (this){ 29 | case ROW -> "row"; 30 | case COLUMN -> "column"; 31 | case ROW_REVERSE -> "row_reverse"; 32 | case COLUMN_REVERSE -> "column_reverse"; 33 | case INVALID -> "invalid"; 34 | }; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/layout/LayoutStyle.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles.layout; 2 | 3 | import kasuga.lib.core.client.frontend.common.layouting.LayoutNode; 4 | import kasuga.lib.core.client.frontend.common.style.Style; 5 | import kasuga.lib.core.client.frontend.common.style.StyleTarget; 6 | import kasuga.lib.core.client.frontend.gui.layout.LayoutNodeContext; 7 | import kasuga.lib.core.client.frontend.gui.nodes.GuiDomNode; 8 | import kasuga.lib.core.client.frontend.gui.styles.LayoutApplierRegistry; 9 | 10 | public abstract class LayoutStyle

extends Style { 11 | @Override 12 | public StyleTarget getTarget() { 13 | return LAYOUT_NODE.create((node)->{ 14 | LayoutApplierRegistry.getInstance().apply(node, this); 15 | }); 16 | } 17 | 18 | public static final StyleTarget.StyleTargetType> LAYOUT_NODE = new StyleTarget.StyleTargetType<>( 19 | (o) -> o instanceof LayoutNodeContext, 20 | (o) -> (LayoutNodeContext) o 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/layout/PositionType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles.layout; 2 | 3 | 4 | public enum PositionType { 5 | STATIC("static"), 6 | ABSOLUTE("absolute"), 7 | RELATIVE("relative"), 8 | INVALID("invalid") 9 | ; 10 | 11 | 12 | PositionType(String type) {} 13 | 14 | public static PositionType fromString(String positionType){ 15 | return switch (positionType.toLowerCase()){ 16 | case "static"->STATIC; 17 | case "absolute"->ABSOLUTE; 18 | case "relative"->RELATIVE; 19 | default -> INVALID; 20 | }; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return switch (this){ 26 | case STATIC -> "static"; 27 | case ABSOLUTE -> "absolute"; 28 | case RELATIVE -> "relative"; 29 | case INVALID -> "invalid"; 30 | }; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/gui/styles/node/SimpleNodeStyleType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.gui.styles.node; 2 | 3 | import kasuga.lib.core.client.frontend.common.style.Style; 4 | import kasuga.lib.core.client.frontend.common.style.StyleTarget; 5 | import kasuga.lib.core.client.frontend.common.style.StyleType; 6 | 7 | import java.util.function.Function; 8 | 9 | public class SimpleNodeStyleType> implements StyleType { 10 | 11 | private final Function creator; 12 | private final T defaultValue; 13 | 14 | SimpleNodeStyleType(Function creator, String defaultValue) { 15 | this.creator = creator; 16 | this.defaultValue = creator.apply(defaultValue); 17 | } 18 | 19 | public static > SimpleNodeStyleType of(Function creator, String defaultValue) { 20 | return new SimpleNodeStyleType<>(creator, defaultValue); 21 | } 22 | 23 | @Override 24 | public T getDefault() { 25 | return defaultValue; 26 | } 27 | 28 | @Override 29 | public T create(String string) { 30 | return creator.apply(string); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/rendering/ImageProvider.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.rendering; 2 | 3 | import kasuga.lib.core.client.render.texture.old.SimpleTexture; 4 | import kasuga.lib.core.client.render.texture.StaticImage; 5 | import kasuga.lib.core.client.render.texture.old.WorldTexture; 6 | 7 | public interface ImageProvider { 8 | WorldTexture getWorldTexture(); 9 | SimpleTexture getSimpleTexture(); 10 | StaticImage getImage(); 11 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/rendering/ImageProviders.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.rendering; 2 | 3 | import kasuga.lib.core.util.data_type.Pair; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | import java.util.HashMap; 7 | import java.util.function.Function; 8 | 9 | public class ImageProviders { 10 | public static HashMap> providers = new HashMap<>(); 11 | 12 | public static ImageProvider get(Pair location) { 13 | Function provider = providers.get(location.getFirst()); 14 | return provider == null ? null : provider.apply(location.getSecond()); 15 | } 16 | 17 | public static void init(){ 18 | providers.put(new ResourceLocation("kasuga_lib","resource"), (name)->new ResourceImageProvider(new ResourceLocation(name))); 19 | providers.put(new ResourceLocation("kasuga_lib","assets"), (name)->new AssetImageProvider(name)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/frontend/rendering/ResourceImageProvider.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.frontend.rendering; 2 | 3 | import kasuga.lib.core.client.render.texture.old.SimpleTexture; 4 | import kasuga.lib.core.client.render.texture.StaticImage; 5 | import kasuga.lib.core.client.render.texture.old.WorldTexture; 6 | import net.minecraft.resources.ResourceLocation; 7 | 8 | import java.io.IOException; 9 | 10 | public class ResourceImageProvider implements ImageProvider { 11 | private final ResourceLocation location; 12 | 13 | public ResourceImageProvider(ResourceLocation location){ 14 | this.location = location; 15 | } 16 | @Override 17 | public WorldTexture getWorldTexture() { 18 | return new WorldTexture(location); 19 | } 20 | 21 | @Override 22 | public SimpleTexture getSimpleTexture() { 23 | return new SimpleTexture(location); 24 | } 25 | 26 | @Override 27 | public StaticImage getImage() { 28 | try { 29 | return StaticImage.createImage(location).get(); 30 | } catch (IOException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/BedrockRenderable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import com.mojang.blaze3d.vertex.VertexConsumer; 5 | import com.mojang.math.Vector3f; 6 | import kasuga.lib.core.client.render.SimpleColor; 7 | import net.minecraftforge.api.distmarker.Dist; 8 | import net.minecraftforge.api.distmarker.OnlyIn; 9 | 10 | import java.util.Map; 11 | 12 | @OnlyIn(Dist.CLIENT) 13 | public interface BedrockRenderable { 14 | Map getChildrens(); 15 | BedrockRenderable getChild(String name); 16 | void applyTranslationAndRotation(PoseStack pose); 17 | void render(PoseStack pose, VertexConsumer consumer, SimpleColor color, int light, int overlay); 18 | default Vector3f convertPivot(Vector3f myPosition, Vector3f parentPosition) { 19 | Vector3f vector3f = myPosition.copy(); 20 | vector3f.sub(parentPosition); 21 | return vector3f; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/anim_instance/InstanceOf.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.anim_instance; 2 | 3 | public @interface InstanceOf { 4 | Class value(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/anim_instance/Ticker.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.anim_instance; 2 | 3 | import net.minecraftforge.api.distmarker.Dist; 4 | import net.minecraftforge.api.distmarker.OnlyIn; 5 | 6 | @OnlyIn(Dist.CLIENT) 7 | public interface Ticker { 8 | 9 | void submit(); 10 | void unload(); 11 | AnimateTicker.TickerType getType(); 12 | void tick(int tick); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/anim_json/LoopMode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.anim_json; 2 | 3 | import net.minecraftforge.api.distmarker.Dist; 4 | import net.minecraftforge.api.distmarker.OnlyIn; 5 | 6 | @OnlyIn(Dist.CLIENT) 7 | public enum LoopMode { 8 | NONE(1), 9 | HOLD_ON_LAST_FRAME(2), 10 | LOOP(3); 11 | 12 | public final int index; 13 | LoopMode(int index){ 14 | this.index = index; 15 | } 16 | 17 | public int getIndex() { 18 | return index; 19 | } 20 | 21 | public static LoopMode fromIndex(int index) { 22 | return switch (index) { 23 | case 2 -> HOLD_ON_LAST_FRAME; 24 | case 3 -> LOOP; 25 | default -> NONE; 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/anim_model/Animable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.anim_model; 2 | 3 | import com.mojang.math.Vector3f; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @OnlyIn(Dist.CLIENT) 8 | public interface Animable { 9 | 10 | void setOffset(Vector3f position); 11 | void setAnimRot(Vector3f rotation); 12 | void setScale(Vector3f scale); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/model_json/ForAnimModel.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.model_json; 2 | 3 | public @interface ForAnimModel { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/model/model_json/Locator.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.model.model_json; 2 | 3 | import com.mojang.math.Vector3f; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @OnlyIn(Dist.CLIENT) 8 | public class Locator { 9 | public final Vector3f position, rotation; 10 | 11 | public Locator(Vector3f position, Vector3f rotation) { 12 | this.rotation = rotation; 13 | this.position = position; 14 | } 15 | 16 | public Locator offset(Vector3f offset) { 17 | Vector3f neoPos = position.copy(); 18 | neoPos.add(offset); 19 | return new Locator(neoPos, rotation); 20 | } 21 | 22 | public Locator copy() { 23 | return new Locator(position.copy(), rotation.copy()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/render/curve/CurveTemplate.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.render.curve; 2 | 3 | import kasuga.lib.core.client.render.texture.Vec2f; 4 | import kasuga.lib.core.util.data_type.Pair; 5 | 6 | import java.util.List; 7 | 8 | public interface CurveTemplate { 9 | List getPointList(); 10 | Pair getRange(); 11 | 12 | default Float getLeft() { 13 | return getRange().getFirst(); 14 | } 15 | 16 | default Float getRight() { 17 | return getRange().getSecond(); 18 | } 19 | void setLeft(float left); 20 | void setRight(float right); 21 | 22 | float getStep(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/render/font/Font.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.render.font; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import net.minecraft.network.chat.Style; 5 | import net.minecraft.resources.ResourceLocation; 6 | 7 | public class Font { 8 | private final ResourceLocation location; 9 | private Style style = Style.EMPTY; 10 | public Font(ResourceLocation location) { 11 | this.location = location; 12 | style.withColor(0xffffff); 13 | if(KasugaLib.STACKS.isTextureRegistryFired()) {loadFont();} 14 | else KasugaLib.STACKS.fontRegistry().stackIn(this); 15 | } 16 | 17 | public Font() { 18 | this.location = null; 19 | } 20 | 21 | public Style getFont() { 22 | return style; 23 | } 24 | 25 | public void loadFont() { 26 | style = Style.EMPTY.withFont(location); 27 | } 28 | 29 | public ResourceLocation getLocation() { 30 | return location; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/client/render/texture/RenderTypeBuilder.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.client.render.texture; 2 | 3 | import net.minecraft.client.renderer.RenderType; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | public interface RenderTypeBuilder { 7 | RenderType build(ResourceLocation location); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/both/BothSetupEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.both; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import net.minecraftforge.client.event.RegisterKeyMappingsEvent; 5 | import net.minecraftforge.eventbus.api.SubscribeEvent; 6 | import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; 7 | 8 | public class BothSetupEvent { 9 | public static void onFMLCommonSetup(FMLCommonSetupEvent event){ 10 | 11 | } 12 | 13 | @SubscribeEvent 14 | public static void RegisterKeyEvent(RegisterKeyMappingsEvent event) { 15 | KasugaLib.STACKS.getRegistries().forEach( 16 | (name, registry) -> { 17 | registry.key().forEach( 18 | ((s, keyBindingReg) -> event.register(keyBindingReg.getMapping())) 19 | ); 20 | } 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/both/CommandEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.both; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.registrations.common.CommandReg; 5 | import net.minecraftforge.event.RegisterCommandsEvent; 6 | import net.minecraftforge.eventbus.api.SubscribeEvent; 7 | import net.minecraftforge.fml.common.Mod; 8 | 9 | 10 | @Mod.EventBusSubscriber(modid = KasugaLib.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) 11 | public class CommandEvent { 12 | @SubscribeEvent 13 | public static void register(RegisterCommandsEvent event){ 14 | CommandReg.register(event.getDispatcher()); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/both/ResourcePackEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.both; 2 | 3 | import kasuga.lib.core.resource.CustomResourceReloadListener; 4 | import net.minecraft.server.commands.DataPackCommand; 5 | import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; 6 | import net.minecraftforge.event.AddReloadListenerEvent; 7 | import net.minecraftforge.eventbus.api.SubscribeEvent; 8 | 9 | public class ResourcePackEvent { 10 | 11 | @SubscribeEvent 12 | public static void onResourcePackReload(AddReloadListenerEvent reloadListenerEvent){ 13 | // reloadListenerEvent.addListener(CustomResourceReloadListener.INSTANCE); 14 | } 15 | 16 | @SubscribeEvent 17 | public static void onClientResourcePackReload(RegisterClientReloadListenersEvent event) { 18 | // event.registerReloadListener(CustomResourceReloadListener.INSTANCE); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/ClientConnection.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | 4 | import kasuga.lib.KasugaLib; 5 | import net.minecraftforge.client.event.ClientPlayerNetworkEvent; 6 | 7 | public class ClientConnection { 8 | 9 | public static void onClientConnect(ClientPlayerNetworkEvent.LoggingIn loggingIn){ 10 | KasugaLib.STACKS.CHANNEL.enableClient(); 11 | } 12 | public static void onClientDisconnect(ClientPlayerNetworkEvent.LoggingOut loggingOut){ 13 | KasugaLib.STACKS.CHANNEL.disableClient(); 14 | KasugaLib.STACKS.CHANNEL.reloadClient(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/GeometryEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import kasuga.lib.core.client.block_bench_model.BlockBenchModelLoader; 4 | import kasuga.lib.core.client.model.AnimModelLoader; 5 | import kasuga.lib.core.client.model.BedrockModelLoader; 6 | import net.minecraftforge.client.event.ModelEvent; 7 | import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; 8 | import net.minecraftforge.eventbus.api.SubscribeEvent; 9 | 10 | public class GeometryEvent { 11 | 12 | @SubscribeEvent 13 | public static void registerGeometry(ModelEvent.RegisterGeometryLoaders event) { 14 | event.register("bedrock_model", BedrockModelLoader.INSTANCE); 15 | event.register("bedrock_animated", AnimModelLoader.INSTANCE); 16 | event.register("blockbench_model", BlockBenchModelLoader.INSTANCE); 17 | } 18 | 19 | @SubscribeEvent 20 | public static void registerReloadListener(RegisterClientReloadListenersEvent event) { 21 | event.registerReloadListener(BedrockModelLoader.INSTANCE); 22 | event.registerReloadListener(AnimModelLoader.INSTANCE); 23 | event.registerReloadListener(BlockBenchModelLoader.INSTANCE); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/InteractionFovEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import kasuga.lib.core.client.interaction.GuiOperatingPerspectiveScreen; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraftforge.client.event.ComputeFovModifierEvent; 6 | 7 | public class InteractionFovEvent { 8 | public static void onComputedFov(ComputeFovModifierEvent event){ 9 | if(Minecraft.getInstance().screen != null && 10 | Minecraft.getInstance().screen instanceof GuiOperatingPerspectiveScreen operating) 11 | event.setNewFovModifier(operating.getFovModifier()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/PacketEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import net.minecraftforge.eventbus.api.SubscribeEvent; 4 | import net.minecraftforge.network.NetworkEvent; 5 | 6 | public class PacketEvent { 7 | 8 | @SubscribeEvent 9 | public static void onClientPayloadHandleEvent(NetworkEvent.ClientCustomPayloadEvent event) { 10 | System.out.println(); 11 | } 12 | 13 | @SubscribeEvent 14 | public static void onServerPayloadHandleEvent(NetworkEvent.ServerCustomPayloadEvent event) { 15 | System.out.println(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/ReloadEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import kasuga.lib.core.addons.minecraft.ClientReloadManager; 4 | import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; 5 | 6 | public class ReloadEvent { 7 | protected static ClientReloadManager reloadManager = new ClientReloadManager(); 8 | public static void onReload(RegisterClientReloadListenersEvent event){ 9 | event.registerReloadListener(reloadManager); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/RenderTickEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.client.frontend.gui.GuiEngine; 5 | import net.minecraftforge.event.TickEvent; 6 | import net.minecraftforge.eventbus.api.SubscribeEvent; 7 | 8 | public class RenderTickEvent { 9 | @SubscribeEvent 10 | public static void onRenderTick(TickEvent.RenderTickEvent renderTickEvent){ 11 | // KasugaLib.STACKS.JAVASCRIPT.renderTick(); 12 | // KasugaLib.STACKS.RENDER.ifPresent(GuiEngine::renderTick); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/client/TextureRegistryEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.client; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | import net.minecraftforge.client.event.ModelEvent; 7 | import net.minecraftforge.eventbus.api.SubscribeEvent; 8 | 9 | @OnlyIn(Dist.CLIENT) 10 | public class TextureRegistryEvent { 11 | 12 | @SubscribeEvent 13 | public static void onModelRegistry(ModelEvent.RegisterAdditional bakingCompleted) { 14 | KasugaLib.STACKS.fireTextureRegistry(); 15 | KasugaLib.STACKS.fontRegistry().onRegister(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/server/ServerConnectionListeners.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.server; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.menu.GuiMenuManager; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraftforge.event.entity.player.PlayerEvent; 7 | 8 | public class ServerConnectionListeners { 9 | public static void onClientDisconnect(PlayerEvent.PlayerLoggedOutEvent playerEvent){ 10 | if(playerEvent.getEntity() instanceof ServerPlayer serverPlayer) 11 | KasugaLib.STACKS.CHANNEL.closeServer(serverPlayer); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/server/ServerLevelEvents.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.server; 2 | 3 | 4 | import net.minecraftforge.event.level.LevelEvent; 5 | import net.minecraftforge.eventbus.api.SubscribeEvent; 6 | 7 | public class ServerLevelEvents { 8 | 9 | @SubscribeEvent 10 | public void onLevelLoad(LevelEvent.Load event) {} 11 | 12 | @SubscribeEvent 13 | public void onLevelSave(LevelEvent.Save event) {} 14 | 15 | @SubscribeEvent 16 | public void onLevelExit(LevelEvent.Unload event) {} 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/server/ServerResourceListener.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.server; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.addons.minecraft.ServerAddon; 5 | import net.minecraftforge.event.server.ServerStartingEvent; 6 | import net.minecraftforge.event.server.ServerStoppingEvent; 7 | 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | 11 | public class ServerResourceListener { 12 | public static void onServerStarting(ServerStartingEvent event){ 13 | KasugaLib.STACKS.JAVASCRIPT.setupServer(); 14 | KasugaLib.STACKS.MENU.initRegistry(); 15 | ServerAddon.load(event.getServer()); 16 | } 17 | 18 | public static void onServerStopping(ServerStoppingEvent event){ 19 | ServerAddon.unload(); 20 | KasugaLib.STACKS.JAVASCRIPT.destoryServer(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/server/ServerStartingEvents.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.server; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.addons.minecraft.ServerAddon; 5 | import kasuga.lib.core.util.Start; 6 | import net.minecraft.server.MinecraftServer; 7 | import net.minecraft.server.dedicated.DedicatedServer; 8 | import net.minecraft.server.packs.resources.CloseableResourceManager; 9 | import net.minecraft.server.packs.resources.ResourceManager; 10 | import net.minecraftforge.event.server.*; 11 | import net.minecraftforge.eventbus.api.SubscribeEvent; 12 | 13 | public class ServerStartingEvents { 14 | 15 | @SubscribeEvent 16 | public static void serverStarting(ServerStartingEvent event) {} 17 | 18 | @SubscribeEvent 19 | public static void serverAboutToStart(ServerAboutToStartEvent event) { 20 | MinecraftServer server = event.getServer(); 21 | if(server instanceof DedicatedServer) { 22 | Start.printLogo(); 23 | } 24 | KasugaLib.server = server; 25 | } 26 | 27 | @SubscribeEvent 28 | public static void serverStopped(ServerStoppedEvent event) { 29 | KasugaLib.server = null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/events/server/ServerTickEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.events.server; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import net.minecraftforge.event.TickEvent; 5 | 6 | public class ServerTickEvent { 7 | public static void onServerTick(TickEvent.ServerTickEvent serverTickEvent){ 8 | KasugaLib.STACKS.JAVASCRIPT.GROUP_SERVER.dispatchTick(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/Asset.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript; 2 | 3 | public interface Asset { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/Tickable.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript; 2 | 3 | public interface Tickable { 4 | public void tick(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/AbstractJavascriptEngineModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | import java.util.HashMap; 4 | 5 | public abstract class AbstractJavascriptEngineModule implements JavascriptEngineModule{ 6 | HashMap featureMap = new HashMap<>(); 7 | @Override 8 | public JavascriptEngineModule setFeature(String name, Object object) { 9 | featureMap.put(name, object); 10 | return this; 11 | } 12 | 13 | @Override 14 | public Object getFeature(String name) { 15 | return featureMap.get(name); 16 | } 17 | 18 | @Override 19 | public boolean hasFeature(String name) { 20 | return featureMap.containsKey(name); 21 | } 22 | 23 | boolean shouldCache = true; 24 | 25 | @Override 26 | public boolean shouldCache() { 27 | return shouldCache; 28 | } 29 | 30 | @Override 31 | public void setShouldCache(boolean shouldCache) { 32 | this.shouldCache = shouldCache; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/JavascriptEngineContext.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | 4 | import kasuga.lib.core.addons.node.NodePackage; 5 | import kasuga.lib.core.javascript.JavascriptContext; 6 | import kasuga.lib.core.util.data_type.Pair; 7 | 8 | import java.io.InputStream; 9 | import java.util.List; 10 | 11 | public interface JavascriptEngineContext { 12 | void loadModule(String moduleName); 13 | 14 | void loadModule(JavascriptEngineModule module); 15 | 16 | JavascriptValue asValue(Object object); 17 | 18 | JavascriptModuleScope getModuleScope(); 19 | 20 | JavascriptEngineModule compileModuleFromSource(NodePackage packageTarget, String fileName, String dirName, InputStream stream); 21 | 22 | JavascriptEngineModule compileNativeModule(Object target, String moduleName); 23 | 24 | JavascriptContext getContext(); 25 | 26 | void tick(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/JavascriptEngineModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | import kasuga.lib.core.addons.node.AssetReader; 4 | import kasuga.lib.core.addons.node.NodePackage; 5 | 6 | public interface JavascriptEngineModule { 7 | public String getAbsoultePath(); 8 | NodePackage getPackage(); 9 | String getDirectoryName(); 10 | Object getFeature(String name); 11 | boolean hasFeature(String name); 12 | boolean shouldCache(); 13 | void setShouldCache(boolean shouldCache); 14 | JavascriptEngineModule setFeature(String name, Object object); 15 | void setAssetReader(AssetReader reader); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/JavascriptModuleLoader.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | public interface JavascriptModuleLoader { 4 | public JavascriptEngineModule load(JavascriptEngineContext engineContext, String name, JavascriptEngineModule source); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/JavascriptValue.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | import kasuga.lib.core.client.frontend.dom.DomContext; 4 | 5 | public interface JavascriptValue { 6 | public boolean isString(); 7 | public String asString(); 8 | 9 | T as(Class className); 10 | 11 | boolean canExecute(); 12 | 13 | JavascriptValue execute(Object ...objects); 14 | void executeVoid(Object ...objects); 15 | 16 | void pin(); 17 | 18 | void unpin(); 19 | 20 | boolean hasMember(String render); 21 | 22 | JavascriptValue getMember(String render); 23 | 24 | JavascriptValue invokeMember(String memberName, Object ...objects); 25 | 26 | boolean isNumber(); 27 | 28 | int asInt(); 29 | 30 | JavascriptValue cloneValue(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/ScriptEngine.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | import kasuga.lib.core.javascript.JavascriptContext; 4 | 5 | public interface ScriptEngine { 6 | 7 | JavascriptEngineContext createInstance(JavascriptContext context); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/ScriptEngines.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine; 2 | 3 | import kasuga.lib.core.javascript.engine.javet.JavetScriptEngine; 4 | import net.minecraftforge.common.util.Lazy; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public class ScriptEngines { 9 | public static Lazy JAVET = Lazy.of(()->new JavetScriptEngine()); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/annotations/HostAccess.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | public class HostAccess { 9 | @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface Export{} 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/annotations/Optimization.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | public class Optimization { 9 | 10 | @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface DisableRuntimeAccessibilityCheck{} 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/javet/JavetScriptEngine.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.javet; 2 | 3 | import com.caoccao.javet.exceptions.JavetException; 4 | import com.caoccao.javet.interop.V8Runtime; 5 | import kasuga.lib.core.javascript.JavascriptContext; 6 | import kasuga.lib.core.javascript.engine.ScriptEngine; 7 | 8 | public class JavetScriptEngine implements ScriptEngine { 9 | public JavetContext createInstance(JavascriptContext context){ 10 | try { 11 | return new JavetContext(context); 12 | } catch (JavetException e) { 13 | throw new RuntimeException(e); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/javet/JavetValue.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.javet; 2 | 3 | import com.caoccao.javet.exceptions.JavetException; 4 | import com.caoccao.javet.values.V8Value; 5 | import com.caoccao.javet.values.reference.V8ValueObject; 6 | import com.caoccao.javet.values.reference.V8ValueReference; 7 | 8 | public class JavetValue { 9 | public static T weakClone(T value) throws JavetException { 10 | T value1 = value.toClone(); 11 | if(value1 instanceof V8ValueReference reference){ 12 | reference.setWeak(); 13 | } 14 | return value1; 15 | } 16 | 17 | public static T markWeak(T value) throws JavetException { 18 | if(value instanceof V8ValueReference reference){ 19 | reference.setWeak(); 20 | } 21 | return value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/javet/RequireFunction.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.javet; 2 | 3 | import com.caoccao.javet.values.V8Value; 4 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 5 | 6 | public interface RequireFunction { 7 | @HostAccess.Export 8 | public V8Value require(String moduleName); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/javet/converter/INativeClassProvider.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.javet.converter; 2 | 3 | import com.caoccao.javet.values.V8Value; 4 | 5 | public interface INativeClassProvider { 6 | public Object getNativeObject(V8Value value); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/engine/javet/converter/MethodOverrideMap.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.engine.javet.converter; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.ArrayList; 5 | import java.util.BitSet; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | 9 | public class MethodOverrideMap { 10 | public HashMap converterMask = new HashMap<>(); 11 | public HashMap> methods = new HashMap<>(); 12 | 13 | public boolean isVoidReturn = true; 14 | 15 | public MethodOverrideMap(){} 16 | 17 | public void initIfAbsent(int parameterCount){ 18 | 19 | converterMask 20 | .computeIfAbsent(parameterCount, (i)->{ 21 | BitSet bitSet = new BitSet(); 22 | bitSet.set(0, i,true); 23 | return bitSet; 24 | }); 25 | 26 | methods.computeIfAbsent(parameterCount, (i)->new ArrayList<>()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/ffi/ResourceLocationFFIHelper.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.ffi; 2 | 3 | import kasuga.lib.core.javascript.engine.JavascriptValue; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | public class ResourceLocationFFIHelper { 7 | public static ResourceLocation fromValue(JavascriptValue value){ 8 | if(!value.isString()) 9 | throw new IllegalArgumentException(); 10 | String val = value.asString(); 11 | return new ResourceLocation(val); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/prebuilt/PrebuiltModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.prebuilt; 2 | 3 | import kasuga.lib.core.javascript.JavascriptContext; 4 | import kasuga.lib.core.javascript.engine.JavascriptValue; 5 | 6 | public abstract class PrebuiltModule { 7 | protected PrebuiltModule(JavascriptContext runtime){ 8 | if(isTickable()){ 9 | runtime.registerTickable(this::tick); 10 | } 11 | runtime.collectEffect(this::close); 12 | } 13 | 14 | protected boolean isTickable(){ 15 | return false; 16 | } 17 | 18 | protected void tick(){} 19 | protected void close() {} 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/prebuilt/nbt/NBTModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.prebuilt.nbt; 2 | 3 | import kasuga.lib.core.javascript.CompoundTagWrapper; 4 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 5 | 6 | public class NBTModule { 7 | private static final NBTModule INSTANCE = new NBTModule(); 8 | 9 | @HostAccess.Export 10 | public CompoundTagWrapper createCompoundTag(){ 11 | return new CompoundTagWrapper(); 12 | } 13 | 14 | public static NBTModule getInstance() { 15 | return INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/prebuilt/process/ProcessModule.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.prebuilt.process; 2 | import kasuga.lib.core.javascript.JavascriptContext; 3 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 4 | import kasuga.lib.core.javascript.prebuilt.PrebuiltModule; 5 | 6 | public class ProcessModule extends PrebuiltModule { 7 | private final JavascriptContext runtime; 8 | 9 | public ProcessModule(JavascriptContext runtime) { 10 | super(runtime); 11 | this.runtime = runtime; 12 | } 13 | 14 | @HostAccess.Export 15 | public String[] listEnv(){ 16 | return runtime.getEnvironment().keySet().toArray(new String[0]); 17 | } 18 | 19 | @HostAccess.Export 20 | public Object getEnv(String key){ 21 | return runtime.getEnvironment().get(key); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/javascript/registration/RegistrationRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.javascript.registration; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | 5 | import java.util.HashMap; 6 | 7 | public class RegistrationRegistry { 8 | 9 | public HashMap> registries = new HashMap<>(); 10 | public void register(ResourceLocation location, JavascriptPriorityRegistry registry){ 11 | registries.put(location, registry); 12 | } 13 | 14 | public JavascriptPriorityRegistry getRegistry(ResourceLocation location){ 15 | return registries.get(location); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/IBlockEntityMenuHolder.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu; 2 | 3 | import java.util.UUID; 4 | 5 | public interface IBlockEntityMenuHolder { 6 | void notifyMenuId(UUID menuId); 7 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/api/GuiMenuOperateProxy.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.api; 2 | 3 | import com.caoccao.javet.annotations.V8Convert; 4 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 5 | import kasuga.lib.core.menu.base.GuiMenu; 6 | 7 | @V8Convert() 8 | public class GuiMenuOperateProxy { 9 | private final GuiMenu guiMenu; 10 | 11 | public GuiMenuOperateProxy(GuiMenu guiMenu) { 12 | this.guiMenu = guiMenu; 13 | } 14 | 15 | public static GuiMenuOperateProxy wrap(GuiMenu guiMenu) { 16 | return new GuiMenuOperateProxy(guiMenu); 17 | } 18 | 19 | @HostAccess.Export 20 | public ChannelHandlerProxy getChannel(){ 21 | return ChannelHandlerProxy.wrap(guiMenu.getChannel()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/api/GuiMenuUtils.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.api; 2 | 3 | import kasuga.lib.core.menu.base.GuiMenu; 4 | import kasuga.lib.core.menu.targets.ClientScreenTarget; 5 | import kasuga.lib.core.util.Envs; 6 | import net.minecraftforge.api.distmarker.Dist; 7 | import net.minecraftforge.fml.DistExecutor; 8 | 9 | public class GuiMenuUtils { 10 | public static void openScreen(GuiMenu menu){ 11 | if(Envs.isClient()){ 12 | DistExecutor.unsafeRunWhenOn(Dist.CLIENT,()->()-> ClientScreenTarget.openScreen(menu)); 13 | }else{ 14 | // @TODO 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/base/GuiBindingTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.base; 2 | 3 | import kasuga.lib.core.client.frontend.gui.GuiInstance; 4 | 5 | public interface GuiBindingTarget {} 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/base/GuiContainerMenu.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.base; 2 | 3 | public abstract class GuiContainerMenu extends GuiMenu{ 4 | protected GuiContainerMenu(GuiMenuType type) { 5 | super(type); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/base/GuiMenuType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.base; 2 | 3 | import java.util.function.Function; 4 | import java.util.function.Supplier; 5 | 6 | public class GuiMenuType { 7 | private Function, T> factory; 8 | 9 | public GuiMenuType(Function, T> factory) { 10 | this.factory = factory; 11 | } 12 | 13 | public T create() { 14 | return factory.apply(this); 15 | } 16 | 17 | public static GuiMenuType createType( 18 | Function, T> factory 19 | ) { 20 | return new GuiMenuType<>(factory); 21 | } 22 | 23 | public static GuiMenuType createType( 24 | Supplier factory 25 | ) { 26 | return new GuiMenuType<>((t)->factory.get()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/locator/IChunkBasedLocator.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.locator; 2 | 3 | import net.minecraft.network.Connection; 4 | import net.minecraft.world.level.ChunkPos; 5 | 6 | public interface IChunkBasedLocator { 7 | ChunkPos getPosition(); 8 | void sendUpTo(Connection connection); 9 | void sendDownTo(Connection connection); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/locator/MenuLocatorRegistry.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.locator; 2 | 3 | import kasuga.lib.core.channel.network.NetworkSerializableRegistry; 4 | 5 | public class MenuLocatorRegistry extends NetworkSerializableRegistry> {} 6 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/locator/MenuLocatorType.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.locator; 2 | 3 | import kasuga.lib.core.channel.network.NetworkSeriaizableType; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | 6 | import java.util.function.Function; 7 | 8 | public class MenuLocatorType extends NetworkSeriaizableType { 9 | public MenuLocatorType(Function deserializer) { 10 | super(deserializer); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/locator/MenuLocatorTypes.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.locator; 2 | 3 | public class MenuLocatorTypes { 4 | public static MenuLocatorType BLOCK = new MenuLocatorType<>(BlockMenuLocator::new); 5 | public static MenuLocatorType ENTITY = new MenuLocatorType<>(EntityMenuLocator::new); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/network/BlockEntityMenuIdSyncHandler.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.network; 2 | 3 | import kasuga.lib.core.menu.IBlockEntityMenuHolder; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.core.BlockPos; 6 | import net.minecraft.resources.ResourceKey; 7 | import net.minecraft.world.level.Level; 8 | 9 | import java.util.UUID; 10 | 11 | public class BlockEntityMenuIdSyncHandler { 12 | public static void handle(Minecraft minecraft, UUID serverId, ResourceKey dimension, BlockPos position){ 13 | Level world = minecraft.level; 14 | if (world != null && world.dimension() == dimension) { 15 | if (world.getBlockEntity(position) instanceof IBlockEntityMenuHolder menuHolder) { 16 | menuHolder.notifyMenuId(serverId); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/network/MenuAddressTypes.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.network; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.channel.address.LabelType; 5 | import net.minecraft.resources.ResourceLocation; 6 | 7 | public class MenuAddressTypes { 8 | public static final LabelType CLIENT = 9 | KasugaLib.STACKS.CHANNEL.labelTypeRegistry.register( 10 | new ResourceLocation("kasuga_lib", "gui_client_menu"), 11 | new LabelType<>(GuiClientMenuAddress::new) 12 | ); 13 | 14 | public static final LabelType SERVER = 15 | KasugaLib.STACKS.CHANNEL.labelTypeRegistry.register( 16 | new ResourceLocation("kasuga_lib", "gui_server_menu"), 17 | new LabelType<>(GuiServerMenuAddress::new) 18 | ); 19 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/targets/ClientScreenTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.targets; 2 | 3 | import kasuga.lib.core.client.frontend.gui.GuiInstance; 4 | import kasuga.lib.core.client.frontend.gui.GuiScreen; 5 | import kasuga.lib.core.menu.base.GuiMenu; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.screens.Screen; 8 | 9 | public class ClientScreenTarget { 10 | private GuiInstance guiInstance; 11 | 12 | public ClientScreenTarget(GuiInstance guiInstance) { 13 | this.guiInstance = guiInstance; 14 | } 15 | 16 | public void openScreen(){ 17 | if (this.guiInstance == null) { 18 | return; 19 | } 20 | Screen screen = new GuiScreen(this.guiInstance); 21 | Minecraft.getInstance().setScreen(screen); 22 | } 23 | 24 | public static void openScreen(GuiMenu menu){ 25 | ClientScreenTarget target = menu.getBinding().apply(Target.SCREEN); 26 | if (target != null) { 27 | target.openScreen(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/targets/ClientTextureTarget.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.targets; 2 | 3 | import kasuga.lib.core.client.frontend.gui.GuiInstance; 4 | 5 | public class ClientTextureTarget { 6 | public ClientTextureTarget(GuiInstance guiInstance) { 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/targets/Target.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.targets; 2 | 3 | import kasuga.lib.core.menu.base.GuiBindingTarget; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | public class Target implements GuiBindingTarget { 7 | private final ResourceLocation id; 8 | 9 | protected Target(ResourceLocation id) { 10 | this.id = id; 11 | } 12 | 13 | public static Target create(ResourceLocation id){ 14 | return new Target(id); 15 | } 16 | 17 | public static Target TEXTURE = new Target(new ResourceLocation("kasuga_lib:texture")); 18 | public static Target SCREEN = new Target(new ResourceLocation("kasuga_lib:screen")); 19 | public static Target WORLD_RENDERER = new Target(new ResourceLocation("kasuga_lib:world_renderer")); 20 | 21 | public static void register(){} 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/menu/targets/TargetsClient.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.menu.targets; 2 | 3 | import kasuga.lib.core.menu.base.BindingClient; 4 | 5 | public class TargetsClient { 6 | public static void register(){ 7 | BindingClient.registerBinding(Target.SCREEN, ClientScreenTarget::new); 8 | BindingClient.registerBinding(Target.WORLD_RENDERER, WorldRendererTarget::new); 9 | BindingClient.registerBinding(Target.TEXTURE, ClientTextureTarget::new); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/network/Packet.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.network; 2 | 3 | import kasuga.lib.core.annos.Inner; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | import net.minecraftforge.network.NetworkEvent; 6 | 7 | /** 8 | * This class is designed for network packages. Network packages transmit our custom data between client and server. 9 | * For packages from client to server, use {@link C2SPacket}. 10 | * For packages from server to client, use {@link S2CPacket} 11 | */ 12 | public abstract class Packet { 13 | 14 | /** 15 | * This constructor is also used as decoder. While the program get data from network, it would 16 | * use this deserializer to create our packet. 17 | * @param buf the bytes we got from network. 18 | */ 19 | public Packet(FriendlyByteBuf buf) {} 20 | 21 | public Packet() {} 22 | 23 | @Inner 24 | abstract public boolean onReach(NetworkEvent.Context context); 25 | 26 | /** 27 | * The encoder of your packet, you must push all your data into this byte buffer. 28 | * @param buf the data container buffer, push your data into it. 29 | */ 30 | abstract public void encode(FriendlyByteBuf buf); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/network/PacketPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraftforge.network.NetworkConstants; 5 | import net.minecraftforge.network.NetworkDirection; 6 | 7 | public abstract class PacketPair { 8 | 9 | public PacketPair() {} 10 | public abstract void encode(FriendlyByteBuf buf); 11 | public abstract void decode(FriendlyByteBuf buf); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/packets/AllPackets.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.packets; 2 | 3 | import kasuga.lib.KasugaLib; 4 | import kasuga.lib.core.channel.packets.ChannelNetworkPacket; 5 | import kasuga.lib.core.menu.network.BlockEntityMenuIdSyncPacket; 6 | import kasuga.lib.core.menu.network.ServerLocatorChangePacket; 7 | import kasuga.lib.registrations.common.ChannelReg; 8 | import kasuga.lib.registrations.registry.SimpleRegistry; 9 | 10 | public class AllPackets { 11 | public static final SimpleRegistry REGISTRY = new SimpleRegistry(KasugaLib.MOD_ID, KasugaLib.EVENTS); 12 | 13 | public static final ChannelReg CHANNEL_REG = new ChannelReg("root") 14 | .brand("1.0") 15 | .loadPacket(BlockEntityMenuIdSyncPacket.class, BlockEntityMenuIdSyncPacket::new) 16 | .loadPacket(ServerLocatorChangePacket.class, ServerLocatorChangePacket::new) 17 | .submit(REGISTRY); 18 | 19 | public static void init(){ 20 | REGISTRY.submit(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/resource/RegisterCustomPackEvent.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.resource; 2 | 3 | import net.minecraftforge.eventbus.api.Event; 4 | 5 | public class RegisterCustomPackEvent extends Event { 6 | 7 | public RegisterCustomPackEvent() { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/sync/DataState.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.sync; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public abstract class DataState { 6 | public int id; 7 | public abstract DataState copy(); 8 | 9 | public abstract CompoundTag serialize(); 10 | 11 | public abstract CompoundTag diff(DataState otherState); 12 | 13 | public abstract void applyDiff(CompoundTag diffTag); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/Callback.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util; 2 | 3 | @FunctionalInterface 4 | public interface Callback { 5 | static Callback nop() { 6 | return ()->{}; 7 | } 8 | 9 | void execute(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/ComponentHelper.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util; 2 | 3 | import kasuga.lib.core.annos.Util; 4 | import net.minecraft.network.chat.Component; 5 | 6 | @Util 7 | public class ComponentHelper { 8 | 9 | public static Component literal(String text) { 10 | return Component.literal(text); 11 | } 12 | 13 | public static Component translatable(String key) { 14 | return Component.translatable(key); 15 | } 16 | 17 | public static Component translatable(String key, Object... args) { 18 | return Component.translatable(key, args); 19 | } 20 | 21 | public static Component keybind(String name) { 22 | return Component.keybind(name); 23 | } 24 | 25 | public static Component empty() { 26 | return Component.empty(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/Envs.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util; 2 | 3 | import kasuga.lib.core.annos.Util; 4 | import net.minecraftforge.fml.loading.FMLLoader; 5 | 6 | /** 7 | * This class is a utility for environment detecting. 8 | */ 9 | @Util 10 | public class Envs { 11 | 12 | /** 13 | * Dev means the environment in IDEs like IDEA, Eclipse and so on. 14 | * @return is we are in dev environment? 15 | */ 16 | @Util 17 | public static boolean isDevEnvironment() { 18 | return !FMLLoader.isProduction(); 19 | } 20 | 21 | /** 22 | * Client means we are in the client game side. The client controls rendering or client ticks. 23 | * @return is the game a client? 24 | */ 25 | @Util 26 | public static boolean isClient() { 27 | return FMLLoader.getDist().isClient(); 28 | } 29 | 30 | /** 31 | * DedicateServer is a kind of server that used for multiplayer gaming. These servers have no client, 32 | * they only runs the logical side of your world. 33 | * @return is the game a dedicate server? 34 | */ 35 | @Util 36 | public static boolean isDedicateServer() { 37 | return FMLLoader.getDist().isDedicatedServer(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/SortedArrayList.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | 6 | public class SortedArrayList> extends ArrayList { 7 | public void insert(T value) { 8 | int i = Collections.binarySearch(this, value); 9 | add(i < 0 ? -i - 1 : i, value); 10 | } 11 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/WeakCache.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util; 2 | 3 | import java.lang.ref.WeakReference; 4 | import java.util.HashMap; 5 | 6 | public class WeakCache extends HashMap> { 7 | public void putCache(K key, V value){ 8 | WeakReference ref = this.put(key, new WeakReference<>(value)); 9 | } 10 | public V getCache(K key){ 11 | WeakReference ref = this.get(key); 12 | return ref == null ? null : ref.get(); 13 | } 14 | 15 | public void collect(){ 16 | this.entrySet().removeIf(entry -> entry.getValue().get() == null); 17 | } 18 | 19 | @Override 20 | public boolean containsKey(Object key) { 21 | return this.get(key) != null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/data_type/PrioritizedItem.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.data_type; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class PrioritizedItem extends Pair implements Comparable>{ 6 | 7 | protected PrioritizedItem(T first, Integer second) { 8 | super(first, second); 9 | } 10 | 11 | @Override 12 | public int compareTo(@NotNull PrioritizedItem o) { 13 | return (second.compareTo(o.second)); 14 | } 15 | 16 | public static PrioritizedItem of(T first, Integer second) { 17 | return new PrioritizedItem(first, second); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/data_type/Vec2i.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.data_type; 2 | 3 | import kasuga.lib.core.client.render.texture.Vec2f; 4 | 5 | public class Vec2i { 6 | 7 | public int x; 8 | public int y; 9 | 10 | public Vec2i(int x, int y) { 11 | this.x = x; 12 | this.y = y; 13 | } 14 | 15 | public Vec2i(Vec2i vec) { 16 | this.x = vec.x; 17 | this.y = vec.y; 18 | } 19 | 20 | public Vec2i(Vec2f vec2f) { 21 | this.x = (int) vec2f.x(); 22 | this.y = (int) vec2f.y(); 23 | } 24 | 25 | public Vec2i() { 26 | this(0, 0); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/glob/GlobFilterNode.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.glob; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import java.util.HashMap; 6 | import java.util.HashSet; 7 | import java.util.concurrent.atomic.AtomicBoolean; 8 | 9 | public class GlobFilterNode { 10 | public AtomicBoolean isUnreachable = new AtomicBoolean(false); 11 | public HashMap children = new HashMap<>(); 12 | 13 | public int filterCount = 0; 14 | 15 | public static int MAX_FILTER_COUNT = 128; 16 | 17 | public @Nullable GlobFilterNode reach(String key) { 18 | if(filterCount > MAX_FILTER_COUNT) 19 | return children.get(key); 20 | return children.computeIfAbsent(key, (k) -> { 21 | filterCount++; 22 | return new GlobFilterNode(); 23 | }); 24 | } 25 | 26 | public boolean reachable() { 27 | return !isUnreachable.get(); 28 | } 29 | 30 | public void setUnreachable() { 31 | isUnreachable.set(true); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/ConversionPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json; 2 | 3 | import com.google.gson.JsonElement; 4 | import lombok.Getter; 5 | import net.minecraft.nbt.Tag; 6 | import org.checkerframework.checker.nullness.qual.NonNull; 7 | 8 | @Getter 9 | public abstract class ConversionPair { 10 | 11 | public final Class tagClazz; 12 | public final Class jsonClazz; 13 | public final String identifier; 14 | 15 | public ConversionPair(String identifier, Class tagClazz, Class jsonClazz) { 16 | this.tagClazz = tagClazz; 17 | this.jsonClazz = jsonClazz; 18 | this.identifier = identifier; 19 | } 20 | 21 | public boolean match(Tag tag) { 22 | return tagClazz.isInstance(tag); 23 | } 24 | 25 | public boolean match(JsonElement element) { 26 | return jsonClazz.isInstance(element); 27 | } 28 | 29 | public abstract K convert(@NonNull T nbt, String path) throws NoAvailableConversionException; 30 | 31 | public abstract T convert(@NonNull K json, String path) throws NoAvailableConversionException; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/ListIsEmptyException.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json; 2 | 3 | import net.minecraft.nbt.Tag; 4 | 5 | public class ListIsEmptyException extends Exception { 6 | 7 | public final String path; 8 | 9 | public final Tag tag; 10 | 11 | public ListIsEmptyException(Tag tag, String path) { 12 | this.tag = tag; 13 | this.path = path; 14 | } 15 | 16 | @Override 17 | public String getMessage() { 18 | return "Lists in template NBT should not be empty! Found empty list at nbt path: " + path; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/NoAvailableConversionException.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json; 2 | 3 | import net.minecraft.nbt.Tag; 4 | 5 | public class NoAvailableConversionException extends Exception { 6 | 7 | public final String path; 8 | public final Class clazz; 9 | 10 | public NoAvailableConversionException(Class clazz, String path) { 11 | super(); 12 | this.clazz = clazz; 13 | this.path = path; 14 | } 15 | 16 | @Override 17 | public String getMessage() { 18 | return "No available conversion pair for " + clazz.getName() + " at " + path; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/collection/ByteArrayPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.collection; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.minecraft.nbt.ByteArrayTag; 5 | import net.minecraft.nbt.ByteTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class ByteArrayPair extends CollectionPair { 9 | 10 | 11 | public ByteArrayPair() { 12 | super("byte_array", ByteArrayTag.class, ByteTag.class); 13 | } 14 | 15 | @Override 16 | public JsonArray convert(@NotNull ByteArrayTag nbt, String path) { 17 | JsonArray array = new JsonArray(); 18 | nbt.forEach(content -> array.add(content.getAsByte())); 19 | return array; 20 | } 21 | 22 | @Override 23 | public ByteArrayTag convert(@NotNull JsonArray json, String path) { 24 | byte[] result = new byte[json.size()]; 25 | for (int i = 0; i < json.size(); i++) { 26 | result[i] = json.get(i).getAsByte(); 27 | } 28 | return new ByteArrayTag(result); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/collection/CollectionPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.collection; 2 | 3 | import com.google.gson.JsonArray; 4 | import kasuga.lib.core.util.nbt_json.ConversionPair; 5 | import lombok.Getter; 6 | import net.minecraft.nbt.CollectionTag; 7 | import net.minecraft.nbt.Tag; 8 | 9 | import java.util.Collection; 10 | 11 | @Getter 12 | public abstract class CollectionPair> extends ConversionPair { 13 | 14 | public final Class contentClazz; 15 | 16 | public CollectionPair(String identifier, Class tagClazz, Class contentClazz) { 17 | super(identifier, tagClazz, JsonArray.class); 18 | this.contentClazz = contentClazz; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/collection/IntArrayPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.collection; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.minecraft.nbt.IntArrayTag; 5 | import net.minecraft.nbt.IntTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class IntArrayPair extends CollectionPair { 9 | 10 | public IntArrayPair() { 11 | super("int_array", IntArrayTag.class, IntTag.class); 12 | } 13 | 14 | @Override 15 | public JsonArray convert(@NotNull IntArrayTag nbt, String path) { 16 | JsonArray array = new JsonArray(); 17 | nbt.forEach(content -> array.add(content.getAsInt())); 18 | return array; 19 | } 20 | 21 | @Override 22 | public IntArrayTag convert(@NotNull JsonArray json, String path) { 23 | int[] result = new int[json.size()]; 24 | for (int i = 0; i < result.length; i++) { 25 | result[i] = json.get(i).getAsInt(); 26 | } 27 | return new IntArrayTag(result); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/collection/LongArrayPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.collection; 2 | 3 | import com.google.gson.JsonArray; 4 | import net.minecraft.nbt.LongArrayTag; 5 | import net.minecraft.nbt.LongTag; 6 | import net.minecraft.nbt.ShortTag; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class LongArrayPair extends CollectionPair { 10 | 11 | public LongArrayPair() { 12 | super("long_array", LongArrayTag.class, LongTag.class); 13 | } 14 | 15 | @Override 16 | public JsonArray convert(@NotNull LongArrayTag nbt, String path) { 17 | JsonArray array = new JsonArray(); 18 | nbt.forEach(content -> array.add(content.getAsLong())); 19 | return array; 20 | } 21 | 22 | @Override 23 | public LongArrayTag convert(@NotNull JsonArray json, String path) { 24 | long[] array = new long[json.size()]; 25 | for (int i = 0; i < array.length; ++i) 26 | array[i] = json.get(i).getAsLong(); 27 | return new LongArrayTag(array); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/BooleanPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.ByteTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class BooleanPair extends PrimitivePair { 9 | 10 | public BooleanPair() { 11 | super("bool", ByteTag.class, Boolean.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if(!super.match(element)) return false; 17 | JsonPrimitive primitive = element.getAsJsonPrimitive(); 18 | return primitive.isBoolean(); 19 | } 20 | 21 | @Override 22 | public JsonPrimitive convert(@NotNull ByteTag nbt, String path) { 23 | return new JsonPrimitive(nbt.getAsByte() != 0); 24 | } 25 | 26 | @Override 27 | public ByteTag convert(@NotNull JsonPrimitive json, String path) { 28 | return ByteTag.valueOf(json.getAsBoolean()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/PrimitivePair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive; 2 | 3 | import com.google.gson.JsonPrimitive; 4 | import kasuga.lib.core.util.nbt_json.ConversionPair; 5 | import lombok.Getter; 6 | import net.minecraft.nbt.Tag; 7 | 8 | @Getter 9 | public abstract class PrimitivePair extends ConversionPair { 10 | 11 | public final Class primitiveType; 12 | 13 | public PrimitivePair(String identifier, Class tagClazz, Class primitiveClazz) { 14 | super(identifier, tagClazz, JsonPrimitive.class); 15 | this.primitiveType = primitiveClazz; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/StringPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.StringTag; 6 | import net.minecraft.nbt.Tag; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class StringPair extends PrimitivePair { 10 | 11 | public StringPair() { 12 | super("str", StringTag.class, String.class); 13 | } 14 | 15 | @Override 16 | public boolean match(JsonElement element) { 17 | if (!super.match(element)) return false; 18 | JsonPrimitive primitive = element.getAsJsonPrimitive(); 19 | return primitive.isString(); 20 | } 21 | 22 | @Override 23 | public JsonPrimitive convert(@NotNull StringTag nbt, String path) { 24 | return new JsonPrimitive(nbt.toString()); 25 | } 26 | 27 | @Override 28 | public StringTag convert(@NotNull JsonPrimitive json, String path) { 29 | return StringTag.valueOf(json.getAsString()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/BytePair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.ByteTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class BytePair extends NumericPair { 9 | 10 | public BytePair() { 11 | super("byte", ByteTag.class, Byte.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | Number number = element.getAsNumber(); 19 | return !str.contains(".") && 20 | number.shortValue() > -129 && 21 | number.shortValue() < 128; 22 | } 23 | 24 | @Override 25 | public JsonPrimitive convert(@NotNull ByteTag nbt, String path) { 26 | return new JsonPrimitive(nbt.getAsByte()); 27 | } 28 | 29 | @Override 30 | public ByteTag convert(@NotNull JsonPrimitive json, String path) { 31 | return ByteTag.valueOf(json.getAsByte()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/DoublePair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.DoubleTag; 6 | import net.minecraft.nbt.Tag; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class DoublePair extends NumericPair { 10 | public DoublePair() { 11 | super("double", DoubleTag.class, Double.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | return str.contains("."); 19 | } 20 | 21 | @Override 22 | public JsonPrimitive convert(@NotNull DoubleTag nbt, String path) { 23 | return new JsonPrimitive(nbt.getAsDouble()); 24 | } 25 | 26 | @Override 27 | public DoubleTag convert(@NotNull JsonPrimitive json, String path) { 28 | return DoubleTag.valueOf(json.getAsDouble()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/FloatPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.FloatTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class FloatPair extends NumericPair { 9 | 10 | public FloatPair() { 11 | super("float", FloatTag.class, Float.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | return str.contains("."); 19 | } 20 | 21 | @Override 22 | public JsonPrimitive convert(@NotNull FloatTag nbt, String path) { 23 | return new JsonPrimitive(nbt.getAsFloat()); 24 | } 25 | 26 | @Override 27 | public FloatTag convert(@NotNull JsonPrimitive json, String path) { 28 | return FloatTag.valueOf(json.getAsFloat()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/IntPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.IntTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class IntPair extends NumericPair { 9 | 10 | public IntPair() { 11 | super("int", IntTag.class, Integer.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | Number number = element.getAsNumber(); 19 | return !str.contains(".") && number.longValue() == number.intValue(); 20 | } 21 | 22 | @Override 23 | public JsonPrimitive convert(@NotNull IntTag nbt, String path) { 24 | return new JsonPrimitive(nbt.getAsInt()); 25 | } 26 | 27 | @Override 28 | public IntTag convert(@NotNull JsonPrimitive json, String path) { 29 | return IntTag.valueOf(json.getAsInt()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/LongPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.LongTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class LongPair extends NumericPair { 9 | 10 | public LongPair() { 11 | super("long", LongTag.class, Long.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | Number number = element.getAsNumber(); 19 | return !str.contains(".") && number.longValue() != number.intValue(); 20 | } 21 | 22 | @Override 23 | public JsonPrimitive convert(@NotNull LongTag nbt, String path) { 24 | return new JsonPrimitive(nbt.getAsLong()); 25 | } 26 | 27 | @Override 28 | public LongTag convert(@NotNull JsonPrimitive json, String path) { 29 | return LongTag.valueOf(json.getAsLong()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/NumericPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import kasuga.lib.core.util.nbt_json.primitive.PrimitivePair; 6 | import net.minecraft.nbt.NumericTag; 7 | 8 | public abstract class NumericPair extends PrimitivePair { 9 | 10 | public NumericPair(String identifier, Class tagClazz, Class primitiveClazz) { 11 | super(identifier, tagClazz, primitiveClazz); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | JsonPrimitive primitive = element.getAsJsonPrimitive(); 18 | return primitive.isNumber(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/nbt_json/primitive/numeric/ShortPair.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.nbt_json.primitive.numeric; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonPrimitive; 5 | import net.minecraft.nbt.ShortTag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class ShortPair extends NumericPair { 9 | 10 | public ShortPair() { 11 | super("short", ShortTag.class, Short.class); 12 | } 13 | 14 | @Override 15 | public boolean match(JsonElement element) { 16 | if (!super.match(element)) return false; 17 | String str = element.getAsString(); 18 | Number number = element.getAsNumber(); 19 | return !str.contains(".") && 20 | number.intValue() < 32768 && 21 | number.intValue() > -32769; 22 | } 23 | 24 | @Override 25 | public JsonPrimitive convert(@NotNull ShortTag nbt, String path) { 26 | return new JsonPrimitive(nbt.getAsShort()); 27 | } 28 | 29 | @Override 30 | public ShortTag convert(@NotNull JsonPrimitive json, String path) { 31 | return ShortTag.valueOf(json.getAsShort()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/projectile/CameraTracker.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.projectile; 2 | 3 | import com.mojang.math.Vector3f; 4 | import lombok.Getter; 5 | import net.minecraft.client.Camera; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.Gui; 8 | import net.minecraft.world.phys.Vec3; 9 | 10 | import static kasuga.lib.core.util.projectile.PanelRenderer.BASE_OFFSET_2; 11 | 12 | @Getter 13 | public class CameraTracker { 14 | 15 | private final Camera camera; 16 | private final Gui gui; 17 | 18 | public CameraTracker(Gui gui, Camera camera) { 19 | this.camera = camera; 20 | this.gui = gui; 21 | } 22 | 23 | public Ray test(float mouseX, float mouseY) { 24 | Vec3 vec = camera.getPosition(); 25 | Vec3 forward = new Vec3(camera.getLookVector()).add(BASE_OFFSET_2); 26 | return new Ray(vec, forward); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/util/projectile/MatrixResolveUtil.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.util.projectile; 2 | 3 | import com.mojang.math.Matrix4f; 4 | import com.mojang.math.Vector3f; 5 | 6 | public class MatrixResolveUtil { 7 | 8 | public static Vector3f getOffset(Matrix4f matrix4f) { 9 | return new Vector3f(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/core/xml/IXmlObject.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.core.xml; 2 | 3 | import java.util.Set; 4 | 5 | public interface IXmlObject { 6 | String key(); 7 | Set getValues(); 8 | T getValue(String key); 9 | void setValue(String key, Object value); 10 | Set> attributes(); 11 | IXmlObject getAttribute(String key); 12 | void setAttribute(String key, Object value); 13 | String toFormattedString(int stage, boolean isPlainText); 14 | boolean isSingleSideElement(); 15 | void setIsSingleSide(boolean singleSide); 16 | boolean isPrimitive(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/AllClient.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env; 2 | 3 | public class AllClient { 4 | 5 | // public static final LazyRecomputable anim = AnimationFile. 6 | // fromFile(AllExampleElements.REGISTRY.asResource("animations/model.animation.json")); 7 | 8 | // public static final LazyRecomputable model = BedrockModelLoader.fromFile( 9 | // AllExampleElements.REGISTRY.asResource("block/test/test_model_complicate")); 10 | 11 | public static void invoke(){} 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/OperateScreenCommand.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import kasuga.lib.core.client.interaction.GuiOperatingPerspectiveScreen; 5 | import net.minecraft.client.Minecraft; 6 | 7 | public class OperateScreenCommand { 8 | public static void invoke(){ 9 | RenderSystem.recordRenderCall(()->{ 10 | Minecraft.getInstance().setScreen(new GuiOperatingPerspectiveScreen()); 11 | }); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluidBlock.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env.block.fluid; 2 | 3 | import net.minecraft.world.item.context.BlockPlaceContext; 4 | import net.minecraft.world.level.block.Block; 5 | import net.minecraft.world.level.block.LiquidBlock; 6 | import net.minecraft.world.level.block.state.BlockBehaviour; 7 | import net.minecraft.world.level.block.state.BlockState; 8 | import net.minecraft.world.level.block.state.StateDefinition; 9 | import net.minecraft.world.level.material.FlowingFluid; 10 | import net.minecraftforge.fluids.ForgeFlowingFluid; 11 | import net.minecraftforge.fluids.IFluidBlock; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | import java.util.function.Supplier; 15 | 16 | public class ExampleFluidBlock extends LiquidBlock { 17 | 18 | public ExampleFluidBlock(Supplier supplier, Properties properties) { 19 | super(supplier, properties); 20 | } 21 | 22 | @Override 23 | public @Nullable BlockState getStateForPlacement(BlockPlaceContext pContext) { 24 | return super.getStateForPlacement(pContext).setValue(LEVEL, 8); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/block/gui/GuiExampleBlockApi.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env.block.gui; 2 | 3 | import kasuga.lib.core.javascript.engine.annotations.HostAccess; 4 | 5 | public class GuiExampleBlockApi { 6 | 7 | private final GuiExampleBlockEntity blockEntity; 8 | 9 | public GuiExampleBlockApi(GuiExampleBlockEntity blockEntity) { 10 | this.blockEntity = blockEntity; 11 | } 12 | 13 | @HostAccess.Export 14 | public void incrementData(){ 15 | if(!blockEntity.isRemoved()) 16 | blockEntity.incrementData(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/client/screens/GreenAppleScreen.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env.client.screens; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; 5 | import net.minecraft.network.chat.Component; 6 | import net.minecraft.world.entity.player.Inventory; 7 | 8 | public class GreenAppleScreen extends AbstractContainerScreen { 9 | public GreenAppleScreen(GreenAppleMenu pMenu, Inventory pPlayerInventory, Component pTitle) { 10 | super(pMenu, pPlayerInventory, pTitle); 11 | } 12 | 13 | @Override 14 | protected void renderBg(PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/network/ExampleC2SPacket.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env.network; 2 | 3 | import kasuga.lib.core.network.C2SPacket; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraftforge.network.NetworkEvent; 7 | 8 | public class ExampleC2SPacket extends C2SPacket { 9 | 10 | public ExampleC2SPacket() { 11 | super(); 12 | } 13 | 14 | public ExampleC2SPacket(FriendlyByteBuf buf) { 15 | super(buf); 16 | } 17 | 18 | @Override 19 | public void handle(NetworkEvent.Context context) { 20 | System.out.println("I am C2S"); 21 | } 22 | 23 | @Override 24 | public void encode(FriendlyByteBuf buf) {} 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/example_env/network/ExampleS2CPacket.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.example_env.network; 2 | 3 | import kasuga.lib.core.network.S2CPacket; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.network.FriendlyByteBuf; 6 | 7 | public class ExampleS2CPacket extends S2CPacket { 8 | 9 | public ExampleS2CPacket() { 10 | super(); 11 | } 12 | 13 | public ExampleS2CPacket(FriendlyByteBuf buf) { 14 | super(buf); 15 | } 16 | @Override 17 | public void handle(Minecraft minecraft) { 18 | System.out.println("I am S2C"); 19 | } 20 | 21 | @Override 22 | public void encode(FriendlyByteBuf buf) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/MixinNbtUtils.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin; 2 | 3 | import kasuga.lib.core.base.UnModeledBlockProperty; 4 | import net.minecraft.nbt.NbtUtils; 5 | import net.minecraft.world.level.block.state.StateDefinition; 6 | import net.minecraft.world.level.block.state.properties.Property; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(NbtUtils.class) 12 | public class MixinNbtUtils { 13 | 14 | @Redirect(method = "readBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/StateDefinition;getProperty(Ljava/lang/String;)Lnet/minecraft/world/level/block/state/properties/Property;"), remap = false) 15 | private static Property doGetProperty(StateDefinition instance, String pPropertyName) { 16 | if (instance.getProperty(pPropertyName) instanceof UnModeledBlockProperty) 17 | return null; 18 | return instance.getProperty(pPropertyName); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/MultiPackResourceManagerAccessor.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin; 2 | 3 | import net.minecraft.server.packs.PackResources; 4 | import net.minecraft.server.packs.resources.FallbackResourceManager; 5 | import net.minecraft.server.packs.resources.MultiPackResourceManager; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.gen.Accessor; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | @Deprecated(forRemoval = true) 13 | @Mixin(MultiPackResourceManager.class) 14 | public interface MultiPackResourceManagerAccessor { 15 | 16 | @Accessor(value = "namespacedManagers") 17 | public Map getNamespacedManagers(); 18 | 19 | @Accessor(value = "packs") 20 | public List getPacks(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/ReloadableResourceManagerAccessor.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin; 2 | 3 | import net.minecraft.server.packs.resources.CloseableResourceManager; 4 | import net.minecraft.server.packs.resources.ReloadableResourceManager; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Deprecated(forRemoval = true) 9 | @Mixin(ReloadableResourceManager.class) 10 | public interface ReloadableResourceManagerAccessor { 11 | 12 | @Accessor(value = "resources") 13 | public CloseableResourceManager getResources(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/client/MixinModelBakery.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin.client; 2 | 3 | import kasuga.lib.core.client.model.BedrockModelLoader; 4 | import net.minecraft.client.resources.model.Material; 5 | import net.minecraft.client.resources.model.ModelBakery; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | 10 | import java.util.Collection; 11 | import java.util.Set; 12 | 13 | @Mixin(ModelBakery.class) 14 | public class MixinModelBakery { 15 | 16 | // @Redirect(method = "", at = @At(value = "INVOKE", target = "Ljava/util/Set;addAll(Ljava/util/Collection;)Z")) 17 | // private boolean addAll(Set instance, Collection es) { 18 | // return instance.addAll(es) & instance.addAll(BedrockModelLoader.ADDITIONAL_MATERIALS); 19 | // } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/resources/DelegatingPackResourcesMixin.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin.resources; 2 | 3 | import net.minecraft.server.packs.FilePackResources; 4 | import net.minecraft.server.packs.PackResources; 5 | import net.minecraftforge.resource.DelegatingPackResources; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.gen.Accessor; 8 | 9 | import java.util.List; 10 | import java.util.zip.ZipFile; 11 | 12 | @Mixin(value = DelegatingPackResources.class, remap = false) 13 | public interface DelegatingPackResourcesMixin { 14 | @Accessor 15 | public List getDelegates(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/resources/FilePackResourceMixin.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin.resources; 2 | 3 | import net.minecraft.server.packs.FilePackResources; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | import java.util.zip.ZipFile; 9 | 10 | @Mixin(FilePackResources.class) 11 | public interface FilePackResourceMixin { 12 | @Invoker 13 | public ZipFile invokeGetOrCreateZipFile(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/mixins/mixin/resources/PathPackResourceMixin.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.mixins.mixin.resources; 2 | 3 | import net.minecraft.server.packs.FilePackResources; 4 | import net.minecraftforge.resource.PathPackResources; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | import java.nio.file.Path; 9 | import java.util.zip.ZipFile; 10 | 11 | @Mixin(value = PathPackResources.class,remap = false) 12 | public interface PathPackResourceMixin { 13 | @Invoker 14 | public Path invokeResolve(String... paths); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/registrations/BlockEntityRendererBuilder.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.registrations; 2 | 3 | import kasuga.lib.registrations.common.BlockEntityReg; 4 | import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; 5 | import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; 6 | import net.minecraft.world.level.block.Block; 7 | import net.minecraft.world.level.block.entity.BlockEntity; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | 10 | 11 | /** 12 | * A function interface that provides a block entity renderer. If you want to use a block entity renderer on your block and 13 | * block entity, you should first override the {@link Block#getRenderShape(BlockState)} method under your block class. 14 | * Then, pass a block entity renderer builder into {@link BlockEntityReg#withRenderer(BlockEntityReg.BlockEntityRendererBuilder)} method. 15 | * The lib would deal with it for you. 16 | * @param the block entity your renderer belongs to. 17 | */ 18 | public interface BlockEntityRendererBuilder { 19 | BlockEntityRenderer build(BlockEntityRendererProvider.Context context); 20 | } -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/registrations/EntityRendererBuilder.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.registrations; 2 | 3 | import net.minecraft.client.renderer.entity.EntityRenderer; 4 | import net.minecraft.client.renderer.entity.EntityRendererProvider; 5 | import net.minecraft.world.entity.Entity; 6 | 7 | public interface EntityRendererBuilder { 8 | EntityRenderer build(EntityRendererProvider.Context context); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/registrations/builders/SelfReferenceItemBuilder.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.registrations.builders; 2 | 3 | import net.minecraft.world.item.Item; 4 | import net.minecraft.world.level.block.Block; 5 | 6 | @FunctionalInterface 7 | public interface SelfReferenceItemBuilder { 8 | I build(B block, Item.Properties properties); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/kasuga/lib/registrations/exception/RegistryElementNotPresentException.java: -------------------------------------------------------------------------------- 1 | package kasuga.lib.registrations.exception; 2 | 3 | public class RegistryElementNotPresentException extends Exception { 4 | private final Class clazz; 5 | private final String output; 6 | public RegistryElementNotPresentException(Class clazz, String output) { 7 | super(); 8 | this.clazz = clazz; 9 | this.output = output; 10 | } 11 | 12 | @Override 13 | public void printStackTrace() { 14 | System.out.println(output); 15 | super.printStackTrace(); 16 | } 17 | 18 | public static RegistryElementNotPresentException of(Class clazz, String regType, String method) { 19 | String builder = "Registry Element " + clazz + " is not present, " + 20 | "pls create a " + regType + " registration before calling " + method; 21 | return new RegistryElementNotPresentException(clazz, builder); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "kasuga_lib resource", 4 | "pack_format": 9, 5 | "forge:resource_pack_format": 9, 6 | "forge:data_pack_format": 10 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /translation/kasugalib.marks.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KasugaLibGroup/KasugaLib/6a062103eb27d4f596b94e19736ffc6c9e11d8e1/translation/kasugalib.marks.docx --------------------------------------------------------------------------------