├── src └── main │ ├── resources │ ├── icon.png │ ├── assets │ │ ├── minecraft │ │ │ └── textures │ │ │ │ └── particle │ │ │ │ ├── particles.png │ │ │ │ └── flame_atlas.png │ │ └── eyelib │ │ │ ├── textures │ │ │ └── gui │ │ │ │ └── sprites │ │ │ │ ├── gui_bg_nine.png │ │ │ │ ├── icons │ │ │ │ ├── entity.png │ │ │ │ ├── folder.png │ │ │ │ ├── model.png │ │ │ │ ├── texture.png │ │ │ │ ├── animation.png │ │ │ │ ├── render_controller.png │ │ │ │ ├── animation_controller.png │ │ │ │ └── entities │ │ │ │ │ └── minecraft │ │ │ │ │ ├── bee.png │ │ │ │ │ ├── cat.png │ │ │ │ │ ├── cow.png │ │ │ │ │ ├── fox.png │ │ │ │ │ ├── frog.png │ │ │ │ │ ├── husk.png │ │ │ │ │ ├── mule.png │ │ │ │ │ ├── pig.png │ │ │ │ │ ├── wolf.png │ │ │ │ │ ├── blaze.png │ │ │ │ │ ├── bogged.png │ │ │ │ │ ├── chicken.png │ │ │ │ │ ├── creeper.png │ │ │ │ │ ├── dolphin.png │ │ │ │ │ ├── drowned.png │ │ │ │ │ ├── evoker.png │ │ │ │ │ ├── ghast.png │ │ │ │ │ ├── hoglin.png │ │ │ │ │ ├── horse.png │ │ │ │ │ ├── llama.png │ │ │ │ │ ├── ocelot.png │ │ │ │ │ ├── panda.png │ │ │ │ │ ├── parrot.png │ │ │ │ │ ├── phantom.png │ │ │ │ │ ├── piglin.png │ │ │ │ │ ├── rabbit.png │ │ │ │ │ ├── ravager.png │ │ │ │ │ ├── sheep.png │ │ │ │ │ ├── slime.png │ │ │ │ │ ├── spider.png │ │ │ │ │ ├── stray.png │ │ │ │ │ ├── strider.png │ │ │ │ │ ├── turtle.png │ │ │ │ │ ├── warden.png │ │ │ │ │ ├── witch.png │ │ │ │ │ ├── wither.png │ │ │ │ │ ├── zoglin.png │ │ │ │ │ ├── zombie.png │ │ │ │ │ ├── enderman.png │ │ │ │ │ ├── guardian.png │ │ │ │ │ ├── mooshroom.png │ │ │ │ │ ├── pillager.png │ │ │ │ │ ├── skeleton.png │ │ │ │ │ ├── villager.png │ │ │ │ │ ├── cave_spider.png │ │ │ │ │ ├── ender_dragon.png │ │ │ │ │ ├── iron_golem.png │ │ │ │ │ ├── magma_cube.png │ │ │ │ │ ├── piglin_brute.png │ │ │ │ │ ├── polar_bear.png │ │ │ │ │ ├── silverfish.png │ │ │ │ │ ├── snow_golem.png │ │ │ │ │ ├── vindicator.png │ │ │ │ │ ├── elder_guardian.png │ │ │ │ │ ├── wandering_trader.png │ │ │ │ │ ├── wither_skeleton.png │ │ │ │ │ ├── zombie_villager.png │ │ │ │ │ └── zombified_piglin.png │ │ │ │ ├── gui_bg_nine_selected.png │ │ │ │ ├── gui_bg_nine.png.mcmeta │ │ │ │ └── gui_bg_nine_selected.png.mcmeta │ │ │ ├── shaders │ │ │ └── core │ │ │ │ ├── rendertype_item_entity_translucent_cull_chunk.fsh │ │ │ │ ├── rendertype_entity_translucent_chunk.fsh │ │ │ │ ├── rendertype_entity_cutout_no_cull_chunk.fsh │ │ │ │ ├── rendertype_item_entity_translucent_cull_chunk.vsh │ │ │ │ ├── rendertype_entity_cutout_no_cull_chunk.vsh │ │ │ │ ├── rendertype_entity_translucent_chunk.vsh │ │ │ │ ├── rendertype_item_entity_translucent_cull_chunk.json │ │ │ │ ├── rendertype_entity_translucent_chunk.json │ │ │ │ └── rendertype_entity_cutout_no_cull_chunk.json │ │ │ └── eyelib │ │ │ ├── materials │ │ │ └── vanilla.material │ │ │ └── particles │ │ │ ├── test_direction_x.json │ │ │ ├── test_direction_y.json │ │ │ ├── test_direction_z.json │ │ │ ├── test_lookat_y.json │ │ │ ├── test_rotate_y.json │ │ │ ├── test_lookat_xyz.json │ │ │ └── test_rotate_xyz.json │ └── eyelib.mixins.json │ └── java │ └── io │ └── github │ └── tt432 │ └── eyelib │ ├── client │ ├── model │ │ ├── tree │ │ │ ├── ModelCubeNode.java │ │ │ ├── ModelTree.java │ │ │ └── ModelGroupNode.java │ │ ├── RootModelPartModel.java │ │ ├── bake │ │ │ └── BakedModels.java │ │ ├── ModelRuntimeData.java │ │ ├── bedrock │ │ │ ├── BrFace.java │ │ │ ├── BrModel.java │ │ │ └── BrTextureMesh.java │ │ ├── locator │ │ │ ├── LocatorEntry.java │ │ │ ├── ModelLocator.java │ │ │ └── GroupLocator.java │ │ ├── GlobalBoneIdHandler.java │ │ └── transformer │ │ │ └── ModelTransformer.java │ ├── gui │ │ ├── MouseAction.java │ │ ├── manager │ │ │ └── ClientEntityView.java │ │ ├── EyelibGuis.java │ │ └── RenderTargets.java │ ├── particle │ │ └── bedrock │ │ │ └── component │ │ │ ├── ComponentTarget.java │ │ │ ├── ParticleComponent.java │ │ │ ├── RegisterParticleComponent.java │ │ │ ├── particle │ │ │ ├── ParticleParticleComponent.java │ │ │ ├── appearance │ │ │ │ └── ParticleAppearanceLighting.java │ │ │ ├── lifetime │ │ │ │ ├── ParticleLifetimeKillPlane.java │ │ │ │ ├── ParticleExpireIfInBlocks.java │ │ │ │ ├── ParticleExpireIfNotInBlocks.java │ │ │ │ └── ParticleLifetimeExpression.java │ │ │ ├── initial │ │ │ │ ├── ParticleInitialSpeed.java │ │ │ │ └── ParticleInitialSpin.java │ │ │ └── motion │ │ │ │ └── ParticleMotionParametric.java │ │ │ └── emitter │ │ │ ├── EmitterParticleComponent.java │ │ │ ├── rate │ │ │ ├── EmitterRateManual.java │ │ │ └── EmitterRateInstant.java │ │ │ ├── EmitterLocalSpace.java │ │ │ ├── EmitterInitialization.java │ │ │ └── shape │ │ │ ├── EmitterShapePoint.java │ │ │ ├── EmitterShapeCustom.java │ │ │ └── Direction.java │ ├── render │ │ ├── visitor │ │ │ ├── ModelRenderVisitorList.java │ │ │ ├── ModelVisitContext.java │ │ │ ├── BuiltInBrModelRenderVisitors.java │ │ │ ├── ModelRenderVisitorRegistry.java │ │ │ ├── RenderModelVisitor.java │ │ │ └── CollectLocatorModelVisitor.java │ │ ├── bone │ │ │ ├── BoneRenderInfoEntry.java │ │ │ └── BoneRenderInfos.java │ │ ├── controller │ │ │ └── RenderControllers.java │ │ ├── RenderParams.java │ │ └── ModelRenderer.java │ ├── animation │ │ ├── AnimationEffects.java │ │ ├── RuntimeParticlePlayData.java │ │ ├── bedrock │ │ │ ├── BrAnimation.java │ │ │ ├── controller │ │ │ │ ├── BrAnimationControllers.java │ │ │ │ └── BrAcParticleEffect.java │ │ │ ├── BrLoopType.java │ │ │ └── BrEffectsKeyFrame.java │ │ ├── Animation.java │ │ ├── AnimationEffect.java │ │ └── BrAnimator.java │ ├── manager │ │ ├── ModelManager.java │ │ ├── AnimationManager.java │ │ ├── ParticleManager.java │ │ ├── MaterialManager.java │ │ ├── RenderControllerManager.java │ │ └── Manager.java │ ├── loader │ │ ├── BrResourcesLoader.java │ │ └── BlockBrModelLoader.java │ ├── compat │ │ └── ar │ │ │ ├── ARCompat.java │ │ │ └── ARCompatImpl.java │ ├── material │ │ └── BrMaterial.java │ ├── entity │ │ └── ClientEntityRuntimeData.java │ ├── ClientTickHandler.java │ ├── gl │ │ ├── stencil │ │ │ ├── StencilFailOp.java │ │ │ ├── StencilPassOp.java │ │ │ ├── StencilDepthFailOp.java │ │ │ ├── StencilFunc.java │ │ │ └── Face.java │ │ ├── DepthFunc.java │ │ └── BlendFactor.java │ └── cursor │ │ ├── CursorManager.java │ │ └── Cursor.java │ ├── common │ ├── behavior │ │ ├── component │ │ │ ├── Physics.java │ │ │ ├── Component.java │ │ │ ├── AmbientSoundInterval.java │ │ │ ├── EmptyComponent.java │ │ │ ├── Variant.java │ │ │ ├── MarkVariant.java │ │ │ ├── Addrider.java │ │ │ └── AdmireItem.java │ │ ├── event │ │ │ ├── EntityEvent.java │ │ │ ├── EntitySpawned.java │ │ │ ├── logic │ │ │ │ ├── Sequence.java │ │ │ │ ├── LogicNode.java │ │ │ │ ├── Add.java │ │ │ │ └── Remove.java │ │ │ └── filter │ │ │ │ ├── Filter.java │ │ │ │ ├── Operator.java │ │ │ │ ├── base │ │ │ │ ├── ActorHealth.java │ │ │ │ └── BaseFilter.java │ │ │ │ ├── Subject.java │ │ │ │ └── ComplexFilter.java │ │ └── BehaviorEntity.java │ └── EntityStatisticsHandler.java │ ├── event │ ├── TextureChangedEvent.java │ ├── InitComponentEvent.java │ └── ManagerEntryChangedEvent.java │ ├── util │ ├── CalledByGeneratedMethod.java │ ├── search │ │ ├── Searchable.java │ │ └── SearchResults.java │ ├── EyelibUtils.java │ ├── Blackboard.java │ ├── ResourceLocations.java │ ├── math │ │ ├── Shapes.java │ │ └── Curves.java │ ├── SimpleTimer.java │ └── client │ │ ├── RenderTypeSerializations.java │ │ ├── BufferBuilders.java │ │ └── AnimationApplier.java │ ├── compute │ ├── LazyComputeBufferBuilder.java │ ├── LazyComputeMeshData.java │ ├── EyelibComputes.java │ └── ComputeShader.java │ ├── capability │ ├── component │ │ ├── RenderControllerComponent.java │ │ └── ClientEntityComponent.java │ ├── EntityStatistics.java │ └── ItemInHandRenderData.java │ ├── mixin │ ├── attachable │ │ ├── IClientItemExtensionsMixin.java │ │ └── AbstractContainerScreenMixin.java │ ├── LivingEntityRendererAccessor.java │ ├── VertexBufferMixin.java │ ├── HumanoidModelMixin.java │ └── BufferBuilderMixin.java │ ├── EyelibClient.java │ ├── molang │ ├── mapping │ │ ├── api │ │ │ ├── MolangFunction.java │ │ │ ├── MolangMapping.java │ │ │ └── MolangFunctionExporter.java │ │ └── MolangToplevel.java │ ├── type │ │ ├── MolangObjects.java │ │ ├── MolangNull.java │ │ ├── MolangObject.java │ │ ├── MolangFloatSupplierObject.java │ │ ├── MolangDynamicObject.java │ │ ├── MolangString.java │ │ ├── MolangArray.java │ │ └── MolangFloat.java │ ├── compiler │ │ ├── MolangClassDescs.java │ │ └── MolangCompileCache.java │ ├── MolangUncompilableException.java │ ├── MolangValue2.java │ └── MolangValue4.java │ └── network │ ├── UpdateDestroyInfoPacket.java │ ├── RemoveParticlePacket.java │ ├── ExtraEntityDataPacket.java │ ├── ExtraEntityUpdateDataPacket.java │ ├── AnimationComponentSyncPacket.java │ ├── SpawnParticlePacket.java │ └── ModelComponentSyncPacket.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── example └── src │ └── main │ └── resources │ └── assets │ └── examplemod │ └── lang │ └── en_us.json ├── .gitattributes ├── .gitignore ├── settings.gradle ├── README.cn.md ├── README.md └── LICENSE /src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/icon.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/textures/particle/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/minecraft/textures/particle/particles.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entity.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/folder.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/model.png -------------------------------------------------------------------------------- /src/main/resources/assets/minecraft/textures/particle/flame_atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/minecraft/textures/particle/flame_atlas.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/texture.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/animation.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine_selected.png -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/tree/ModelCubeNode.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.tree; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface ModelCubeNode { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/Physics.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public class Physics { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/EntityEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public class EntityEvent { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/render_controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/render_controller.png -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/EntitySpawned.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public class EntitySpawned { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/animation_controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/animation_controller.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/bee.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cat.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cow.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/fox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/fox.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/frog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/frog.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/husk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/husk.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/mule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/mule.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/pig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/pig.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wolf.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/blaze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/blaze.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/bogged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/bogged.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/chicken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/chicken.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/creeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/creeper.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/dolphin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/dolphin.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/drowned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/drowned.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/evoker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/evoker.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ghast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ghast.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/hoglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/hoglin.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/horse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/horse.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/llama.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/llama.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ocelot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ocelot.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/panda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/panda.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/parrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/parrot.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/phantom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/phantom.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/piglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/piglin.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/rabbit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/rabbit.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ravager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ravager.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/sheep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/sheep.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/slime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/slime.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/spider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/spider.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/stray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/stray.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/strider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/strider.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/turtle.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/warden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/warden.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/witch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/witch.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wither.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wither.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zoglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zoglin.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombie.png -------------------------------------------------------------------------------- /example/src/main/resources/assets/examplemod/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "itemGroup.examplemod": "Example Mod Tab", 3 | "block.examplemod.example_block": "Example Block", 4 | "item.examplemod.example_item": "Example Item" 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/enderman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/enderman.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/guardian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/guardian.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/mooshroom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/mooshroom.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/pillager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/pillager.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/skeleton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/skeleton.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/villager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/villager.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cave_spider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/cave_spider.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ender_dragon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/ender_dragon.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/iron_golem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/iron_golem.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/magma_cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/magma_cube.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/piglin_brute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/piglin_brute.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/polar_bear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/polar_bear.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/silverfish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/silverfish.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/snow_golem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/snow_golem.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/vindicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/vindicator.png -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/Component.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface Component { 7 | String id(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/elder_guardian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/elder_guardian.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine.png.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "gui": { 3 | "scaling": { 4 | "type": "nine_slice", 5 | "width": 16, 6 | "height": 16, 7 | "border": 4 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wandering_trader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wandering_trader.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wither_skeleton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/wither_skeleton.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombie_villager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombie_villager.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombified_piglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TT432/eyelib/HEAD/src/main/resources/assets/eyelib/textures/gui/sprites/icons/entities/minecraft/zombified_piglin.png -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/textures/gui/sprites/gui_bg_nine_selected.png.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "gui": { 3 | "scaling": { 4 | "type": "nine_slice", 5 | "width": 16, 6 | "height": 16, 7 | "border": 4 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gui/MouseAction.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gui; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public enum MouseAction { 7 | CLICK, 8 | DOUBLE_CLICK, 9 | PRESS, 10 | DRAG 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/event/TextureChangedEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.event; 2 | 3 | import net.neoforged.bus.api.Event; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public class TextureChangedEvent extends Event { 9 | } 10 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/ComponentTarget.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public enum ComponentTarget { 7 | EMITTER, 8 | PARTICLE 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/AmbientSoundInterval.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | /** 4 | * Delay for an entity playing its sound. 5 | * @author TT432 6 | */ 7 | public class AmbientSoundInterval { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/tree/ModelTree.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.tree; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface ModelTree, C extends ModelCubeNode> { 7 | G getGroup(int groupId); 8 | } 9 | -------------------------------------------------------------------------------- /.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 | runs 24 | run-data 25 | 26 | repo 27 | 28 | 文档 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/RootModelPartModel.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model; 2 | 3 | import net.minecraft.client.model.geom.ModelPart; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public interface RootModelPartModel { 9 | ModelPart getRootPart(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gui/manager/ClientEntityView.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gui.manager; 2 | 3 | import io.github.tt432.eyelib.client.entity.BrClientEntity; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public class ClientEntityView { 9 | BrClientEntity entity; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/ModelRenderVisitorList.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public record ModelRenderVisitorList( 9 | List visitors 10 | ) { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/ParticleComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface ParticleComponent { 7 | ParticleComponent EMPTY = new ParticleComponent() { 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/tree/ModelGroupNode.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.tree; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface ModelGroupNode { 7 | ModelGroupNode getChild(int groupName); 8 | 9 | C getCubeNode(int index); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/CalledByGeneratedMethod.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | @Target(ElementType.METHOD) 10 | public @interface CalledByGeneratedMethod { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/compute/LazyComputeBufferBuilder.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.compute; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public interface LazyComputeBufferBuilder { 7 | 8 | VertexComputeHelper getEyelib$helper(); 9 | 10 | void setEyelib$helper(VertexComputeHelper helper) ; 11 | } 12 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenLocal() 4 | gradlePluginPortal() 5 | maven { url = 'https://maven.neoforged.net/releases' } 6 | } 7 | } 8 | 9 | plugins { 10 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' 11 | } 12 | 13 | rootProject.name = "eyelib" 14 | include(":example") -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/AnimationEffects.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public class AnimationEffects { 10 | public final List> particles = new ArrayList<>(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/capability/component/RenderControllerComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.capability.component; 2 | 3 | import io.github.tt432.eyelib.client.render.controller.RenderControllerEntry; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public class RenderControllerComponent { 9 | RenderControllerEntry renderController; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/attachable/IClientItemExtensionsMixin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin.attachable; 2 | 3 | import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | @Mixin(IClientItemExtensions.class) 10 | public interface IClientItemExtensionsMixin { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/search/Searchable.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.search; 2 | 3 | import java.util.Map; 4 | import java.util.stream.Stream; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public interface Searchable { 10 | Stream> search(String searchStr); 11 | 12 | default SearchResults results() { 13 | return new SearchResults<>(this); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/event/InitComponentEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.event; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import net.neoforged.bus.api.Event; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @EqualsAndHashCode(callSuper = true) 11 | @Data 12 | public class InitComponentEvent extends Event { 13 | public final Object entity; 14 | public final Object componentObject; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/EyelibClient.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib; 2 | 3 | import net.neoforged.api.distmarker.Dist; 4 | import net.neoforged.fml.common.Mod; 5 | import org.lwjgl.opengl.GL; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @Mod(value = Eyelib.MOD_ID, dist = Dist.CLIENT) 11 | public class EyelibClient { 12 | public static boolean supportComputeShader() { 13 | return GL.getCapabilities().GL_ARB_compute_shader; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/ModelManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.client.model.Model; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class ModelManager extends Manager { 12 | public static final ModelManager INSTANCE = new ModelManager(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/loader/BrResourcesLoader.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.loader; 2 | 3 | import com.google.gson.GsonBuilder; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public abstract class BrResourcesLoader extends SimpleJsonWithSuffixResourceReloadListener { 9 | public BrResourcesLoader(String directory, String suffix) { 10 | super(new GsonBuilder().setLenient().create(), "eyelib/" + directory, suffix); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/bake/BakedModels.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.bake; 2 | 3 | import lombok.experimental.UtilityClass; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @UtilityClass 13 | public class BakedModels { 14 | private final Map> cache = new HashMap<>(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/ModelRuntimeData.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model; 2 | 3 | import io.github.tt432.eyelib.client.model.transformer.ModelTransformer; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public interface ModelRuntimeData> { 10 | @Nullable 11 | D getData(int id); 12 | 13 | ModelTransformer transformer(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/RuntimeParticlePlayData.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation; 2 | 3 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public record RuntimeParticlePlayData( 10 | String particleUUID, 11 | BrParticleEmitter emitter, 12 | @Nullable String locator, 13 | float startTicks 14 | ) { 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/event/ManagerEntryChangedEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.event; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import net.neoforged.bus.api.Event; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class ManagerEntryChangedEvent extends Event { 13 | private final String managerName; 14 | private final String entryName; 15 | private final Object entryData; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/AnimationManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.client.animation.Animation; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class AnimationManager extends Manager> { 12 | public static final AnimationManager INSTANCE = new AnimationManager(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/ParticleManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticle; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class ParticleManager extends Manager { 12 | public static final ParticleManager INSTANCE = new ParticleManager(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/MaterialManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.client.material.BrMaterialEntry; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class MaterialManager extends Manager { 12 | public static final MaterialManager INSTANCE = new MaterialManager(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/EmptyComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | import com.mojang.serialization.Codec; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public record EmptyComponent() implements Component { 9 | public static final EmptyComponent INSTANCE = new EmptyComponent(); 10 | 11 | public static final Codec CODEC = Codec.unit(INSTANCE); 12 | 13 | @Override 14 | public String id() { 15 | return "empty"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/RenderControllerManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.client.render.controller.RenderControllerEntry; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 11 | public class RenderControllerManager extends Manager { 12 | public static final RenderControllerManager INSTANCE = new RenderControllerManager(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/eyelib.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.github.tt432.eyelib.mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "mixins": [ 7 | "attachable.IClientItemExtensionsMixin" 8 | ], 9 | "client": [ 10 | "BufferBuilderMixin", 11 | "HumanoidModelMixin", 12 | "LivingEntityRendererAccessor", 13 | "MultiPlayerGameModeMixin", 14 | "VertexBufferMixin", 15 | "attachable.AbstractContainerScreenMixin" 16 | ], 17 | "injectors": { 18 | "defaultRequire": 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/LivingEntityRendererAccessor.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin; 2 | 3 | import net.minecraft.client.renderer.entity.LivingEntityRenderer; 4 | import net.minecraft.world.entity.LivingEntity; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @Mixin(LivingEntityRenderer.class) 12 | public interface LivingEntityRendererAccessor { 13 | @Invoker 14 | float callGetWhiteOverlayProgress(LivingEntity le, float partialTicks); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/mapping/api/MolangFunction.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.mapping.api; 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 | /** 9 | * @author TT432 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface MolangFunction { 14 | String value(); 15 | 16 | String[] alias() default ""; 17 | 18 | String description() default ""; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/RegisterParticleComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component; 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 | /** 9 | * @author TT432 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | public @interface RegisterParticleComponent { 14 | String value(); 15 | 16 | String type() default ""; 17 | 18 | ComponentTarget target(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/ParticleParticleComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle; 2 | 3 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 4 | import io.github.tt432.eyelib.client.particle.bedrock.component.ParticleComponent; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public interface ParticleParticleComponent extends ParticleComponent { 10 | default void onStart(BrParticleParticle particle) { 11 | } 12 | 13 | default void onFrame(BrParticleParticle particle) { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/compat/ar/ARCompat.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.compat.ar; 2 | 3 | import io.github.tt432.eyelib.client.model.bake.BakedModel; 4 | import io.github.tt432.eyelib.client.render.RenderParams; 5 | import net.neoforged.fml.loading.LoadingModList; 6 | 7 | public class ARCompat { 8 | public static final boolean AR_INSTALLED = LoadingModList.get().getModFileById("acceleratedrendering") != null; 9 | 10 | public static boolean renderWithAR(BakedModel.BakedBone bakedBone, RenderParams params) { 11 | return ARCompatImpl.renderWithAR(bakedBone, params); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangObjects.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | import io.github.tt432.eyelib.util.CalledByGeneratedMethod; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public class MolangObjects { 9 | @CalledByGeneratedMethod 10 | public static MolangObject valueOf(Object value) { 11 | return switch (value) { 12 | case Number f -> MolangFloat.valueOf(f.floatValue()); 13 | case String s -> MolangString.valueOf(s); 14 | case MolangObject o -> o; 15 | default -> MolangNull.INSTANCE; 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/compute/LazyComputeMeshData.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.compute; 2 | 3 | import com.mojang.blaze3d.vertex.ByteBufferBuilder; 4 | import com.mojang.blaze3d.vertex.MeshData; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @Getter 12 | @Setter 13 | public class LazyComputeMeshData extends MeshData { 14 | VertexComputeHelper helper; 15 | 16 | public LazyComputeMeshData(ByteBufferBuilder.Result vertexBuffer, DrawState drawState, VertexComputeHelper helper) { 17 | super(vertexBuffer, drawState); 18 | this.helper = helper; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangNull.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public record MolangNull() implements MolangObject { 7 | public static final MolangNull INSTANCE = new MolangNull(); 8 | 9 | @Override 10 | public float asFloat() { 11 | return 0; 12 | } 13 | 14 | @Override 15 | public boolean asBoolean() { 16 | return false; 17 | } 18 | 19 | @Override 20 | public String asString() { 21 | return ""; 22 | } 23 | 24 | @Override 25 | public boolean isNumber() { 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/material/BrMaterial.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.material; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public record BrMaterial( 12 | Map materials 13 | ) { 14 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 15 | Codec.dispatchedMap(Codec.STRING, BrMaterialEntry.CODEC::apply).fieldOf("materials").forGetter(BrMaterial::materials) 16 | ).apply(ins, BrMaterial::new)); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/Variant.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public record Variant( 10 | int value 11 | ) implements Component { 12 | 13 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 14 | Codec.INT.fieldOf("value").forGetter(Variant::value) 15 | ).apply(ins, Variant::new)); 16 | 17 | @Override 18 | public String id() { 19 | return "variant"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/compute/EyelibComputes.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.compute; 2 | 3 | import com.mojang.blaze3d.vertex.MeshData; 4 | import lombok.experimental.UtilityClass; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | @UtilityClass 10 | public class EyelibComputes { 11 | 12 | public void compute(MeshData meshData, int vertexBufferId) { 13 | if (meshData instanceof LazyComputeMeshData lc) { 14 | VertexComputeHelper helper = lc.getHelper(); 15 | 16 | if (helper != null) { 17 | helper.compute(vertexBufferId); 18 | helper.clear(); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangObject.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | import io.github.tt432.eyelib.util.CalledByGeneratedMethod; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public interface MolangObject { 9 | float asFloat(); 10 | 11 | boolean asBoolean(); 12 | 13 | String asString(); 14 | 15 | boolean isNumber(); 16 | 17 | @CalledByGeneratedMethod 18 | default float equalsF(MolangObject other) { 19 | return equals(other) ? 1 : 0; 20 | } 21 | 22 | @CalledByGeneratedMethod 23 | default float nEqualsF(MolangObject other) { 24 | return equals(other) ? 0 : 1; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/MarkVariant.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public record MarkVariant( 10 | int value 11 | ) implements Component { 12 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 13 | Codec.INT.fieldOf("value").forGetter(MarkVariant::value) 14 | ).apply(ins, MarkVariant::new)); 15 | 16 | @Override 17 | public String id() { 18 | return "mark_variant"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_item_entity_translucent_cull_chunk.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform sampler2D Sampler0; 6 | 7 | uniform vec4 ColorModulator; 8 | uniform float FogStart; 9 | uniform float FogEnd; 10 | uniform vec4 FogColor; 11 | 12 | in float vertexDistance; 13 | in vec4 vertexColor; 14 | in vec2 texCoord0; 15 | in vec2 texCoord1; 16 | 17 | out vec4 fragColor; 18 | 19 | void main() { 20 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 21 | if (color.a < 0.1) { 22 | discard; 23 | } 24 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/search/SearchResults.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.search; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @RequiredArgsConstructor 14 | public class SearchResults { 15 | private final Searchable searchable; 16 | @Getter 17 | private final List> suggestions = new ArrayList<>(); 18 | 19 | public void update(String searchString) { 20 | suggestions.clear(); 21 | searchable.search(searchString).forEach(suggestions::add); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/materials/vanilla.material: -------------------------------------------------------------------------------- 1 | { 2 | "materials": { 3 | "cutout": { 4 | "vertexShader": "a", 5 | "fragmentShader": "b", 6 | "defines": [], 7 | "samplerStates": [], 8 | "states": [], 9 | "variants": [] 10 | }, 11 | "translucent": { 12 | "vertexShader": "a", 13 | "fragmentShader": "b", 14 | "defines": [], 15 | "samplerStates": [], 16 | "states": [], 17 | "variants": [] 18 | }, 19 | "solid": { 20 | "vertexShader": "a", 21 | "fragmentShader": "b", 22 | "defines": [], 23 | "samplerStates": [], 24 | "states": [], 25 | "variants": [] 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/compiler/MolangClassDescs.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.compiler; 2 | 3 | import io.github.tt432.eyelib.molang.MolangScope; 4 | import io.github.tt432.eyelib.molang.type.MolangObject; 5 | 6 | import java.lang.constant.ClassDesc; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public final class MolangClassDescs { 12 | public static ClassDesc CD_MolangObject = ClassDesc.of(MolangObject.class.getName()); 13 | public static ClassDesc CD_MolangScope = ClassDesc.of(MolangScope.class.getName()); 14 | 15 | private MolangClassDescs() { 16 | throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/bedrock/BrAnimation.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation.bedrock; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @Slf4j 13 | public record BrAnimation( 14 | Map animations 15 | ) { 16 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 17 | Codec.dispatchedMap(Codec.STRING, BrAnimationEntry::codec).fieldOf("animations").forGetter(o -> o.animations) 18 | ).apply(ins, BrAnimation::new)); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/bone/BoneRenderInfoEntry.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.bone; 2 | 3 | import lombok.Data; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.joml.Vector3f; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @Data 11 | public class BoneRenderInfoEntry { 12 | @NotNull 13 | private final Vector3f renderScala = new Vector3f(1); 14 | @NotNull 15 | private final Vector3f renderPosition = new Vector3f(); 16 | @NotNull 17 | private final Vector3f renderRotation = new Vector3f(); 18 | 19 | public void resetRenderInfo() { 20 | renderScala.set(1); 21 | renderPosition.set(0); 22 | renderRotation.set(0); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/controller/RenderControllers.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.controller; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public record RenderControllers( 12 | Map render_controllers 13 | ) { 14 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 15 | Codec.unboundedMap(Codec.STRING, RenderControllerEntry.CODEC).fieldOf("render_controllers").forGetter(RenderControllers::render_controllers) 16 | ).apply(ins, RenderControllers::new)); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/entity/ClientEntityRuntimeData.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.entity; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.client.model.Model; 5 | import it.unimi.dsi.fastutil.objects.Object2ObjectMap; 6 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public class ClientEntityRuntimeData { 12 | Object2ObjectMap models = new Object2ObjectOpenHashMap<>(); 13 | 14 | public void setup(BrClientEntity clientEntity) { 15 | clientEntity.geometry().forEach((shortName, geometry) -> { 16 | models.put(shortName, Eyelib.getModelManager().get(geometry)); 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangFloatSupplierObject.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | import io.github.tt432.eyelib.molang.MolangScope; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public record MolangFloatSupplierObject( 9 | MolangScope.FloatSupplier supplier 10 | ) implements MolangObject { 11 | 12 | @Override 13 | public float asFloat() { 14 | return supplier.get(); 15 | } 16 | 17 | @Override 18 | public boolean asBoolean() { 19 | return supplier.get() != 0; 20 | } 21 | 22 | @Override 23 | public String asString() { 24 | return ""; 25 | } 26 | 27 | @Override 28 | public boolean isNumber() { 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /README.cn.md: -------------------------------------------------------------------------------- 1 | # Eyelib 2 | 3 | 基于《Minecraft》的渲染 mod。 4 | 5 | [English](README.md) | [中文](README.cn.md) 6 | 7 | ![Maven Central Version](https://img.shields.io/maven-central/v/io.github.tt432/eyelib) 8 | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/TT432/eyelib) 9 | 10 | ## 快速上手 11 | 12 | 该库已发布至 Maven Central。 13 | 14 | ```groovy 15 | dependencies { 16 | implementation "io.github.tt432:eyelib:${eyelib_version}" 17 | } 18 | ``` 19 | 20 | ## 依赖 21 | 22 | - [Antlr-Molang](https://github.com/TT432/antlr-molang) 用于解析 Molang。 23 | - [jdk-classfile-backport](https://github.com/dmlloyd/jdk-classfile-backport) 用于生成 molang 字节码。 24 | - [lombok](https://projectlombok.org/) 用于生成 getter/setter 等。 25 | - [Chin](https://github.com/TT432/chin) 用于提供工具类。 -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/logic/Sequence.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.logic; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.capability.EntityBehaviorData; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public record Sequence( 12 | List nodes 13 | ) implements LogicNode { 14 | public static final Codec CODEC = LogicNode.CODEC.codec().listOf().xmap(Sequence::new, Sequence::nodes); 15 | 16 | @Override 17 | public void eval(EntityBehaviorData data) { 18 | // 遍历 nodes 列表,依次执行每个逻辑节点的 eval 方法 19 | for (LogicNode node : nodes) { 20 | node.eval(data); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangDynamicObject.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | public record MolangDynamicObject( 9 | Supplier supplier 10 | ) implements MolangObject { 11 | @Override 12 | public float asFloat() { 13 | return supplier.get().asFloat(); 14 | } 15 | 16 | @Override 17 | public boolean asBoolean() { 18 | return supplier.get().asBoolean(); 19 | } 20 | 21 | @Override 22 | public String asString() { 23 | return supplier.get().asString(); 24 | } 25 | 26 | @Override 27 | public boolean isNumber() { 28 | return supplier.get().isNumber(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/mapping/MolangToplevel.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.mapping; 2 | 3 | import io.github.tt432.eyelib.molang.mapping.api.MolangMapping; 4 | import io.github.tt432.eyelib.util.math.EyeMath; 5 | import lombok.AccessLevel; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @MolangMapping("") 12 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 13 | @SuppressWarnings("unused") 14 | public final class MolangToplevel { 15 | public static final float pi = EyeMath.PI; 16 | public static final float e = EyeMath.E; 17 | 18 | public static float loop(float times, Runnable r) { 19 | for (int i = 0; i < times; i++) { 20 | r.run(); 21 | } 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/EyelibUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util; 2 | 3 | import io.github.tt432.eyelib.molang.type.MolangArray; 4 | import io.github.tt432.eyelib.molang.type.MolangNull; 5 | import io.github.tt432.eyelib.molang.type.MolangObject; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public class EyelibUtils { 11 | @CalledByGeneratedMethod 12 | public static MolangObject blackhole(MolangObject... f) { 13 | return f[f.length - 1]; 14 | } 15 | 16 | @CalledByGeneratedMethod 17 | public static MolangObject get(MolangObject object, float index) { 18 | return object instanceof MolangArray ma 19 | ? ma.value().get(Math.min(Math.max((int) index, 0), ma.value().size() - 1)) 20 | : MolangNull.INSTANCE; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangString.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public record MolangString( 7 | String v 8 | ) implements MolangObject { 9 | public static MolangString valueOf(String value) { 10 | return new MolangString(value); 11 | } 12 | 13 | @Override 14 | public float asFloat() { 15 | return 0; 16 | } 17 | 18 | @Override 19 | public boolean asBoolean() { 20 | return false; 21 | } 22 | 23 | @Override 24 | public String asString() { 25 | return v; 26 | } 27 | 28 | @Override 29 | public boolean isNumber() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return v; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_translucent_chunk.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform sampler2D Sampler0; 6 | 7 | uniform vec4 ColorModulator; 8 | uniform float FogStart; 9 | uniform float FogEnd; 10 | uniform vec4 FogColor; 11 | 12 | in float vertexDistance; 13 | in vec4 vertexColor; 14 | in vec4 lightMapColor; 15 | in vec4 overlayColor; 16 | in vec2 texCoord0; 17 | 18 | out vec4 fragColor; 19 | 20 | void main() { 21 | vec4 color = texture(Sampler0, texCoord0); 22 | if (color.a < 0.1) { 23 | discard; 24 | } 25 | color *= vertexColor * ColorModulator; 26 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 27 | color *= lightMapColor; 28 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_cutout_no_cull_chunk.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform sampler2D Sampler0; 6 | 7 | uniform vec4 ColorModulator; 8 | uniform float FogStart; 9 | uniform float FogEnd; 10 | uniform vec4 FogColor; 11 | 12 | in float vertexDistance; 13 | in vec4 vertexColor; 14 | in vec4 lightMapColor; 15 | in vec4 overlayColor; 16 | in vec2 texCoord0; 17 | 18 | out vec4 fragColor; 19 | 20 | void main() { 21 | vec4 color = texture(Sampler0, texCoord0); 22 | if (color.a < 0.1) { 23 | discard; 24 | } 25 | color *= vertexColor * ColorModulator; 26 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 27 | color *= lightMapColor; 28 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Eyelib 2 | 3 | the renderer lib for _Minecraft_. 4 | 5 | [English](README.md) | [中文](README.cn.md) 6 | 7 | ![Maven Central Version](https://img.shields.io/maven-central/v/io.github.tt432/eyelib) 8 | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/TT432/eyelib) 9 | 10 | ## Getting Started 11 | 12 | The lib is published to Maven Central. 13 | 14 | ```groovy 15 | dependencies { 16 | implementation "io.github.tt432:eyelib:${eyelib_version}" 17 | } 18 | ``` 19 | 20 | ## Dependencies 21 | 22 | - [Antlr-Molang](https://github.com/TT432/antlr-molang) for parse Molang. 23 | - [jdk-classfile-backport](https://github.com/dmlloyd/jdk-classfile-backport) for generate bytecode for Molang. 24 | - [lombok](https://projectlombok.org/) for generate getter/setter and more. 25 | - [Chin](https://github.com/TT432/chin) for utils. -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/MolangUncompilableException.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public class MolangUncompilableException extends RuntimeException{ 7 | public MolangUncompilableException() { 8 | } 9 | 10 | public MolangUncompilableException(String message) { 11 | super(message); 12 | } 13 | 14 | public MolangUncompilableException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | public MolangUncompilableException(Throwable cause) { 19 | super(cause); 20 | } 21 | 22 | public MolangUncompilableException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 23 | super(message, cause, enableSuppression, writableStackTrace); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/ClientTickHandler.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import net.minecraft.client.Minecraft; 7 | import net.neoforged.api.distmarker.Dist; 8 | import net.neoforged.bus.api.SubscribeEvent; 9 | import net.neoforged.fml.common.EventBusSubscriber; 10 | import net.neoforged.neoforge.client.event.ClientTickEvent; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @EventBusSubscriber(Dist.CLIENT) 16 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 17 | public class ClientTickHandler { 18 | @Getter 19 | static int tick; 20 | 21 | @SubscribeEvent 22 | public static void onEvent(ClientTickEvent.Pre event) { 23 | if (!Minecraft.getInstance().isPaused()) 24 | tick++; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/Filter.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter; 2 | 3 | import com.mojang.datafixers.util.Either; 4 | import com.mojang.serialization.Codec; 5 | import io.github.tt432.eyelib.common.behavior.event.filter.base.BaseFilter; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public interface Filter { 11 | Codec CODEC = Codec.either(BaseFilter.CODEC, ComplexFilter.CODEC.codec()).xmap( 12 | e -> e.left().map(b -> (Filter) b).orElse(e.right().orElseThrow()), 13 | v -> switch (v) { 14 | case BaseFilter baseFilter -> Either.left(baseFilter); 15 | case ComplexFilter complexFilter -> Either.right(complexFilter); 16 | default -> throw new IllegalStateException("Unexpected value: " + v); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/stencil/StencilFailOp.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl.stencil; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.lwjgl.opengl.GL11; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum StencilFailOp implements StringRepresentable { 11 | /** 12 | * 保留缓冲区原有值 13 | */ 14 | Keep(GL11.GL_KEEP), 15 | 16 | /** 17 | * 使用参考值与掩码的按位与结果替换缓冲区值 18 | */ 19 | Replace(GL11.GL_REPLACE); 20 | 21 | public static final Codec CODEC = StringRepresentable.fromEnum(StencilFailOp::values); 22 | public final int value; 23 | 24 | StencilFailOp(int value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public String getSerializedName() { 30 | return name(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/stencil/StencilPassOp.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl.stencil; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.lwjgl.opengl.GL11; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum StencilPassOp implements StringRepresentable { 11 | /** 12 | * 保留缓冲区原有值 13 | */ 14 | Keep(GL11.GL_KEEP), 15 | 16 | /** 17 | * 使用参考值与掩码的按位与结果替换缓冲区值 18 | */ 19 | Replace(GL11.GL_REPLACE); 20 | 21 | public static final Codec CODEC = StringRepresentable.fromEnum(StencilPassOp::values); 22 | public final int value; 23 | 24 | StencilPassOp(int value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public String getSerializedName() { 30 | return name(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gui/EyelibGuis.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gui; 2 | 3 | import lombok.experimental.UtilityClass; 4 | 5 | /** 6 | * @author TT432 7 | */ 8 | @UtilityClass 9 | public class EyelibGuis { 10 | @FunctionalInterface 11 | public interface DrawStringAction { 12 | void draw(int xOffset, String string); 13 | } 14 | 15 | /** 16 | * example: getBoldString("123456789", 2, 6) // 12§l3456§r789 17 | */ 18 | public String getBoldString(String value, int highlightStart, int highlightEnd) { 19 | String startSubString = value.substring(0, highlightStart); 20 | String centerSubString = "§l" + value.substring(highlightStart, highlightEnd); 21 | String endSubString = "§r" + value.substring(highlightEnd); 22 | return startSubString + centerSubString + endSubString; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/appearance/ParticleAppearanceLighting.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.appearance; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @RegisterParticleComponent(value = "particle_appearance_lighting", target = ComponentTarget.PARTICLE) 12 | public record ParticleAppearanceLighting() implements ParticleParticleComponent { 13 | public static final Codec CODEC = Codec.unit(new ParticleAppearanceLighting()); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/stencil/StencilDepthFailOp.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl.stencil; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.lwjgl.opengl.GL11; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum StencilDepthFailOp implements StringRepresentable { 11 | /** 12 | * 保留缓冲区原有值 13 | */ 14 | Keep(GL11.GL_KEEP), 15 | 16 | /** 17 | * 使用参考值与掩码的按位与结果替换缓冲区值 18 | */ 19 | Replace(GL11.GL_REPLACE); 20 | 21 | public static final Codec CODEC = StringRepresentable.fromEnum(StencilDepthFailOp::values); 22 | public final int value; 23 | 24 | StencilDepthFailOp(int value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public String getSerializedName() { 30 | return name(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangArray.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public record MolangArray( 10 | List value 11 | ) implements MolangObject { 12 | 13 | public MolangArray() { 14 | this(new ArrayList<>()); 15 | } 16 | 17 | @Override 18 | public float asFloat() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean asBoolean() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public String asString() { 29 | return ""; 30 | } 31 | 32 | @Override 33 | public boolean isNumber() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return value.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/Blackboard.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public final class Blackboard { 10 | private final Map data = new HashMap<>(); 11 | 12 | public void put(String key, Object value) { 13 | data.put(key, value); 14 | } 15 | 16 | @SuppressWarnings("unchecked") 17 | public T getOrDefault(String key, T defaultValue) { 18 | return (T) data.getOrDefault(key, defaultValue); 19 | } 20 | 21 | @SuppressWarnings("unchecked") 22 | public T get(String key) { 23 | return (T) data.get(key); 24 | } 25 | 26 | @SuppressWarnings("unchecked") 27 | public T getOrCreate(String key, T defaultValue) { 28 | return (T) data.computeIfAbsent(key, k -> defaultValue); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/Animation.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation; 2 | 3 | import io.github.tt432.eyelib.client.manager.AnimationManager; 4 | import io.github.tt432.eyelib.client.render.bone.BoneRenderInfos; 5 | import io.github.tt432.eyelib.molang.MolangScope; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public interface Animation { 13 | /** 14 | * @return name 15 | * @see AnimationManager 16 | */ 17 | String name(); 18 | 19 | void onFinish(D data); 20 | 21 | boolean anyAnimationFinished(D data); 22 | 23 | boolean allAnimationFinished(D data); 24 | 25 | D createData(); 26 | 27 | void tickAnimation(D data, Map animations, MolangScope scope, float ticks, float multiplier, 28 | BoneRenderInfos renderInfos, AnimationEffects effects, Runnable animationStartFeedback); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/RenderParams.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import com.mojang.blaze3d.vertex.VertexConsumer; 5 | import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; 6 | import lombok.With; 7 | import net.minecraft.client.renderer.RenderType; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.minecraft.world.entity.Entity; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @With 16 | public record RenderParams( 17 | @Nullable Entity renderTarget, 18 | PoseStack.Pose pose0, 19 | PoseStack poseStack, 20 | RenderType renderType, 21 | ResourceLocation texture, 22 | boolean isSolid, 23 | VertexConsumer consumer, 24 | int light, 25 | int overlay, 26 | Int2BooleanOpenHashMap partVisibility 27 | ) { 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/logic/LogicNode.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.logic; 2 | 3 | import com.mojang.serialization.MapCodec; 4 | import io.github.tt432.eyelib.capability.EntityBehaviorData; 5 | import io.github.tt432.eyelib.util.codec.EyelibCodec; 6 | 7 | import java.util.Map; 8 | 9 | import static io.github.tt432.eyelib.util.codec.EyelibCodec.list; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | public interface LogicNode { 15 | MapCodec CODEC = list(() -> Map.of( 16 | "add", new EyelibCodec.CodecInfo<>(Add.class, Add.CODEC), 17 | "randomize", new EyelibCodec.CodecInfo<>(Randomize.class, Randomize.CODEC), 18 | "sequence", new EyelibCodec.CodecInfo<>(Sequence.class, Sequence.CODEC), 19 | "remove", new EyelibCodec.CodecInfo<>(Remove.class, Remove.CODEC) 20 | )); 21 | 22 | void eval(EntityBehaviorData data); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/Operator.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum Operator implements StringRepresentable { 11 | NEQ("!="), 12 | EQ("=="), 13 | LESS("<"), 14 | GREATER(">"), 15 | LESS_EQUAL("<="), 16 | GREATER_EQUAL(">="), 17 | NEQ2("<>"), 18 | EQ2("="), 19 | EQUALS("equals"), 20 | NOT("not"); 21 | 22 | public static final Codec CODEC = StringRepresentable.fromEnum(Operator::values); 23 | final String realString; 24 | 25 | Operator(String realString) { 26 | this.realString = realString; 27 | } 28 | 29 | @Override 30 | public @NotNull String getSerializedName() { 31 | return realString; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/bedrock/BrFace.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.bedrock; 2 | 3 | import it.unimi.dsi.fastutil.Pair; 4 | import lombok.Getter; 5 | import org.joml.Vector2f; 6 | import org.joml.Vector3f; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @Getter 12 | public class BrFace { 13 | private final Vector3f normal; 14 | /** 15 | * uv0 -> uv1 16 | */ 17 | private final Vector2f[] uv; 18 | private final Vector3f[] vertex; 19 | 20 | public BrFace(Vector3f normal, Pair uv, Vector3f[] vertex) { 21 | this.normal = normal; 22 | this.vertex = vertex; 23 | 24 | var uv1 = uv.right().add(uv.left(), new Vector2f()); 25 | 26 | this.uv = new Vector2f[]{ 27 | uv.left(), 28 | new Vector2f(uv.left().x, uv1.y), 29 | uv1, 30 | new Vector2f(uv1.x, uv.left().y), 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/locator/LocatorEntry.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.locator; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.model.tree.ModelCubeNode; 6 | import net.minecraft.util.ExtraCodecs; 7 | import org.joml.Vector3f; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record LocatorEntry( 13 | String name, 14 | Vector3f offset, 15 | Vector3f rotation 16 | ) implements ModelCubeNode { 17 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 18 | Codec.STRING.fieldOf("name").forGetter(LocatorEntry::name), 19 | ExtraCodecs.VECTOR3F.fieldOf("offset").forGetter(LocatorEntry::offset), 20 | ExtraCodecs.VECTOR3F.fieldOf("rotation").forGetter(LocatorEntry::rotation) 21 | ).apply(ins, LocatorEntry::new)); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/manager/Manager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.manager; 2 | 3 | import io.github.tt432.eyelib.event.ManagerEntryChangedEvent; 4 | import net.neoforged.neoforge.common.NeoForge; 5 | 6 | import javax.annotation.Nullable; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public abstract class Manager { 14 | private final Map data = new HashMap<>(); 15 | 16 | public void put(String name, T value) { 17 | data.put(name, value); 18 | NeoForge.EVENT_BUS.post(new ManagerEntryChangedEvent(getManagerName(), name, value)); 19 | } 20 | 21 | @Nullable 22 | public T get(String name) { 23 | return data.get(name); 24 | } 25 | 26 | public String getManagerName() { 27 | return getClass().getSimpleName(); 28 | } 29 | 30 | public Map getAllData() { 31 | return new HashMap<>(data); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/Addrider.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | /** 7 | * Adds a rider to the entity. 8 | * 9 | * @param entity_type Type of entity to acquire as a rider 10 | * @param spawn_event Trigger event when a rider is acquired 11 | * @author TT432 12 | */ 13 | public record Addrider( 14 | String entity_type, 15 | String spawn_event 16 | ) implements Component { 17 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 18 | Codec.STRING.optionalFieldOf("entity_type", "").forGetter(o -> o.entity_type), 19 | Codec.STRING.optionalFieldOf("spawn_event", "").forGetter(o -> o.spawn_event) 20 | ).apply(ins, Addrider::new)); 21 | 22 | @Override 23 | public String id() { 24 | return "addrider"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/locator/ModelLocator.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.locator; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.model.GlobalBoneIdHandler; 6 | import io.github.tt432.eyelib.client.model.tree.ModelTree; 7 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record ModelLocator( 13 | Int2ObjectMap groupLocatorMap 14 | ) implements ModelTree { 15 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 16 | GlobalBoneIdHandler.map(GroupLocator.CODEC).fieldOf("groupLocatorMap").forGetter(ModelLocator::groupLocatorMap) 17 | ).apply(ins, ModelLocator::new)); 18 | 19 | @Override 20 | public GroupLocator getGroup(int groupName) { 21 | return groupLocatorMap.get(groupName); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/mapping/api/MolangMapping.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.mapping.api; 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 | /** 9 | * usage: 10 | * 11 | *
{@code
12 |  * @MolangMapping("math")
13 |  * class MolangMath {
14 |  *     public static float max(float a, float b) {
15 |  *         return a > b ? a : b;
16 |  *     }
17 |  * }
18 |  * }
19 | *

20 | * 此处的 max 可以对应 math.max(a, b)
21 | * 目标类的方法或字段都需要是 public static 才可调用 22 | * 23 | * @author TT432 24 | */ 25 | @Target(ElementType.TYPE) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface MolangMapping { 28 | /** 29 | * @return molang function or field name 30 | */ 31 | String value(); 32 | 33 | /** 34 | * @return will add MolangScope arg first if false 35 | */ 36 | boolean pureFunction() default true; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/bedrock/controller/BrAnimationControllers.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation.bedrock.controller; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public record BrAnimationControllers( 12 | Map animationControllers 13 | ) { 14 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 15 | Codec.dispatchedMap( 16 | Codec.STRING, 17 | k -> BrAnimationController.Factory.CODEC.xmap( 18 | f -> f.create(k), 19 | BrAnimationController.Factory::from 20 | ) 21 | ).optionalFieldOf("animation_controllers", Map.of()).forGetter(o -> o.animationControllers) 22 | ).apply(ins, BrAnimationControllers::new)); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/type/MolangFloat.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.type; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public record MolangFloat( 7 | float value 8 | ) implements MolangObject { 9 | public static final MolangFloat ZERO = new MolangFloat(0); 10 | 11 | public static MolangFloat valueOf(float value) { 12 | return new MolangFloat(value); 13 | } 14 | 15 | public static MolangFloat valueOf(MolangFloat value) { 16 | return value; 17 | } 18 | 19 | @Override 20 | public float asFloat() { 21 | return value; 22 | } 23 | 24 | @Override 25 | public boolean asBoolean() { 26 | return value != 0; 27 | } 28 | 29 | @Override 30 | public String asString() { 31 | return ""; 32 | } 33 | 34 | @Override 35 | public boolean isNumber() { 36 | return true; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return Float.toString(value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/compiler/MolangCompileCache.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.compiler; 2 | 3 | import io.github.tt432.eyelib.molang.MolangValue; 4 | 5 | /** 6 | * 统一的 Molang 编译缓存接口,供编译处理器依赖。 7 | */ 8 | public interface MolangCompileCache { 9 | 10 | /** 为表达式分配或获取稳定的数字ID与类名 */ 11 | record ClassNameId(long id, String className) {} 12 | 13 | void ensureInitialized(); 14 | 15 | MolangValue.MolangFunction getCachedFunction(String expression); 16 | 17 | void putFunctionCache(String expression, MolangValue.MolangFunction func); 18 | 19 | MolangCompileHandler.CompiledClassInfo getClassInfoByClassName(String className); 20 | 21 | MolangCompileHandler.CompiledClassInfo getClassInfoByExpression(String expression); 22 | 23 | ClassNameId reserveClassNameForExpression(String expression); 24 | 25 | void upsertCompiledClassInfo(MolangCompileHandler.CompiledClassInfo info); 26 | 27 | void exportCache(); 28 | 29 | void importCache(); 30 | 31 | void shutdown(); 32 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/lifetime/ParticleLifetimeKillPlane.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.lifetime; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 7 | import net.minecraft.util.ExtraCodecs; 8 | import org.joml.Vector4f; 9 | 10 | /** 11 | * todo 12 | * 13 | * @author TT432 14 | */ 15 | @RegisterParticleComponent(value = "particle_kill_plane", target = ComponentTarget.PARTICLE) 16 | public record ParticleLifetimeKillPlane( 17 | Vector4f plane 18 | ) implements ParticleParticleComponent { 19 | public static final Codec CODEC = 20 | ExtraCodecs.VECTOR4F.xmap(ParticleLifetimeKillPlane::new, ParticleLifetimeKillPlane::plane); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/ResourceLocations.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | import net.minecraft.resources.ResourceLocation; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 12 | public class ResourceLocations { 13 | public static final ResourceLocation EMPTY = ResourceLocations.of("__blank"); 14 | 15 | public static boolean isEmpty(ResourceLocation location) { 16 | return EMPTY.equals(location); 17 | } 18 | 19 | public static ResourceLocation of(String namespace, String path) { 20 | return ResourceLocation.fromNamespaceAndPath(namespace, path); 21 | } 22 | 23 | public static ResourceLocation of(String value) { 24 | return ResourceLocation.parse(value); 25 | } 26 | 27 | public static ResourceLocation mod(String path) { 28 | return ResourceLocation.fromNamespaceAndPath(Eyelib.MOD_ID, path); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/math/Shapes.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.math; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | import net.minecraft.util.RandomSource; 6 | import org.joml.Vector3f; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 12 | public class Shapes { 13 | public static Vector3f getRandomPointInAABB(RandomSource random, boolean surfaceOnly, Vector3f offset, Vector3f halfDim) { 14 | var x = random.nextFloat() - 0.5F; 15 | var y = random.nextFloat() - 0.5F; 16 | var z = random.nextFloat() - 0.5F; 17 | 18 | if (surfaceOnly) { 19 | switch (random.nextInt(6)) { 20 | case 0 -> x = 1; 21 | case 1 -> y = 1; 22 | case 2 -> z = 1; 23 | case 3 -> x = -1; 24 | case 4 -> y = -1; 25 | default -> z = -1; 26 | } 27 | } 28 | 29 | return offset.add(halfDim.mul(x, y, z)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_item_entity_translucent_cull_chunk.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | #moj_import 5 | 6 | in vec3 Position; 7 | in vec4 Color; 8 | in vec2 UV0; 9 | in vec2 UV1; 10 | in ivec2 UV2; 11 | in vec3 Normal; 12 | 13 | uniform sampler2D Sampler2; 14 | 15 | uniform mat4 ModelViewMat; 16 | uniform mat4 ProjMat; 17 | uniform vec3 ChunkOffset; 18 | uniform int FogShape; 19 | 20 | uniform vec3 Light0_Direction; 21 | uniform vec3 Light1_Direction; 22 | 23 | out float vertexDistance; 24 | out vec4 vertexColor; 25 | out vec2 texCoord0; 26 | out vec2 texCoord1; 27 | out vec2 texCoord2; 28 | 29 | void main() { 30 | vec3 pos = Position + ChunkOffset; 31 | gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0); 32 | 33 | vertexDistance = fog_distance(pos, FogShape); 34 | vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color) * texelFetch(Sampler2, UV2 / 16, 0); 35 | texCoord0 = UV0; 36 | texCoord1 = UV1; 37 | texCoord2 = UV2; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/DepthFunc.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.lwjgl.opengl.GL11; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public enum DepthFunc implements StringRepresentable { 12 | Always(GL11.GL_ALWAYS),// 总是通过 13 | Equal(GL11.GL_EQUAL),// 深度值与缓冲区值相等时通过 14 | NotEqual(GL11.GL_NOTEQUAL),// 深度值与缓冲区值不相等时通过 15 | Less(GL11.GL_LESS),// 深度值小于缓冲区值时通过 16 | Greater(GL11.GL_GREATER),// 深度值大于缓冲区值时通过 17 | GreaterEqual(GL11.GL_GEQUAL),// 深度值大于等于缓冲区值时通过 18 | LessEqual(GL11.GL_LEQUAL);// 深度值小于等于缓冲区值时通过 19 | 20 | public static final Codec CODEC = StringRepresentable.fromEnum(DepthFunc::values); 21 | 22 | public final int value; 23 | 24 | DepthFunc(int value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public @NotNull String getSerializedName() { 30 | return name(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_direction_x.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_direction_x", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "direction_x", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_direction_y.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_direction_y", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "direction_y", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_direction_z.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_direction_z", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "direction_z", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/bedrock/BrModel.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.bedrock; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonObject; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record BrModel( 13 | List models 14 | ) { 15 | 16 | public static BrModel parse(JsonObject object) { 17 | List models = new ArrayList<>(); 18 | 19 | if (object.has("minecraft:geometry")) { 20 | for (JsonElement jsonElement : object.getAsJsonArray("minecraft:geometry")) { 21 | models.add(BrModelEntry.parse(jsonElement.getAsJsonObject())); 22 | } 23 | } else { 24 | object.asMap().forEach((n, m) -> { 25 | if (n.startsWith("geometry")) { 26 | models.add(BrModelEntry.parse2(n, m.getAsJsonObject())); 27 | } 28 | }); 29 | } 30 | 31 | return new BrModel(models); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/ModelVisitContext.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; 4 | 5 | import javax.annotation.Nullable; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public final class ModelVisitContext { 12 | private final Map data = new Object2ObjectOpenHashMap<>(); 13 | 14 | public void put(String key, Object value) { 15 | data.put(key, value); 16 | } 17 | 18 | public boolean contains(String key) { 19 | return data.containsKey(key); 20 | } 21 | 22 | @SuppressWarnings("unchecked") 23 | @Nullable 24 | public T get(String key) { 25 | if (!data.containsKey(key)) return null; 26 | return (T) data.get(key); 27 | } 28 | 29 | @SuppressWarnings("unchecked") 30 | public T orCreate(String key, T value) { 31 | return (T) data.computeIfAbsent(key, s -> value); 32 | } 33 | 34 | public void clear() { 35 | data.clear(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/capability/component/ClientEntityComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.capability.component; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.client.entity.BrClientEntity; 5 | import io.github.tt432.eyelib.event.ManagerEntryChangedEvent; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import net.neoforged.neoforge.common.NeoForge; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @Getter 16 | @Setter 17 | public class ClientEntityComponent { 18 | private BrClientEntity clientEntity; 19 | public List components; 20 | 21 | { 22 | NeoForge.EVENT_BUS.addListener(ManagerEntryChangedEvent.class, event -> { 23 | if (event.getManagerName().equals(Eyelib.getClientEntityLoader().getManagerName()) 24 | && clientEntity != null 25 | && event.getEntryName().equals(clientEntity.identifier())) { 26 | clientEntity = (BrClientEntity) event.getEntryData(); 27 | } 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/UpdateDestroyInfoPacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.util.ResourceLocations; 5 | import io.netty.buffer.ByteBuf; 6 | import net.minecraft.network.codec.ByteBufCodecs; 7 | import net.minecraft.network.codec.StreamCodec; 8 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record UpdateDestroyInfoPacket( 14 | boolean dig 15 | ) implements CustomPacketPayload { 16 | public static final Type TYPE = 17 | new Type<>(ResourceLocations.of(Eyelib.MOD_ID, "update_destroy_info")); 18 | 19 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 20 | ByteBufCodecs.BOOL, 21 | UpdateDestroyInfoPacket::dig, 22 | UpdateDestroyInfoPacket::new 23 | ); 24 | 25 | @Override 26 | public Type type() { 27 | return TYPE; 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/logic/Add.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.logic; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.capability.EntityBehaviorData; 6 | import io.github.tt432.eyelib.common.behavior.component.group.ComponentGroup; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record Add( 14 | List component_groups 15 | ) implements LogicNode { 16 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 17 | Codec.STRING.listOf().fieldOf("component_groups").forGetter(Add::component_groups) 18 | ).apply(ins, Add::new)); 19 | 20 | @Override 21 | public void eval(EntityBehaviorData data) { 22 | if (data.getBehavior().isPresent()) { 23 | data.getComponentGroups().addAll(component_groups().stream().map(s -> data.getBehavior().map(b -> b.component_groups().get(s)).orElse(ComponentGroup.EMPTY)).toList()); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/VertexBufferMixin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin; 2 | 3 | import com.mojang.blaze3d.vertex.MeshData; 4 | import com.mojang.blaze3d.vertex.VertexBuffer; 5 | import io.github.tt432.eyelib.compute.EyelibComputes; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @Mixin(VertexBuffer.class) 16 | public class VertexBufferMixin { 17 | @Shadow 18 | public int vertexBufferId; 19 | 20 | @Inject(method = "upload", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lcom/mojang/blaze3d/vertex/VertexBuffer;uploadVertexBuffer(Lcom/mojang/blaze3d/vertex/MeshData$DrawState;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/vertex/VertexFormat;")) 21 | private void eyelib$upload(MeshData meshData, CallbackInfo ci) { 22 | EyelibComputes.compute(meshData, vertexBufferId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_cutout_no_cull_chunk.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | #moj_import 5 | 6 | in vec3 Position; 7 | in vec4 Color; 8 | in vec2 UV0; 9 | in ivec2 UV1; 10 | in ivec2 UV2; 11 | in vec3 Normal; 12 | 13 | uniform sampler2D Sampler1; 14 | uniform sampler2D Sampler2; 15 | 16 | uniform mat4 ModelViewMat; 17 | uniform mat4 ProjMat; 18 | uniform vec3 ChunkOffset; 19 | uniform int FogShape; 20 | 21 | uniform vec3 Light0_Direction; 22 | uniform vec3 Light1_Direction; 23 | 24 | out float vertexDistance; 25 | out vec4 vertexColor; 26 | out vec4 lightMapColor; 27 | out vec4 overlayColor; 28 | out vec2 texCoord0; 29 | 30 | void main() { 31 | vec3 pos = Position + ChunkOffset; 32 | gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0); 33 | 34 | vertexDistance = fog_distance(pos, FogShape); 35 | vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); 36 | lightMapColor = texelFetch(Sampler2, UV2 / 16, 0); 37 | overlayColor = texelFetch(Sampler1, UV1, 0); 38 | texCoord0 = UV0; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_translucent_chunk.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | #moj_import 5 | 6 | in vec3 Position; 7 | in vec4 Color; 8 | in vec2 UV0; 9 | in ivec2 UV1; 10 | in ivec2 UV2; 11 | in vec3 Normal; 12 | 13 | uniform sampler2D Sampler1; 14 | uniform sampler2D Sampler2; 15 | 16 | uniform mat4 ModelViewMat; 17 | uniform mat4 ProjMat; 18 | uniform vec3 ChunkOffset; 19 | uniform int FogShape; 20 | 21 | uniform vec3 Light0_Direction; 22 | uniform vec3 Light1_Direction; 23 | 24 | out float vertexDistance; 25 | out vec4 vertexColor; 26 | out vec4 lightMapColor; 27 | out vec4 overlayColor; 28 | out vec2 texCoord0; 29 | 30 | void main() { 31 | vec3 pos = Position + ChunkOffset; 32 | gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0); 33 | 34 | vertexDistance = fog_distance(pos, FogShape); 35 | vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); 36 | lightMapColor = texelFetch(Sampler2, UV2 / 16, 0); 37 | overlayColor = texelFetch(Sampler1, UV1, 0); 38 | texCoord0 = UV0; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/SimpleTimer.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util; 2 | 3 | /** 4 | * @author TT432 5 | */ 6 | public class SimpleTimer { 7 | private long startNanoTime; 8 | private boolean paused; 9 | private long fullPausedNanoTime; 10 | private long pausedNanoTime; 11 | 12 | public SimpleTimer() { 13 | startNanoTime = System.nanoTime(); 14 | } 15 | 16 | public void setPaused(boolean paused) { 17 | if (paused && !this.paused) { 18 | this.paused = true; 19 | pausedNanoTime = System.nanoTime(); 20 | } else if (!paused && this.paused) { 21 | this.paused = false; 22 | fullPausedNanoTime += System.nanoTime() - pausedNanoTime; 23 | } 24 | } 25 | 26 | public long getNanoTime() { 27 | if (paused) return pausedNanoTime - startNanoTime - fullPausedNanoTime; 28 | else return System.nanoTime() - startNanoTime - fullPausedNanoTime; 29 | } 30 | 31 | public void reset() { 32 | startNanoTime = System.nanoTime(); 33 | fullPausedNanoTime = 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/logic/Remove.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.logic; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.capability.EntityBehaviorData; 6 | import io.github.tt432.eyelib.common.behavior.component.group.ComponentGroup; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record Remove( 14 | List component_groups 15 | ) implements LogicNode { 16 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 17 | Codec.STRING.listOf().fieldOf("component_groups").forGetter(Remove::component_groups) 18 | ).apply(ins, Remove::new)); 19 | 20 | @Override 21 | public void eval(EntityBehaviorData data) { 22 | if (data.getBehavior().isPresent()) { 23 | data.getComponentGroups().removeAll(component_groups().stream().map(s -> data.getBehavior().map(b -> b.component_groups().get(s)).orElse(ComponentGroup.EMPTY)).toList()); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/bedrock/controller/BrAcParticleEffect.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation.bedrock.controller; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.molang.MolangValue; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record BrAcParticleEffect( 13 | Optional effect, 14 | Optional locator, 15 | boolean bindToActor, 16 | MolangValue preEffectScript 17 | ) { 18 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 19 | Codec.STRING.optionalFieldOf("effect").forGetter(o -> o.effect), 20 | Codec.STRING.optionalFieldOf("locator").forGetter(o -> o.locator), 21 | Codec.BOOL.optionalFieldOf("bind_to_actor", false).forGetter(o -> o.bindToActor), 22 | MolangValue.CODEC.optionalFieldOf("pre_effect_script", MolangValue.ZERO).forGetter(o -> o.preEffectScript) 23 | ).apply(ins, BrAcParticleEffect::new)); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/ModelRenderer.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render; 2 | 3 | import io.github.tt432.eyelib.client.model.Model; 4 | import io.github.tt432.eyelib.client.model.ModelRuntimeData; 5 | import io.github.tt432.eyelib.client.render.visitor.ModelRenderVisitorList; 6 | import io.github.tt432.eyelib.client.render.visitor.ModelVisitContext; 7 | import io.github.tt432.eyelib.client.render.visitor.ModelVisitor; 8 | import lombok.experimental.UtilityClass; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @UtilityClass 14 | public class ModelRenderer { 15 | @SuppressWarnings("unchecked") 16 | private static T cast(Object o) { 17 | return (T) o; 18 | } 19 | 20 | public static > void render(RenderParams renderParams, Model model, R infos, 21 | ModelRenderVisitorList visitors) { 22 | for (ModelVisitor visitor : visitors.visitors()) { 23 | visitor.visitModel(renderParams, new ModelVisitContext(), cast(infos), model); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023 TT432 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/RemoveParticlePacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.util.ResourceLocations; 5 | import io.netty.buffer.ByteBuf; 6 | import net.minecraft.network.codec.ByteBufCodecs; 7 | import net.minecraft.network.codec.StreamCodec; 8 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record RemoveParticlePacket( 14 | String removeId 15 | ) implements CustomPacketPayload { 16 | public static final CustomPacketPayload.Type TYPE = 17 | new CustomPacketPayload.Type<>(ResourceLocations.of(Eyelib.MOD_ID, "remove_particle")); 18 | 19 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 20 | ByteBufCodecs.STRING_UTF8, 21 | RemoveParticlePacket::removeId, 22 | RemoveParticlePacket::new 23 | ); 24 | 25 | @Override 26 | public Type type() { 27 | return TYPE; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/component/AdmireItem.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.component; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | /** 7 | * Allows an entity to ignore attackable targets for a given duration. 8 | * 9 | * @param cooldown_after_being_attacked Duration, in seconds, for which mob won't admire items if it was hurt 10 | * @param duration Duration, in seconds, that the mob is pacified. 11 | * @author TT432 12 | */ 13 | public record AdmireItem( 14 | int cooldown_after_being_attacked, 15 | int duration 16 | ) implements Component { 17 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 18 | Codec.INT.optionalFieldOf("cooldown_after_being_attacked", 0).forGetter(AdmireItem::cooldown_after_being_attacked), 19 | Codec.INT.optionalFieldOf("duration", 10).forGetter(AdmireItem::duration) 20 | ).apply(ins, AdmireItem::new)); 21 | 22 | @Override 23 | public String id() { 24 | return "admire_item"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/HumanoidModelMixin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin; 2 | 3 | import io.github.tt432.eyelib.client.model.RootModelPartModel; 4 | import net.minecraft.client.model.HumanoidModel; 5 | import net.minecraft.client.model.geom.ModelPart; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Unique; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | import java.util.function.Function; 13 | 14 | /** 15 | * @author TT432 16 | */ 17 | @Mixin(HumanoidModel.class) 18 | public class HumanoidModelMixin implements RootModelPartModel { 19 | @Unique 20 | private ModelPart eyelib$part; 21 | 22 | @Inject(method = "(Lnet/minecraft/client/model/geom/ModelPart;Ljava/util/function/Function;)V", at = @At("RETURN")) 23 | private void eyelib$init(ModelPart part, Function p_170680_, CallbackInfo ci) { 24 | this.eyelib$part = part; 25 | } 26 | 27 | @Override 28 | public ModelPart getRootPart() { 29 | return eyelib$part; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_lookat_y.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_lookat_y", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "lookat_y", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_rotate_y.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_rotate_y", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "rotate_y", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_lookat_xyz.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_lookat_xyz", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "lookat_xyz", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/eyelib/particles/test_rotate_xyz.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.10.0", 3 | "particle_effect": { 4 | "description": { 5 | "identifier": "eyelib:test_rotate_xyz", 6 | "basic_render_parameters": { 7 | "material": "particles_alpha", 8 | "texture": "textures/blocks/wool_colored_white" 9 | } 10 | }, 11 | "components": { 12 | "minecraft:emitter_rate_steady": { 13 | "spawn_rate": 4, 14 | "max_particles": 100 15 | }, 16 | "minecraft:emitter_lifetime_looping": { 17 | "active_time": 1 18 | }, 19 | "minecraft:emitter_shape_point": {}, 20 | "minecraft:particle_lifetime_expression": { 21 | "max_lifetime": 1 22 | }, 23 | "minecraft:particle_initial_speed": 0, 24 | "minecraft:particle_motion_dynamic": {}, 25 | "minecraft:particle_appearance_billboard": { 26 | "size": [0.2, 0.2], 27 | "facing_camera_mode": "rotate_xyz", 28 | "uv": { 29 | "texture_width": 16, 30 | "texture_height": 16, 31 | "uv": [0, 0], 32 | "uv_size": [16, 16] 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/bedrock/BrTextureMesh.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.bedrock; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import net.minecraft.util.ExtraCodecs; 6 | import org.joml.Vector3f; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public record BrTextureMesh( 12 | String texture, 13 | Vector3f position, 14 | Vector3f rotation, 15 | Vector3f local_pivot, 16 | Vector3f scale 17 | ) { 18 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 19 | Codec.STRING.fieldOf("texture").forGetter(o -> o.texture), 20 | ExtraCodecs.VECTOR3F.optionalFieldOf("position", new Vector3f()).forGetter(o -> o.position), 21 | ExtraCodecs.VECTOR3F.optionalFieldOf("rotation", new Vector3f()).forGetter(o -> o.rotation), 22 | ExtraCodecs.VECTOR3F.optionalFieldOf("local_pivot", new Vector3f()).forGetter(o -> o.local_pivot), 23 | ExtraCodecs.VECTOR3F.optionalFieldOf("scale", new Vector3f(1)).forGetter(o -> o.scale) 24 | ).apply(ins, BrTextureMesh::new)); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/base/ActorHealth.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter.base; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.MapCodec; 5 | import com.mojang.serialization.codecs.RecordCodecBuilder; 6 | import io.github.tt432.eyelib.common.behavior.event.filter.Operator; 7 | import io.github.tt432.eyelib.common.behavior.event.filter.Subject; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public final class ActorHealth extends BaseFilter { 13 | public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(ins -> ins.group( 14 | Codec.INT.fieldOf("value").forGetter(o -> o.value), 15 | Subject.CODEC.optionalFieldOf("subject", Subject.self).forGetter(o -> o.subject), 16 | Operator.CODEC.optionalFieldOf("operator", Operator.EQUALS).forGetter(o -> o.operator), 17 | Codec.STRING.fieldOf("domain").forGetter(o -> o.domain) 18 | ).apply(ins, ActorHealth::new)); 19 | 20 | public ActorHealth(Integer value, Subject subject, Operator operator, String domain) { 21 | super(value, subject, operator, domain); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/EntityStatisticsHandler.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common; 2 | 3 | import io.github.tt432.eyelib.capability.EntityStatistics; 4 | import io.github.tt432.eyelib.capability.EyelibAttachableData; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.phys.Vec3; 7 | import net.neoforged.bus.api.SubscribeEvent; 8 | import net.neoforged.fml.common.EventBusSubscriber; 9 | import net.neoforged.neoforge.event.tick.EntityTickEvent; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | @EventBusSubscriber 15 | public class EntityStatisticsHandler { 16 | @SubscribeEvent 17 | public static void onEvent(EntityTickEvent.Post event) { 18 | Entity entity = event.getEntity(); 19 | Vec3 pos = entity.position(); 20 | var x = pos.x - entity.xo; 21 | var z = pos.z - entity.zo; 22 | EntityStatistics data = entity.getData(EyelibAttachableData.ENTITY_STATISTICS); 23 | entity.setData(EyelibAttachableData.ENTITY_STATISTICS, 24 | data.withPreDistanceWalked(data.distanceWalked()) 25 | .withDistanceWalked(data.distanceWalked() + (float) Math.sqrt(x * x + z * z))); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/attachable/AbstractContainerScreenMixin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin.attachable; 2 | 3 | import io.github.tt432.eyelib.client.AttchableHandler; 4 | import net.minecraft.client.gui.GuiGraphics; 5 | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; 6 | import net.minecraft.world.inventory.Slot; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @Mixin(AbstractContainerScreen.class) 16 | public class AbstractContainerScreenMixin { 17 | @Inject(method = "renderSlot", at = @At("HEAD")) 18 | private void eyelib$renderSlotStart(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) { 19 | AttchableHandler.setRenderingScreen((AbstractContainerScreen) (Object) this, slot); 20 | } 21 | @Inject(method = "renderSlot", at = @At("TAIL")) 22 | private void eyelib$renderSlotEnd(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) { 23 | AttchableHandler.clearRenderingScreen(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/Subject.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | 6 | /** 7 | * 该枚举类定义了交互中涉及的不同主体类型。 8 | * 9 | * @author TT432 10 | */ 11 | public enum Subject implements StringRepresentable { 12 | /** 13 | * 交互所涉及的数据块。 14 | */ 15 | block, 16 | /** 17 | * 参与交互的破坏性参与者。 18 | */ 19 | damager, 20 | /** 21 | * 交互的另一个成员,而不是调用方。 22 | */ 23 | other, 24 | /** 25 | * 调用方的当前父级。 26 | */ 27 | parent, 28 | /** 29 | * 参与交互的玩家。 30 | */ 31 | player, 32 | /** 33 | * 调用测试的实体或对象。 34 | */ 35 | self, 36 | /** 37 | * 调用方的当前目标。 38 | */ 39 | target; 40 | 41 | /** 42 | * 提供一个编解码器,用于将 {@link Subject} 枚举与字符串进行相互转换。 43 | */ 44 | public static final Codec CODEC = StringRepresentable.fromEnum(Subject::values); 45 | 46 | /** 47 | * 获取该枚举常量的序列化名称,这里直接返回枚举常量的名称。 48 | * 49 | * @return 枚举常量的名称 50 | */ 51 | @Override 52 | public String getSerializedName() { 53 | return name(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/cursor/CursorManager.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.cursor; 2 | 3 | import io.github.tt432.eyelib.util.client.NativeImages; 4 | import net.minecraft.resources.ResourceLocation; 5 | import org.lwjgl.glfw.GLFWImage; 6 | import org.lwjgl.system.MemoryUtil; 7 | 8 | import java.nio.ByteBuffer; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public class CursorManager { 14 | public static Cursor load(ResourceLocation location, int xhot, int yhot) { 15 | return NativeImages.downloadImage(location, 16 | image -> { 17 | ByteBuffer copy = MemoryUtil.memAlloc((int) image.size); 18 | MemoryUtil.memCopy(image.pixels, MemoryUtil.memAddress(copy), image.size); 19 | return new Cursor( 20 | new GLFWImage(ByteBuffer.allocateDirect(GLFWImage.SIZEOF)) 21 | .height(image.getHeight()) 22 | .width(image.getWidth()) 23 | .pixels(copy), 24 | xhot, 25 | yhot 26 | ); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/initial/ParticleInitialSpeed.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.initial; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 8 | import io.github.tt432.eyelib.molang.MolangValue; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @RegisterParticleComponent(value = "particle_initial_speed", target = ComponentTarget.PARTICLE) 14 | public record ParticleInitialSpeed( 15 | MolangValue speed 16 | ) implements ParticleParticleComponent { 17 | public static final Codec CODEC = 18 | MolangValue.CODEC.xmap(ParticleInitialSpeed::new, ParticleInitialSpeed::speed); 19 | 20 | @Override 21 | public void onStart(BrParticleParticle particle) { 22 | particle.setSpeed(speed.eval(particle.molangScope)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/BuiltInBrModelRenderVisitors.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import lombok.AccessLevel; 5 | import lombok.NoArgsConstructor; 6 | import net.neoforged.neoforge.registries.DeferredHolder; 7 | import net.neoforged.neoforge.registries.DeferredRegister; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 13 | public class BuiltInBrModelRenderVisitors { 14 | public static final DeferredRegister VISITORS = 15 | DeferredRegister.create(ModelRenderVisitorRegistry.VISITOR_REGISTRY, Eyelib.MOD_ID); 16 | 17 | public static final DeferredHolder BLANK = 18 | VISITORS.register("blank", RenderModelVisitor::new); 19 | 20 | public static final DeferredHolder COLLECT_LOCATOR = 21 | VISITORS.register("collect_locator", CollectLocatorModelVisitor::new); 22 | 23 | public static final DeferredHolder HIGH_SPEED_RENDER = 24 | VISITORS.register("high_speed", HighSpeedRenderModelVisitor::new); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/bedrock/BrLoopType.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation.bedrock; 2 | 3 | import com.mojang.datafixers.util.Either; 4 | import com.mojang.serialization.Codec; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | @Slf4j 11 | public enum BrLoopType { 12 | HOLD_ON_LAST_FRAME, 13 | LOOP, 14 | ONCE; 15 | 16 | public static final Codec CODEC = Codec.either( 17 | Codec.STRING.xmap( 18 | s -> switch (s) { 19 | case "hold_on_last_frame" -> HOLD_ON_LAST_FRAME; 20 | case "true" -> LOOP; 21 | default -> ONCE; 22 | }, 23 | t -> switch (t) { 24 | case LOOP -> "true"; 25 | case HOLD_ON_LAST_FRAME -> "hold_on_last_frame"; 26 | default -> "false"; 27 | }), 28 | Codec.BOOL.xmap(b -> b ? LOOP : ONCE, t -> t == LOOP)) 29 | .xmap(Either::unwrap, Either::left) 30 | .orElse(ONCE); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/base/BaseFilter.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter.base; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.common.behavior.event.filter.Filter; 5 | import io.github.tt432.eyelib.common.behavior.event.filter.Operator; 6 | import io.github.tt432.eyelib.common.behavior.event.filter.Subject; 7 | import lombok.AllArgsConstructor; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @AllArgsConstructor 13 | public abstract sealed class BaseFilter implements Filter permits ActorHealth { 14 | protected final T value; 15 | protected final Subject subject; 16 | protected final Operator operator; 17 | protected final String domain; 18 | 19 | public static final Codec> CODEC = Codec.STRING.dispatch("test", 20 | v -> switch (v) { 21 | case ActorHealth ah -> "actor_health"; 22 | default -> throw new IllegalStateException("Unexpected value: " + v); 23 | }, 24 | s -> switch (s) { 25 | case "actor_health" -> ActorHealth.CODEC; 26 | default -> throw new IllegalStateException("Unexpected value: " + s); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/BlendFactor.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.lwjgl.opengl.GL11; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum BlendFactor implements StringRepresentable { 11 | // 缓冲区颜色值 12 | DestColor(GL11.GL_DST_COLOR), 13 | // 当前颜色值 14 | SourceColor(GL11.GL_SRC_COLOR), 15 | // (0,0,0) 16 | Zero(GL11.GL_ZERO), 17 | // (1,1,1) 18 | One(GL11.GL_ONE), 19 | // (1,1,1) - 缓冲区颜色值 20 | OneMinusDestColor(GL11.GL_ONE_MINUS_DST_COLOR), 21 | // (1,1,1) - 当前颜色值 22 | OneMinusSrcColor(GL11.GL_ONE_MINUS_SRC_COLOR), 23 | // 当前颜色中的alpha值 24 | SourceAlpha(GL11.GL_SRC_ALPHA), 25 | // 缓冲区颜色中的alpha值 26 | DestAlpha(GL11.GL_DST_ALPHA), 27 | // 1 - 当前颜色值中的alpha值 28 | OneMinusSrcAlpha(GL11.GL_ONE_MINUS_SRC_ALPHA), 29 | ; 30 | 31 | public static final Codec CODEC = StringRepresentable.fromEnum(BlendFactor::values); 32 | 33 | public final int factor; 34 | 35 | BlendFactor(int factor) { 36 | this.factor = factor; 37 | } 38 | 39 | @Override 40 | public String getSerializedName() { 41 | return name(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/client/RenderTypeSerializations.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.client; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | import net.minecraft.client.renderer.RenderType; 6 | import net.minecraft.resources.ResourceLocation; 7 | 8 | import java.util.function.Function; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 14 | public class RenderTypeSerializations { 15 | public record EntityRenderTypeData( 16 | ResourceLocation id, 17 | boolean isSolid, 18 | Function factory 19 | ) { 20 | } 21 | 22 | /** 23 | * TODO: 设置更多的解析 24 | * @param id id 25 | * @return EntityRenderTypeData 26 | */ 27 | public static EntityRenderTypeData getFactory(ResourceLocation id) { 28 | return switch (id.toString()) { 29 | case "minecraft:cutout" -> new EntityRenderTypeData(id, false, RenderType::entityCutout); 30 | case "minecraft:translucent", "minecraft:particles_blend" -> new EntityRenderTypeData(id, false, RenderType::entityTranslucent); 31 | default -> new EntityRenderTypeData(id, true, RenderType::entitySolid); 32 | }; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/ExtraEntityDataPacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.capability.ExtraEntityData; 5 | import io.github.tt432.eyelib.util.ResourceLocations; 6 | import io.netty.buffer.ByteBuf; 7 | import net.minecraft.network.codec.ByteBufCodecs; 8 | import net.minecraft.network.codec.StreamCodec; 9 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | public record ExtraEntityDataPacket( 15 | int entityId, 16 | ExtraEntityData data 17 | ) implements CustomPacketPayload { 18 | public static final Type TYPE = 19 | new Type<>(ResourceLocations.of(Eyelib.MOD_ID, "extra_entity_data")); 20 | 21 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 22 | ByteBufCodecs.VAR_INT, 23 | ExtraEntityDataPacket::entityId, 24 | ExtraEntityData.STREAM_CODEC, 25 | ExtraEntityDataPacket::data, 26 | ExtraEntityDataPacket::new 27 | ); 28 | 29 | @Override 30 | public Type type() { 31 | return TYPE; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/client/BufferBuilders.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.client; 2 | 3 | import com.mojang.blaze3d.vertex.BufferBuilder; 4 | import com.mojang.blaze3d.vertex.ByteBufferBuilder; 5 | import lombok.experimental.UtilityClass; 6 | import org.lwjgl.system.MemoryUtil; 7 | 8 | import java.nio.ByteBuffer; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @UtilityClass 14 | public class BufferBuilders { 15 | public void putAll(BufferBuilder a, BufferBuilder b) { 16 | putAll(a, b.buffer, b.vertices); 17 | } 18 | 19 | public void putAll(BufferBuilder a, ByteBufferBuilder b, int vertices) { 20 | ByteBufferBuilder aBuffer = a.buffer; 21 | long reserve = aBuffer.reserve(b.writeOffset); 22 | a.vertexPointer = reserve; 23 | MemoryUtil.memCopy(b.pointer, reserve, b.writeOffset); 24 | 25 | a.vertices += vertices; 26 | } 27 | 28 | public void putAll(BufferBuilder a, ByteBuffer result, int vertices) { 29 | ByteBufferBuilder aBuffer = a.buffer; 30 | long reserve = aBuffer.reserve(result.capacity()); 31 | a.vertexPointer = reserve; 32 | MemoryUtil.memCopy(MemoryUtil.memAddress(result), reserve, result.capacity()); 33 | 34 | a.vertices += vertices; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/ModelRenderVisitorRegistry.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.util.ResourceLocations; 5 | import lombok.AccessLevel; 6 | import lombok.NoArgsConstructor; 7 | import net.minecraft.core.Registry; 8 | import net.minecraft.resources.ResourceKey; 9 | import net.neoforged.bus.api.SubscribeEvent; 10 | import net.neoforged.fml.common.EventBusSubscriber; 11 | import net.neoforged.neoforge.registries.NewRegistryEvent; 12 | import net.neoforged.neoforge.registries.RegistryBuilder; 13 | 14 | /** 15 | * @author TT432 16 | */ 17 | @EventBusSubscriber 18 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 19 | public class ModelRenderVisitorRegistry { 20 | public static final ResourceKey> VISITOR_REGISTRY_KEY = 21 | ResourceKey.createRegistryKey(ResourceLocations.of(Eyelib.MOD_ID, "model_visitor")); 22 | 23 | public static final Registry VISITOR_REGISTRY = new RegistryBuilder<>(VISITOR_REGISTRY_KEY) 24 | .sync(true) 25 | .create(); 26 | 27 | @SubscribeEvent 28 | public static void onEvent(NewRegistryEvent event) { 29 | event.register(VISITOR_REGISTRY); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/compute/ComputeShader.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.compute; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import static org.lwjgl.opengl.GL11.GL_FALSE; 7 | import static org.lwjgl.opengl.GL20.*; 8 | import static org.lwjgl.opengl.GL43.GL_COMPUTE_SHADER; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @Slf4j 14 | public record ComputeShader( 15 | String content, 16 | int program 17 | ) { 18 | public static ComputeShader of(String content) { 19 | RenderSystem.assertOnRenderThread(); 20 | 21 | int shader = glCreateShader(GL_COMPUTE_SHADER); 22 | glShaderSource(shader, content); 23 | glCompileShader(shader); 24 | 25 | if (glGetShaderi(shader, GL_COMPILE_STATUS) == GL_FALSE) { 26 | log.error("Shader compile error: {}", glGetShaderInfoLog(shader)); 27 | } 28 | 29 | var program = glCreateProgram(); 30 | glAttachShader(program, shader); 31 | glLinkProgram(program); 32 | 33 | if (glGetProgrami(program, GL_LINK_STATUS) == GL_FALSE) { 34 | log.error("Program link error: {}", glGetProgramInfoLog(program)); 35 | } 36 | 37 | return new ComputeShader(content, program); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/stencil/StencilFunc.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl.stencil; 2 | 3 | import com.mojang.serialization.Codec; 4 | import net.minecraft.util.StringRepresentable; 5 | import org.lwjgl.opengl.GL11; 6 | 7 | /** 8 | * @author TT432 9 | */ 10 | public enum StencilFunc implements StringRepresentable { 11 | /** 12 | * 总是通过模板测试 13 | */ 14 | Always(GL11.GL_ALWAYS), 15 | 16 | /** 17 | * 当参考值等于缓冲区值时通过测试 18 | */ 19 | Equal(GL11.GL_EQUAL), 20 | 21 | /** 22 | * 当参考值不等于缓冲区值时通过测试 23 | */ 24 | NotEqual(GL11.GL_NOTEQUAL), 25 | 26 | /** 27 | * 当参考值小于缓冲区值时通过测试 28 | */ 29 | Less(GL11.GL_LESS), 30 | 31 | /** 32 | * 当参考值大于缓冲区值时通过测试 33 | */ 34 | Greater(GL11.GL_GREATER), 35 | 36 | /** 37 | * 当参考值大于等于缓冲区值时通过测试 38 | */ 39 | GreaterEqual(GL11.GL_GEQUAL), 40 | 41 | /** 42 | * 当参考值小于等于缓冲区值时通过测试 43 | */ 44 | LessEqual(GL11.GL_LEQUAL); 45 | 46 | public static final Codec CODEC = StringRepresentable.fromEnum(StencilFunc::values); 47 | public final int value; 48 | 49 | StencilFunc(int value) { 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public String getSerializedName() { 55 | return name(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/locator/GroupLocator.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.locator; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.model.GlobalBoneIdHandler; 6 | import io.github.tt432.eyelib.client.model.tree.ModelGroupNode; 7 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | public record GroupLocator( 15 | Int2ObjectMap< GroupLocator> children, 16 | List cubes 17 | ) implements ModelGroupNode { 18 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 19 | GlobalBoneIdHandler.map(GroupLocator.CODEC).fieldOf("children").forGetter(GroupLocator::children), 20 | LocatorEntry.CODEC.listOf().fieldOf("cubes").forGetter(GroupLocator::cubes) 21 | ).apply(ins, GroupLocator::new)); 22 | 23 | @Override 24 | public GroupLocator getChild(int groupName) { 25 | return children.get(groupName); 26 | } 27 | 28 | @Override 29 | public LocatorEntry getCubeNode(int index) { 30 | if (index < 0 || index >= cubes.size()) return null; 31 | return cubes.get(index); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/capability/EntityStatistics.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.capability; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.netty.buffer.ByteBuf; 6 | import lombok.With; 7 | import net.minecraft.network.codec.ByteBufCodecs; 8 | import net.minecraft.network.codec.StreamCodec; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @With 14 | public record EntityStatistics( 15 | float preDistanceWalked, 16 | float distanceWalked 17 | ) { 18 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 19 | Codec.FLOAT.fieldOf("preDistanceWalked").forGetter(EntityStatistics::preDistanceWalked), 20 | Codec.FLOAT.fieldOf("distanceWalked").forGetter(EntityStatistics::distanceWalked) 21 | ).apply(ins, EntityStatistics::new)); 22 | 23 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 24 | ByteBufCodecs.FLOAT, 25 | EntityStatistics::preDistanceWalked, 26 | ByteBufCodecs.FLOAT, 27 | EntityStatistics::distanceWalked, 28 | EntityStatistics::new 29 | ); 30 | 31 | public static EntityStatistics empty() { 32 | return new EntityStatistics(0, 0); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/ExtraEntityUpdateDataPacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.capability.ExtraEntityUpdateData; 5 | import io.github.tt432.eyelib.util.ResourceLocations; 6 | import io.netty.buffer.ByteBuf; 7 | import net.minecraft.network.codec.ByteBufCodecs; 8 | import net.minecraft.network.codec.StreamCodec; 9 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | public record ExtraEntityUpdateDataPacket( 15 | int entityId, 16 | ExtraEntityUpdateData data 17 | ) implements CustomPacketPayload { 18 | public static final Type TYPE = 19 | new Type<>(ResourceLocations.of(Eyelib.MOD_ID, "extra_entity_update")); 20 | 21 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 22 | ByteBufCodecs.VAR_INT, 23 | ExtraEntityUpdateDataPacket::entityId, 24 | ExtraEntityUpdateData.STREAM_CODEC, 25 | ExtraEntityUpdateDataPacket::data, 26 | ExtraEntityUpdateDataPacket::new 27 | ); 28 | 29 | @Override 30 | public Type type() { 31 | return TYPE; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/EmitterParticleComponent.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter; 2 | 3 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 4 | import io.github.tt432.eyelib.client.particle.bedrock.component.ParticleComponent; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.emitter.shape.Direction; 6 | import io.github.tt432.eyelib.molang.MolangScope; 7 | import org.joml.Vector3f; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public interface EmitterParticleComponent extends ParticleComponent { 13 | default void onStart(BrParticleEmitter emitter) { 14 | } 15 | 16 | default void onTick(BrParticleEmitter emitter) { 17 | } 18 | 19 | default void onPreTick(BrParticleEmitter emitter) { 20 | } 21 | 22 | default void onLoop(BrParticleEmitter emitter) { 23 | } 24 | 25 | default boolean canEmit(BrParticleEmitter emitter) { 26 | return true; 27 | } 28 | 29 | @FunctionalInterface 30 | interface EvalVector3f { 31 | Vector3f eval(MolangScope scope); 32 | } 33 | 34 | default EvalVector3f getEmitPosition(BrParticleEmitter emitter) { 35 | return null; 36 | } 37 | 38 | default Direction direction() { 39 | return Direction.EMPTY; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/BehaviorEntity.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.common.behavior.component.group.ComponentGroup; 6 | import net.minecraft.resources.ResourceLocation; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record BehaviorEntity( 14 | ResourceLocation identifier, 15 | Map component_groups 16 | ) { 17 | public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( 18 | RecordCodecBuilder.create(instance2 -> instance2.group( 19 | RecordCodecBuilder.create(instance3 -> instance3.group( 20 | ResourceLocation.CODEC.fieldOf("identifier").forGetter(r -> r) 21 | ).apply(instance3, r -> r)).fieldOf("description").forGetter(BehaviorEntity::identifier), 22 | Codec.unboundedMap(Codec.STRING, ComponentGroup.CODEC).fieldOf("component_groups").forGetter(BehaviorEntity::component_groups) 23 | ).apply(instance2, BehaviorEntity::new)).fieldOf("minecraft:entity").forGetter(e -> e) 24 | ).apply(instance, e -> e)); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/MolangValue2.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.chin.codec.ChinExtraCodecs; 5 | import io.github.tt432.chin.util.Tuple; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.joml.Vector2f; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @Slf4j 13 | public record MolangValue2( 14 | MolangValue x, 15 | MolangValue y 16 | ) { 17 | public static final MolangValue2 ZERO = new MolangValue2(MolangValue.ZERO, MolangValue.ZERO); 18 | public static final MolangValue2 ONE = new MolangValue2(MolangValue.ONE, MolangValue.ONE); 19 | 20 | public static final MolangValue2 AXIS_X = new MolangValue2(MolangValue.ONE, MolangValue.ZERO); 21 | public static final MolangValue2 AXIS_Y = new MolangValue2(MolangValue.ZERO, MolangValue.ONE); 22 | 23 | public static final Codec CODEC = ChinExtraCodecs.tuple(MolangValue.CODEC, MolangValue.CODEC) 24 | .bmap(MolangValue2::new, mv2 -> Tuple.of(mv2.x, mv2.y)); 25 | 26 | public float getX(MolangScope scope) { 27 | return x.eval(scope); 28 | } 29 | 30 | public float getY(MolangScope scope) { 31 | return y.eval(scope); 32 | } 33 | 34 | public Vector2f eval(MolangScope scope) { 35 | return new Vector2f(getX(scope), getY(scope)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/cursor/Cursor.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.cursor; 2 | 3 | import lombok.Getter; 4 | import net.minecraft.client.Minecraft; 5 | import org.lwjgl.glfw.GLFWImage; 6 | import org.lwjgl.system.Pointer; 7 | 8 | import static org.lwjgl.glfw.GLFW.*; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @Getter 14 | public class Cursor extends Pointer.Default { 15 | private final GLFWImage image; 16 | private final int xhot; 17 | private final int yhot; 18 | 19 | boolean using; 20 | 21 | private static long createCursor(GLFWImage image, int xhot, int yhot) { 22 | long l = glfwCreateCursor(image, xhot, yhot); 23 | if (l == 0) 24 | org.lwjgl.glfw.GLFW.nglfwGetError(0L); 25 | return l; 26 | } 27 | 28 | public Cursor(GLFWImage image, int xhot, int yhot) { 29 | super(createCursor(image, xhot, yhot)); 30 | this.image = image; 31 | this.xhot = xhot; 32 | this.yhot = yhot; 33 | } 34 | 35 | public void set() { 36 | if (!using) { 37 | using = true; 38 | glfwSetCursor(Minecraft.getInstance().getWindow().getWindow(), address()); 39 | } 40 | } 41 | 42 | public void destroy() { 43 | if (using) { 44 | using = false; 45 | glfwDestroyCursor(address()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/AnimationEffect.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation; 2 | 3 | import io.github.tt432.eyelib.molang.MolangScope; 4 | import org.apache.logging.log4j.util.TriConsumer; 5 | 6 | import java.util.List; 7 | import java.util.TreeMap; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record AnimationEffect( 13 | TreeMap> data, 14 | TriConsumer action 15 | ) { 16 | public Runtime runtime() { 17 | return new Runtime<>(new TreeMap<>(data), action); 18 | } 19 | 20 | public record Runtime( 21 | TreeMap> data, 22 | TriConsumer action 23 | ) { 24 | public static void processEffect(Runtime runtime, float ticks, MolangScope scope) { 25 | if (runtime != null && !runtime.data().isEmpty() && runtime.data().firstKey() < ticks) { 26 | runtime.data().pollFirstEntry().getValue().forEach(v -> runtime.action().accept(scope, ticks, v)); 27 | } 28 | } 29 | } 30 | 31 | public static final AnimationEffect EMPTY = new AnimationEffect<>(new TreeMap<>(), (s, f, v) -> { 32 | }); 33 | 34 | @SuppressWarnings("unchecked") 35 | public static AnimationEffect empty() { 36 | return (AnimationEffect) EMPTY; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/AnimationComponentSyncPacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.capability.component.AnimationComponent; 5 | import io.github.tt432.eyelib.util.ResourceLocations; 6 | import io.netty.buffer.ByteBuf; 7 | import net.minecraft.network.codec.ByteBufCodecs; 8 | import net.minecraft.network.codec.StreamCodec; 9 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | public record AnimationComponentSyncPacket( 15 | int entityId, 16 | AnimationComponent.SerializableInfo animationInfo 17 | ) implements CustomPacketPayload { 18 | public static final Type TYPE = 19 | new Type<>(ResourceLocations.of(Eyelib.MOD_ID, "animation_component")); 20 | 21 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 22 | ByteBufCodecs.VAR_INT, 23 | AnimationComponentSyncPacket::entityId, 24 | AnimationComponent.SerializableInfo.STREAM_CODEC, 25 | AnimationComponentSyncPacket::animationInfo, 26 | AnimationComponentSyncPacket::new 27 | ); 28 | 29 | @Override 30 | public Type type() { 31 | return TYPE; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/math/Curves.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.math; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | import org.joml.Vector2f; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author DustW 11 | */ 12 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 13 | public class Curves { 14 | public static float lerpSplineCurve(List points, float time) { 15 | float p = (points.size() - 1) * time; 16 | 17 | int intPoint = (int) Math.floor(p); 18 | float weight = p - intPoint; 19 | 20 | Vector2f p0 = points.get(intPoint == 0 ? intPoint : Math.min(intPoint - 1, points.size() - 1)); 21 | Vector2f p1 = points.get(Math.min(intPoint, points.size() - 1)); 22 | Vector2f p2 = points.get(intPoint > points.size() - 2 ? points.size() - 1 : intPoint + 1); 23 | Vector2f p3 = points.get(intPoint > points.size() - 3 ? points.size() - 1 : intPoint + 2); 24 | 25 | return catmullRom(weight, p0.y(), p1.y(), p2.y(), p3.y()); 26 | } 27 | 28 | public static float catmullRom(float t, float p0, float p1, float p2, float p3) { 29 | float v0 = (p2 - p0) * .5F; 30 | float v1 = (p3 - p1) * .5F; 31 | float t2 = t * t; 32 | float t3 = t2 * t; 33 | return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gl/stencil/Face.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gl.stencil; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | 6 | /** 7 | * @author TT432 8 | */ 9 | public record Face( 10 | StencilDepthFailOp stencilDepthFailOp, 11 | StencilFailOp stencilFailOp, 12 | StencilFunc stencilFunc, 13 | StencilPassOp stencilPassOp 14 | ) { 15 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 16 | StencilDepthFailOp.CODEC.fieldOf("stencilDepthFailOp").forGetter(Face::stencilDepthFailOp), 17 | StencilFailOp.CODEC.fieldOf("stencilFailOp").forGetter(Face::stencilFailOp), 18 | StencilFunc.CODEC.fieldOf("stencilFunc").forGetter(Face::stencilFunc), 19 | StencilPassOp.CODEC.fieldOf("stencilPassOp").forGetter(Face::stencilPassOp) 20 | ).apply(ins, Face::new)); 21 | 22 | public static final Face DEFAULT_FRONT = new Face( 23 | StencilDepthFailOp.Keep, 24 | StencilFailOp.Keep, 25 | StencilFunc.Always, 26 | StencilPassOp.Keep 27 | ); 28 | 29 | public static final Face DEFAULT_BACK = new Face( 30 | StencilDepthFailOp.Keep, 31 | StencilFailOp.Keep, 32 | StencilFunc.Always, 33 | StencilPassOp.Keep 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/SpawnParticlePacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.util.ResourceLocations; 5 | import io.netty.buffer.ByteBuf; 6 | import net.minecraft.network.codec.ByteBufCodecs; 7 | import net.minecraft.network.codec.StreamCodec; 8 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 9 | import net.minecraft.resources.ResourceLocation; 10 | import org.joml.Vector3f; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | public record SpawnParticlePacket( 16 | String spawnId, 17 | ResourceLocation particleId, 18 | Vector3f position 19 | ) implements CustomPacketPayload { 20 | public static final Type TYPE = 21 | new Type<>(ResourceLocations.of(Eyelib.MOD_ID, "spawn_particle")); 22 | 23 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 24 | ByteBufCodecs.STRING_UTF8, 25 | SpawnParticlePacket::spawnId, 26 | ResourceLocation.STREAM_CODEC, 27 | SpawnParticlePacket::particleId, 28 | ByteBufCodecs.VECTOR3F, 29 | SpawnParticlePacket::position, 30 | SpawnParticlePacket::new 31 | ); 32 | 33 | @Override 34 | public Type type() { 35 | return TYPE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_item_entity_translucent_cull_chunk.json: -------------------------------------------------------------------------------- 1 | { 2 | "vertex": "eyelib:rendertype_item_entity_translucent_cull_chunk", 3 | "fragment": "eyelib:rendertype_item_entity_translucent_cull_chunk", 4 | "samplers": [ 5 | { "name": "Sampler0" }, 6 | { "name": "Sampler2" } 7 | ], 8 | "uniforms": [ 9 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 10 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 11 | { "name": "ChunkOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] }, 12 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 13 | { "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 14 | { "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 15 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 16 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 17 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 18 | { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/GlobalBoneIdHandler.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model; 2 | 3 | import com.mojang.serialization.Codec; 4 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 5 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 6 | import it.unimi.dsi.fastutil.objects.Object2IntMap; 7 | import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public class GlobalBoneIdHandler { 13 | public static final Codec STRING_ID_CODEC = Codec.STRING.xmap(GlobalBoneIdHandler::get, GlobalBoneIdHandler::get); 14 | 15 | public static Codec> map(Codec valueCodec) { 16 | return Codec.unboundedMap(GlobalBoneIdHandler.STRING_ID_CODEC, valueCodec).xmap(Int2ObjectOpenHashMap::new, m -> m); 17 | } 18 | 19 | private static final Object2IntMap map = new Object2IntOpenHashMap<>(); 20 | private static final Int2ObjectMap map2 = new Int2ObjectOpenHashMap<>(); 21 | private static int counter; 22 | 23 | public static String get(int id) { 24 | return map2.get(id); 25 | } 26 | 27 | public static int get(String boneName) { 28 | if (boneName.isBlank()) return -1; 29 | 30 | return map.computeIfAbsent(boneName, k -> { 31 | int result = counter++; 32 | map2.put(result, boneName); 33 | return result; 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_translucent_chunk.json: -------------------------------------------------------------------------------- 1 | { 2 | "vertex": "eyelib:rendertype_entity_translucent_chunk", 3 | "fragment": "eyelib:rendertype_entity_translucent_chunk", 4 | "samplers": [ 5 | { "name": "Sampler0" }, 6 | { "name": "Sampler1" }, 7 | { "name": "Sampler2" } 8 | ], 9 | "uniforms": [ 10 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 11 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 12 | { "name": "ChunkOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] }, 13 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 14 | { "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 15 | { "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 16 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 17 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 18 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 19 | { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/assets/eyelib/shaders/core/rendertype_entity_cutout_no_cull_chunk.json: -------------------------------------------------------------------------------- 1 | { 2 | "vertex": "eyelib:rendertype_entity_cutout_no_cull_chunk", 3 | "fragment": "eyelib:rendertype_entity_cutout_no_cull_chunk", 4 | "samplers": [ 5 | { "name": "Sampler0" }, 6 | { "name": "Sampler1" }, 7 | { "name": "Sampler2" } 8 | ], 9 | "uniforms": [ 10 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 11 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 12 | { "name": "ChunkOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] }, 13 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 14 | { "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 15 | { "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 16 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 17 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 18 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 19 | { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/lifetime/ParticleExpireIfInBlocks.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.lifetime; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 8 | import net.minecraft.core.registries.BuiltInRegistries; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @RegisterParticleComponent(value = "particle_expire_if_in_blocks", target = ComponentTarget.PARTICLE) 16 | public record ParticleExpireIfInBlocks( 17 | List blocks 18 | ) implements ParticleParticleComponent { 19 | public static final Codec CODEC = 20 | Codec.STRING.listOf().xmap(ParticleExpireIfInBlocks::new, ParticleExpireIfInBlocks::blocks); 21 | 22 | @Override 23 | public void onFrame(BrParticleParticle particle) { 24 | if (blocks.contains(BuiltInRegistries.BLOCK.getKey(particle.level() 25 | .getBlockState(particle.getBlockPosition()) 26 | .getBlock()).toString())) { 27 | particle.remove(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/RenderModelVisitor.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import com.mojang.blaze3d.vertex.VertexConsumer; 5 | import io.github.tt432.eyelib.client.model.Model; 6 | import io.github.tt432.eyelib.client.render.RenderParams; 7 | import org.joml.Vector2fc; 8 | import org.joml.Vector3f; 9 | import org.joml.Vector3fc; 10 | import org.joml.Vector4f; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | public class RenderModelVisitor extends ModelVisitor { 16 | private static final Vector4f tPosition = new Vector4f(); 17 | private static final Vector3f tNormal = new Vector3f(); 18 | 19 | @Override 20 | public void visitVertex(RenderParams renderParams, ModelVisitContext context, Model.Cube cube, Vector3fc vertex, Vector2fc uv, Vector3fc normal) { 21 | PoseStack poseStack = renderParams.poseStack(); 22 | PoseStack.Pose last = poseStack.last(); 23 | 24 | last.pose().transformAffine(vertex.x(), vertex.y(), vertex.z(), 1, tPosition); 25 | last.normal().transform(normal, tNormal); 26 | 27 | VertexConsumer consumer = renderParams.consumer(); 28 | consumer.addVertex(tPosition.x, tPosition.y, tPosition.z, 29 | 0xFF_FF_FF_FF, 30 | uv.x(), uv.y(), 31 | renderParams.overlay(), renderParams.light(), 32 | tNormal.x, tNormal.y, tNormal.z); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/lifetime/ParticleExpireIfNotInBlocks.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.lifetime; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 8 | import net.minecraft.core.registries.BuiltInRegistries; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @RegisterParticleComponent(value = "particle_expire_if_not_in_blocks", target = ComponentTarget.PARTICLE) 16 | public record ParticleExpireIfNotInBlocks( 17 | List blocks 18 | ) implements ParticleParticleComponent { 19 | public static final Codec CODEC = 20 | Codec.STRING.listOf().xmap(ParticleExpireIfNotInBlocks::new, ParticleExpireIfNotInBlocks::blocks); 21 | 22 | @Override 23 | public void onFrame(BrParticleParticle particle) { 24 | if (!blocks.contains(BuiltInRegistries.BLOCK.getKey(particle.level() 25 | .getBlockState(particle.getBlockPosition()) 26 | .getBlock()).toString())) { 27 | particle.remove(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/mixin/BufferBuilderMixin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.mixin; 2 | 3 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation; 4 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 5 | import com.mojang.blaze3d.vertex.BufferBuilder; 6 | import com.mojang.blaze3d.vertex.ByteBufferBuilder; 7 | import com.mojang.blaze3d.vertex.MeshData; 8 | import io.github.tt432.eyelib.compute.LazyComputeBufferBuilder; 9 | import io.github.tt432.eyelib.compute.LazyComputeMeshData; 10 | import io.github.tt432.eyelib.compute.VertexComputeHelper; 11 | import lombok.Getter; 12 | import lombok.Setter; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Unique; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | 17 | /** 18 | * @author TT432 19 | */ 20 | @Mixin(BufferBuilder.class) 21 | public class BufferBuilderMixin implements LazyComputeBufferBuilder { 22 | @Getter 23 | @Setter 24 | @Unique 25 | VertexComputeHelper eyelib$helper; 26 | 27 | @WrapOperation(method = "storeMesh", at = @At(value = "NEW", target = "(Lcom/mojang/blaze3d/vertex/ByteBufferBuilder$Result;Lcom/mojang/blaze3d/vertex/MeshData$DrawState;)Lcom/mojang/blaze3d/vertex/MeshData;")) 28 | private MeshData eyelib$newMeshData(ByteBufferBuilder.Result vertexBuffer, MeshData.DrawState drawState, Operation original) { 29 | return new LazyComputeMeshData(vertexBuffer, drawState, eyelib$helper); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/network/ModelComponentSyncPacket.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.network; 2 | 3 | import io.github.tt432.eyelib.Eyelib; 4 | import io.github.tt432.eyelib.capability.component.ModelComponent; 5 | import io.github.tt432.eyelib.util.ResourceLocations; 6 | import io.netty.buffer.ByteBuf; 7 | import net.minecraft.network.codec.ByteBufCodecs; 8 | import net.minecraft.network.codec.StreamCodec; 9 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * @author TT432 16 | */ 17 | public record ModelComponentSyncPacket( 18 | int entityId, 19 | List modelInfo 20 | ) implements CustomPacketPayload { 21 | public static final CustomPacketPayload.Type TYPE = 22 | new CustomPacketPayload.Type<>(ResourceLocations.of(Eyelib.MOD_ID, "model_component")); 23 | 24 | public static final StreamCodec STREAM_CODEC = StreamCodec.composite( 25 | ByteBufCodecs.VAR_INT, 26 | ModelComponentSyncPacket::entityId, 27 | ByteBufCodecs.collection(ArrayList::new, ModelComponent.SerializableInfo.STREAM_CODEC), 28 | ModelComponentSyncPacket::modelInfo, 29 | ModelComponentSyncPacket::new 30 | ); 31 | 32 | @Override 33 | public Type type() { 34 | return TYPE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/bedrock/BrEffectsKeyFrame.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation.bedrock; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.molang.MolangValue; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record BrEffectsKeyFrame( 13 | float timestamp, 14 | String effect, 15 | Optional locator, 16 | Optional preEffectScript 17 | ) { 18 | public record Factory( 19 | String effect, 20 | Optional locator, 21 | Optional preEffectScript 22 | ) { 23 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 24 | Codec.STRING.fieldOf("effect").forGetter(o -> o.effect), 25 | Codec.STRING.optionalFieldOf("locator").forGetter(o -> o.locator), 26 | MolangValue.CODEC.optionalFieldOf("pre_effect_script").forGetter(o -> o.preEffectScript) 27 | ).apply(ins, Factory::new)); 28 | 29 | public BrEffectsKeyFrame to(float timestamp) { 30 | return new BrEffectsKeyFrame(timestamp, effect, locator, preEffectScript); 31 | } 32 | 33 | public static Factory from(BrEffectsKeyFrame keyFrame) { 34 | return new Factory(keyFrame.effect(), keyFrame.locator(), keyFrame.preEffectScript); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/rate/EmitterRateManual.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter.rate; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.emitter.EmitterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 8 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 9 | import io.github.tt432.eyelib.molang.MolangValue; 10 | 11 | /** 12 | * 只在被游戏告知应当发射时发射。多被用在旧版粒子效果 13 | * 14 | * @param maxParticles 每次粒子发射后评估 15 | * @author TT432 16 | */ 17 | @RegisterParticleComponent(value = "emitter_rate_manual", type = "emitter_rate", target = ComponentTarget.EMITTER) 18 | public record EmitterRateManual( 19 | MolangValue maxParticles 20 | ) implements EmitterParticleComponent { 21 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 22 | MolangValue.CODEC.optionalFieldOf("max_particles", MolangValue.getConstant(50)) 23 | .forGetter(o -> o.maxParticles) 24 | ).apply(ins, EmitterRateManual::new)); 25 | 26 | @Override 27 | public boolean canEmit(BrParticleEmitter emitter) { 28 | return emitter.getEmitCount() < maxParticles().eval(emitter.molangScope); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/rate/EmitterRateInstant.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter.rate; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.emitter.EmitterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 8 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 9 | import io.github.tt432.eyelib.molang.MolangValue; 10 | 11 | /** 12 | * 一次性发射全部粒子,除非循环否则没有更多 13 | * 14 | * @param numParticles 粒子发射数量。每次发射器循环评估一次 15 | * @author TT432 16 | */ 17 | @RegisterParticleComponent(value = "emitter_rate_instant", type = "emitter_rate", target = ComponentTarget.EMITTER) 18 | public record EmitterRateInstant( 19 | MolangValue numParticles 20 | ) implements EmitterParticleComponent { 21 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 22 | MolangValue.CODEC.optionalFieldOf("num_particles", MolangValue.getConstant(10)) 23 | .forGetter(o -> o.numParticles) 24 | ).apply(ins, EmitterRateInstant::new)); 25 | 26 | @Override 27 | public void onLoop(BrParticleEmitter emitter) { 28 | for (int i = 0; i < ((int) numParticles.eval(emitter.molangScope)); i++) { 29 | emitter.emit(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/motion/ParticleMotionParametric.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.motion; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 8 | import io.github.tt432.eyelib.molang.MolangValue; 9 | import io.github.tt432.eyelib.molang.MolangValue3; 10 | 11 | /** 12 | * todo 13 | * 14 | * @author TT432 15 | */ 16 | @RegisterParticleComponent(value = "particle_motion_parametric", type = "particle_motion", target = ComponentTarget.PARTICLE) 17 | public record ParticleMotionParametric( 18 | MolangValue3 relativePosition, 19 | MolangValue3 direction, 20 | MolangValue rotation 21 | ) implements ParticleParticleComponent { 22 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 23 | MolangValue3.CODEC.optionalFieldOf("relative_position", MolangValue3.ZERO).forGetter(o -> o.relativePosition), 24 | MolangValue3.CODEC.optionalFieldOf("direction", MolangValue3.ZERO).forGetter(o -> o.direction), 25 | MolangValue.CODEC.optionalFieldOf("rotation", MolangValue.ZERO).forGetter(o -> o.rotation) 26 | ).apply(ins, ParticleMotionParametric::new)); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/loader/BlockBrModelLoader.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.loader; 2 | 3 | import com.google.gson.JsonDeserializationContext; 4 | import com.google.gson.JsonObject; 5 | import com.google.gson.JsonParseException; 6 | import io.github.tt432.eyelib.Eyelib; 7 | import io.github.tt432.eyelib.client.model.UnBakedBrModel; 8 | import io.github.tt432.eyelib.client.model.bedrock.BrModel; 9 | import io.github.tt432.eyelib.util.ResourceLocations; 10 | import lombok.AccessLevel; 11 | import lombok.NoArgsConstructor; 12 | import net.neoforged.api.distmarker.Dist; 13 | import net.neoforged.bus.api.SubscribeEvent; 14 | import net.neoforged.fml.common.EventBusSubscriber; 15 | import net.neoforged.neoforge.client.event.ModelEvent; 16 | import net.neoforged.neoforge.client.model.geometry.IGeometryLoader; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | /** 20 | * @author TT432 21 | */ 22 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 23 | @EventBusSubscriber(value = Dist.CLIENT) 24 | public class BlockBrModelLoader implements IGeometryLoader { 25 | @SubscribeEvent 26 | public static void onEvent(ModelEvent.RegisterGeometryLoaders event) { 27 | event.register(ResourceLocations.of(Eyelib.MOD_ID, "bedrock_model"), new BlockBrModelLoader()); 28 | } 29 | 30 | @Override 31 | public @NotNull UnBakedBrModel read(@NotNull JsonObject jsonObject, @NotNull JsonDeserializationContext deserializationContext) throws JsonParseException { 32 | return new UnBakedBrModel(BrModel.parse(jsonObject).models().get(0)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/animation/BrAnimator.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.animation; 2 | 3 | import io.github.tt432.eyelib.capability.component.AnimationComponent; 4 | import io.github.tt432.eyelib.client.render.bone.BoneRenderInfos; 5 | import io.github.tt432.eyelib.molang.MolangScope; 6 | import io.github.tt432.eyelib.molang.MolangValue; 7 | import lombok.AccessLevel; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author TT432 14 | */ 15 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 16 | public final class BrAnimator { 17 | @SuppressWarnings("unchecked") 18 | private static T cast(Object o) { 19 | return (T) o; 20 | } 21 | 22 | public static BoneRenderInfos tickAnimation(AnimationComponent component, MolangScope scope, AnimationEffects effects, 23 | float ticks, Runnable animationStartFeedback) { 24 | BoneRenderInfos infos = new BoneRenderInfos(); 25 | 26 | for (Map.Entry, MolangValue> entry : component.getAnimate().entrySet()) { 27 | Animation animation = entry.getKey(); 28 | MolangValue multiplier = entry.getValue(); 29 | if (animation == null) continue; 30 | 31 | animation.tickAnimation(cast(component.getAnimationData(animation.name())), 32 | component.getSerializableInfo().animations(), scope, ticks, multiplier.eval(scope), 33 | infos, effects, animationStartFeedback); 34 | } 35 | 36 | return infos; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/EmitterLocalSpace.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | 8 | /** 9 | * 该组件指定发射器的参考系。仅在发射器附加到实体时适用。
10 | * 当 {@link #position} 为 true 时,粒子将在实体空间中模拟,否则它们将在世界空间中模拟。
11 | * {@link #rotation} 的工作方式与此相同。
12 | * 默认情况下,两个属性均为 false,这使得粒子相对于发射器发射,然后独立于发射器进行模拟。
13 | * 请注意,rotation = true 和 position = false 是无效选项。
14 | * {@link #velocity} 属性会将发射器的速度添加到粒子的初始速度中。 15 | * 16 | * @author TT432 17 | */ 18 | @RegisterParticleComponent(value = "emitter_local_space", target = ComponentTarget.EMITTER) 19 | public record EmitterLocalSpace( 20 | boolean position, 21 | boolean rotation, 22 | boolean velocity 23 | ) implements EmitterParticleComponent { 24 | public static final EmitterLocalSpace EMPTY = new EmitterLocalSpace(false, false, false); 25 | 26 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 27 | Codec.BOOL.optionalFieldOf("position", false).forGetter(o -> o.position), 28 | Codec.BOOL.optionalFieldOf("rotation", false).forGetter(o -> o.rotation), 29 | Codec.BOOL.optionalFieldOf("velocity", false).forGetter(o -> o.velocity) 30 | ).apply(ins, EmitterLocalSpace::new)); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/bone/BoneRenderInfos.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.bone; 2 | 3 | import io.github.tt432.eyelib.client.model.ModelRuntimeData; 4 | import io.github.tt432.eyelib.client.model.bedrock.BrBone; 5 | import io.github.tt432.eyelib.client.model.transformer.BedrockTransformer; 6 | import io.github.tt432.eyelib.client.model.transformer.ModelTransformer; 7 | import it.unimi.dsi.fastutil.Function; 8 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 9 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 10 | import lombok.Getter; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * @author TT432 15 | */ 16 | @Getter 17 | public class BoneRenderInfos implements ModelRuntimeData { 18 | public static final BoneRenderInfos EMPTY = new BoneRenderInfos(); 19 | 20 | private final Int2ObjectMap infos = new Int2ObjectOpenHashMap<>(); 21 | 22 | public void reset() { 23 | infos.values().forEach(BoneRenderInfoEntry::resetRenderInfo); 24 | } 25 | 26 | public void set(BoneRenderInfos other) { 27 | reset(); 28 | infos.putAll(other.infos); 29 | } 30 | 31 | private static final Function FUNC = s -> new BoneRenderInfoEntry(); 32 | 33 | @Override 34 | @NotNull 35 | public BoneRenderInfoEntry getData(int id) { 36 | return infos.computeIfAbsent(id, FUNC); 37 | } 38 | 39 | @Override 40 | public ModelTransformer transformer() { 41 | return BedrockTransformer.INSTANCE; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/model/transformer/ModelTransformer.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.model.transformer; 2 | 3 | import io.github.tt432.eyelib.client.model.Model; 4 | import io.github.tt432.eyelib.client.model.ModelRuntimeData; 5 | import org.joml.Vector3f; 6 | import org.joml.Vector3fc; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public interface ModelTransformer> { 12 | default Vector3fc pivot(M model, R data) { 13 | return new Vector3f(); 14 | } 15 | 16 | Vector3fc initPosition(M model, R data); 17 | 18 | /** 19 | * init + offset 20 | */ 21 | Vector3fc position(M model, R data); 22 | 23 | void position(M model, R data, float x, float y, float z); 24 | 25 | default void position(M model, R data, Vector3fc pos) { 26 | position(model, data, pos.x(), pos.y(), pos.z()); 27 | } 28 | 29 | Vector3fc initRotation(M model, R data); 30 | 31 | /** 32 | * init + offset 33 | */ 34 | Vector3fc rotation(M model, R data); 35 | 36 | void rotation(M model, R data, float x, float y, float z); 37 | 38 | default void rotation(M model, R data, Vector3fc rotation) { 39 | rotation(model, data, rotation.x(), rotation.y(), rotation.z()); 40 | } 41 | 42 | Vector3fc initScale(M model, R data); 43 | 44 | /** 45 | * init + offset 46 | */ 47 | Vector3fc scale(M model, R data); 48 | 49 | void scale(M model, R data, float x, float y, float z); 50 | 51 | default void scale(M model, R data, Vector3fc scale) { 52 | scale(model, data, scale.x(), scale.y(), scale.z()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/EmitterInitialization.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 8 | import io.github.tt432.eyelib.molang.MolangValue; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @RegisterParticleComponent(value = "emitter_initialization", target = ComponentTarget.EMITTER) 14 | public record EmitterInitialization( 15 | MolangValue creationExpression, 16 | MolangValue perUpdateExpression 17 | ) implements EmitterParticleComponent { 18 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 19 | MolangValue.CODEC.optionalFieldOf("creation_expression", MolangValue.FALSE_VALUE) 20 | .forGetter(o -> o.creationExpression), 21 | MolangValue.CODEC.optionalFieldOf("per_update_expression", MolangValue.FALSE_VALUE) 22 | .forGetter(o -> o.perUpdateExpression) 23 | ).apply(ins, EmitterInitialization::new)); 24 | 25 | @Override 26 | public void onStart(BrParticleEmitter emitter) { 27 | creationExpression.eval(emitter.molangScope); 28 | } 29 | 30 | @Override 31 | public void onPreTick(BrParticleEmitter emitter) { 32 | perUpdateExpression.eval(emitter.molangScope); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/shape/EmitterShapePoint.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter.shape; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.emitter.EmitterParticleComponent; 8 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 9 | import io.github.tt432.eyelib.molang.MolangValue3; 10 | 11 | /** 12 | * 所有粒子从发射器偏移的一个点发射。 13 | * 14 | * @author TT432 15 | */ 16 | @RegisterParticleComponent(value = "emitter_shape_point", type = "emitter_shape", target = ComponentTarget.EMITTER) 17 | public record EmitterShapePoint( 18 | MolangValue3 offset, 19 | Direction direction 20 | ) implements EmitterParticleComponent { 21 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 22 | MolangValue3.CODEC.optionalFieldOf("offset", MolangValue3.ZERO).forGetter(o -> o.offset), 23 | MolangValue3.CODEC.xmap( 24 | mv3 -> new Direction(Direction.Type.CUSTOM, mv3), 25 | Direction::custom 26 | ).optionalFieldOf("direction", Direction.EMPTY).forGetter(o -> o.direction) 27 | ).apply(ins, EmitterShapePoint::new)); 28 | 29 | @Override 30 | public EvalVector3f getEmitPosition(BrParticleEmitter emitter) { 31 | return offset::eval; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/compat/ar/ARCompatImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.compat.ar; 2 | 3 | import com.github.argon4w.acceleratedrendering.core.CoreFeature; 4 | import com.github.argon4w.acceleratedrendering.core.buffers.accelerated.builders.VertexConsumerExtension; 5 | import com.github.argon4w.acceleratedrendering.features.entities.AcceleratedEntityRenderingFeature; 6 | import io.github.tt432.eyelib.client.model.bake.BakedModel; 7 | import io.github.tt432.eyelib.client.render.RenderParams; 8 | import lombok.experimental.ExtensionMethod; 9 | 10 | @ExtensionMethod(VertexConsumerExtension.class) 11 | public class ARCompatImpl { 12 | public static boolean renderWithAR(BakedModel.BakedBone bakedBone, RenderParams params) { 13 | var extension = params.consumer().getAccelerated(); 14 | var pose = params.poseStack().last(); 15 | 16 | if (AcceleratedEntityRenderingFeature.isEnabled() 17 | && AcceleratedEntityRenderingFeature.shouldUseAcceleratedPipeline() 18 | && (CoreFeature.isRenderingLevel() || (CoreFeature.isRenderingGui() && AcceleratedEntityRenderingFeature.shouldAccelerateInGui())) 19 | && extension.isAccelerated() 20 | ) { 21 | extension.doRender( 22 | AcceleratedBakedBoneRenderer.INSTANCE, 23 | bakedBone, 24 | pose.pose(), 25 | pose.normal(), 26 | params.light(), 27 | params.overlay(), 28 | -1 29 | ); 30 | 31 | return true; 32 | } else { 33 | return false; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/render/visitor/CollectLocatorModelVisitor.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.render.visitor; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | import io.github.tt432.eyelib.client.model.Model; 5 | import io.github.tt432.eyelib.client.model.ModelRuntimeData; 6 | import io.github.tt432.eyelib.client.model.locator.LocatorEntry; 7 | import io.github.tt432.eyelib.client.model.transformer.ModelTransformer; 8 | import io.github.tt432.eyelib.client.render.RenderParams; 9 | import org.joml.Matrix4f; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * @author TT432 16 | */ 17 | public class CollectLocatorModelVisitor extends ModelVisitor { 18 | @Override 19 | public void visitCube(RenderParams renderParams, ModelVisitContext context, Model.Cube cube) { 20 | 21 | } 22 | 23 | @Override 24 | public > void visitLocator(RenderParams renderParams, ModelVisitContext context, Model.Bone bone, LocatorEntry locator, R data, ModelTransformer transformer) { 25 | PoseStack poseStack = renderParams.poseStack(); 26 | poseStack.pushPose(); 27 | PoseStack.Pose last = poseStack.last(); 28 | Matrix4f pose = last.pose(); 29 | 30 | pose.translate(locator.offset()); 31 | 32 | var rotation = locator.rotation(); 33 | 34 | last.normal().rotateZYX(rotation.z(), rotation.y(), rotation.x()); 35 | last.pose().rotateZYX(rotation.z(), rotation.y(), rotation.x()); 36 | 37 | context.>orCreate("locators", new HashMap<>()).put(locator.name(), new Matrix4f(poseStack.poseStack.getLast().pose())); 38 | poseStack.popPose(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/mapping/api/MolangFunctionExporter.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang.mapping.api; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 13 | public class MolangFunctionExporter { 14 | public static void export() { 15 | try (var fw = new FileWriter("./exportedMolang.csv")) { 16 | visitNode(MolangMappingTree.INSTANCE.toplevelNode, fw); 17 | } catch (IOException e) { 18 | throw new RuntimeException(e); 19 | } 20 | } 21 | 22 | private static void visitNode(MolangMappingTree.Node node, FileWriter fw) { 23 | node.actualFunctions.forEach((k, v) -> { 24 | for (MolangMappingTree.FunctionInfo functionInfo : v) { 25 | MolangFunction molangFunction = functionInfo.molangFunction(); 26 | if (molangFunction != null) { 27 | try { 28 | fw.write(molangFunction.value() + "," + String.join(" ", molangFunction.alias()) + "," + molangFunction.description() + "\n"); 29 | } catch (IOException e) { 30 | throw new RuntimeException(e); 31 | } 32 | } else { 33 | try { 34 | fw.write(functionInfo.method().getName() + ", ,\n"); 35 | } catch (IOException e) { 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | } 40 | }); 41 | node.children.values().forEach(c -> visitNode(c, fw)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/initial/ParticleInitialSpin.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.initial; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 8 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 9 | import io.github.tt432.eyelib.molang.MolangScope; 10 | import io.github.tt432.eyelib.molang.MolangValue; 11 | 12 | /** 13 | * @param rotation degrees 14 | * @param rotationRate degrees/sec 15 | * @author TT432 16 | */ 17 | @RegisterParticleComponent(value = "particle_initial_spin", target = ComponentTarget.PARTICLE) 18 | public record ParticleInitialSpin( 19 | MolangValue rotation, 20 | MolangValue rotationRate 21 | ) implements ParticleParticleComponent { 22 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 23 | MolangValue.CODEC.optionalFieldOf("rotation", MolangValue.FALSE_VALUE).forGetter(o -> o.rotation), 24 | MolangValue.CODEC.optionalFieldOf("rotation_rate", MolangValue.FALSE_VALUE).forGetter(o -> o.rotationRate) 25 | ).apply(ins, ParticleInitialSpin::new)); 26 | 27 | @Override 28 | public void onStart(BrParticleParticle particle) { 29 | MolangScope scope = particle.molangScope; 30 | particle.setRotation(rotation.eval(scope)); 31 | particle.setRotationRate(rotationRate.eval(scope)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/capability/ItemInHandRenderData.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.capability; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.molang.type.MolangString; 6 | import net.minecraft.world.entity.LivingEntity; 7 | import net.minecraft.world.item.ItemStack; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | public record ItemInHandRenderData( 13 | RenderData leftHandData, 14 | RenderData rightHandData 15 | ) { 16 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 17 | RenderData.codec().fieldOf("leftHandData").forGetter(o -> o.leftHandData), 18 | RenderData.codec().fieldOf("rightHandData").forGetter(o -> o.rightHandData) 19 | ).apply(ins, ItemInHandRenderData::new)); 20 | 21 | public static ItemInHandRenderData empty() { 22 | return new ItemInHandRenderData(new RenderData<>(), new RenderData<>()); 23 | } 24 | 25 | public void init(LivingEntity entity, RenderData parents) { 26 | if (entity.getMainHandItem() != leftHandData.getOwner()) { 27 | leftHandData.init(entity.getMainHandItem()); 28 | leftHandData.getScope().setParent(parents.getScope()); 29 | leftHandData.getScope().set("context.item_slot", MolangString.valueOf("off_hand")); 30 | } 31 | if (entity.getOffhandItem() != rightHandData.getOwner()) { 32 | rightHandData.init(entity.getOffhandItem()); 33 | rightHandData.getScope().setParent(parents.getScope()); 34 | leftHandData.getScope().set("context.item_slot", MolangString.valueOf("main_hand")); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/shape/EmitterShapeCustom.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter.shape; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleEmitter; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 8 | import io.github.tt432.eyelib.client.particle.bedrock.component.emitter.EmitterParticleComponent; 9 | import io.github.tt432.eyelib.molang.MolangValue3; 10 | 11 | /** 12 | * 所有粒子基于指定的一组 Molang 表达式发射 13 | * 14 | * @param offset 指定从发射器到发射粒子的偏移量。每发射一个粒子时评估一次 15 | * @param direction 指定粒子的方向。每发射一个粒子时评估一次 16 | * @author TT432 17 | */ 18 | @RegisterParticleComponent(value = "emitter_shape_custom", type = "emitter_shape", target = ComponentTarget.EMITTER) 19 | public record EmitterShapeCustom( 20 | MolangValue3 offset, 21 | Direction direction 22 | ) implements EmitterParticleComponent { 23 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 24 | MolangValue3.CODEC.optionalFieldOf("offset", MolangValue3.ZERO).forGetter(o -> o.offset), 25 | MolangValue3.CODEC.xmap( 26 | mv3 -> new Direction(Direction.Type.CUSTOM, mv3), 27 | Direction::custom 28 | ).optionalFieldOf("direction", Direction.EMPTY).forGetter(o -> o.direction) 29 | ).apply(ins, EmitterShapeCustom::new)); 30 | 31 | @Override 32 | public EvalVector3f getEmitPosition(BrParticleEmitter emitter) { 33 | return offset::eval; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/common/behavior/event/filter/ComplexFilter.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.common.behavior.event.filter; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.MapCodec; 5 | import io.github.tt432.eyelib.util.codec.EyelibCodec; 6 | import lombok.AllArgsConstructor; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author TT432 13 | */ 14 | @AllArgsConstructor 15 | public sealed class ComplexFilter implements Filter permits ComplexFilter.AllOf, ComplexFilter.OneOf, ComplexFilter.NoneOf { 16 | public final List filters; 17 | 18 | public static final MapCodec CODEC = EyelibCodec.list(() -> Map.of( 19 | "all_of", new EyelibCodec.CodecInfo<>(AllOf.class, AllOf.CODEC), 20 | "one_of", new EyelibCodec.CodecInfo<>(OneOf.class, OneOf.CODEC), 21 | "none_of", new EyelibCodec.CodecInfo<>(NoneOf.class, NoneOf.CODEC) 22 | )); 23 | 24 | public static final class AllOf extends ComplexFilter { 25 | public static final Codec CODEC = Filter.CODEC.listOf().xmap(AllOf::new, f -> f.filters); 26 | 27 | public AllOf(List filters) { 28 | super(filters); 29 | } 30 | } 31 | 32 | public static final class OneOf extends ComplexFilter { 33 | public static final Codec CODEC = Filter.CODEC.listOf().xmap(OneOf::new, f -> f.filters); 34 | 35 | public OneOf(List filters) { 36 | super(filters); 37 | } 38 | } 39 | 40 | public static final class NoneOf extends ComplexFilter { 41 | public static final Codec CODEC = Filter.CODEC.listOf().xmap(NoneOf::new, f -> f.filters); 42 | 43 | public NoneOf(List filters) { 44 | super(filters); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/util/client/AnimationApplier.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.util.client; 2 | 3 | import io.github.tt432.eyelib.client.model.Model; 4 | import io.github.tt432.eyelib.client.model.ModelRuntimeData; 5 | import io.github.tt432.eyelib.client.model.transformer.ModelTransformer; 6 | import io.github.tt432.eyelib.client.render.bone.BoneRenderInfoEntry; 7 | import lombok.experimental.UtilityClass; 8 | import org.joml.Vector3f; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | @UtilityClass 14 | public class AnimationApplier { 15 | public > void apply( 16 | BoneRenderInfoEntry entry, M model, R data, ModelTransformer transformer 17 | ) { 18 | var initPosition = transformer.initPosition(model, data); 19 | Vector3f renderPosition = entry.getRenderPosition(); 20 | transformer.position( 21 | model, 22 | data, 23 | renderPosition.x + initPosition.x(), 24 | renderPosition.y + initPosition.y(), 25 | renderPosition.z + initPosition.z() 26 | ); 27 | var initRotation = transformer.initRotation(model, data); 28 | Vector3f renderRotation = entry.getRenderRotation(); 29 | transformer.rotation( 30 | model, 31 | data, 32 | renderRotation.x + initRotation.x(), 33 | renderRotation.y + initRotation.y(), 34 | renderRotation.z + initRotation.z() 35 | ); 36 | var initScale = transformer.initScale(model, data); 37 | Vector3f renderScala = entry.getRenderScala(); 38 | transformer.scale( 39 | model, 40 | data, 41 | renderScala.x * initScale.x(), 42 | renderScala.y * initScale.y(), 43 | renderScala.z * initScale.z() 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/particle/lifetime/ParticleLifetimeExpression.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.particle.lifetime; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import io.github.tt432.eyelib.client.particle.bedrock.BrParticleParticle; 6 | import io.github.tt432.eyelib.client.particle.bedrock.component.ComponentTarget; 7 | import io.github.tt432.eyelib.client.particle.bedrock.component.RegisterParticleComponent; 8 | import io.github.tt432.eyelib.client.particle.bedrock.component.particle.ParticleParticleComponent; 9 | import io.github.tt432.eyelib.molang.MolangValue; 10 | 11 | /** 12 | * @param expirationExpression true 时消失,每帧评估 13 | * @param maxLifetime 超时消失,评估一次,为 0 不消失 14 | * @author TT432 15 | */ 16 | @RegisterParticleComponent(value = "particle_lifetime_expression", target = ComponentTarget.PARTICLE) 17 | public record ParticleLifetimeExpression( 18 | MolangValue expirationExpression, 19 | MolangValue maxLifetime 20 | ) implements ParticleParticleComponent { 21 | public static final Codec CODEC = RecordCodecBuilder.create(ins -> ins.group( 22 | MolangValue.CODEC.optionalFieldOf("expiration_expression", MolangValue.FALSE_VALUE).forGetter(o -> o.expirationExpression), 23 | MolangValue.CODEC.optionalFieldOf("max_lifetime", MolangValue.FALSE_VALUE).forGetter(o -> o.maxLifetime) 24 | ).apply(ins, ParticleLifetimeExpression::new)); 25 | 26 | @Override 27 | public void onStart(BrParticleParticle particle) { 28 | particle.setLifetime(maxLifetime.eval(particle.molangScope)); 29 | } 30 | 31 | @Override 32 | public void onFrame(BrParticleParticle particle) { 33 | if (particle.getAge() >= particle.getLifetime() || expirationExpression.evalAsBool(particle.molangScope)) { 34 | particle.remove(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/gui/RenderTargets.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.gui; 2 | 3 | import com.mojang.blaze3d.pipeline.RenderTarget; 4 | 5 | import java.lang.invoke.MethodHandles; 6 | import java.lang.invoke.VarHandle; 7 | 8 | /** 9 | * @author TT432 10 | */ 11 | public class RenderTargets { 12 | public static final VarHandle colorTextureIdHandle; 13 | public static final VarHandle depthBufferIdHandle; 14 | 15 | static { 16 | try { 17 | MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(RenderTarget.class, MethodHandles.lookup()); 18 | colorTextureIdHandle = lookup.findVarHandle(RenderTarget.class, "colorTextureId", int.class); 19 | depthBufferIdHandle = lookup.findVarHandle(RenderTarget.class, "depthBufferId", int.class); 20 | } catch (IllegalAccessException | NoSuchFieldException e) { 21 | throw new RuntimeException(e); 22 | } 23 | } 24 | 25 | public static void swap(RenderTarget a, RenderTarget b) { 26 | var width = a.width; 27 | var height = a.height; 28 | var viewWidth = a.viewWidth; 29 | var viewHeight = a.viewHeight; 30 | var frameBufferId = a.frameBufferId; 31 | var colorTextureId = colorTextureIdHandle.get(a); 32 | var depthBufferId = depthBufferIdHandle.get(a); 33 | 34 | a.width = b.width; 35 | a.height = b.height; 36 | a.viewWidth = b.viewWidth; 37 | a.viewHeight = b.viewHeight; 38 | a.frameBufferId = b.frameBufferId; 39 | colorTextureIdHandle.set(a, colorTextureIdHandle.get(b)); 40 | depthBufferIdHandle.set(a, depthBufferIdHandle.get(b)); 41 | 42 | b.width = width; 43 | b.height = height; 44 | b.viewWidth = viewWidth; 45 | b.viewHeight = viewHeight; 46 | b.frameBufferId = frameBufferId; 47 | colorTextureIdHandle.set(b, colorTextureId); 48 | depthBufferIdHandle.set(b, depthBufferId); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/molang/MolangValue4.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.molang; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.chin.codec.ChinExtraCodecs; 5 | import io.github.tt432.chin.util.Tuple; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.joml.Vector4f; 8 | 9 | /** 10 | * @author TT432 11 | */ 12 | @Slf4j 13 | public record MolangValue4( 14 | MolangValue x, 15 | MolangValue y, 16 | MolangValue z, 17 | MolangValue w 18 | ) { 19 | 20 | public static final MolangValue4 ZERO = new MolangValue4(MolangValue.ZERO, MolangValue.ZERO, MolangValue.ZERO, MolangValue.ZERO); 21 | 22 | public static final MolangValue4 AXIS_X = new MolangValue4(MolangValue.ONE, MolangValue.ZERO, MolangValue.ZERO, MolangValue.ZERO); 23 | public static final MolangValue4 AXIS_Y = new MolangValue4(MolangValue.ZERO, MolangValue.ONE, MolangValue.ZERO, MolangValue.ZERO); 24 | public static final MolangValue4 AXIS_Z = new MolangValue4(MolangValue.ZERO, MolangValue.ZERO, MolangValue.ONE, MolangValue.ZERO); 25 | public static final MolangValue4 AXIS_W = new MolangValue4(MolangValue.ZERO, MolangValue.ZERO, MolangValue.ZERO, MolangValue.ONE); 26 | 27 | public static final Codec CODEC = ChinExtraCodecs 28 | .tuple(MolangValue.CODEC, MolangValue.CODEC, MolangValue.CODEC, MolangValue.CODEC) 29 | .bmap(MolangValue4::new, mv4 -> Tuple.of(mv4.x, mv4.y, mv4.z, mv4.w)); 30 | 31 | public float getX(MolangScope scope) { 32 | return x.eval(scope); 33 | } 34 | 35 | public float getY(MolangScope scope) { 36 | return y.eval(scope); 37 | } 38 | 39 | public float getZ(MolangScope scope) { 40 | return z.eval(scope); 41 | } 42 | 43 | public float getW(MolangScope scope) { 44 | return w.eval(scope); 45 | } 46 | 47 | public Vector4f eval(MolangScope scope) { 48 | return new Vector4f(getX(scope), getY(scope), getZ(scope), getW(scope)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/github/tt432/eyelib/client/particle/bedrock/component/emitter/shape/Direction.java: -------------------------------------------------------------------------------- 1 | package io.github.tt432.eyelib.client.particle.bedrock.component.emitter.shape; 2 | 3 | import com.mojang.serialization.Codec; 4 | import io.github.tt432.eyelib.molang.MolangScope; 5 | import io.github.tt432.eyelib.molang.MolangValue3; 6 | import net.minecraft.util.StringRepresentable; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.joml.Vector3f; 9 | 10 | /** 11 | * @author TT432 12 | */ 13 | public record Direction( 14 | Type type, 15 | MolangValue3 custom 16 | ) { 17 | public static final Direction EMPTY = new Direction(Type.OUTWARDS, null); 18 | 19 | public static final Codec CODEC = Codec.withAlternative( 20 | Codec.STRING.xmap(s -> switch (s) { 21 | case "inwards" -> new Direction(Type.INWARDS, MolangValue3.ZERO); 22 | default -> new Direction(Type.OUTWARDS, MolangValue3.ZERO); 23 | }, 24 | d -> d.type.name().toLowerCase()), 25 | MolangValue3.CODEC.xmap(mv3 -> new Direction(Type.CUSTOM, mv3), d -> d.custom) 26 | ); 27 | 28 | public boolean isEmpty() { 29 | return this == EMPTY; 30 | } 31 | 32 | public Vector3f getVec(MolangScope scope, Vector3f center, Vector3f other) { 33 | return switch (type) { 34 | case INWARDS -> center.sub(other, new Vector3f()).normalize().mul(16); 35 | case OUTWARDS -> other.sub(center, new Vector3f()).normalize().mul(16); 36 | case CUSTOM -> custom.eval(scope); 37 | }; 38 | } 39 | 40 | public enum Type implements StringRepresentable { 41 | INWARDS, 42 | OUTWARDS, 43 | CUSTOM; 44 | public static final Codec CODEC = StringRepresentable.fromEnum(Type::values); 45 | 46 | @Override 47 | @NotNull 48 | public String getSerializedName() { 49 | return name().toLowerCase(); 50 | } 51 | } 52 | } 53 | --------------------------------------------------------------------------------