├── src ├── main │ ├── generated │ │ ├── data │ │ │ ├── c │ │ │ │ └── tags │ │ │ │ │ ├── block │ │ │ │ │ ├── wools │ │ │ │ │ │ ├── red.json │ │ │ │ │ │ ├── black.json │ │ │ │ │ │ ├── blue.json │ │ │ │ │ │ ├── brown.json │ │ │ │ │ │ ├── cyan.json │ │ │ │ │ │ ├── gray.json │ │ │ │ │ │ ├── green.json │ │ │ │ │ │ ├── lime.json │ │ │ │ │ │ ├── pink.json │ │ │ │ │ │ ├── white.json │ │ │ │ │ │ ├── magenta.json │ │ │ │ │ │ ├── orange.json │ │ │ │ │ │ ├── purple.json │ │ │ │ │ │ ├── yellow.json │ │ │ │ │ │ ├── light_blue.json │ │ │ │ │ │ └── light_gray.json │ │ │ │ │ └── wools.json │ │ │ │ │ └── item │ │ │ │ │ ├── wools │ │ │ │ │ ├── red.json │ │ │ │ │ ├── black.json │ │ │ │ │ ├── blue.json │ │ │ │ │ ├── brown.json │ │ │ │ │ ├── cyan.json │ │ │ │ │ ├── gray.json │ │ │ │ │ ├── green.json │ │ │ │ │ ├── lime.json │ │ │ │ │ ├── orange.json │ │ │ │ │ ├── pink.json │ │ │ │ │ ├── purple.json │ │ │ │ │ ├── white.json │ │ │ │ │ ├── yellow.json │ │ │ │ │ ├── magenta.json │ │ │ │ │ ├── light_blue.json │ │ │ │ │ └── light_gray.json │ │ │ │ │ └── wools.json │ │ │ └── codechickenlib │ │ │ │ └── lang │ │ │ │ └── en_us.json │ │ ├── .cache │ │ │ ├── 15d5dd4ace2ad25407a17728f6fbc07b246efd63 │ │ │ ├── f0722e2ccb61f3087e21fc378db7b4f9b32dbea1 │ │ │ └── 95d738e2c774c5a4b0452cf55df2775d732b2634 │ │ └── assets │ │ │ └── codechickenlib │ │ │ └── lang │ │ │ └── en_us.json │ ├── resources │ │ ├── pack.mcmeta │ │ ├── assets │ │ │ └── codechickenlib │ │ │ │ ├── atlases │ │ │ │ └── gui.json │ │ │ │ └── textures │ │ │ │ └── gui │ │ │ │ ├── cursors │ │ │ │ ├── drag.png │ │ │ │ ├── resize_h.png │ │ │ │ ├── resize_v.png │ │ │ │ ├── resize_diag_tlbr.png │ │ │ │ └── resize_diag_trbl.png │ │ │ │ ├── widgets │ │ │ │ ├── slot.png │ │ │ │ ├── slot_large.png │ │ │ │ ├── energy_empty.png │ │ │ │ ├── energy_full.png │ │ │ │ ├── progress_arrow_empty.png │ │ │ │ └── progress_arrow_full.png │ │ │ │ └── dynamic │ │ │ │ ├── gui_vanilla.png │ │ │ │ ├── button_pressed.png │ │ │ │ ├── button_vanilla.png │ │ │ │ ├── gui_borderless.png │ │ │ │ ├── button_borderless.png │ │ │ │ ├── button_highlight.png │ │ │ │ ├── button_vanilla_disabled.png │ │ │ │ ├── button_borderless_pressed.png │ │ │ │ ├── button_highlight_pressed.png │ │ │ │ └── button_highlight_borderless.png │ │ ├── META-INF │ │ │ ├── MANIFEST.MF │ │ │ └── neoforge.mods.toml │ │ └── mixins.codechickenlib.json │ └── java │ │ └── codechicken │ │ └── lib │ │ ├── package-info.java │ │ ├── util │ │ ├── Copyable.java │ │ ├── package-info.java │ │ ├── ClientUtils.java │ │ ├── ServerUtils.java │ │ └── VectorUtils.java │ │ ├── data │ │ ├── package-info.java │ │ ├── DataUtils.java │ │ └── MCByteStream.java │ │ ├── math │ │ └── package-info.java │ │ ├── vec │ │ ├── package-info.java │ │ ├── uv │ │ │ ├── package-info.java │ │ │ ├── UVScale.java │ │ │ ├── UVTransformation.java │ │ │ ├── ScaledIconTransformation.java │ │ │ ├── MultiIconTransformation.java │ │ │ ├── UVTranslation.java │ │ │ ├── UVRotation.java │ │ │ ├── IconTransformation.java │ │ │ └── UV.java │ │ ├── IrreversibleTransformationException.java │ │ ├── SwapYZ.java │ │ ├── VariableTransformation.java │ │ ├── RedundantTransformation.java │ │ ├── AxisCycle.java │ │ ├── Transformation.java │ │ ├── Scale.java │ │ ├── Line3.java │ │ └── Translation.java │ │ ├── block │ │ ├── package-info.java │ │ └── component │ │ │ ├── package-info.java │ │ │ ├── data │ │ │ ├── package-info.java │ │ │ └── TagComponent.java │ │ │ ├── tile │ │ │ └── package-info.java │ │ │ ├── PropertyComponent.java │ │ │ └── StateAwareComponent.java │ │ ├── colour │ │ ├── package-info.java │ │ ├── ColourARGB.java │ │ └── CustomGradient.java │ │ ├── config │ │ ├── package-info.java │ │ ├── parser │ │ │ ├── package-info.java │ │ │ ├── ConfigSerializer.java │ │ │ └── ConfigParseException.java │ │ ├── ValueType.java │ │ └── ConfigCallback.java │ │ ├── datagen │ │ ├── package-info.java │ │ ├── recipe │ │ │ ├── package-info.java │ │ │ ├── AbstractItemStackRecipeBuilder.java │ │ │ ├── RecipeBuilder.java │ │ │ └── SpecialCraftingRecipeBuilder.java │ │ ├── NoValidationBLockLootSubProvider.java │ │ └── ClassModelLoaderBuilder.java │ │ ├── fluid │ │ ├── package-info.java │ │ └── FluidUtils.java │ │ ├── model │ │ ├── package-info.java │ │ ├── pipeline │ │ │ ├── package-info.java │ │ │ ├── transformers │ │ │ │ └── package-info.java │ │ │ └── IPipelineElementFactory.java │ │ ├── bakedmodels │ │ │ ├── package-info.java │ │ │ └── OverrideListModel.java │ │ ├── IVertexProducer.java │ │ ├── ItemQuadBakery.java │ │ ├── PerspectiveModelState.java │ │ ├── DummyBakedModel.java │ │ ├── PerspectiveModel.java │ │ └── IVertexConsumer.java │ │ ├── render │ │ ├── package-info.java │ │ ├── block │ │ │ └── package-info.java │ │ ├── item │ │ │ ├── package-info.java │ │ │ └── map │ │ │ │ ├── package-info.java │ │ │ │ └── IMapRenderer.java │ │ ├── model │ │ │ └── package-info.java │ │ ├── buffer │ │ │ ├── package-info.java │ │ │ ├── ISpriteAwareVertexConsumer.java │ │ │ ├── AlphaOverrideVertexConsumer.java │ │ │ ├── DelegateRenderType.java │ │ │ ├── TransformingVertexConsumer.java │ │ │ └── DelegatingVertexConsumer.java │ │ ├── shader │ │ │ ├── package-info.java │ │ │ ├── UniformPair.java │ │ │ ├── ConstantCache.java │ │ │ ├── BinaryType.java │ │ │ ├── SimpleShaderObject.java │ │ │ ├── NamedShaderObject.java │ │ │ ├── AssetShaderObject.java │ │ │ ├── ShaderConstantCache.java │ │ │ └── AbstractShaderObject.java │ │ ├── lighting │ │ │ ├── package-info.java │ │ │ ├── PlanarLightModel.java │ │ │ ├── SimpleBrightnessModel.java │ │ │ └── PlanarLightMatrix.java │ │ ├── particle │ │ │ ├── package-info.java │ │ │ ├── IModelParticleProvider.java │ │ │ ├── ICustomParticleBlock.java │ │ │ └── CustomBreakingParticle.java │ │ ├── pipeline │ │ │ ├── package-info.java │ │ │ ├── attribute │ │ │ │ ├── package-info.java │ │ │ │ ├── ColourAttribute.java │ │ │ │ ├── SideAttribute.java │ │ │ │ ├── LightingAttribute.java │ │ │ │ ├── LightCoordAttribute.java │ │ │ │ └── NormalAttribute.java │ │ │ ├── VertexAttribute.java │ │ │ ├── ColourMultiplier.java │ │ │ ├── IVertexOperation.java │ │ │ └── IVertexSource.java │ │ └── CCRenderEventHandler.java │ │ ├── texture │ │ └── package-info.java │ │ ├── world │ │ ├── package-info.java │ │ └── IChunkLoadTile.java │ │ ├── internal │ │ ├── package-info.java │ │ ├── mixin │ │ │ ├── package-info.java │ │ │ ├── dev │ │ │ │ ├── package-info.java │ │ │ │ └── GameNarratorMixin.java │ │ │ ├── compat │ │ │ │ └── EmbeddiumCCLMixin.java │ │ │ ├── MinecraftMixin.java │ │ │ ├── CCLMixinPlugin.java │ │ │ ├── ItemRendererMixin.java │ │ │ └── ShaderInstanceMixin.java │ │ ├── compat │ │ │ └── package-info.java │ │ ├── network │ │ │ ├── package-info.java │ │ │ ├── ClientConfigurationPacketHandler.java │ │ │ ├── ServerPacketHandler.java │ │ │ ├── CCLNetwork.java │ │ │ └── ClientPacketHandler.java │ │ ├── command │ │ │ ├── admin │ │ │ │ └── package-info.java │ │ │ ├── dev │ │ │ │ ├── package-info.java │ │ │ │ └── DevCommands.java │ │ │ └── client │ │ │ │ ├── package-info.java │ │ │ │ └── ItemInfoCommand.java │ │ ├── ExceptionMessageEventHandler.java │ │ └── TileChunkLoadHook.java │ │ ├── inventory │ │ ├── package-info.java │ │ └── container │ │ │ ├── package-info.java │ │ │ ├── data │ │ │ ├── package-info.java │ │ │ ├── IntData.java │ │ │ ├── ByteData.java │ │ │ ├── LongData.java │ │ │ ├── FloatData.java │ │ │ ├── ShortData.java │ │ │ ├── DoubleData.java │ │ │ ├── BooleanData.java │ │ │ ├── AbstractDataStore.java │ │ │ └── FluidData.java │ │ │ ├── modular │ │ │ └── package-info.java │ │ │ ├── IContainerSyncVar.java │ │ │ ├── SlotHandleClicks.java │ │ │ ├── SlotDummyOutput.java │ │ │ └── IntegerSync.java │ │ ├── raytracer │ │ ├── package-info.java │ │ └── IndexedVoxelShape.java │ │ ├── capability │ │ └── package-info.java │ │ ├── packet │ │ ├── package-info.java │ │ ├── SimpleClientPacketHandler.java │ │ └── SimpleServerPacketHandler.java │ │ ├── gui │ │ └── modular │ │ │ └── lib │ │ │ ├── geometry │ │ │ ├── Axis.java │ │ │ ├── Align.java │ │ │ ├── GeoParam.java │ │ │ ├── Direction.java │ │ │ └── GeoRef.java │ │ │ ├── ContentElement.java │ │ │ ├── container │ │ │ ├── ContainerScreenAccess.java │ │ │ ├── ContainerGuiProvider.java │ │ │ └── DataSync.java │ │ │ ├── ForegroundRender.java │ │ │ ├── DynamicTextures.java │ │ │ ├── BackgroundRender.java │ │ │ ├── TextState.java │ │ │ ├── GuiProvider.java │ │ │ └── ColourState.java │ │ └── CodeChickenLib.java └── test │ ├── resources │ ├── model │ │ ├── test.mtl │ │ ├── test.obj │ │ ├── test_group.obj │ │ ├── test_group_object.obj │ │ └── test_multi_object.obj │ └── tests │ │ └── legacy_serializer │ │ └── test.cfg │ └── java │ └── codechicken │ └── lib │ ├── test │ ├── package-info.java │ └── TestResourceProvider.java │ ├── config │ ├── JsonConfigSerializerTests.java │ ├── TomlConfigSerializerTests.java │ └── LegacyConfigSerializerTest.java │ └── render │ └── model │ └── MatLibTests.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── settings.gradle ├── .gitignore ├── .github └── workflows │ └── check.yml └── README.md /src/main/generated/data/c/tags/block/wools/red.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:red_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/red.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:red_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/black.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:black_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/blue.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:blue_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/brown.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:brown_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/cyan.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:cyan_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/gray.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:gray_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/green.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:green_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/lime.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:lime_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/pink.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:pink_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/white.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:white_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/black.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:black_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/blue.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:blue_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/brown.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:brown_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/cyan.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:cyan_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/gray.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:gray_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/green.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:green_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/lime.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:lime_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/orange.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:orange_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/pink.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:pink_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/purple.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:purple_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/white.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:white_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/yellow.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:yellow_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/magenta.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:magenta_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/orange.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:orange_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/purple.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:purple_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/yellow.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:yellow_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/magenta.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:magenta_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/light_blue.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:light_blue_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools/light_gray.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:light_gray_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/light_blue.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:light_blue_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools/light_gray.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:light_gray_wool" 4 | ] 5 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 22, 4 | "description": "CCL resource pack" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=false 2 | 3 | mc_version=1.21.1 4 | forge_version=21.1.72 5 | mod_version=4.6.1 6 | jei_version=19.21.0.246 7 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/util/Copyable.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.util; 2 | 3 | public interface Copyable { 4 | 5 | T copy(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/data/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.data; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/math/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.math; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/util/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.util; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.vec; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.block; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/colour/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.colour; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.config; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.datagen; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/fluid/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.fluid; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.model; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/texture/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.texture; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.vec.uv; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/world/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.world; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.inventory; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/raytracer/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.raytracer; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/capability/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.capability; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/block/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.block; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/item/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.item; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/model/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.model; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/parser/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.config.parser; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/recipe/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.datagen.recipe; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.mixin; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/pipeline/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.model.pipeline; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.buffer; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.shader; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.block.component; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/compat/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.compat; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/network/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.network; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/bakedmodels/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.model.bakedmodels; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/item/map/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.item.map; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/lighting/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.lighting; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/particle/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.particle; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.pipeline; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/dev/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.mixin.dev; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.inventory.container; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/data/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.block.component.data; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/tile/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.block.component.tile; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/command/admin/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.command.admin; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/command/dev/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.command.dev; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/atlases/gui.json: -------------------------------------------------------------------------------- 1 | { 2 | "sources": [ 3 | { 4 | "type": "directory", 5 | "source": "gui", 6 | "prefix": "gui/" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/command/client/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.internal.command.client; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.inventory.container.data; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | COMMENT: This file exists purely for dev time, 2 | anything added here should be mirrored in the build.gradle. 3 | MixinConfigs: mixins.codechickenlib.json 4 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/modular/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.inventory.container.modular; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/pipeline/transformers/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.model.pipeline.transformers; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package codechicken.lib.render.pipeline.attribute; 3 | 4 | import net.covers1624.quack.annotation.NonNullApi; 5 | -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/cursors/drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/cursors/drag.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/slot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/slot.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_h.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_v.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/slot_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/slot_large.png -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/packet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by covers1624 on 3/7/24. 3 | */ 4 | @NonNullApi 5 | package codechicken.lib.packet; 6 | 7 | import net.covers1624.quack.annotation.NonNullApi; 8 | -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/gui_vanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/gui_vanilla.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/energy_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/energy_empty.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/energy_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/energy_full.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_pressed.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_vanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_vanilla.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/gui_borderless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/gui_borderless.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_diag_tlbr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_diag_tlbr.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_diag_trbl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/cursors/resize_diag_trbl.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_borderless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_borderless.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight.png -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/UniformPair.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | /** 4 | * Created by covers1624 on 24/5/20. 5 | */ 6 | public record UniformPair(String name, UniformType type) { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/progress_arrow_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/progress_arrow_empty.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/widgets/progress_arrow_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/widgets/progress_arrow_full.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_vanilla_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_vanilla_disabled.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_borderless_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_borderless_pressed.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight_pressed.png -------------------------------------------------------------------------------- /src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight_borderless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCBProject/CodeChickenLib/master/src/main/resources/assets/codechickenlib/textures/gui/dynamic/button_highlight_borderless.png -------------------------------------------------------------------------------- /src/main/generated/.cache/15d5dd4ace2ad25407a17728f6fbc07b246efd63: -------------------------------------------------------------------------------- 1 | // 1.21.1 2024-12-06T17:16:20.755131366 codechickenlib Languages: en_us 2 | d535acbe9649e564744ed63aef209ce1508ec451 assets/codechickenlib/lang/en_us.json 3 | d535acbe9649e564744ed63aef209ce1508ec451 data/codechickenlib/lang/en_us.json 4 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/ValueType.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config; 2 | 3 | /** 4 | * Created by covers1624 on 17/4/22. 5 | */ 6 | public enum ValueType { 7 | UNKNOWN, 8 | BOOLEAN, 9 | STRING, 10 | INT, 11 | LONG, 12 | HEX, 13 | DOUBLE, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/IVertexProducer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model; 2 | 3 | public interface IVertexProducer { 4 | 5 | /** 6 | * @param consumer consumer to receive the vertex data this producer can provide 7 | */ 8 | void pipe(IVertexConsumer consumer); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/geometry/Axis.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.geometry; 2 | 3 | /** 4 | * Created by brandon3055 on 02/09/2023 5 | */ 6 | public enum Axis { 7 | X, 8 | Y; 9 | 10 | public Axis opposite() { 11 | return this == X ? Y : X; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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 = 'CodeChickenLib' 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # exclude all 2 | /* 3 | 4 | # Gradle stuff 5 | !gradle/ 6 | !gradlew 7 | !gradlew.bat 8 | !build.gradle 9 | !gradle.properties 10 | !settings.gradle 11 | 12 | # Other Files. 13 | !LICENSE 14 | !README.md 15 | 16 | # Include git important files 17 | !.gitmodules 18 | !.gitignore 19 | !.github/ 20 | 21 | # Include Important Folders 22 | !src/ 23 | -------------------------------------------------------------------------------- /src/test/resources/model/test.mtl: -------------------------------------------------------------------------------- 1 | # Blender 3.1.0 MTL File: 'None' 2 | # www.blender.org 3 | 4 | newmtl Material 5 | Ns 360.000000 6 | Ka 0.700000 0.600000 0.500000 7 | map_Ka ka.png 8 | Kd 0.800000 0.700000 0.600000 9 | map_Kd kd.png 10 | Ks 0.800000 0.700000 0.600000 11 | map_Ks ks.png 12 | Ke 0.100000 0.200000 0.300000 13 | Ni 1.450000 14 | d 1.500000 15 | illum 5 16 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/test/package-info.java: -------------------------------------------------------------------------------- 1 | @FieldsAreNonnullByDefault 2 | @ParametersAreNonnullByDefault 3 | @MethodsReturnNonnullByDefault 4 | package codechicken.lib.test; 5 | 6 | import net.covers1624.quack.annotation.FieldsAreNonnullByDefault; 7 | import net.covers1624.quack.annotation.MethodsReturnNonnullByDefault; 8 | 9 | import javax.annotation.ParametersAreNonnullByDefault; 10 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/geometry/Align.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.geometry; 2 | 3 | /** 4 | * Created by brandon3055 on 31/08/2023 5 | */ 6 | public enum Align { 7 | MIN, 8 | CENTER, 9 | MAX; 10 | public static Align LEFT = MIN; 11 | public static Align RIGHT = MAX; 12 | public static Align TOP = MIN; 13 | public static Align BOTTOM = MAX; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/IContainerSyncVar.java: -------------------------------------------------------------------------------- 1 | //package codechicken.lib.inventory.container; 2 | // 3 | //import codechicken.lib.packet.PacketCustom; 4 | // 5 | //public interface IContainerSyncVar { 6 | // 7 | // boolean changed(); 8 | // 9 | // void reset(); 10 | // 11 | // void writeChange(PacketCustom packet); 12 | // 13 | // void readChange(PacketCustom packet); 14 | //} 15 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/ISpriteAwareVertexConsumer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.buffer; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | 6 | /** 7 | * Created by covers1624 on 4/23/20. 8 | */ 9 | public interface ISpriteAwareVertexConsumer extends VertexConsumer { 10 | 11 | void sprite(TextureAtlasSprite sprite); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | name: Check 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | BUILD_NUMBER: 9999 7 | GITHUB_CI: true 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Setup Java 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: 21 19 | distribution: 'temurin' 20 | - name: Build 21 | run: ./gradlew check 22 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/ConstantCache.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | /** 4 | * Provides methods to mutate specilization constants 5 | * before the shader is specialized. 6 | *

7 | * Created by KitsuneAlex on 19/11/21. 8 | */ 9 | public interface ConstantCache { 10 | 11 | void constant1i(int id, int value); 12 | 13 | void constant1f(int id, float value); 14 | 15 | void constant1b(int id, boolean value); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/block/wools.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "#c:wools/white", 4 | "#c:wools/orange", 5 | "#c:wools/magenta", 6 | "#c:wools/light_blue", 7 | "#c:wools/yellow", 8 | "#c:wools/lime", 9 | "#c:wools/pink", 10 | "#c:wools/gray", 11 | "#c:wools/light_gray", 12 | "#c:wools/cyan", 13 | "#c:wools/purple", 14 | "#c:wools/blue", 15 | "#c:wools/brown", 16 | "#c:wools/green", 17 | "#c:wools/red", 18 | "#c:wools/black" 19 | ] 20 | } -------------------------------------------------------------------------------- /src/main/generated/data/c/tags/item/wools.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "#c:wools/white", 4 | "#c:wools/orange", 5 | "#c:wools/magenta", 6 | "#c:wools/light_blue", 7 | "#c:wools/yellow", 8 | "#c:wools/lime", 9 | "#c:wools/pink", 10 | "#c:wools/gray", 11 | "#c:wools/light_gray", 12 | "#c:wools/cyan", 13 | "#c:wools/purple", 14 | "#c:wools/blue", 15 | "#c:wools/brown", 16 | "#c:wools/green", 17 | "#c:wools/red", 18 | "#c:wools/black" 19 | ] 20 | } -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/ContentElement.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | 4 | import codechicken.lib.gui.modular.elements.GuiElement; 5 | 6 | /** 7 | * Implemented by elements that have a separate child element to which content should be added. 8 | * e.g. scroll element, manipulable element etc... 9 | * Created by brandon3055 on 13/11/2023 10 | */ 11 | public interface ContentElement> { 12 | 13 | T getContentElement(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/IrreversibleTransformationException.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | public class IrreversibleTransformationException extends RuntimeException { 4 | 5 | public ITransformation t; 6 | 7 | public IrreversibleTransformationException(ITransformation t) { 8 | this.t = t; 9 | } 10 | 11 | @Override 12 | public String getMessage() { 13 | return "The following transformation is irreversible:\n" + t; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/mixins.codechickenlib.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "codechicken.lib.internal.mixin", 5 | "plugin": "codechicken.lib.internal.mixin.CCLMixinPlugin", 6 | "target": "@env(DEFAULT)", 7 | "compatibilityLevel": "JAVA_17", 8 | "client": [ 9 | "dev.GameNarratorMixin", 10 | "ItemRendererMixin", 11 | "MinecraftMixin", 12 | "ShaderInstanceMixin", 13 | "compat.EmbeddiumCCLMixin" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/model/test.obj: -------------------------------------------------------------------------------- 1 | # Blender 3.1.0 2 | # www.blender.org 3 | mtllib test.mtl 4 | o Cube 5 | v 1.000000 1.000000 -1.000000 6 | v 1.000000 -1.000000 -1.000000 7 | v 1.000000 1.000000 1.000000 8 | v 1.000000 -1.000000 1.000000 9 | vn -0.0000 1.0000 -0.0000 10 | vn -0.0000 -0.0000 1.0000 11 | vn -1.0000 -0.0000 -0.0000 12 | vn -0.0000 -1.0000 -0.0000 13 | vt 0.625000 0.500000 14 | vt 0.375000 0.500000 15 | vt 0.625000 0.750000 16 | vt 0.375000 0.750000 17 | s 0 18 | usemtl Material 19 | f 1/1/1 2/2/2 3/3/3 4/4/4 20 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/SwapYZ.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | public class SwapYZ extends VariableTransformation { 4 | 5 | public SwapYZ() { 6 | super(new Matrix4(1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1)); 7 | } 8 | 9 | @Override 10 | public void apply(Vector3 vec) { 11 | double vz = vec.z; 12 | vec.z = vec.y; 13 | vec.y = vz; 14 | } 15 | 16 | @Override 17 | public Transformation inverse() { 18 | return this; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/model/test_group.obj: -------------------------------------------------------------------------------- 1 | # Blender 3.1.0 2 | # www.blender.org 3 | mtllib test.mtl 4 | g Cube 5 | v 1.000000 1.000000 -1.000000 6 | v 1.000000 -1.000000 -1.000000 7 | v 1.000000 1.000000 1.000000 8 | v 1.000000 -1.000000 1.000000 9 | vn -0.0000 1.0000 -0.0000 10 | vn -0.0000 -0.0000 1.0000 11 | vn -1.0000 -0.0000 -0.0000 12 | vn -0.0000 -1.0000 -0.0000 13 | vt 0.625000 0.500000 14 | vt 0.375000 0.500000 15 | vt 0.625000 0.750000 16 | vt 0.375000 0.750000 17 | s 0 18 | usemtl Material 19 | f 1/1/1 2/2/2 3/3/3 4/4/4 20 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/data/DataUtils.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.data; 2 | 3 | import java.io.OutputStream; 4 | 5 | /** 6 | * Created by covers1624 on 4/15/20. 7 | */ 8 | class DataUtils { 9 | 10 | /** 11 | * {@link OutputStream#write(byte[], int, int)} 12 | */ 13 | static void checkLen(int arrLen, int off, int len) { 14 | if ((off < 0) || (off > arrLen) || (len < 0) || ((off + len) > arrLen) || ((off + len) < 0)) { 15 | throw new IndexOutOfBoundsException(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/model/test_group_object.obj: -------------------------------------------------------------------------------- 1 | # Blender 3.1.0 2 | # www.blender.org 3 | mtllib test.mtl 4 | g Group 5 | o Cube 6 | v 1.000000 1.000000 -1.000000 7 | v 1.000000 -1.000000 -1.000000 8 | v 1.000000 1.000000 1.000000 9 | v 1.000000 -1.000000 1.000000 10 | vn -0.0000 1.0000 -0.0000 11 | vn -0.0000 -0.0000 1.0000 12 | vn -1.0000 -0.0000 -0.0000 13 | vn -0.0000 -1.0000 -0.0000 14 | vt 0.625000 0.500000 15 | vt 0.375000 0.500000 16 | vt 0.625000 0.750000 17 | vt 0.375000 0.750000 18 | s 0 19 | usemtl Material 20 | f 1/1/1 2/2/2 3/3/3 4/4/4 21 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/BinaryType.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import org.lwjgl.opengl.GL46; 4 | 5 | /** 6 | * All currently supported shader binary types. 7 | *

8 | * Created by KitsuneAlex on 19/11/21. 9 | */ 10 | public enum BinaryType { 11 | SPIR_V(GL46.GL_SHADER_BINARY_FORMAT_SPIR_V); 12 | 13 | private final int glCode; 14 | 15 | BinaryType(int glCode) { 16 | this.glCode = glCode; 17 | } 18 | 19 | public int getGLCode() { 20 | return glCode; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/util/ClientUtils.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.util; 2 | 3 | import codechicken.lib.render.CCRenderEventHandler; 4 | import net.minecraft.client.Minecraft; 5 | 6 | public class ClientUtils { 7 | 8 | public static boolean inWorld() { 9 | return Minecraft.getInstance().getConnection() != null; 10 | } 11 | 12 | public static float getRenderFrame() { 13 | return CCRenderEventHandler.renderFrame; 14 | } 15 | 16 | public static double getRenderTime() { 17 | return CCRenderEventHandler.renderTime + getRenderFrame(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/SlotHandleClicks.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container; 2 | 3 | import net.minecraft.world.Container; 4 | import net.minecraft.world.entity.player.Player; 5 | import net.minecraft.world.inventory.ClickType; 6 | import net.minecraft.world.inventory.Slot; 7 | 8 | public abstract class SlotHandleClicks extends Slot { 9 | 10 | public SlotHandleClicks(Container inv, int slot, int x, int y) { 11 | super(inv, slot, x, y); 12 | } 13 | 14 | public abstract void slotClick(ContainerExtended container, Player player, int button, ClickType clickType); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/VariableTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | public abstract class VariableTransformation extends Transformation { 4 | 5 | public final Matrix4 mat; 6 | 7 | public VariableTransformation(Matrix4 mat) { 8 | this.mat = mat; 9 | } 10 | 11 | @Override 12 | public void applyN(Vector3 normal) { 13 | apply(normal); 14 | } 15 | 16 | @Override 17 | public void apply(Matrix4 mat) { 18 | mat.multiply(this.mat); 19 | } 20 | 21 | @Override 22 | public Transformation copy() { 23 | return this; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/SimpleShaderObject.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * Created by covers1624 on 24/5/20. 7 | */ 8 | public class SimpleShaderObject extends AbstractShaderObject { 9 | 10 | private final String source; 11 | 12 | protected SimpleShaderObject(String name, ShaderType type, Collection uniforms, String source) { 13 | super(name, type, uniforms); 14 | this.source = source; 15 | } 16 | 17 | @Override 18 | protected String getSource() { 19 | return source; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/PropertyComponent.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.block.component; 2 | 3 | import net.minecraft.world.level.block.state.properties.Property; 4 | import org.jetbrains.annotations.ApiStatus; 5 | 6 | /** 7 | * Created by covers1624 on 22/7/22. 8 | */ 9 | @ApiStatus.Experimental 10 | public abstract class PropertyComponent> extends StateAwareComponent { 11 | 12 | public final Property property; 13 | public final V defaultValue; 14 | 15 | protected PropertyComponent(Property property, V defaultValue) { 16 | this.property = property; 17 | this.defaultValue = defaultValue; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/util/ServerUtils.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.util; 2 | 3 | import net.minecraft.resources.ResourceKey; 4 | import net.minecraft.world.level.Level; 5 | import net.neoforged.neoforge.server.ServerLifecycleHooks; 6 | 7 | import java.nio.file.Path; 8 | 9 | /** 10 | * Created by covers1624 on 22/10/2016. 11 | */ 12 | public class ServerUtils { 13 | 14 | public static Path getSaveDirectory() { 15 | return getSaveDirectory(Level.OVERWORLD); 16 | } 17 | 18 | public static Path getSaveDirectory(ResourceKey dimension) { 19 | return ServerLifecycleHooks.getCurrentServer().storageSource.getDimensionPath(dimension); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/recipe/AbstractItemStackRecipeBuilder.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.datagen.recipe; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.item.crafting.Recipe; 6 | 7 | /** 8 | * Created by covers1624 on 28/12/20. 9 | */ 10 | public abstract class AbstractItemStackRecipeBuilder> extends AbstractRecipeBuilder { 11 | 12 | protected AbstractItemStackRecipeBuilder(ResourceLocation id, ItemStack result) { 13 | super(id, result); 14 | } 15 | 16 | @Override 17 | public abstract Recipe _build(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/SlotDummyOutput.java: -------------------------------------------------------------------------------- 1 | //package codechicken.lib.inventory.container; 2 | // 3 | //import net.minecraft.entity.player.EntityPlayer; 4 | //import net.minecraft.inventory.ClickType; 5 | //import net.minecraft.inventory.IInventory; 6 | //import net.minecraft.item.ItemStack; 7 | // 8 | //public class SlotDummyOutput extends SlotHandleClicks { 9 | // 10 | // public SlotDummyOutput(IInventory inv, int slot, int x, int y) { 11 | // super(inv, slot, x, y); 12 | // } 13 | // 14 | // @Override 15 | // public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, ClickType clickType) { 16 | // return ItemStack.EMPTY; 17 | // } 18 | //} 19 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/compat/EmbeddiumCCLMixin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin.compat; 2 | 3 | import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; 4 | import org.embeddedt.embeddium.compat.ccl.CCLCompat; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Overwrite; 7 | import org.spongepowered.asm.mixin.Pseudo; 8 | 9 | /** 10 | * Created by covers1624 on 2/7/25. 11 | */ 12 | @Pseudo 13 | @Mixin (CCLCompat.class) 14 | abstract class EmbeddiumCCLMixin { 15 | 16 | /** 17 | * @author covers1624 18 | * @reason Its broken and CCL ships its own. 19 | */ 20 | @Overwrite 21 | public static void onClientSetup(FMLClientSetupEvent event) { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/world/IChunkLoadTile.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.world; 2 | 3 | import net.minecraft.world.level.chunk.LevelChunk; 4 | 5 | /** 6 | * Provides a callback for tile entities when a chunk is loaded, as an alternative to validate when the chunk hasn't been added to the world. 7 | * To hook all world join/seperate events. Use this, TileEntity.validate with a worldObj.blockExists check, TileEntity.onChunkUnload and TileEntity.invalidate 8 | * Be sure to call TileChunkLoadHook.init() from your mod during initialisation 9 | * You could easily implement this in your own mod, but providing it here reduces the number of times the chunkTileEntityMap needs to be iterated 10 | */ 11 | public interface IChunkLoadTile { 12 | 13 | void onChunkLoad(LevelChunk chunk); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/parser/ConfigSerializer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config.parser; 2 | 3 | import codechicken.lib.config.ConfigCategoryImpl; 4 | 5 | import java.io.IOException; 6 | import java.nio.file.Path; 7 | 8 | /** 9 | * Represents a serializer capable of reading the provided file into 10 | * a tag tree. 11 | *

12 | * Created by covers1624 on 18/4/22. 13 | */ 14 | public interface ConfigSerializer { 15 | 16 | ConfigSerializer LEGACY = new LegacyConfigSerializer(); 17 | ConfigSerializer JSON = new JsonConfigSerializer(); 18 | ConfigSerializer TOML = new TomlConfigSerializer(); 19 | 20 | void parse(Path file, ConfigCategoryImpl rootTag) throws IOException; 21 | 22 | void save(Path file, ConfigCategoryImpl rootTag) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/AlphaOverrideVertexConsumer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.buffer; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | 5 | /** 6 | * Created by covers1624 on 29/3/22. 7 | */ 8 | public class AlphaOverrideVertexConsumer extends DelegatingVertexConsumer { 9 | 10 | private final int alpha; 11 | 12 | public AlphaOverrideVertexConsumer(VertexConsumer delegate, double alpha) { 13 | this(delegate, (int) (255 * alpha)); 14 | } 15 | 16 | public AlphaOverrideVertexConsumer(VertexConsumer delegate, int alpha) { 17 | super(delegate); 18 | this.alpha = alpha; 19 | } 20 | 21 | @Override 22 | public VertexConsumer setColor(int r, int g, int b, int a) { 23 | return super.setColor(r, g, b, alpha); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/network/ClientConfigurationPacketHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.network; 2 | 3 | import codechicken.lib.config.ConfigSyncManager; 4 | import codechicken.lib.packet.ICustomPacketHandler; 5 | import codechicken.lib.packet.PacketCustom; 6 | import net.minecraft.client.Minecraft; 7 | 8 | import static codechicken.lib.internal.network.CCLNetwork.L_CONFIG_SYNC; 9 | 10 | /** 11 | * Created by covers1624 on 5/3/20. 12 | */ 13 | public class ClientConfigurationPacketHandler implements ICustomPacketHandler.IClientConfigurationPacketHandler { 14 | 15 | @Override 16 | public void handlePacket(PacketCustom packet, Minecraft mc) { 17 | switch (packet.getType()) { 18 | case L_CONFIG_SYNC -> ConfigSyncManager.readSyncPacket(packet); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/data/MCByteStream.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.data; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | 5 | /** 6 | * An {@link MCDataOutput} implementation that 7 | * provides a byte array of the data received. 8 | *

9 | * Created by covers1624 on 4/16/20. 10 | */ 11 | public class MCByteStream extends MCDataOutputStream { 12 | 13 | private final ByteArrayOutputStream bos; 14 | 15 | public MCByteStream() { 16 | this(new ByteArrayOutputStream()); 17 | } 18 | 19 | public MCByteStream(ByteArrayOutputStream bos) { 20 | super(bos); 21 | this.bos = bos; 22 | } 23 | 24 | /** 25 | * Get the data buffered. 26 | * 27 | * @return The bytes. 28 | */ 29 | public byte[] getBytes() { 30 | return bos.toByteArray(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/MinecraftMixin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin; 2 | 3 | import codechicken.lib.internal.ItemFileRenderer; 4 | import net.minecraft.client.Minecraft; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | /** 11 | * Created by covers1624 on 27/2/23. 12 | */ 13 | @Mixin (Minecraft.class) 14 | abstract class MinecraftMixin { 15 | 16 | @Inject ( 17 | method = "runTick", 18 | at = @At ( 19 | value = "TAIL" 20 | ) 21 | ) 22 | private void onRunTick(boolean p_91384_, CallbackInfo ci) { 23 | ItemFileRenderer.tick(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/tests/legacy_serializer/test.cfg: -------------------------------------------------------------------------------- 1 | //A comment 2 | # Also a comment 3 | ~1.1 4 | //Specifies a new ConfigTag. 5 | "Tag1" { 6 | ~1.2.3.4 7 | 8 | B:"boolean"=false 9 | S:"string"="This is a string with data, Cannot be Multi Line." 10 | I:"integer"=123456789 11 | D:"double"=1.2345 12 | H:"hex"=0xFFFFFFFF 13 | 14 | B:"boolean_array" < 15 | true 16 | false 17 | true 18 | false 19 | > 20 | 21 | S:"string_array" < 22 | value 23 | value2 24 | value33 25 | > 26 | 27 | I:"integer_array" < 28 | 1 29 | 2 30 | 3 31 | 4 32 | 5 33 | 6 34 | > 35 | 36 | D:"double_array" < 37 | 1.2 38 | 3.4 39 | 5.6 40 | 7.8 41 | > 42 | 43 | H:"hex_array" < 44 | 0xFFFF 45 | 0x00FF 46 | > 47 | } 48 | 49 | "Tag2" { 50 | "Tag3" { 51 | "Tag4" { 52 | B:"depth_test"=true 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/IntegerSync.java: -------------------------------------------------------------------------------- 1 | //package codechicken.lib.inventory.container; 2 | // 3 | //import codechicken.lib.packet.PacketCustom; 4 | // 5 | //public abstract class IntegerSync implements IContainerSyncVar { 6 | // 7 | // public int c_value; 8 | // 9 | // @Override 10 | // public boolean changed() { 11 | // return getValue() != c_value; 12 | // } 13 | // 14 | // @Override 15 | // public void reset() { 16 | // c_value = getValue(); 17 | // } 18 | // 19 | // @Override 20 | // public void writeChange(PacketCustom packet) { 21 | // packet.writeInt(getValue()); 22 | // } 23 | // 24 | // @Override 25 | // public void readChange(PacketCustom packet) { 26 | // c_value = packet.readInt(); 27 | // } 28 | // 29 | // public abstract int getValue(); 30 | //} 31 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/parser/ConfigParseException.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config.parser; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Created by covers1624 on 18/07/2017. 7 | */ 8 | public class ConfigParseException extends IOException { 9 | 10 | public ConfigParseException(String message) { 11 | super(message); 12 | } 13 | 14 | public ConfigParseException(String format, Object... data) { 15 | this(String.format(format, data)); 16 | } 17 | 18 | public ConfigParseException(Throwable cause, String format, Object... data) { 19 | this(cause, String.format(format, data)); 20 | } 21 | 22 | public ConfigParseException(Throwable cause, String message) { 23 | super(message, cause); 24 | } 25 | 26 | public ConfigParseException(Throwable cause) { 27 | super(cause); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/dev/GameNarratorMixin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin.dev; 2 | 3 | import com.mojang.text2speech.Narrator; 4 | import net.minecraft.client.GameNarrator; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Redirect; 8 | 9 | /** 10 | * Created by covers1624 on 13/11/23. 11 | */ 12 | @Mixin (GameNarrator.class) 13 | abstract class GameNarratorMixin { 14 | 15 | @Redirect ( 16 | method = "", 17 | at = @At ( 18 | value = "INVOKE", 19 | target = "Lcom/mojang/text2speech/Narrator;getNarrator()Lcom/mojang/text2speech/Narrator;" 20 | ) 21 | ) 22 | private Narrator redirectGetNarator() { 23 | // GO AWAY NARRATOR ERRORS! 24 | return Narrator.EMPTY; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/config/ConfigCallback.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config; 2 | 3 | /** 4 | * Created by covers1624 on 2/5/22. 5 | */ 6 | public interface ConfigCallback { 7 | 8 | /** 9 | * Called when a ConfigTag is modified. 10 | * 11 | * @param tag The tag that was modified. For convenience. 12 | * This is identical to the tag which it was registered on. 13 | * @param reason The reason this callback was fired. 14 | */ 15 | void onSync(T tag, Reason reason); 16 | 17 | enum Reason { 18 | /** 19 | * Callback fired manually across part of the Config tree. 20 | */ 21 | MANUAL, 22 | /** 23 | * Tag was synced S -> C. 24 | */ 25 | SYNC, 26 | /** 27 | * Tag was rolled back on disconnect from server. 28 | */ 29 | ROLLBACK, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/geometry/GeoParam.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.geometry; 2 | 3 | /** 4 | * Used to define the 6 core parameters that make up an elements geometry 5 | * These are named Left, Right, Width, Top, Bottom, Height. 6 | * These names were chosen for ease of use, and to make it clear what they represent. 7 | * Internally they are known as xMin, xMax, xSize, yMin, yMax, ySize. 8 | *

9 | * Created by brandon3055 on 30/06/2023 10 | */ 11 | public enum GeoParam { 12 | /** X_MIN */ 13 | LEFT(Axis.X), 14 | /** X_MAX */ 15 | RIGHT(Axis.X), 16 | /** X_SIZE */ 17 | WIDTH(Axis.X), 18 | 19 | /** Y_MIN */ 20 | TOP(Axis.Y), 21 | /** Y_MAX */ 22 | BOTTOM(Axis.Y), 23 | /** Y_SIZE */ 24 | HEIGHT(Axis.Y); 25 | 26 | public final Axis axis; 27 | 28 | GeoParam(Axis axis) { 29 | this.axis = axis; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/network/ServerPacketHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.network; 2 | 3 | import codechicken.lib.inventory.container.modular.ModularGuiContainerMenu; 4 | import codechicken.lib.packet.ICustomPacketHandler.IServerPacketHandler; 5 | import codechicken.lib.packet.PacketCustom; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.server.network.ServerGamePacketListenerImpl; 8 | 9 | import static codechicken.lib.internal.network.CCLNetwork.S_GUI_SYNC; 10 | 11 | /** 12 | * Created by covers1624 on 14/07/2017. 13 | */ 14 | public class ServerPacketHandler implements IServerPacketHandler { 15 | 16 | @Override 17 | public void handlePacket(PacketCustom packet, ServerPlayer sender) { 18 | switch (packet.getType()) { 19 | case S_GUI_SYNC -> ModularGuiContainerMenu.handlePacketFromClient(sender, packet); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/container/ContainerScreenAccess.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.container; 2 | 3 | import codechicken.lib.gui.modular.elements.GuiSlots; 4 | import codechicken.lib.gui.modular.lib.GuiRender; 5 | import net.minecraft.client.gui.screens.inventory.MenuAccess; 6 | import net.minecraft.world.inventory.AbstractContainerMenu; 7 | import net.minecraft.world.inventory.Slot; 8 | 9 | /** 10 | * Used by {@link ContainerGuiProvider} 11 | * Provides access to the ContainerMenu as well as some essential functions. 12 | *

13 | * Created by brandon3055 on 08/09/2023 14 | */ 15 | public interface ContainerScreenAccess extends MenuAccess { 16 | 17 | /** 18 | * This is the modular gui friendly method used by elements such as {@link GuiSlots} to render inventory item stacks. 19 | */ 20 | void renderSlot(GuiRender render, Slot slot); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/generated/data/codechickenlib/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "ccl.commands.count.fail": "Found no entities.", 3 | "ccl.commands.count.total": "Found %s entities.", 4 | "ccl.commands.gc.after": "After:", 5 | "ccl.commands.gc.before": "Before:", 6 | "ccl.commands.gc.performing": "Performing GC..", 7 | "ccl.commands.killall.fail": "Found no entities.", 8 | "ccl.commands.killall.fail.player": "You cannot kill players with this command.", 9 | "ccl.commands.killall.success": "Killed %s entities.", 10 | "ccl.commands.killall.success.line": "Killed %s", 11 | "ccl.energy_bar.capacity": "Capacity:", 12 | "ccl.energy_bar.energy_storage": "Energy Storage", 13 | "ccl.energy_bar.rf": "RF", 14 | "ccl.energy_bar.stored": "Stored:", 15 | "ccl.fluid_tank.capacity": "Capacity:", 16 | "ccl.fluid_tank.contains": "Contains:", 17 | "ccl.fluid_tank.fluid_storage": "Fluid Storage", 18 | "ccl.fluid_tank.mb": "mB", 19 | "ccl.fluid_tank.stored": "Stored:" 20 | } -------------------------------------------------------------------------------- /src/main/generated/assets/codechickenlib/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "ccl.commands.count.fail": "Found no entities.", 3 | "ccl.commands.count.total": "Found %s entities.", 4 | "ccl.commands.gc.after": "After:", 5 | "ccl.commands.gc.before": "Before:", 6 | "ccl.commands.gc.performing": "Performing GC..", 7 | "ccl.commands.killall.fail": "Found no entities.", 8 | "ccl.commands.killall.fail.player": "You cannot kill players with this command.", 9 | "ccl.commands.killall.success": "Killed %s entities.", 10 | "ccl.commands.killall.success.line": "Killed %s", 11 | "ccl.energy_bar.capacity": "Capacity:", 12 | "ccl.energy_bar.energy_storage": "Energy Storage", 13 | "ccl.energy_bar.rf": "RF", 14 | "ccl.energy_bar.stored": "Stored:", 15 | "ccl.fluid_tank.capacity": "Capacity:", 16 | "ccl.fluid_tank.contains": "Contains:", 17 | "ccl.fluid_tank.fluid_storage": "Fluid Storage", 18 | "ccl.fluid_tank.mb": "mB", 19 | "ccl.fluid_tank.stored": "Stored:" 20 | } -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/data/TagComponent.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.block.component.data; 2 | 3 | import net.minecraft.data.DataProvider; 4 | import net.minecraft.tags.TagKey; 5 | import net.minecraft.world.level.block.Block; 6 | import net.neoforged.neoforge.common.data.BlockTagsProvider; 7 | import org.jetbrains.annotations.ApiStatus; 8 | 9 | /** 10 | * A data generator component for defining Block tags. 11 | *

12 | * Created by covers1624 on 22/7/22. 13 | * 14 | * @see DataGenComponent 15 | */ 16 | @ApiStatus.Experimental 17 | public class TagComponent extends DataGenComponent { 18 | 19 | public final TagKey tag; 20 | 21 | public TagComponent(TagKey tag) { 22 | this.tag = tag; 23 | } 24 | 25 | @Override 26 | protected void addToProvider(DataProvider provider) { 27 | if (provider instanceof BlockTagsProvider p) { 28 | p.tag(tag).add(getBlock()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/resources/model/test_multi_object.obj: -------------------------------------------------------------------------------- 1 | # Blender 3.1.0 2 | # www.blender.org 3 | mtllib test.mtl 4 | o Cube 5 | v 1.000000 1.000000 -1.000000 6 | v 1.000000 -1.000000 -1.000000 7 | v 1.000000 1.000000 1.000000 8 | v 1.000000 -1.000000 1.000000 9 | vn -0.0000 1.0000 -0.0000 10 | vn -0.0000 -0.0000 1.0000 11 | vn -1.0000 -0.0000 -0.0000 12 | vn -0.0000 -1.0000 -0.0000 13 | vt 0.625000 0.500000 14 | vt 0.375000 0.500000 15 | vt 0.625000 0.750000 16 | vt 0.375000 0.750000 17 | s 0 18 | usemtl Material 19 | f 1/1/1 2/2/2 3/3/3 4/4/4 20 | 21 | o Cube2 22 | v 1.000000 1.000000 -1.000000 23 | v 1.000000 -1.000000 -1.000000 24 | v 1.000000 1.000000 1.000000 25 | v 1.000000 -1.000000 1.000000 26 | vn -0.0000 1.0000 -0.0000 27 | vn -0.0000 -0.0000 1.0000 28 | vn -1.0000 -0.0000 -0.0000 29 | vn -0.0000 -1.0000 -0.0000 30 | vt 0.625000 0.500000 31 | vt 0.375000 0.500000 32 | vt 0.625000 0.750000 33 | vt 0.375000 0.750000 34 | s 0 35 | usemtl Material 36 | f 5/5/5 6/6/6 7/7/7 8/8/8 37 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/fluid/FluidUtils.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.fluid; 2 | 3 | import net.minecraft.world.level.material.Fluid; 4 | import net.minecraft.world.level.material.Fluids; 5 | import net.neoforged.neoforge.fluids.FluidStack; 6 | import net.neoforged.neoforge.fluids.FluidType; 7 | 8 | public class FluidUtils { 9 | 10 | public static int B = FluidType.BUCKET_VOLUME; 11 | public static FluidStack water = new FluidStack(Fluids.WATER, 1000); 12 | public static FluidStack lava = new FluidStack(Fluids.LAVA, 1000); 13 | 14 | public static int getLuminosity(FluidStack stack, double density) { 15 | if (stack.isEmpty()) { 16 | return 0; 17 | } 18 | Fluid fluid = stack.getFluid(); 19 | FluidType type = fluid.getFluidType(); 20 | int light = type.getLightLevel(stack); 21 | if (type.isLighterThanAir()) { 22 | light = (int) (light * density); 23 | } 24 | return light; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/block/component/StateAwareComponent.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.block.component; 2 | 3 | import codechicken.lib.block.ModularBlock; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.world.item.context.BlockPlaceContext; 6 | import net.minecraft.world.level.LevelAccessor; 7 | import net.minecraft.world.level.block.Rotation; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | import org.jetbrains.annotations.ApiStatus; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * Created by covers1624 on 22/7/22. 14 | */ 15 | @ApiStatus.Experimental 16 | public abstract class StateAwareComponent extends ModularBlock.Component { 17 | 18 | @Nullable 19 | public BlockState getStateForPlacement(BlockState state, BlockPlaceContext ctx) { 20 | return state; 21 | } 22 | 23 | public BlockState rotate(BlockState state, LevelAccessor level, BlockPos pos, Rotation rotation) { 24 | return state; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/config/JsonConfigSerializerTests.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config; 2 | 3 | import codechicken.lib.config.parser.ConfigSerializer; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.util.Random; 9 | 10 | /** 11 | * Created by covers1624 on 19/5/22. 12 | */ 13 | public class JsonConfigSerializerTests extends ConfigRoundTripTest { 14 | 15 | @Test 16 | public void testRoundTrip() throws Throwable { 17 | Path dir = Files.createTempDirectory("json_test_"); 18 | dir.toFile().deleteOnExit(); 19 | Path config = dir.resolve("config.json"); 20 | 21 | ConfigCategoryImpl rootTag = generateTestTag(new Random()); 22 | ConfigSerializer.JSON.save(config, rootTag); 23 | 24 | ConfigCategoryImpl readTag = new ConfigCategoryImpl("rootTag", null); 25 | ConfigSerializer.JSON.parse(config, readTag); 26 | 27 | assertTagsParseSame(rootTag, readTag); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/config/TomlConfigSerializerTests.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config; 2 | 3 | import codechicken.lib.config.parser.ConfigSerializer; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.util.Random; 9 | 10 | /** 11 | * Created by covers1624 on 19/5/22. 12 | */ 13 | public class TomlConfigSerializerTests extends ConfigRoundTripTest { 14 | 15 | @Test 16 | public void testRoundTrip() throws Throwable { 17 | Path dir = Files.createTempDirectory("toml_test_"); 18 | dir.toFile().deleteOnExit(); 19 | Path config = dir.resolve("config.toml"); 20 | 21 | ConfigCategoryImpl rootTag = generateTestTag(new Random()); 22 | ConfigSerializer.TOML.save(config, rootTag); 23 | 24 | ConfigCategoryImpl readTag = new ConfigCategoryImpl("rootTag", null); 25 | ConfigSerializer.TOML.parse(config, readTag); 26 | 27 | assertTagsParseSame(rootTag, readTag); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/test/TestResourceProvider.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.test; 2 | 3 | import codechicken.lib.render.model.OBJParserTests; 4 | import net.minecraft.resources.ResourceLocation; 5 | import net.minecraft.server.packs.resources.Resource; 6 | import net.minecraft.server.packs.resources.ResourceProvider; 7 | 8 | import java.util.Objects; 9 | import java.util.Optional; 10 | 11 | /** 12 | * Simple singleton {@link ResourceProvider} instance for unit tests. 13 | *

14 | * Created by covers1624 on 14/4/22. 15 | */ 16 | public class TestResourceProvider implements ResourceProvider { 17 | 18 | public static final TestResourceProvider INSTANCE = new TestResourceProvider(); 19 | 20 | private TestResourceProvider() { 21 | } 22 | 23 | @Override 24 | public Optional getResource(ResourceLocation resource) { 25 | return Optional.of(new Resource(null, () -> Objects.requireNonNull(OBJParserTests.class.getResourceAsStream("/" + resource.getPath()), "Resource " + resource + " doesnt exist."))); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/VertexAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline; 2 | 3 | import codechicken.lib.render.pipeline.attribute.AttributeKey; 4 | 5 | /** 6 | * Management class for a vertex attribute such as colour, normal etc 7 | * This class should handle the loading of the attribute from an Attribute provided by 8 | * {@link IVertexSource#getAttribute(AttributeKey)} or the computation of this attribute from others 9 | * 10 | * @param The type for this attribute eg. int[], Vector3[] 11 | */ 12 | public abstract class VertexAttribute implements IVertexOperation { 13 | 14 | /** 15 | * Set to true when the attribute is part of the pipeline. Should only be managed by CCRenderState when constructing the pipeline 16 | */ 17 | public boolean active = false; 18 | private final AttributeKey key; 19 | 20 | public VertexAttribute(AttributeKey key) { 21 | this.key = key; 22 | } 23 | 24 | @Override 25 | public int operationID() { 26 | return key.operationIndex; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/item/map/IMapRenderer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.item.map; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | /** 6 | * Used to handle rendering FirstPerson items the same as a map. 7 | *

8 | * Created by covers1624 on 15/02/2017. 9 | */ 10 | public interface IMapRenderer { 11 | 12 | /** 13 | * If the IMapRenderer should handle rendering the data from this map. 14 | * 15 | * @param stack The ItemStack to render map data from. 16 | * @param inFrame If the ItemStack is inside an ItemFrame. 17 | * @return Should this IMapRenderer handle with this context. 18 | */ 19 | boolean shouldHandle(ItemStack stack, boolean inFrame); 20 | 21 | /** 22 | * If this is called you are expected to do something. 23 | * This is ONLY called if shouldHandle returns true. 24 | * 25 | * @param stack The ItemStack to render the map data from. 26 | * @param inFrame If the ItemStack is inside an ItemFrame. 27 | */ 28 | void renderMap(ItemStack stack, boolean inFrame); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/recipe/RecipeBuilder.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.datagen.recipe; 2 | 3 | import net.minecraft.advancements.AdvancementHolder; 4 | import net.minecraft.data.recipes.RecipeOutput; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.minecraft.world.item.crafting.Recipe; 7 | import net.neoforged.neoforge.common.conditions.ICondition; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by covers1624 on 27/12/20. 14 | */ 15 | public interface RecipeBuilder { 16 | 17 | ResourceLocation getId(); 18 | 19 | BuiltRecipe build(); 20 | 21 | // Compat with vanilla's Recipe Provider. 22 | default void build(RecipeOutput output) { 23 | BuiltRecipe built = build(); 24 | output.accept(getId(), built.recipe, built.advancement, built.conditions.toArray(ICondition[]::new)); 25 | } 26 | 27 | record BuiltRecipe( 28 | Recipe recipe, 29 | @Nullable AdvancementHolder advancement, 30 | List conditions 31 | ) { } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/geometry/Direction.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.geometry; 2 | 3 | /** 4 | * Created by brandon3055 on 04/09/2023 5 | */ 6 | public enum Direction { 7 | UP(Axis.Y), 8 | LEFT(Axis.X), 9 | DOWN(Axis.Y), 10 | RIGHT(Axis.X); 11 | 12 | private static Direction[] VALUES = values(); 13 | 14 | private final Axis axis; 15 | 16 | Direction(Axis axis) { 17 | this.axis = axis; 18 | } 19 | 20 | public Axis getAxis() { 21 | return axis; 22 | } 23 | 24 | public Direction opposite() { 25 | if (axis == Axis.X) return this == LEFT ? RIGHT : LEFT; 26 | else return this == UP ? DOWN : UP; 27 | } 28 | 29 | public Direction rotateCW() { 30 | return values()[(ordinal() + VALUES.length - 1) % VALUES.length]; 31 | } 32 | 33 | public Direction rotateCCW() { 34 | return values()[(ordinal() + 1) % VALUES.length]; 35 | } 36 | 37 | public double rotationTo(Direction other) { 38 | return (this.ordinal() - other.ordinal()) * 90; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/NamedShaderObject.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import java.util.Collection; 6 | import java.util.Objects; 7 | 8 | /** 9 | * Created by covers1624 on 9/3/22. 10 | */ 11 | public abstract class NamedShaderObject implements ShaderObject { 12 | 13 | private final String name; 14 | private final ShaderType type; 15 | private final ImmutableList uniforms; 16 | 17 | protected NamedShaderObject(String name, ShaderType type, Collection uniforms) { 18 | this.name = Objects.requireNonNull(name); 19 | this.type = Objects.requireNonNull(type); 20 | this.uniforms = ImmutableList.copyOf(uniforms); 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | @Override 29 | public ShaderType getShaderType() { 30 | return type; 31 | } 32 | 33 | @Override 34 | public ImmutableList getUniforms() { 35 | return uniforms; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/pipeline/IPipelineElementFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of CodeChickenLib. 3 | * Copyright (c) 2018, covers1624, All rights reserved. 4 | * 5 | * CodeChickenLib is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 2.1 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * CodeChickenLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with CodeChickenLib. If not, see . 17 | */ 18 | 19 | package codechicken.lib.model.pipeline; 20 | 21 | /** 22 | * @author covers1624 23 | */ 24 | @FunctionalInterface 25 | public interface IPipelineElementFactory { 26 | 27 | T create(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/neoforge.mods.toml: -------------------------------------------------------------------------------- 1 | modLoader="javafml" 2 | loaderVersion="[2,)" 3 | issueTrackerURL="https://github.com/TheCBProject/CodeChickenLib" 4 | license="GNU Lesser General Public License v2.1" 5 | 6 | [[mods]] 7 | modId="codechickenlib" 8 | displayName="CodeChicken Lib" 9 | version="${file.jarVersion}" 10 | 11 | updateJSONURL="https://version-check.covers1624.net/check/?mod=CodeChickenLib&mc=${mc_version}" 12 | displayURL="https://www.curseforge.com/minecraft/mc-mods/codechicken-lib-1-8" 13 | authors="ChickenBones, covers1624" 14 | description=''' 15 | CodeChickenLib is a library of systems to help make various aspects of minecraft modding easier. 16 | It contains libraries for 3D math and transformations, model rendering, packets, config, colours, asm and a few other things.. 17 | ''' 18 | [[dependencies.codechickenlib]] 19 | modId="neoforge" 20 | type="required" 21 | versionRange="[${forge_version},)" 22 | ordering="NONE" 23 | side="BOTH" 24 | [[dependencies.codechickenlib]] 25 | modId="minecraft" 26 | type="required" 27 | versionRange="[1.21.1]" 28 | ordering="NONE" 29 | side="BOTH" 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/colour/ColourARGB.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.colour; 2 | 3 | public class ColourARGB extends Colour { 4 | 5 | public ColourARGB(int colour) { 6 | super((colour >> 16) & 0xFF, (colour >> 8) & 0xFF, colour & 0xFF, (colour >> 24) & 0xFF); 7 | } 8 | 9 | public ColourARGB(int a, int r, int g, int b) { 10 | super(r, g, b, a); 11 | } 12 | 13 | public ColourARGB(ColourARGB colour) { 14 | super(colour); 15 | } 16 | 17 | @Override 18 | public ColourARGB copy() { 19 | return new ColourARGB(this); 20 | } 21 | 22 | @Override 23 | public Colour set(int colour) { 24 | return set(new ColourARGB(colour)); 25 | } 26 | 27 | @Override 28 | public int pack() { 29 | return pack(this); 30 | } 31 | 32 | @Override 33 | public float[] packArray() { 34 | return new float[] { (a & 0xFF) / 255f, (r & 0xFF) / 255f, (g & 0xFF) / 255f, (b & 0xFF) / 255f }; 35 | } 36 | 37 | public static int pack(Colour colour) { 38 | return (colour.a & 0xFF) << 24 | (colour.r & 0xFF) << 16 | (colour.g & 0xFF) << 8 | (colour.b & 0xFF); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/UVScale.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.MathContext; 5 | import java.math.RoundingMode; 6 | 7 | public class UVScale extends UVTransformation { 8 | 9 | double su; 10 | double sv; 11 | 12 | public UVScale(double scaleu, double scalev) { 13 | su = scaleu; 14 | sv = scalev; 15 | } 16 | 17 | public UVScale(double d) { 18 | this(d, d); 19 | } 20 | 21 | public UVScale(UVScale other) { 22 | this(other.su, other.sv); 23 | } 24 | 25 | @Override 26 | public void apply(UV uv) { 27 | uv.u *= su; 28 | uv.v *= sv; 29 | } 30 | 31 | @Override 32 | public UVTransformation inverse() { 33 | return new UVScale(1 / su, 1 / sv); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 39 | return "UVScale(" + new BigDecimal(su, cont) + ", " + new BigDecimal(sv, cont) + ")"; 40 | } 41 | 42 | @Override 43 | public UVScale copy() { 44 | return new UVScale(this); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/IntData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.IntTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class IntData extends AbstractDataStore { 14 | 15 | public IntData() { 16 | super(0); 17 | } 18 | 19 | public IntData(int defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeVarInt(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readVarInt(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return IntTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsInt(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/ByteData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.ByteTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class ByteData extends AbstractDataStore { 14 | 15 | public ByteData() { 16 | super((byte) 0); 17 | } 18 | 19 | public ByteData(byte defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeByte(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readByte(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return ByteTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsByte(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/LongData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.LongTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class LongData extends AbstractDataStore { 14 | 15 | public LongData() { 16 | super(0L); 17 | } 18 | 19 | public LongData(long defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeVarLong(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readVarLong(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return LongTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsLong(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/RedundantTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | public class RedundantTransformation extends Transformation { 4 | 5 | public static final RedundantTransformation INSTANCE = new RedundantTransformation(); 6 | 7 | private RedundantTransformation() { 8 | } 9 | 10 | @Override 11 | public void apply(Vector3 vec) { 12 | } 13 | 14 | @Override 15 | public void apply(Matrix4 mat) { 16 | } 17 | 18 | @Override 19 | public void applyN(Vector3 normal) { 20 | } 21 | 22 | @Override 23 | public Transformation at(Vector3 point) { 24 | return this; 25 | } 26 | 27 | @Override 28 | public Transformation inverse() { 29 | return this; 30 | } 31 | 32 | @Override 33 | public Transformation merge(Transformation next) { 34 | return next; 35 | } 36 | 37 | @Override 38 | public boolean isRedundant() { 39 | return true; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Nothing()"; 45 | } 46 | 47 | @Override 48 | public RedundantTransformation copy() { 49 | return this; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/FloatData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.FloatTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class FloatData extends AbstractDataStore { 14 | 15 | public FloatData() { 16 | super(0F); 17 | } 18 | 19 | public FloatData(float defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeFloat(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readFloat(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return FloatTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsFloat(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/ShortData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.NumericTag; 7 | import net.minecraft.nbt.ShortTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class ShortData extends AbstractDataStore { 14 | 15 | public ShortData() { 16 | super((short) 0); 17 | } 18 | 19 | public ShortData(short defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeShort(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readShort(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return ShortTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsShort(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CodeChickenLib 2 | ============== 3 | [![](http://cf.way2muchnoise.eu/short_codechicken-lib-1-8_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/codechicken-lib-1-8) 4 | [![](http://cf.way2muchnoise.eu/versions/Available%20for_codechicken-lib-1-8_full.svg)](https://www.curseforge.com/minecraft/mc-mods/codechicken-lib-1-8/files) 5 | [![](https://img.shields.io/discord/214781374698225666.svg?logo=discord&label=Discord&labelColor=2d2d2d&style=flat)](https://discord.gg/9nr3qyC) 6 | [![](https://img.shields.io/badge/Nexus%20index-maven-blue?style=flat&labelColor=2d2d2d)](https://nexus.covers1624.net/#browse/browse:maven-hosted:codechicken%2FCodeChickenLib) 7 | [![](https://img.shields.io/badge/Patreon-covers1624-red?style=flat&labelColor=2d2d2d&logo=patreon)](https://www.patreon.com/covers1624) 8 | 9 | 10 | 11 | This is a library of systems to help make various aspects of minecraft modding easier. 12 | It contains libraries for 3D math and transformations, model rendering, packets, config, colours, ASM and a few other things. 13 | 14 | 15 | Grab it on CurseForge [here!](https://www.curseforge.com/minecraft/mc-mods/codechicken-lib-1-8) 16 | 17 | Maven for developers: `https://maven.covers1624.net` 18 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/DoubleData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.DoubleTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class DoubleData extends AbstractDataStore { 14 | 15 | public DoubleData() { 16 | super(0D); 17 | } 18 | 19 | public DoubleData(double defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeDouble(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readDouble(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return DoubleTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsDouble(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/BooleanData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.ByteTag; 7 | import net.minecraft.nbt.NumericTag; 8 | import net.minecraft.nbt.Tag; 9 | 10 | /** 11 | * Created by brandon3055 on 09/09/2023 12 | */ 13 | public class BooleanData extends AbstractDataStore { 14 | 15 | public BooleanData() { 16 | super(false); 17 | } 18 | 19 | public BooleanData(boolean defaultValue) { 20 | super(defaultValue); 21 | } 22 | 23 | @Override 24 | public void toBytes(MCDataOutput buf) { 25 | buf.writeBoolean(value); 26 | } 27 | 28 | @Override 29 | public void fromBytes(MCDataInput buf) { 30 | value = buf.readBoolean(); 31 | } 32 | 33 | @Override 34 | public Tag toTag(HolderLookup.Provider holders) { 35 | return ByteTag.valueOf(value); 36 | } 37 | 38 | @Override 39 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 40 | value = ((NumericTag) tag).getAsByte() != 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/DelegateRenderType.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.buffer; 2 | 3 | import com.mojang.blaze3d.vertex.MeshData; 4 | import com.mojang.blaze3d.vertex.VertexFormat; 5 | import net.covers1624.quack.util.SneakyUtils; 6 | import net.minecraft.client.renderer.RenderType; 7 | 8 | /** 9 | * Created by covers1624 on 25/5/20. 10 | */ 11 | public class DelegateRenderType extends RenderType { 12 | 13 | protected RenderType parent; 14 | 15 | public DelegateRenderType(RenderType parent) { 16 | this(parent, parent.format()); 17 | } 18 | 19 | public DelegateRenderType(RenderType parent, VertexFormat format) { 20 | super(parent.name, format, parent.mode(), parent.bufferSize(), parent.affectsCrumbling(), parent.sortOnUpload, SneakyUtils.none(), SneakyUtils.none()); 21 | this.parent = parent; 22 | } 23 | 24 | @Override 25 | public void draw(MeshData meshData) { 26 | parent.draw(meshData); 27 | } 28 | 29 | @Override 30 | public void setupRenderState() { 31 | parent.setupRenderState(); 32 | } 33 | 34 | @Override 35 | public void clearRenderState() { 36 | parent.clearRenderState(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/UVTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.IVertexOperation; 5 | import codechicken.lib.vec.ITransformation; 6 | 7 | /** 8 | * Abstract supertype for any UV transformation 9 | */ 10 | public abstract class UVTransformation extends ITransformation implements IVertexOperation { 11 | 12 | public static final int operationIndex = IVertexOperation.registerOperation(); 13 | 14 | public UVTransformation at(UV point) { 15 | return new UVTransformationList(new UVTranslation(-point.u, -point.v), this, new UVTranslation(point.u, point.v)); 16 | } 17 | 18 | public UVTransformationList with(UVTransformation t) { 19 | return new UVTransformationList(this, t); 20 | } 21 | 22 | @Override 23 | public boolean load(CCRenderState ccrs) { 24 | return !isRedundant(); 25 | } 26 | 27 | @Override 28 | public void operate(CCRenderState ccrs) { 29 | apply(ccrs.vert.uv); 30 | ccrs.sprite = null; 31 | } 32 | 33 | @Override 34 | public int operationID() { 35 | return operationIndex; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/ExceptionMessageEventHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal; 2 | 3 | import net.covers1624.quack.util.CrashLock; 4 | import net.neoforged.neoforge.client.event.ClientTickEvent; 5 | import net.neoforged.neoforge.common.NeoForge; 6 | 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * Created by covers1624 on 25/07/18. 13 | */ 14 | public class ExceptionMessageEventHandler { 15 | 16 | private static final CrashLock LOCK = new CrashLock("Already Initialized"); 17 | 18 | public static Set exceptionMessageCache = new HashSet<>(); 19 | private static long lastExceptionClear; 20 | 21 | public static void init() { 22 | LOCK.lock(); 23 | NeoForge.EVENT_BUS.addListener(ExceptionMessageEventHandler::clientTick); 24 | } 25 | 26 | private static void clientTick(ClientTickEvent.Post event) { 27 | //Clear the known exceptions every 5 seconds. 28 | long time = System.nanoTime(); 29 | if (TimeUnit.NANOSECONDS.toSeconds(time - lastExceptionClear) > 5) { 30 | lastExceptionClear = time; 31 | exceptionMessageCache.clear(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/colour/CustomGradient.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.colour; 2 | 3 | import codechicken.lib.math.MathHelper; 4 | import codechicken.lib.texture.TextureUtils; 5 | import net.minecraft.resources.ResourceLocation; 6 | 7 | import java.awt.image.BufferedImage; 8 | 9 | public class CustomGradient { 10 | 11 | public int[] gradient; 12 | 13 | public CustomGradient(ResourceLocation textureFile) { 14 | BufferedImage img = TextureUtils.loadBufferedImage(textureFile); 15 | if (img == null) { 16 | throw new RuntimeException("File not found: " + textureFile); 17 | } 18 | 19 | int[] data = new int[img.getWidth()]; 20 | img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth()); 21 | gradient = new int[img.getWidth()]; 22 | for (int i = 0; i < data.length; i++) { 23 | gradient[i] = (data[i] << 8) | (((data[i]) >> 24) & 0xFF); 24 | } 25 | } 26 | 27 | public ColourRGBA getColour(double position) { 28 | return new ColourRGBA(getColourI(position)); 29 | } 30 | 31 | public int getColourI(double position) { 32 | int off = (int) MathHelper.clip(gradient.length * position, 0, gradient.length - 1); 33 | return gradient[off]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/geometry/GeoRef.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.geometry; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * Used to access one of the 6 core parameters that make up an element's geometry. 7 | *

8 | * The primary purpose of this class is to provide a convenient way to reference a geometry 9 | * parameter when defining constraints. 10 | * It also helps make the code more debuggable. 11 | * I could just make literally everything a lambda, but that makes debugging kinda painful when things break. 12 | *

13 | * Created by brandon3055 on 30/06/2023 14 | */ 15 | public class GeoRef implements Supplier { 16 | public final GuiParent geometry; 17 | public final GeoParam parameter; 18 | 19 | public GeoRef(GuiParent geometry, GeoParam parameter) { 20 | this.geometry = geometry; 21 | this.parameter = parameter; 22 | } 23 | 24 | @Override 25 | public Double get() { 26 | return geometry.getValue(parameter); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "GeoReference{" + 32 | "geometry=" + geometry + 33 | ", parameter=" + parameter + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/lighting/PlanarLightModel.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.lighting; 2 | 3 | import codechicken.lib.colour.ColourRGBA; 4 | import codechicken.lib.render.CCRenderState; 5 | import codechicken.lib.render.pipeline.IVertexOperation; 6 | 7 | /** 8 | * Faster precomputed version of LightModel that only works for axis planar sides 9 | */ 10 | public class PlanarLightModel implements IVertexOperation { 11 | 12 | public static PlanarLightModel standardLightModel = LightModel.standardLightModel.reducePlanar(); 13 | 14 | public int[] colours; 15 | 16 | public PlanarLightModel(int[] colours) { 17 | this.colours = colours; 18 | } 19 | 20 | @Override 21 | public boolean load(CCRenderState ccrs) { 22 | if (!ccrs.computeLighting) { 23 | return false; 24 | } 25 | 26 | ccrs.pipeline.addDependency(ccrs.sideAttrib); 27 | ccrs.pipeline.addDependency(ccrs.colourAttrib); 28 | return true; 29 | } 30 | 31 | @Override 32 | public void operate(CCRenderState ccrs) { 33 | ccrs.colour = ColourRGBA.multiply(ccrs.colour, colours[ccrs.side]); 34 | } 35 | 36 | @Override 37 | public int operationID() { 38 | return LightModel.operationIndex; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/AbstractDataStore.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.Tag; 7 | 8 | import java.util.Objects; 9 | 10 | /** 11 | * The base class of a simple general purpose serializable data system. 12 | *

13 | * Created by brandon3055 on 08/09/2023 14 | */ 15 | public abstract class AbstractDataStore { 16 | 17 | protected T value; 18 | 19 | public AbstractDataStore(T defaultValue) { 20 | this.value = defaultValue; 21 | } 22 | 23 | public T get() { 24 | return value; 25 | } 26 | 27 | public void set(T value) { 28 | this.value = value; 29 | markDirty(); 30 | } 31 | 32 | public void markDirty() { } 33 | 34 | public abstract void toBytes(MCDataOutput buf); 35 | 36 | public abstract void fromBytes(MCDataInput buf); 37 | 38 | public abstract Tag toTag(HolderLookup.Provider holders); 39 | 40 | public abstract void fromTag(HolderLookup.Provider holders, Tag tag); 41 | 42 | public boolean isSameValue(T newValue) { 43 | return Objects.equals(value, newValue); 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/ColourAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline.attribute; 2 | 3 | import codechicken.lib.colour.ColourRGBA; 4 | import codechicken.lib.render.CCRenderState; 5 | import codechicken.lib.render.pipeline.VertexAttribute; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Sets colour in CCRS to the specified colour in the model. 10 | */ 11 | public class ColourAttribute extends VertexAttribute { 12 | 13 | public static final AttributeKey attributeKey = AttributeKey.create("colour", int[]::new); 14 | 15 | private int @Nullable [] colourRef; 16 | 17 | public ColourAttribute() { 18 | super(attributeKey); 19 | } 20 | 21 | @Override 22 | public boolean load(CCRenderState ccrs) { 23 | assert ccrs.model != null; 24 | 25 | colourRef = ccrs.model.getAttribute(attributeKey); 26 | return colourRef != null || !ccrs.model.hasAttribute(attributeKey); 27 | } 28 | 29 | @Override 30 | public void operate(CCRenderState ccrs) { 31 | if (colourRef != null) { 32 | ccrs.colour = ColourRGBA.multiply(ccrs.baseColour, colourRef[ccrs.vertexIndex]); 33 | } else { 34 | ccrs.colour = ccrs.baseColour; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/ColourMultiplier.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline; 2 | 3 | import codechicken.lib.colour.ColourRGBA; 4 | import codechicken.lib.render.CCRenderState; 5 | 6 | public class ColourMultiplier implements IVertexOperation { 7 | 8 | private static final ThreadLocal instances = ThreadLocal.withInitial(() -> new ColourMultiplier(-1)); 9 | 10 | public static ColourMultiplier instance(int colour) { 11 | ColourMultiplier instance = instances.get(); 12 | instance.colour = colour; 13 | return instance; 14 | } 15 | 16 | public static final int operationIndex = IVertexOperation.registerOperation(); 17 | public int colour; 18 | 19 | public ColourMultiplier(int colour) { 20 | this.colour = colour; 21 | } 22 | 23 | @Override 24 | public boolean load(CCRenderState ccrs) { 25 | if (colour == -1) { 26 | return false; 27 | } 28 | 29 | ccrs.pipeline.addDependency(ccrs.colourAttrib); 30 | return true; 31 | } 32 | 33 | @Override 34 | public void operate(CCRenderState ccrs) { 35 | ccrs.colour = ColourRGBA.multiply(ccrs.colour, colour); 36 | } 37 | 38 | @Override 39 | public int operationID() { 40 | return operationIndex; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/ScaledIconTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.vec.IrreversibleTransformationException; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | 6 | public class ScaledIconTransformation extends IconTransformation { 7 | 8 | public double su = 0.0F; 9 | public double sv = 0.0F; 10 | 11 | public ScaledIconTransformation(TextureAtlasSprite icon) { 12 | super(icon); 13 | } 14 | 15 | public ScaledIconTransformation(TextureAtlasSprite icon, double su, double sv) { 16 | super(icon); 17 | 18 | this.su = su; 19 | this.sv = sv; 20 | } 21 | 22 | public ScaledIconTransformation(ScaledIconTransformation other) { 23 | this(other.icon, other.su, other.sv); 24 | } 25 | 26 | @Override 27 | public void apply(UV uv) { 28 | uv.u = icon.getU((float) (uv.u % 2)) + su * (icon.getU1() - icon.getU0()); 29 | uv.v = icon.getV((float) (uv.v % 2)) + sv * (icon.getV1() - icon.getV0()); 30 | } 31 | 32 | @Override 33 | public UVTransformation inverse() { 34 | throw new IrreversibleTransformationException(this); 35 | } 36 | 37 | @Override 38 | public ScaledIconTransformation copy() { 39 | return new ScaledIconTransformation(this); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/network/CCLNetwork.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.network; 2 | 3 | import codechicken.lib.CodeChickenLib; 4 | import codechicken.lib.packet.PacketCustomChannel; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.neoforged.bus.api.IEventBus; 7 | 8 | import static codechicken.lib.CodeChickenLib.MOD_ID; 9 | 10 | /** 11 | * Created by covers1624 on 28/10/19. 12 | */ 13 | public class CCLNetwork { 14 | 15 | public static final ResourceLocation NET_CHANNEL = ResourceLocation.fromNamespaceAndPath(MOD_ID, "internal"); 16 | public static final PacketCustomChannel channel = new PacketCustomChannel(NET_CHANNEL) 17 | .optional() 18 | .versioned(CodeChickenLib.container().getModInfo().getVersion().toString()) 19 | .clientConfiguration(() -> ClientConfigurationPacketHandler::new) 20 | .client(() -> ClientPacketHandler::new) 21 | .server(() -> ServerPacketHandler::new); 22 | 23 | //Client handled. 24 | public static final int C_ADD_LANDING_EFFECTS = 1; 25 | public static final int C_GUI_SYNC = 20; 26 | 27 | //Server handled. 28 | public static final int S_GUI_SYNC = 20; 29 | 30 | //Login handled. 31 | public static final int L_CONFIG_SYNC = 1; 32 | 33 | public static void init(IEventBus modBus) { 34 | channel.init(modBus); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/SideAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline.attribute; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.VertexAttribute; 5 | import codechicken.lib.util.VectorUtils; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Sets the side state in CCRS based on the provided model. If the model does not have side data it requires normals. 10 | */ 11 | public class SideAttribute extends VertexAttribute { 12 | 13 | public static final AttributeKey attributeKey = AttributeKey.create("side", int[]::new); 14 | 15 | private int @Nullable [] sideRef; 16 | 17 | public SideAttribute() { 18 | super(attributeKey); 19 | } 20 | 21 | @Override 22 | public boolean load(CCRenderState ccrs) { 23 | assert ccrs.model != null; 24 | 25 | sideRef = ccrs.model.getAttribute(attributeKey); 26 | if (ccrs.model.hasAttribute(attributeKey)) { 27 | return sideRef != null; 28 | } 29 | 30 | ccrs.pipeline.addDependency(ccrs.normalAttrib); 31 | return true; 32 | } 33 | 34 | @Override 35 | public void operate(CCRenderState ccrs) { 36 | if (sideRef != null) { 37 | ccrs.side = sideRef[ccrs.vertexIndex]; 38 | } else { 39 | ccrs.side = VectorUtils.findSide(ccrs.normal); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/generated/.cache/f0722e2ccb61f3087e21fc378db7b4f9b32dbea1: -------------------------------------------------------------------------------- 1 | // 1.21.1 2024-12-06T17:16:20.755323336 CodeChickenLib Item tags. 2 | 9b9a1318b746e42366ee1747896a1c61d71bc0ae data/c/tags/item/wools.json 3 | dc26d59698d238e0c60c400dbffea2ba82af4365 data/c/tags/item/wools/black.json 4 | 4b007eca91284e115e6a0c208c8dddbbf0aed7bc data/c/tags/item/wools/blue.json 5 | 9f867580ce1e743583fab6a17e3d03248865eafc data/c/tags/item/wools/brown.json 6 | b4b458788e919f93343c36ef996f828bcf610abc data/c/tags/item/wools/cyan.json 7 | 62e9def05a24ce6a0f8b7fdb1490d7e856991d47 data/c/tags/item/wools/gray.json 8 | 1bdd1be741fcfa89c90c2bf0af6706b6c63139ca data/c/tags/item/wools/green.json 9 | e054a5fe2248aa8c0a7f66d210cb54a639c661f6 data/c/tags/item/wools/light_blue.json 10 | bf7627f1264b6899bedb6f55e19898dad5d03d8c data/c/tags/item/wools/light_gray.json 11 | aceb5be462f62f63438e67877d38c89951e8919e data/c/tags/item/wools/lime.json 12 | cfd0d2c16adae65fbf8640439a1814ab244082cb data/c/tags/item/wools/magenta.json 13 | 842c228466435a5cc9221a17f70a778db8617590 data/c/tags/item/wools/orange.json 14 | 3ff0870e67b5b9c122d8e59400180e4bd93780a3 data/c/tags/item/wools/pink.json 15 | fec60767247bdbebf6cd451bb3692c9a8ffef908 data/c/tags/item/wools/purple.json 16 | 85f94b89b0d20e38f4e9f464fb443064c29f2bf1 data/c/tags/item/wools/red.json 17 | 8e71446b54f055edb3ba7a025d4335cb78da1b45 data/c/tags/item/wools/white.json 18 | 0de700cdfc12e281290ea7bc709d3241620ec9fb data/c/tags/item/wools/yellow.json 19 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/MultiIconTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.vec.IrreversibleTransformationException; 5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | public class MultiIconTransformation extends UVTransformation { 9 | 10 | public TextureAtlasSprite[] icons; 11 | @Nullable 12 | private TextureAtlasSprite icon; 13 | 14 | public MultiIconTransformation(TextureAtlasSprite... icons) { 15 | this.icons = icons; 16 | } 17 | 18 | public MultiIconTransformation(MultiIconTransformation other) { 19 | this(other.icons.clone()); 20 | icon = null; // Redundant but shuts Intellij up. 21 | } 22 | 23 | @Override 24 | public void operate(CCRenderState ccrs) { 25 | super.operate(ccrs); 26 | ccrs.sprite = icon; 27 | } 28 | 29 | @Override 30 | public void apply(UV uv) { 31 | icon = icons[uv.tex % icons.length]; 32 | uv.u = icon.getU((float) uv.u); 33 | uv.v = icon.getV((float) uv.v); 34 | } 35 | 36 | @Override 37 | public UVTransformation inverse() { 38 | throw new IrreversibleTransformationException(this); 39 | } 40 | 41 | @Override 42 | public MultiIconTransformation copy() { 43 | return new MultiIconTransformation(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/render/model/MatLibTests.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.model; 2 | 3 | import codechicken.lib.colour.ColourRGBA; 4 | import codechicken.lib.test.TestResourceProvider; 5 | import net.minecraft.resources.ResourceLocation; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import static org.junit.jupiter.api.Assertions.assertEquals; 9 | import static org.junit.jupiter.api.Assertions.assertNotNull; 10 | 11 | /** 12 | * Created by covers1624 on 14/4/22. 13 | */ 14 | public class MatLibTests { 15 | 16 | @Test 17 | public void testMatLibParse() { 18 | MatLib matLib = MatLib.parse(TestResourceProvider.INSTANCE, ResourceLocation.parse("test:model/test.mtl")); 19 | assertEquals(1, matLib.materials.size()); 20 | ModelMaterial material = matLib.getMaterial("Material"); 21 | assertNotNull(material); 22 | assertEquals(new ColourRGBA(0xB2997FFF), material.ambientColour); 23 | assertEquals("ka.png", material.ambientColourMap); 24 | assertEquals(new ColourRGBA(0xCCB299FF), material.diffuseColour); 25 | assertEquals("kd.png", material.diffuseColourMap); 26 | assertEquals(new ColourRGBA(0xCCB299FF), material.specularColour); 27 | assertEquals("ks.png", material.specularColourMap); 28 | assertEquals(360.0F, material.specularHighlight); 29 | assertEquals(1.5F, material.dissolve); 30 | assertEquals(5.0F, material.illumination); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/TransformingVertexConsumer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.buffer; 2 | 3 | import codechicken.lib.vec.Matrix4; 4 | import codechicken.lib.vec.Transformation; 5 | import codechicken.lib.vec.Vector3; 6 | import com.mojang.blaze3d.vertex.PoseStack; 7 | import com.mojang.blaze3d.vertex.VertexConsumer; 8 | 9 | /** 10 | * Created by covers1624 on 4/24/20. 11 | */ 12 | public class TransformingVertexConsumer extends DelegatingVertexConsumer { 13 | 14 | private final Transformation transform; 15 | private final Vector3 storage = new Vector3(); 16 | 17 | public TransformingVertexConsumer(VertexConsumer delegate, PoseStack stack) { 18 | this(delegate, new Matrix4(stack)); 19 | } 20 | 21 | public TransformingVertexConsumer(VertexConsumer delegate, Transformation transform) { 22 | super(delegate); 23 | this.transform = transform; 24 | } 25 | 26 | @Override 27 | public VertexConsumer addVertex(float x, float y, float z) { 28 | storage.set(x, y, z); 29 | transform.apply(storage); 30 | return super.addVertex((float) storage.x, (float) storage.y, (float) storage.z); 31 | } 32 | 33 | @Override 34 | public VertexConsumer setNormal(float x, float y, float z) { 35 | storage.set(x, y, z); 36 | transform.applyN(storage); 37 | return delegate.setNormal((float) storage.x, (float) storage.y, (float) storage.z); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/generated/.cache/95d738e2c774c5a4b0452cf55df2775d732b2634: -------------------------------------------------------------------------------- 1 | // 1.21.1 2024-12-06T17:16:20.746404632 CodeChickenLib Block tags. 2 | 9b9a1318b746e42366ee1747896a1c61d71bc0ae data/c/tags/block/wools.json 3 | dc26d59698d238e0c60c400dbffea2ba82af4365 data/c/tags/block/wools/black.json 4 | 4b007eca91284e115e6a0c208c8dddbbf0aed7bc data/c/tags/block/wools/blue.json 5 | 9f867580ce1e743583fab6a17e3d03248865eafc data/c/tags/block/wools/brown.json 6 | b4b458788e919f93343c36ef996f828bcf610abc data/c/tags/block/wools/cyan.json 7 | 62e9def05a24ce6a0f8b7fdb1490d7e856991d47 data/c/tags/block/wools/gray.json 8 | 1bdd1be741fcfa89c90c2bf0af6706b6c63139ca data/c/tags/block/wools/green.json 9 | e054a5fe2248aa8c0a7f66d210cb54a639c661f6 data/c/tags/block/wools/light_blue.json 10 | bf7627f1264b6899bedb6f55e19898dad5d03d8c data/c/tags/block/wools/light_gray.json 11 | aceb5be462f62f63438e67877d38c89951e8919e data/c/tags/block/wools/lime.json 12 | cfd0d2c16adae65fbf8640439a1814ab244082cb data/c/tags/block/wools/magenta.json 13 | 842c228466435a5cc9221a17f70a778db8617590 data/c/tags/block/wools/orange.json 14 | 3ff0870e67b5b9c122d8e59400180e4bd93780a3 data/c/tags/block/wools/pink.json 15 | fec60767247bdbebf6cd451bb3692c9a8ffef908 data/c/tags/block/wools/purple.json 16 | 85f94b89b0d20e38f4e9f464fb443064c29f2bf1 data/c/tags/block/wools/red.json 17 | 8e71446b54f055edb3ba7a025d4335cb78da1b45 data/c/tags/block/wools/white.json 18 | 0de700cdfc12e281290ea7bc709d3241620ec9fb data/c/tags/block/wools/yellow.json 19 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/ForegroundRender.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | 5 | /** 6 | * Allows a Gui Elements to render content in front of child elements. 7 | * Note: Most elements should use {@link BackgroundRender} to render their content. 8 | *

9 | * Created by brandon3055 on 07/08/2023 10 | */ 11 | public interface ForegroundRender { 12 | 13 | /** 14 | * Specifies the z depth of the foreground content. 15 | * Used when calculating the total depth of this gui element. 16 | * Recommended minimum depth is 0.01 or 0.035 if this element renders text. (text shadows are rendered with a 0.03 offset) 17 | * 18 | * @return the z height of the background content. 19 | */ 20 | default double getForegroundDepth() { 21 | return 0.01; 22 | } 23 | 24 | /** 25 | * Used to render content in front of this elements child elements. 26 | * When rendering element content, always use the {@link PoseStack} available via the provided {@link GuiRender} 27 | * Where applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete. 28 | * 29 | * @param render Contains gui context information as well as essential render methods/utils including the PoseStack. 30 | */ 31 | void renderForeground(GuiRender render, double mouseX, double mouseY, float partialTicks); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/container/ContainerGuiProvider.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.container; 2 | 3 | import codechicken.lib.gui.modular.ModularGui; 4 | import codechicken.lib.gui.modular.ModularGuiContainer; 5 | import codechicken.lib.gui.modular.lib.GuiProvider; 6 | import net.minecraft.client.gui.screens.inventory.MenuAccess; 7 | import net.minecraft.world.inventory.AbstractContainerMenu; 8 | 9 | /** 10 | * Created by brandon3055 on 08/09/2023 11 | */ 12 | public abstract class ContainerGuiProvider implements GuiProvider { 13 | 14 | private ContainerScreenAccess screenAccess; 15 | 16 | public void setMenuAccess(ContainerScreenAccess screenAccess) { 17 | this.screenAccess = screenAccess; 18 | } 19 | 20 | @Override 21 | public final void buildGui(ModularGui gui) { 22 | buildGui(gui, screenAccess); 23 | } 24 | 25 | /** 26 | * This is the same as {@link GuiProvider#buildGui(ModularGui)} except you have access to the {@link MenuAccess} 27 | * The given menu accessor should always be the parent screen unless your using some custom modular gui implementation. 28 | * 29 | * @param gui The modular gui instance. 30 | * @param screenAccess The screen access (This will be a gui class that extends {@link ModularGuiContainer} 31 | */ 32 | public abstract void buildGui(ModularGui gui, ContainerScreenAccess screenAccess); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/LightingAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline.attribute; 2 | 3 | import codechicken.lib.colour.ColourRGBA; 4 | import codechicken.lib.render.CCRenderState; 5 | import codechicken.lib.render.pipeline.VertexAttribute; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Created by covers1624 on 10/10/2016. 10 | */ 11 | public class LightingAttribute extends VertexAttribute { 12 | 13 | public static final AttributeKey attributeKey = AttributeKey.create("lighting", int[]::new); 14 | 15 | private int @Nullable [] colourRef; 16 | 17 | public LightingAttribute() { 18 | super(attributeKey); 19 | } 20 | 21 | @Override 22 | public boolean load(CCRenderState ccrs) { 23 | assert ccrs.cFmt != null; 24 | assert ccrs.model != null; 25 | 26 | if (!ccrs.computeLighting || !ccrs.cFmt.hasColor || !ccrs.model.hasAttribute(attributeKey)) { 27 | return false; 28 | } 29 | 30 | colourRef = ccrs.model.getAttribute(attributeKey); 31 | if (colourRef != null) { 32 | ccrs.pipeline.addDependency(ccrs.colourAttrib); 33 | return true; 34 | } 35 | return false; 36 | } 37 | 38 | @Override 39 | public void operate(CCRenderState ccrs) { 40 | assert colourRef != null; 41 | ccrs.colour = ColourRGBA.multiply(ccrs.colour, colourRef[ccrs.vertexIndex]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/AxisCycle.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | public class AxisCycle { 4 | 5 | public static Transformation[] cycles = new Transformation[] { 6 | RedundantTransformation.INSTANCE, 7 | new VariableTransformation(new Matrix4(0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)) { 8 | @Override 9 | public void apply(Vector3 vec) { 10 | double d0 = vec.x; 11 | double d1 = vec.y; 12 | double d2 = vec.z; 13 | vec.x = d2; 14 | vec.y = d0; 15 | vec.z = d1; 16 | } 17 | 18 | @Override 19 | public Transformation inverse() { 20 | return cycles[2]; 21 | } 22 | }, 23 | new VariableTransformation(new Matrix4(0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1)) { 24 | @Override 25 | public void apply(Vector3 vec) { 26 | double d0 = vec.x; 27 | double d1 = vec.y; 28 | double d2 = vec.z; 29 | vec.x = d1; 30 | vec.y = d2; 31 | vec.z = d0; 32 | } 33 | 34 | @Override 35 | public Transformation inverse() { 36 | return cycles[1]; 37 | } 38 | } 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/AssetShaderObject.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraft.server.packs.resources.ResourceManager; 5 | import net.minecraft.server.packs.resources.ResourceManagerReloadListener; 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.Collection; 11 | import java.util.Objects; 12 | 13 | /** 14 | * Created by covers1624 on 24/5/20. 15 | */ 16 | public class AssetShaderObject extends AbstractShaderObject implements ResourceManagerReloadListener { 17 | 18 | private static final Logger LOGGER = LogManager.getLogger(); 19 | 20 | private final ResourceLocation asset; 21 | @Nullable 22 | private String source; 23 | 24 | public AssetShaderObject(String name, ShaderType type, Collection uniforms, ResourceLocation asset) { 25 | super(name, type, uniforms); 26 | this.asset = Objects.requireNonNull(asset); 27 | } 28 | 29 | @Override 30 | protected String getSource() { 31 | if (source == null) { 32 | source = new GlslProcessor(asset).process().processedSource(); 33 | } 34 | 35 | return source; 36 | } 37 | 38 | @Override 39 | public void onResourceManagerReload(ResourceManager resourceManager) { 40 | source = null; 41 | dirty = true; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/TileChunkLoadHook.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal; 2 | 3 | import codechicken.lib.world.IChunkLoadTile; 4 | import net.covers1624.quack.util.CrashLock; 5 | import net.minecraft.world.level.block.entity.BlockEntity; 6 | import net.minecraft.world.level.chunk.ChunkAccess; 7 | import net.minecraft.world.level.chunk.ImposterProtoChunk; 8 | import net.minecraft.world.level.chunk.LevelChunk; 9 | import net.neoforged.neoforge.common.NeoForge; 10 | import net.neoforged.neoforge.event.level.ChunkEvent; 11 | 12 | public class TileChunkLoadHook { 13 | 14 | private static final CrashLock LOCK = new CrashLock("Already Initialized."); 15 | 16 | public static void init() { 17 | LOCK.lock(); 18 | 19 | NeoForge.EVENT_BUS.addListener(TileChunkLoadHook::onChunkLoad); 20 | } 21 | 22 | private static void onChunkLoad(ChunkEvent.Load event) { 23 | ChunkAccess iChunk = event.getChunk(); 24 | LevelChunk chunk; 25 | if (iChunk instanceof LevelChunk) { 26 | chunk = (LevelChunk) iChunk; 27 | } else if (iChunk instanceof ImposterProtoChunk) { 28 | chunk = ((ImposterProtoChunk) iChunk).getWrapped(); 29 | } else { 30 | return; 31 | } 32 | 33 | for (BlockEntity tile : chunk.getBlockEntities().values()) { 34 | if (tile instanceof IChunkLoadTile) { 35 | ((IChunkLoadTile) tile).onChunkLoad(chunk); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/packet/SimpleClientPacketHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.packet; 2 | 3 | import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; 4 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.multiplayer.ClientPacketListener; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | 10 | import static codechicken.lib.packet.ICustomPacketHandler.IClientPacketHandler; 11 | 12 | /** 13 | * Created by covers1624 on 21/5/20. 14 | */ 15 | public class SimpleClientPacketHandler implements IClientPacketHandler { 16 | 17 | private static final Logger LOGGER = LogManager.getLogger(); 18 | 19 | private static final Int2ObjectMap handlers = new Int2ObjectArrayMap<>(); 20 | 21 | protected void addHandler(int id, IClientPacketHandler handler) { 22 | if (handlers.containsKey(id)) { 23 | throw new IllegalArgumentException("Handler already registered for ID: " + id); 24 | } 25 | handlers.put(id, handler); 26 | } 27 | 28 | @Override 29 | public void handlePacket(PacketCustom packet, Minecraft mc) { 30 | IClientPacketHandler h = handlers.get(packet.getType()); 31 | if (h != null) { 32 | h.handlePacket(packet, mc); 33 | } else { 34 | LOGGER.warn("Received unknown packet on channel '{}' with descriptor '{}'.", packet.getChannel(), packet.getType()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/ItemQuadBakery.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model; 2 | 3 | import com.mojang.math.Transformation; 4 | import net.minecraft.client.renderer.block.model.BakedQuad; 5 | import net.minecraft.client.renderer.block.model.BlockElement; 6 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 7 | import net.minecraft.client.resources.model.ModelState; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.neoforged.neoforge.client.model.SimpleModelState; 10 | import net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper; 11 | 12 | import java.util.LinkedList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by covers1624 on 13/02/2017. 17 | */ 18 | public class ItemQuadBakery { 19 | 20 | public static final SimpleModelState IDENTITY = new SimpleModelState(Transformation.identity()); 21 | 22 | public static List bakeItem(TextureAtlasSprite... sprites) { 23 | return bakeItem(IDENTITY, sprites); 24 | } 25 | 26 | public static List bakeItem(ModelState state, TextureAtlasSprite... sprites) { 27 | List quads = new LinkedList<>(); 28 | for (int i = 0; i < sprites.length; i++) { 29 | TextureAtlasSprite sprite = sprites[i]; 30 | List unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite); 31 | quads.addAll(UnbakedGeometryHelper.bakeElements(unbaked, e -> sprite, state)); 32 | } 33 | return quads; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/DynamicTextures.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | 5 | import java.util.function.Function; 6 | 7 | /** 8 | * Designed for use with DynamicTextureProvider 9 | *

10 | * Created by brandon3055 on 07/09/2023 11 | */ 12 | public interface DynamicTextures { 13 | 14 | void makeTextures(Function textures); 15 | 16 | default String dynamicTexture(Function textures, ResourceLocation dynamicInput, ResourceLocation outputLocation, int width, int height, int border) { 17 | return textures.apply(new DynamicTexture(dynamicInput, outputLocation, width, height, border, border, border, border)); 18 | } 19 | 20 | default String dynamicTexture(Function textures, ResourceLocation dynamicInput, ResourceLocation outputLocation, int width, int height, int topBorder, int leftBorder, int bottomBorder, int rightBorder) { 21 | return textures.apply(new DynamicTexture(dynamicInput, outputLocation, width, height, topBorder, leftBorder, bottomBorder, rightBorder)); 22 | } 23 | 24 | record DynamicTexture(ResourceLocation dynamicInput, ResourceLocation outputLocation, int width, int height, int topBorder, int leftBorder, int bottomBorder, int rightBorder) { 25 | public String guiTexturePath() { 26 | return outputLocation.getPath().replace("textures/gui/", "").replace(".gui", ""); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/PerspectiveModelState.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model; 2 | 3 | import codechicken.lib.util.TransformUtils; 4 | import com.google.common.collect.ImmutableMap; 5 | import com.mojang.math.Transformation; 6 | import net.minecraft.client.resources.model.ModelState; 7 | import net.minecraft.world.item.ItemDisplayContext; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * A simple {@link ModelState} implementation which 13 | * is composed of multiple {@link Transformation}s. 14 | *

15 | * Created by covers1624 on 9/7/22. 16 | * @see TransformUtils 17 | */ 18 | public class PerspectiveModelState implements ModelState { 19 | 20 | public static final PerspectiveModelState IDENTITY = new PerspectiveModelState(ImmutableMap.of()); 21 | 22 | private final Map transforms; 23 | private final boolean isUvLocked; 24 | 25 | public PerspectiveModelState(Map transforms) { 26 | this(transforms, false); 27 | } 28 | 29 | public PerspectiveModelState(Map transforms, boolean isUvLocked) { 30 | this.transforms = ImmutableMap.copyOf(transforms); 31 | this.isUvLocked = isUvLocked; 32 | } 33 | 34 | public Transformation getTransform(ItemDisplayContext context) { 35 | return transforms.getOrDefault(context, Transformation.identity()); 36 | } 37 | 38 | @Override 39 | public boolean isUvLocked() { 40 | return isUvLocked; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/IVertexOperation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | 5 | /** 6 | * Represents an operation to be run for each vertex that operates on and modifies the current state 7 | */ 8 | public interface IVertexOperation { 9 | 10 | static int registerOperation() { 11 | return VertexOperationRegistry.nextOperationIndex(); 12 | } 13 | 14 | static int operationCount() { 15 | return VertexOperationRegistry.nextOperationIndex; 16 | } 17 | 18 | /** 19 | * Load any required references and add dependencies to the pipeline based on the current model (may be null) 20 | * Return false if this operation is redundant in the pipeline with the given model 21 | */ 22 | boolean load(CCRenderState ccrs); 23 | 24 | /** 25 | * Perform the operation on the current render state 26 | */ 27 | void operate(CCRenderState ccrs); 28 | 29 | /** 30 | * Get the unique id representing this type of operation. Duplicate operation IDs within the pipeline may have unexpected results. 31 | * ID should be obtained from CCRenderState.registerOperation() and stored in a static variable 32 | */ 33 | int operationID(); 34 | 35 | class VertexOperationRegistry { 36 | 37 | static int nextOperationIndex; 38 | 39 | private static synchronized int nextOperationIndex() { 40 | return VertexOperationRegistry.nextOperationIndex++; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/packet/SimpleServerPacketHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.packet; 2 | 3 | import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; 4 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.server.network.ServerGamePacketListenerImpl; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | 10 | import static codechicken.lib.packet.ICustomPacketHandler.IServerPacketHandler; 11 | 12 | /** 13 | * Created by covers1624 on 21/5/20. 14 | */ 15 | public class SimpleServerPacketHandler implements IServerPacketHandler { 16 | 17 | private static final Logger LOGGER = LogManager.getLogger(); 18 | 19 | private static final Int2ObjectMap handlers = new Int2ObjectArrayMap<>(); 20 | 21 | protected void addHandler(int id, IServerPacketHandler handler) { 22 | if (handlers.containsKey(id)) { 23 | throw new IllegalArgumentException("Handler already registered for ID: " + id); 24 | } 25 | handlers.put(id, handler); 26 | } 27 | 28 | @Override 29 | public void handlePacket(PacketCustom packet, ServerPlayer sender) { 30 | IServerPacketHandler h = handlers.get(packet.getType()); 31 | if (h != null) { 32 | h.handlePacket(packet, sender); 33 | } else { 34 | LOGGER.warn("Received unknown packet on channel '{}' with descriptor '{}'.", packet.getChannel(), packet.getType()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/ShaderConstantCache.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import it.unimi.dsi.fastutil.ints.Int2IntArrayMap; 4 | 5 | /** 6 | * Created by KitsuneAlex on 19/11/21. 7 | */ 8 | public class ShaderConstantCache implements ConstantCache { 9 | 10 | private final Int2IntArrayMap values = new Int2IntArrayMap(); 11 | 12 | @Override 13 | public void constant1i(int id, int value) { 14 | if (id < 0) throw new IllegalArgumentException("Constant location ID must be >= 0"); 15 | 16 | int oldValue = values.get(id); 17 | if (oldValue == value) return; 18 | 19 | values.put(id, value); 20 | } 21 | 22 | @Override 23 | public void constant1f(int id, float value) { 24 | if (id < 0) throw new IllegalArgumentException("Constant location ID must be >= 0"); 25 | 26 | float oldValue = Float.intBitsToFloat(values.get(id)); 27 | if (oldValue == value) return; 28 | 29 | values.put(id, Float.floatToIntBits(value)); 30 | } 31 | 32 | @Override 33 | public void constant1b(int id, boolean value) { 34 | if (id < 0) throw new IllegalArgumentException("Constant location ID must be >= 0"); 35 | 36 | boolean oldValue = values.get(id) == 1; 37 | if (oldValue == value) return; 38 | 39 | values.put(id, value ? 1 : 0); 40 | } 41 | 42 | public int[] getIndices() { 43 | return values.keySet().toIntArray(); 44 | } 45 | 46 | public int[] getValues() { 47 | return values.values().toIntArray(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/BackgroundRender.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | 5 | /** 6 | * Allows a Gui Elements to render content behind child elements. 7 | * This is the default render mode for the majority of elements. 8 | *

9 | * Created by brandon3055 on 07/08/2023 10 | */ 11 | public interface BackgroundRender { 12 | 13 | /** 14 | * Specifies the z depth of the background content. 15 | * After {@link #renderBackground(GuiRender, double, double, float)} is called, the PoseStack will be translated by this amount in the z direction 16 | * before any assigned child elements are rendered. 17 | * Recommended minimum depth is 0.01 or 0.035 if this element renders text. (text shadows are rendered with a 0.03 offset) 18 | * 19 | * @return the z height of the background content. 20 | */ 21 | default double getBackgroundDepth() { 22 | return 0.01; 23 | } 24 | 25 | /** 26 | * Used to render content behind this elements child elements. 27 | * When rendering element content, always use the {@link PoseStack} available via the provided {@link GuiRender} 28 | * Where applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete. 29 | * 30 | * @param render Contains gui context information as well as essential render methods/utils including the PoseStack. 31 | */ 32 | void renderBackground(GuiRender render, double mouseX, double mouseY, float partialTicks); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/network/ClientPacketHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.network; 2 | 3 | import codechicken.lib.inventory.container.modular.ModularGuiContainerMenu; 4 | import codechicken.lib.packet.ICustomPacketHandler.IClientPacketHandler; 5 | import codechicken.lib.packet.PacketCustom; 6 | import codechicken.lib.render.particle.CustomParticleHandler; 7 | import codechicken.lib.vec.Vector3; 8 | import net.minecraft.client.Minecraft; 9 | import net.minecraft.core.BlockPos; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | 12 | import static codechicken.lib.internal.network.CCLNetwork.C_ADD_LANDING_EFFECTS; 13 | import static codechicken.lib.internal.network.CCLNetwork.C_GUI_SYNC; 14 | import static java.util.Objects.requireNonNull; 15 | 16 | /** 17 | * Created by covers1624 on 14/07/2017. 18 | */ 19 | public class ClientPacketHandler implements IClientPacketHandler { 20 | 21 | @Override 22 | public void handlePacket(PacketCustom packet, Minecraft mc) { 23 | switch (packet.getType()) { 24 | case C_ADD_LANDING_EFFECTS -> { 25 | BlockPos pos = packet.readPos(); 26 | Vector3 vec = packet.readVector(); 27 | int numParticles = packet.readVarInt(); 28 | BlockState state = requireNonNull(mc.level).getBlockState(pos); 29 | CustomParticleHandler.addLandingEffects(mc.level, pos, state, vec, numParticles); 30 | } 31 | case C_GUI_SYNC -> ModularGuiContainerMenu.handlePacketFromServer(requireNonNull(mc.player), packet); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/LightCoordAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline.attribute; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.lighting.LC; 5 | import codechicken.lib.render.pipeline.VertexAttribute; 6 | import codechicken.lib.vec.Transformation; 7 | import codechicken.lib.vec.Vector3; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Uses the position of the lightmatrix to compute LC if not provided 12 | */ 13 | public class LightCoordAttribute extends VertexAttribute { 14 | 15 | public static final AttributeKey attributeKey = AttributeKey.create("light_coord", LC[]::new); 16 | 17 | private final Vector3 vec = new Vector3(); // for computation 18 | 19 | private LC @Nullable [] lcRef; 20 | 21 | public LightCoordAttribute() { 22 | super(attributeKey); 23 | } 24 | 25 | @Override 26 | public boolean load(CCRenderState ccrs) { 27 | assert ccrs.model != null; 28 | 29 | lcRef = ccrs.model.getAttribute(attributeKey); 30 | if (ccrs.model.hasAttribute(attributeKey)) { 31 | return lcRef != null; 32 | } 33 | 34 | ccrs.pipeline.addDependency(ccrs.sideAttrib); 35 | ccrs.pipeline.addRequirement(Transformation.operationIndex); 36 | return true; 37 | } 38 | 39 | @Override 40 | public void operate(CCRenderState ccrs) { 41 | if (lcRef != null) { 42 | ccrs.lc.set(lcRef[ccrs.vertexIndex]); 43 | } else { 44 | ccrs.lc.compute(vec.set(ccrs.vert.vec), ccrs.side); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/command/client/ItemInfoCommand.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.command.client; 2 | 3 | import com.mojang.brigadier.CommandDispatcher; 4 | import com.mojang.brigadier.context.CommandContext; 5 | import net.minecraft.commands.CommandSourceStack; 6 | import net.minecraft.core.registries.BuiltInRegistries; 7 | import net.minecraft.network.chat.Component; 8 | import net.minecraft.world.entity.EquipmentSlot; 9 | import net.minecraft.world.entity.player.Player; 10 | import net.minecraft.world.item.ItemStack; 11 | 12 | import static net.minecraft.commands.Commands.literal; 13 | 14 | /** 15 | * Created by covers1624 on 2/9/22. 16 | */ 17 | public class ItemInfoCommand { 18 | 19 | public static void register(CommandDispatcher dispatcher) { 20 | dispatcher.register(literal("ccl") 21 | .then(literal("item_info") 22 | .executes(ItemInfoCommand::execute) 23 | ) 24 | ); 25 | } 26 | 27 | private static int execute(CommandContext command) { 28 | CommandSourceStack ctx = command.getSource(); 29 | Player player = command.getSource().getPlayer(); 30 | ItemStack stack = player.hasItemInSlot(EquipmentSlot.MAINHAND) ? player.getMainHandItem() : player.getOffhandItem(); 31 | if (stack.isEmpty()) return 0; 32 | 33 | ctx.sendSuccess(() -> Component.literal("Registry Name: " + BuiltInRegistries.ITEM.getKey(stack.getItem())), false); 34 | ctx.sendSuccess(() -> Component.literal("Components : " + stack.getComponents()), false); 35 | return 0; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/CCLMixinPlugin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | /** 12 | * Created by covers1624 on 13/11/23. 13 | */ 14 | public class CCLMixinPlugin implements IMixinConfigPlugin { 15 | 16 | private static final boolean USE_DEV_MIXINS = Boolean.getBoolean("ccl.dev.mixins"); 17 | 18 | @Override 19 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 20 | // Don't load development mixins unless explicitly enabled. 21 | // These mixins are usually quite hacky/aggressive and accomplish specific things for my dev environment. 22 | return !mixinClassName.startsWith("codechicken.lib.internal.mixin.dev") || USE_DEV_MIXINS; 23 | } 24 | 25 | // @formatter:off 26 | @Override public void onLoad(String mixinPackage) { } 27 | @Nullable @Override public String getRefMapperConfig() { return null; } 28 | @Override public void acceptTargets(Set myTargets, Set otherTargets) { } 29 | @Nullable @Override public List getMixins() { return null; } 30 | @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { } 31 | @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { } 32 | // @formatter:on 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/DummyBakedModel.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model; 2 | 3 | import codechicken.lib.texture.TextureUtils; 4 | import net.minecraft.client.renderer.block.model.BakedQuad; 5 | import net.minecraft.client.renderer.block.model.ItemOverrides; 6 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 7 | import net.minecraft.client.resources.model.BakedModel; 8 | import net.minecraft.core.Direction; 9 | import net.minecraft.util.RandomSource; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.Collections; 14 | import java.util.List; 15 | 16 | /** 17 | * Simple dummy model. 18 | * Created by covers1624 on 7/25/2016. 19 | */ 20 | public class DummyBakedModel implements BakedModel { 21 | 22 | @Override 23 | public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) { 24 | return Collections.emptyList(); 25 | } 26 | 27 | @Override 28 | public boolean useAmbientOcclusion() { 29 | return false; 30 | } 31 | 32 | @Override 33 | public boolean isGui3d() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public boolean usesBlockLight() { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean isCustomRenderer() { 44 | return false; 45 | } 46 | 47 | @Override 48 | public TextureAtlasSprite getParticleIcon() { 49 | return TextureUtils.getMissingSprite(); 50 | } 51 | 52 | @Override 53 | public ItemOverrides getOverrides() { 54 | return ItemOverrides.EMPTY; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/raytracer/IndexedVoxelShape.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.raytracer; 2 | 3 | import it.unimi.dsi.fastutil.doubles.DoubleList; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.phys.BlockHitResult; 7 | import net.minecraft.world.phys.Vec3; 8 | import net.minecraft.world.phys.shapes.VoxelShape; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | /** 12 | * A VoxelShape implementation, produces a {@link VoxelShapeBlockHitResult} when ray traced. 13 | * {@link IndexedVoxelShape#data} will be passed through to {@link VoxelShapeBlockHitResult#hitInfo} and 14 | * to {@link VoxelShapeBlockHitResult#subHit} if it's an integer. 15 | *

16 | * Created by covers1624 on 5/12/20. 17 | */ 18 | public class IndexedVoxelShape extends VoxelShape { 19 | 20 | private final VoxelShape parent; 21 | private final Object data; 22 | 23 | public IndexedVoxelShape(VoxelShape parent, Object data) { 24 | super(parent.shape); 25 | this.parent = parent; 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public DoubleList getCoords(Direction.Axis axis) { 31 | return parent.getCoords(axis); 32 | } 33 | 34 | @Nullable 35 | @Override 36 | public VoxelShapeBlockHitResult clip(Vec3 start, Vec3 end, BlockPos pos) { 37 | BlockHitResult result = parent.clip(start, end, pos); 38 | if (result == null) return null; 39 | double dist = result.getLocation().distanceToSqr(start); 40 | return new VoxelShapeBlockHitResult(result, this, dist); 41 | } 42 | 43 | public Object getData() { 44 | return data; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/attribute/NormalAttribute.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline.attribute; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.VertexAttribute; 5 | import codechicken.lib.vec.Rotation; 6 | import codechicken.lib.vec.Vector3; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * Apples normals to the render operation. If the model is a planar model it uses known normals. 11 | */ 12 | public class NormalAttribute extends VertexAttribute { 13 | 14 | public static final AttributeKey attributeKey = AttributeKey.create("normal", Vector3[]::new); 15 | 16 | private Vector3 @Nullable [] normalRef; 17 | 18 | public NormalAttribute() { 19 | super(attributeKey); 20 | } 21 | 22 | @Override 23 | public boolean load(CCRenderState ccrs) { 24 | assert ccrs.model != null; 25 | 26 | normalRef = ccrs.model.getAttribute(attributeKey); 27 | if (ccrs.model.hasAttribute(attributeKey)) { 28 | return normalRef != null; 29 | } 30 | 31 | if (ccrs.model.hasAttribute(SideAttribute.attributeKey)) { 32 | ccrs.pipeline.addDependency(ccrs.sideAttrib); 33 | return true; 34 | } 35 | throw new IllegalStateException("Normals requested but neither normal or side attrutes are provided by the model"); 36 | } 37 | 38 | @Override 39 | public void operate(CCRenderState ccrs) { 40 | if (normalRef != null) { 41 | ccrs.normal.set(normalRef[ccrs.vertexIndex]); 42 | } else { 43 | ccrs.normal.set(Rotation.axes[ccrs.side]); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/shader/AbstractShaderObject.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.shader; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.lwjgl.opengl.GL20; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * Created by covers1624 on 24/5/20. 10 | */ 11 | public abstract class AbstractShaderObject extends NamedShaderObject { 12 | 13 | protected int shaderId = -1; 14 | protected boolean dirty; 15 | 16 | protected AbstractShaderObject(String name, ShaderType type, Collection uniforms) { 17 | super(name, type, uniforms); 18 | } 19 | 20 | @Override 21 | public boolean isDirty() { 22 | return dirty; 23 | } 24 | 25 | @Override 26 | public void alloc() { 27 | if (dirty || shaderId == -1) { 28 | if (shaderId == -1) { 29 | shaderId = GL20.glCreateShader(getShaderType().getGLCode()); 30 | if (shaderId == 0) { 31 | throw new RuntimeException("Allocation of ShaderObject failed."); 32 | } 33 | } 34 | GL20.glShaderSource(shaderId, getSource()); 35 | GL20.glCompileShader(shaderId); 36 | if (GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { 37 | throw new RuntimeException("ShaderProgram linkage failure. \n" + GL20.glGetShaderInfoLog(shaderId)); 38 | } 39 | dirty = false; 40 | } 41 | } 42 | 43 | @Override 44 | public int getShaderID() { 45 | return shaderId; 46 | } 47 | 48 | @Override 49 | public void onLink(int programId) { 50 | 51 | } 52 | 53 | protected abstract String getSource(); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/UVTranslation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.math.MathHelper; 4 | 5 | import java.math.BigDecimal; 6 | import java.math.MathContext; 7 | import java.math.RoundingMode; 8 | 9 | public class UVTranslation extends UVTransformation { 10 | 11 | public double du; 12 | public double dv; 13 | 14 | public UVTranslation(double u, double v) { 15 | du = u; 16 | dv = v; 17 | } 18 | 19 | public UVTranslation(UVTranslation other) { 20 | this(other.du, other.dv); 21 | } 22 | 23 | @Override 24 | public void apply(UV uv) { 25 | uv.u += du; 26 | uv.v += dv; 27 | } 28 | 29 | @Override 30 | public UVTransformation at(UV point) { 31 | return this; 32 | } 33 | 34 | @Override 35 | public UVTransformation inverse() { 36 | return new UVTranslation(-du, -dv); 37 | } 38 | 39 | @Override 40 | public UVTransformation merge(UVTransformation next) { 41 | if (next instanceof UVTranslation t) { 42 | return new UVTranslation(du + t.du, dv + t.dv); 43 | } 44 | 45 | return null; 46 | } 47 | 48 | @Override 49 | public boolean isRedundant() { 50 | return MathHelper.between(-1E-5, du, 1E-5) && MathHelper.between(-1E-5, dv, 1E-5); 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 56 | return "UVTranslation(" + new BigDecimal(du, cont) + ", " + new BigDecimal(dv, cont) + ")"; 57 | } 58 | 59 | @Override 60 | public UVTranslation copy() { 61 | return new UVTranslation(this); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/TextState.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import codechicken.lib.gui.modular.elements.GuiTextField; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import java.util.function.Consumer; 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * The primary interface for managing getting and setting the text in a {@link GuiTextField} 11 | *

12 | * Created by brandon3055 on 03/09/2023 13 | */ 14 | public interface TextState { 15 | 16 | String getText(); 17 | 18 | void setText(String text); 19 | 20 | static TextState simpleState(String defaultValue) { 21 | return simpleState(defaultValue, null); 22 | } 23 | 24 | static TextState simpleState(String defaultValue, @Nullable Consumer changeListener) { 25 | return new TextState() { 26 | private String value = defaultValue; 27 | 28 | @Override 29 | public String getText() { 30 | return value; 31 | } 32 | 33 | @Override 34 | public void setText(String text) { 35 | this.value = text; 36 | if (changeListener != null) { 37 | changeListener.accept(value); 38 | } 39 | } 40 | }; 41 | } 42 | 43 | static TextState create(Supplier getValue, Consumer setValue) { 44 | return new TextState() { 45 | @Override 46 | public String getText() { 47 | return getValue.get(); 48 | } 49 | 50 | @Override 51 | public void setText(String text) { 52 | setValue.accept(text); 53 | } 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/command/dev/DevCommands.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.command.dev; 2 | 3 | import com.mojang.brigadier.CommandDispatcher; 4 | import com.mojang.brigadier.context.CommandContext; 5 | import net.minecraft.commands.CommandBuildContext; 6 | import net.minecraft.commands.CommandSourceStack; 7 | import net.minecraft.server.MinecraftServer; 8 | import net.minecraft.server.level.ServerLevel; 9 | import net.minecraft.world.level.GameRules; 10 | 11 | import static net.minecraft.commands.Commands.literal; 12 | 13 | /** 14 | * Created by covers1624 on 11/12/21. 15 | */ 16 | public class DevCommands { 17 | 18 | public static void register(CommandDispatcher dispatcher, CommandBuildContext context) { 19 | dispatcher.register(literal("ccl") 20 | .then(literal("setup_dev_world") 21 | .requires(e -> e.hasPermission(4)) 22 | .executes(DevCommands::setupWorld) 23 | ) 24 | ); 25 | } 26 | 27 | private static int setupWorld(CommandContext ctx) { 28 | CommandSourceStack source = ctx.getSource(); 29 | MinecraftServer server = source.getServer(); 30 | GameRules gameRules = server.getGameRules(); 31 | 32 | for (ServerLevel level : server.getAllLevels()) { 33 | level.setWeatherParameters(6000, 0, false, false); 34 | } 35 | 36 | gameRules.getRule(GameRules.RULE_DAYLIGHT) 37 | .set(false, server); 38 | gameRules.getRule(GameRules.RULE_WEATHER_CYCLE) 39 | .set(false, server); 40 | gameRules.getRule(GameRules.RULE_DO_TRADER_SPAWNING) 41 | .set(false, server); 42 | return 0; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/PerspectiveModel.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model; 2 | 3 | import codechicken.lib.util.TransformUtils; 4 | import com.mojang.blaze3d.vertex.PoseStack; 5 | import com.mojang.math.Transformation; 6 | import net.minecraft.client.resources.model.BakedModel; 7 | import net.minecraft.world.item.ItemDisplayContext; 8 | import org.jetbrains.annotations.Nullable; 9 | import org.joml.Vector3f; 10 | 11 | /** 12 | * A simple {@link BakedModel} implementation, with automatic handling of 13 | * {@link PerspectiveModelState}s. 14 | *

15 | * Created by covers1624 on 9/7/22. 16 | * 17 | * @see TransformUtils 18 | */ 19 | public interface PerspectiveModel extends BakedModel { 20 | 21 | /** 22 | * The {@link PerspectiveModelState} for this model. 23 | * 24 | * @return The state or {@code null} for vanilla behaviour. 25 | */ 26 | @Nullable 27 | PerspectiveModelState getModelState(); 28 | 29 | @Override 30 | default BakedModel applyTransform(ItemDisplayContext context, PoseStack pStack, boolean leftFlip) { 31 | PerspectiveModelState modelState = getModelState(); 32 | if (modelState != null) { 33 | Transformation transform = getModelState().getTransform(context); 34 | 35 | Vector3f trans = transform.getTranslation(); 36 | pStack.translate(trans.x(), trans.y(), trans.z()); 37 | 38 | pStack.mulPose(transform.getLeftRotation()); 39 | 40 | Vector3f scale = transform.getScale(); 41 | pStack.scale(scale.x(), scale.y(), scale.z()); 42 | 43 | pStack.mulPose(transform.getRightRotation()); 44 | return this; 45 | } 46 | return BakedModel.super.applyTransform(context, pStack, leftFlip); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/Transformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.IVertexOperation; 5 | 6 | /** 7 | * Abstract supertype for any 3D vector transformation 8 | */ 9 | public abstract class Transformation extends ITransformation implements IVertexOperation { 10 | 11 | public static final int operationIndex = IVertexOperation.registerOperation(); 12 | 13 | /** 14 | * Applies this transformation to a normal (doesn't translate) 15 | * 16 | * @param normal The normal to transform 17 | */ 18 | public abstract void applyN(Vector3 normal); 19 | 20 | /** 21 | * Applies this transformation to a matrix as a multiplication on the right hand side. 22 | * 23 | * @param mat The matrix to combine this transformation with 24 | */ 25 | public abstract void apply(Matrix4 mat); 26 | 27 | public Transformation at(Vector3 point) { 28 | return new TransformationList(new Translation(-point.x, -point.y, -point.z), this, point.translation()); 29 | } 30 | 31 | public TransformationList with(Transformation t) { 32 | return new TransformationList(this, t); 33 | } 34 | 35 | @Override 36 | public boolean load(CCRenderState ccrs) { 37 | ccrs.pipeline.addRequirement(ccrs.normalAttrib.operationID()); 38 | return !isRedundant(); 39 | } 40 | 41 | @Override 42 | public void operate(CCRenderState ccrs) { 43 | apply(ccrs.vert.vec); 44 | if (ccrs.normalAttrib.active) { 45 | applyN(ccrs.normal); 46 | } 47 | } 48 | 49 | @Override 50 | public int operationID() { 51 | return operationIndex; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/UVRotation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.math.MathHelper; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import java.math.BigDecimal; 7 | import java.math.MathContext; 8 | import java.math.RoundingMode; 9 | 10 | public class UVRotation extends UVTransformation { 11 | 12 | public double angle; 13 | 14 | /** 15 | * @param angle The angle to rotate counterclockwise in radians 16 | */ 17 | public UVRotation(double angle) { 18 | this.angle = angle; 19 | } 20 | 21 | public UVRotation(UVRotation other) { 22 | this(other.angle); 23 | } 24 | 25 | @Override 26 | public void apply(UV uv) { 27 | double c = Math.cos(angle); 28 | double s = Math.sin(angle); 29 | double u2 = c * uv.u + s * uv.v; 30 | uv.v = -s * uv.u + c * uv.v; 31 | uv.u = u2; 32 | } 33 | 34 | @Override 35 | public UVTransformation inverse() { 36 | return new UVRotation(-angle); 37 | } 38 | 39 | @Nullable 40 | @Override 41 | public UVTransformation merge(UVTransformation next) { 42 | if (next instanceof UVRotation) { 43 | return new UVRotation(angle + ((UVRotation) next).angle); 44 | } 45 | 46 | return null; 47 | } 48 | 49 | @Override 50 | public boolean isRedundant() { 51 | return MathHelper.between(-1E-5, angle, 1E-5); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 57 | return "UVRotation(" + new BigDecimal(angle, cont) + ")"; 58 | } 59 | 60 | @Override 61 | public UVRotation copy() { 62 | return new UVRotation(this); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/container/DataSync.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib.container; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.inventory.container.data.AbstractDataStore; 5 | import codechicken.lib.inventory.container.modular.ModularGuiContainerMenu; 6 | 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * This class provides a convenient way to synchronize server side data with a client side screen via the ContainerMenu 11 | *

12 | * Created by brandon3055 on 09/09/2023 13 | */ 14 | public class DataSync { 15 | public static final int PKT_SEND_CHANGES = 255; 16 | private final ModularGuiContainerMenu containerMenu; 17 | private final AbstractDataStore dataStore; 18 | private final Supplier valueGetter; 19 | 20 | public DataSync(ModularGuiContainerMenu containerMenu, AbstractDataStore dataStore, Supplier valueGetter) { 21 | this.containerMenu = containerMenu; 22 | this.dataStore = dataStore; 23 | this.valueGetter = valueGetter; 24 | containerMenu.dataSyncs.add(this); 25 | } 26 | 27 | public T get() { 28 | return dataStore.get(); 29 | } 30 | 31 | /** 32 | * This should only ever be called server side! 33 | */ 34 | public void detectAndSend() { 35 | if (dataStore.isSameValue(valueGetter.get())) { 36 | return; 37 | } 38 | dataStore.set(valueGetter.get()); 39 | containerMenu.sendPacketToClient(PKT_SEND_CHANGES, buf -> { 40 | buf.writeByte((byte) containerMenu.dataSyncs.indexOf(this)); 41 | dataStore.toBytes(buf); 42 | }); 43 | } 44 | 45 | public void handleSyncPacket(MCDataInput buf) { 46 | dataStore.fromBytes(buf); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/bakedmodels/OverrideListModel.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.model.bakedmodels; 2 | 3 | import codechicken.lib.texture.TextureUtils; 4 | import net.minecraft.client.renderer.block.model.BakedQuad; 5 | import net.minecraft.client.renderer.block.model.ItemOverrides; 6 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 7 | import net.minecraft.client.resources.model.BakedModel; 8 | import net.minecraft.core.Direction; 9 | import net.minecraft.util.RandomSource; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.Collections; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by covers1624 on 29/06/2017. 18 | */ 19 | public class OverrideListModel implements BakedModel { 20 | 21 | private final ItemOverrides overrides; 22 | 23 | public OverrideListModel(ItemOverrides overrides) { 24 | this.overrides = overrides; 25 | } 26 | 27 | @Override 28 | public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) { 29 | return Collections.emptyList(); 30 | } 31 | 32 | @Override 33 | public boolean useAmbientOcclusion() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public boolean isGui3d() { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean usesBlockLight() { 44 | return false; 45 | } 46 | 47 | @Override 48 | public boolean isCustomRenderer() { 49 | return false; 50 | } 51 | 52 | @Override 53 | public TextureAtlasSprite getParticleIcon() { 54 | return TextureUtils.getMissingSprite(); 55 | } 56 | 57 | @Override 58 | public ItemOverrides getOverrides() { 59 | return overrides; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/buffer/DelegatingVertexConsumer.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.buffer; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | 6 | /** 7 | * A simple {@link VertexConsumer} implementation which forwards to a delegate. 8 | *

9 | * Created by covers1624 on 29/3/22. 10 | */ 11 | public abstract class DelegatingVertexConsumer implements ISpriteAwareVertexConsumer { 12 | 13 | protected final VertexConsumer delegate; 14 | 15 | public DelegatingVertexConsumer(VertexConsumer delegate) { 16 | this.delegate = delegate; 17 | } 18 | 19 | @Override 20 | public void sprite(TextureAtlasSprite sprite) { 21 | if (delegate instanceof ISpriteAwareVertexConsumer spriteCons) { 22 | spriteCons.sprite(sprite); 23 | } 24 | } 25 | 26 | @Override 27 | public VertexConsumer addVertex(float x, float y, float z) { 28 | delegate.addVertex(x, y, z); 29 | return this; 30 | } 31 | 32 | @Override 33 | public VertexConsumer setColor(int r, int g, int b, int a) { 34 | delegate.setColor(r, g, b, a); 35 | return this; 36 | } 37 | 38 | @Override 39 | public VertexConsumer setUv(float u, float v) { 40 | delegate.setUv(u, v); 41 | return this; 42 | } 43 | 44 | @Override 45 | public VertexConsumer setUv1(int u, int v) { 46 | delegate.setUv1(u, v); 47 | return this; 48 | } 49 | 50 | @Override 51 | public VertexConsumer setUv2(int u, int v) { 52 | delegate.setUv2(u, v); 53 | return this; 54 | } 55 | 56 | @Override 57 | public VertexConsumer setNormal(float x, float y, float z) { 58 | delegate.setNormal(x, y, z); 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/IconTransformation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | 6 | public class IconTransformation extends UVTransformation { 7 | 8 | public TextureAtlasSprite icon; 9 | 10 | public IconTransformation(TextureAtlasSprite icon) { 11 | this.icon = icon; 12 | } 13 | 14 | public IconTransformation(IconTransformation other) { 15 | this(other.icon); 16 | } 17 | 18 | @Override 19 | public void operate(CCRenderState ccrs) { 20 | super.operate(ccrs); 21 | ccrs.sprite = icon; 22 | } 23 | 24 | @Override 25 | public void apply(UV uv) { 26 | uv.u = icon.getU((float) uv.u); 27 | uv.v = icon.getV((float) uv.v); 28 | } 29 | 30 | @Override 31 | public UVTransformation inverse() { 32 | return new Inverse(icon); 33 | } 34 | 35 | @Override 36 | public IconTransformation copy() { 37 | return new IconTransformation(this); 38 | } 39 | 40 | private static class Inverse extends IconTransformation { 41 | 42 | public Inverse(TextureAtlasSprite icon) { 43 | super(icon); 44 | } 45 | 46 | public Inverse(Inverse other) { 47 | super(other); 48 | } 49 | 50 | @Override 51 | public void apply(UV uv) { 52 | uv.u = icon.getUOffset((float) uv.u) / 16; 53 | uv.v = icon.getVOffset((float) uv.v) / 16; 54 | } 55 | 56 | @Override 57 | public UVTransformation inverse() { 58 | return new IconTransformation(icon); 59 | } 60 | 61 | @Override 62 | public IconTransformation copy() { 63 | return new Inverse(this); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/particle/IModelParticleProvider.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.particle; 2 | 3 | import codechicken.lib.texture.TextureUtils; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | import net.minecraft.client.resources.model.BakedModel; 6 | import net.minecraft.core.BlockPos; 7 | import net.minecraft.world.level.BlockAndTintGetter; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | import net.minecraft.world.phys.BlockHitResult; 10 | import net.neoforged.neoforge.client.model.data.ModelData; 11 | 12 | import java.util.Set; 13 | 14 | /** 15 | * Created by covers1624 on 12/07/2017. 16 | */ 17 | public interface IModelParticleProvider extends BakedModel { 18 | 19 | @Override 20 | default TextureAtlasSprite getParticleIcon() { 21 | return TextureUtils.getMissingSprite(); 22 | } 23 | 24 | /** 25 | * Used to retrieve the particles to randomly choose from for hit particles. 26 | * 27 | * @param traceResult The trace result. 28 | * @param state The state, getActualState and getExtendedState has been called. 29 | * @param world The world. 30 | * @param pos The pos. 31 | * @return A Set of Textures to use. 32 | */ 33 | Set getHitEffects(BlockHitResult traceResult, BlockState state, BlockAndTintGetter world, BlockPos pos, ModelData modelData); 34 | 35 | /** 36 | * Used to retrieve the destroy particles for the block. 37 | * 38 | * @param state The state, getActualState and getExtendedState has been called. 39 | * @param world The world. 40 | * @param pos The pos. 41 | * @return A Set of Textures to use. 42 | */ 43 | Set getDestroyEffects(BlockState state, BlockAndTintGetter world, BlockPos pos, ModelData data); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/GuiProvider.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import codechicken.lib.gui.modular.ModularGui; 4 | import codechicken.lib.gui.modular.elements.GuiElement; 5 | import codechicken.lib.gui.modular.lib.container.ContainerGuiProvider; 6 | 7 | /** 8 | * This interface is used to build modular gui Screens. 9 | * For modular gui container screens use {@link ContainerGuiProvider} 10 | * 11 | * Created by brandon3055 on 19/08/2023 12 | */ 13 | public interface GuiProvider { 14 | 15 | /** 16 | * Override this to defile a custom root gui element. 17 | * Useful if you want to use something like a background texture or a manipulable element as the root element. 18 | * 19 | * @param gui The modular GUI. 20 | * @return the root gui element. 21 | */ 22 | default GuiElement createRootElement(ModularGui gui) { 23 | return new GuiElement<>(gui); 24 | } 25 | 26 | /** 27 | * Use this method to build the modular gui. 28 | *

29 | * Initialize the gui root element with {@link ModularGui#initStandardGui(int, int)}, {@link ModularGui#initFullscreenGui()} 30 | * This applies bindings to fix the size and position of the root element, you can also do this manually for custom configurations. 31 | *

32 | * Build your gui by adding and configuring your desired gui elements. 33 | * Elements must be added to the root gui element which is obtainable via gui.getRoot() 34 | *

35 | * Note: gui elements are added on construction, meaning you do not need to use element.addChild. 36 | * Instead, just construct the elements, and pass in the root element (or any other initialized element) as the parent. 37 | * 38 | * @param gui The modular gui instance. 39 | */ 40 | void buildGui(ModularGui gui); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/ItemRendererMixin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin; 2 | 3 | import codechicken.lib.render.item.IItemRenderer; 4 | import com.mojang.blaze3d.vertex.PoseStack; 5 | import net.minecraft.client.renderer.MultiBufferSource; 6 | import net.minecraft.client.renderer.entity.ItemRenderer; 7 | import net.minecraft.client.resources.model.BakedModel; 8 | import net.minecraft.world.item.ItemDisplayContext; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.neoforged.neoforge.client.ClientHooks; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | /** 17 | * {@link IItemRenderer} model extension mixin. 18 | *

19 | * Created by covers1624 on 9/8/20. 20 | */ 21 | @Mixin (ItemRenderer.class) 22 | abstract class ItemRendererMixin { 23 | 24 | @Inject ( 25 | method = "render", 26 | at = @At ("HEAD"), 27 | cancellable = true 28 | ) 29 | public void onRenderItem(ItemStack stack, ItemDisplayContext context, boolean leftHand, PoseStack mStack, MultiBufferSource buffers, int packedLight, int packedOverlay, BakedModel modelIn, CallbackInfo ci) { 30 | if (modelIn instanceof IItemRenderer) { 31 | ci.cancel(); 32 | mStack.pushPose(); 33 | // If anyone doesn't return an IItemRenderer from here, your doing it wrong. 34 | IItemRenderer renderer = (IItemRenderer) ClientHooks.handleCameraTransforms(mStack, modelIn, context, leftHand); 35 | mStack.translate(-0.5D, -0.5D, -0.5D); 36 | renderer.renderItem(stack, context, mStack, buffers, packedLight, packedOverlay); 37 | mStack.popPose(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/util/VectorUtils.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.util; 2 | 3 | import codechicken.lib.vec.Vector3; 4 | import net.minecraft.core.Direction; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | /** 8 | * Created by covers1624 on 4/10/2016. 9 | */ 10 | public class VectorUtils { 11 | 12 | /** 13 | * Calculates a normal for the given vertices. 14 | * 15 | * @param vertices The vertices to calculate a normal for, Expected to be a length of 3. 16 | * @return The normal. 17 | */ 18 | public static Vector3 calculateNormal(Vector3... vertices) { 19 | Vector3 diff1 = vertices[1].copy().subtract(vertices[0]); 20 | Vector3 diff2 = vertices[2].copy().subtract(vertices[0]); 21 | return diff1.crossProduct(diff2).normalize().copy(); 22 | } 23 | 24 | /** 25 | * Calculates the int direction a normal is facing. 26 | * 27 | * @param normal The normal to calculate from. 28 | * @return The direction the normal is facing. 29 | */ 30 | public static int findSide(Vector3 normal) { 31 | Direction dir = findSideE(normal); 32 | if (dir == null) return -1; 33 | 34 | return dir.ordinal(); 35 | } 36 | 37 | /** 38 | * Calculates the EnumFacing for a given normal. 39 | * 40 | * @param normal The normal to calculate from. 41 | * @return The direction the normal is facing. 42 | */ 43 | public static @Nullable Direction findSideE(Vector3 normal) { 44 | if (normal.y <= -0.99) return Direction.DOWN; 45 | if (normal.y >= 0.99) return Direction.UP; 46 | if (normal.z <= -0.99) return Direction.NORTH; 47 | if (normal.z >= 0.99) return Direction.SOUTH; 48 | if (normal.x <= -0.99) return Direction.WEST; 49 | if (normal.x >= 0.99) return Direction.EAST; 50 | 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/Scale.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.MathContext; 5 | import java.math.RoundingMode; 6 | 7 | public class Scale extends Transformation { 8 | 9 | public Vector3 factor; 10 | 11 | public Scale(Vector3 factor) { 12 | this.factor = factor; 13 | } 14 | 15 | public Scale(double factor) { 16 | this(new Vector3(factor, factor, factor)); 17 | } 18 | 19 | public Scale(double x, double y, double z) { 20 | this(new Vector3(x, y, z)); 21 | } 22 | 23 | public Scale(Scale scale) { 24 | this(scale.factor.copy()); 25 | } 26 | 27 | @Override 28 | public void apply(Vector3 vec) { 29 | vec.multiply(factor); 30 | } 31 | 32 | @Override 33 | public void applyN(Vector3 normal) { 34 | } 35 | 36 | @Override 37 | public void apply(Matrix4 mat) { 38 | mat.scale(factor); 39 | } 40 | 41 | @Override 42 | public Transformation inverse() { 43 | return new Scale(1 / factor.x, 1 / factor.y, 1 / factor.z); 44 | } 45 | 46 | @Override 47 | public Transformation merge(Transformation next) { 48 | if (next instanceof Scale) { 49 | return new Scale(factor.copy().multiply(((Scale) next).factor)); 50 | } 51 | 52 | return null; 53 | } 54 | 55 | @Override 56 | public boolean isRedundant() { 57 | return factor.equalsT(Vector3.ONE); 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 63 | return "Scale(" + new BigDecimal(factor.x, cont) + ", " + new BigDecimal(factor.y, cont) + ", " + new BigDecimal(factor.z, cont) + ")"; 64 | } 65 | 66 | @Override 67 | public Scale copy() { 68 | return new Scale(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/particle/ICustomParticleBlock.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.particle; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.server.level.ServerLevel; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.entity.LivingEntity; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | import net.neoforged.neoforge.common.extensions.IBlockExtension; 10 | 11 | /** 12 | * Trait like interface for adding CustomParticle support to any block, Simply implement :D 13 | *

14 | * Created by covers1624 on 31/10/19. 15 | */ 16 | public interface ICustomParticleBlock extends IBlockExtension { 17 | 18 | @Override 19 | default boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) { 20 | CustomParticleHandler.handleLandingEffects(worldserver, pos, entity, numberOfParticles); 21 | return true; 22 | } 23 | 24 | @Override 25 | default boolean addRunningEffects(BlockState state, Level world, BlockPos pos, Entity entity) { 26 | return world.isClientSide && CustomParticleHandler.handleRunningEffects(world, pos, state, entity); 27 | } 28 | 29 | // TODO IBlockRenderProperties 30 | // @Override 31 | // @OnlyIn (Dist.CLIENT) 32 | // default boolean addHitEffects(BlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { 33 | // return CustomParticleHandler.handleHitEffects(state, worldObj, target, manager); 34 | // } 35 | // 36 | // @Override 37 | // @OnlyIn (Dist.CLIENT) 38 | // default boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager) { 39 | // return CustomParticleHandler.handleDestroyEffects(world, pos, state, manager); 40 | // } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/pipeline/IVertexSource.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.pipeline; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.attribute.AttributeKey; 5 | import codechicken.lib.vec.Vertex5; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Created by covers1624 on 10/10/2016. 10 | */ 11 | public interface IVertexSource { 12 | 13 | /** 14 | * The vertices for this model. 15 | * 16 | * @return The Vertices. 17 | */ 18 | Vertex5[] getVertices(); 19 | 20 | /** 21 | * The number of vertices available in the model. 22 | *

23 | * By default, this method just returns the 24 | * length of the @link #getVertices()} array. 25 | * 26 | * @return The number of vertices available. 27 | */ 28 | default int getVertexCount() { 29 | return getVertices().length; 30 | } 31 | 32 | /** 33 | * Gets an attribute from this {@link IVertexSource}. 34 | * 35 | * @param attr The vertex attribute to get 36 | * @return The {@code T} for the given {@link AttributeKey} 37 | * or {@code null} of the Attribute does not exist. 38 | */ 39 | @Nullable 40 | T getAttribute(AttributeKey attr); 41 | 42 | /** 43 | * Returns {@code true} if the specified attribute is provided by this {@link IVertexSource}. 44 | *

45 | * The {@link IVertexSource} will either return data from {@link #getAttribute(AttributeKey)} 46 | * or set the state in {@link #prepareVertex(CCRenderState)}. 47 | * 48 | * @return {@code true} if the attribute exists. 49 | */ 50 | boolean hasAttribute(AttributeKey attr); 51 | 52 | /** 53 | * Called before the pipeline processes a vertex. 54 | * 55 | * @param ccrs The instance. 56 | */ 57 | void prepareVertex(CCRenderState ccrs); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/inventory/container/data/FluidData.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.inventory.container.data; 2 | 3 | import codechicken.lib.data.MCDataInput; 4 | import codechicken.lib.data.MCDataOutput; 5 | import net.minecraft.core.HolderLookup; 6 | import net.minecraft.nbt.NbtOps; 7 | import net.minecraft.nbt.Tag; 8 | import net.neoforged.neoforge.fluids.FluidStack; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | /** 13 | * Created by brandon3055 on 09/09/2023 14 | */ 15 | public class FluidData extends AbstractDataStore { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(FluidData.class); 18 | 19 | public FluidData() { 20 | super(FluidStack.EMPTY); 21 | } 22 | 23 | public FluidData(FluidStack defaultValue) { 24 | super(defaultValue); 25 | } 26 | 27 | @Override 28 | public void set(FluidStack value) { 29 | this.value = value.copy(); 30 | markDirty(); 31 | } 32 | 33 | @Override 34 | public void toBytes(MCDataOutput buf) { 35 | buf.writeFluidStack(value); 36 | } 37 | 38 | @Override 39 | public void fromBytes(MCDataInput buf) { 40 | value = buf.readFluidStack(); 41 | } 42 | 43 | @Override 44 | public Tag toTag(HolderLookup.Provider holders) { 45 | return FluidStack.OPTIONAL_CODEC 46 | .encodeStart(holders.createSerializationContext(NbtOps.INSTANCE), value) 47 | .getOrThrow(); 48 | } 49 | 50 | @Override 51 | public void fromTag(HolderLookup.Provider holders, Tag tag) { 52 | value = FluidStack.OPTIONAL_CODEC 53 | .parse(holders.createSerializationContext(NbtOps.INSTANCE), tag) 54 | .getOrThrow(); 55 | } 56 | 57 | @Override 58 | public boolean isSameValue(FluidStack newValue) { 59 | return value.equals(newValue); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/NoValidationBLockLootSubProvider.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.datagen; 2 | 3 | import net.minecraft.core.HolderLookup; 4 | import net.minecraft.core.RegistryAccess; 5 | import net.minecraft.data.loot.BlockLootSubProvider; 6 | import net.minecraft.resources.ResourceKey; 7 | import net.minecraft.resources.ResourceLocation; 8 | import net.minecraft.world.flag.FeatureFlagSet; 9 | import net.minecraft.world.item.Item; 10 | import net.minecraft.world.level.storage.loot.LootTable; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | import java.util.Set; 15 | import java.util.function.BiConsumer; 16 | 17 | /** 18 | * Created by covers1624 on 16/9/24. 19 | */ 20 | public abstract class NoValidationBLockLootSubProvider extends BlockLootSubProvider { 21 | 22 | private final Map, LootTable.Builder> map; 23 | 24 | protected NoValidationBLockLootSubProvider(HolderLookup.Provider registries) { 25 | this(Set.of(), registries); 26 | } 27 | 28 | protected NoValidationBLockLootSubProvider(Set explosionResistant, HolderLookup.Provider registries) { 29 | this(explosionResistant, FeatureFlagSet.of(), registries); 30 | } 31 | 32 | protected NoValidationBLockLootSubProvider(Set explosionResistant, FeatureFlagSet flags, HolderLookup.Provider registries) { 33 | this(explosionResistant, flags, new HashMap<>(), registries); 34 | } 35 | 36 | protected NoValidationBLockLootSubProvider(Set explosionResistant, FeatureFlagSet flags, Map, LootTable.Builder> map, HolderLookup.Provider registries) { 37 | super(explosionResistant, flags, map, registries); 38 | this.map = map; 39 | } 40 | 41 | @Override 42 | public void generate(BiConsumer, LootTable.Builder> cons) { 43 | generate(); 44 | map.forEach(cons); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/ClassModelLoaderBuilder.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.datagen; 2 | 3 | import com.google.gson.JsonObject; 4 | import net.minecraft.client.resources.model.BakedModel; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.neoforged.neoforge.client.model.generators.CustomLoaderBuilder; 7 | import net.neoforged.neoforge.client.model.generators.ModelBuilder; 8 | import net.neoforged.neoforge.common.data.ExistingFileHelper; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.lang.reflect.Constructor; 12 | import java.lang.reflect.Modifier; 13 | 14 | import static codechicken.lib.CodeChickenLib.MOD_ID; 15 | import static java.util.Objects.requireNonNull; 16 | 17 | /** 18 | * Created by covers1624 on 1/21/25. 19 | */ 20 | public class ClassModelLoaderBuilder> extends CustomLoaderBuilder { 21 | 22 | private @Nullable Class clazz; 23 | 24 | public ClassModelLoaderBuilder(T parent, ExistingFileHelper existingFileHelper) { 25 | super(ResourceLocation.fromNamespaceAndPath(MOD_ID, "class"), parent, existingFileHelper, false); 26 | } 27 | 28 | public ClassModelLoaderBuilder clazz(Class clazz) { 29 | try { 30 | Constructor ctor = clazz.getConstructor(); 31 | if (!Modifier.isPublic(ctor.getModifiers())) { 32 | throw new IllegalArgumentException("Expected single no-args public constructor."); 33 | } 34 | } catch (NoSuchMethodException ex) { 35 | throw new IllegalStateException("Expected single no-args public constructor.", ex); 36 | } 37 | this.clazz = clazz; 38 | return this; 39 | } 40 | 41 | @Override 42 | public JsonObject toJson(JsonObject json) { 43 | super.toJson(json); 44 | json.addProperty("class", requireNonNull(clazz).getName()); 45 | return json; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/codechicken/lib/config/LegacyConfigSerializerTest.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.config; 2 | 3 | import codechicken.lib.config.parser.ConfigSerializer; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.nio.file.Paths; 9 | import java.nio.file.StandardCopyOption; 10 | import java.util.Random; 11 | 12 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 13 | import static org.junit.jupiter.api.Assertions.assertTrue; 14 | 15 | /** 16 | * Created by covers1624 on 21/4/22. 17 | */ 18 | public class LegacyConfigSerializerTest extends ConfigRoundTripTest { 19 | 20 | @Test 21 | public void testParseSerializeRondTrip() throws Throwable { 22 | Path dir = Files.createTempDirectory("legacy_test_"); 23 | dir.toFile().deleteOnExit(); 24 | Path config = dir.resolve("config.cfg"); 25 | 26 | ConfigCategoryImpl rootTag = generateTestTag(new Random()); 27 | ConfigSerializer.LEGACY.save(config, rootTag); 28 | 29 | ConfigCategoryImpl readTag = new ConfigCategoryImpl("rootTag", null); 30 | ConfigSerializer.LEGACY.parse(config, readTag); 31 | 32 | assertTagsParseSame(rootTag, readTag); 33 | } 34 | 35 | @Test 36 | public void testThroughConfigFile() throws Throwable { 37 | Path file = Files.createTempFile("temp", ".cfg"); 38 | file.toFile().deleteOnExit(); 39 | copyTestFile(file); 40 | 41 | ConfigCategory config = new ConfigFile("rootTag") 42 | .path(file) 43 | .load(); 44 | 45 | assertNotEquals(0, config.getChildren().size()); 46 | } 47 | 48 | private static void copyTestFile(Path dst) throws Throwable { 49 | Path resource = Paths.get(LegacyConfigSerializerTest.class.getResource("/tests/legacy_serializer/test.cfg").toURI()); 50 | Files.copy(resource, dst, StandardCopyOption.REPLACE_EXISTING); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/internal/mixin/ShaderInstanceMixin.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.internal.mixin; 2 | 3 | import codechicken.lib.render.shader.CCShaderInstance; 4 | import com.mojang.blaze3d.shaders.Program; 5 | import net.minecraft.client.renderer.ShaderInstance; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.minecraft.server.packs.resources.ResourceProvider; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.gen.Invoker; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Redirect; 12 | 13 | import java.io.IOException; 14 | 15 | import static net.covers1624.quack.util.SneakyUtils.unsafeCast; 16 | 17 | /** 18 | * Created by covers1624 on 9/4/22. 19 | */ 20 | @Mixin (ShaderInstance.class) 21 | public abstract class ShaderInstanceMixin { 22 | 23 | private ShaderInstance self() { 24 | return unsafeCast(this); 25 | } 26 | 27 | @Redirect ( 28 | method = "(Lnet/minecraft/server/packs/resources/ResourceProvider;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/blaze3d/vertex/VertexFormat;)V", 29 | at = @At ( 30 | value = "INVOKE", 31 | target = "Lnet/minecraft/client/renderer/ShaderInstance;getOrCreate(Lnet/minecraft/server/packs/resources/ResourceProvider;Lcom/mojang/blaze3d/shaders/Program$Type;Ljava/lang/String;)Lcom/mojang/blaze3d/shaders/Program;" 32 | ) 33 | ) 34 | private Program onGetOrCreate(ResourceProvider provider, Program.Type type, String s) throws IOException { 35 | if (self() instanceof CCShaderInstance instance) { 36 | return instance.compileProgram(provider, type, ResourceLocation.parse(s)); 37 | } 38 | 39 | return callGetOrCreate(provider, type, s); 40 | } 41 | 42 | @Invoker 43 | public abstract Program callGetOrCreate(ResourceProvider provider, Program.Type type, String s); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/lighting/SimpleBrightnessModel.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.lighting; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.IVertexOperation; 5 | import net.minecraft.client.renderer.LevelRenderer; 6 | import net.minecraft.core.BlockPos; 7 | import net.minecraft.core.Direction; 8 | import net.minecraft.world.level.BlockAndTintGetter; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import static java.util.Objects.requireNonNull; 12 | 13 | /** 14 | * Simple brightness model that only works for axis planar sides 15 | */ 16 | public class SimpleBrightnessModel implements IVertexOperation { 17 | 18 | public static final int operationIndex = IVertexOperation.registerOperation(); 19 | public static SimpleBrightnessModel instance = new SimpleBrightnessModel(); 20 | 21 | public @Nullable BlockAndTintGetter access; 22 | public BlockPos pos = BlockPos.ZERO; 23 | 24 | private int sampled = 0; 25 | private final int[] samples = new int[6]; 26 | 27 | public void locate(BlockAndTintGetter a, BlockPos bPos) { 28 | access = a; 29 | pos = bPos; 30 | sampled = 0; 31 | } 32 | 33 | public int sample(int side) { 34 | requireNonNull(access, "SimpleBrightnessModel must be located first."); 35 | if ((sampled & 1 << side) == 0) { 36 | samples[side] = LevelRenderer.getLightColor(access, pos.relative(Direction.BY_3D_DATA[side])); 37 | sampled |= 1 << side; 38 | } 39 | return samples[side]; 40 | } 41 | 42 | @Override 43 | public boolean load(CCRenderState ccrs) { 44 | 45 | ccrs.pipeline.addDependency(ccrs.sideAttrib); 46 | return true; 47 | } 48 | 49 | @Override 50 | public void operate(CCRenderState ccrs) { 51 | ccrs.brightness = sample(ccrs.side); 52 | } 53 | 54 | @Override 55 | public int operationID() { 56 | return operationIndex; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/model/IVertexConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of CodeChickenLib. 3 | * Copyright (c) 2018, covers1624, All rights reserved. 4 | * 5 | * CodeChickenLib is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 2.1 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * CodeChickenLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with CodeChickenLib. If not, see . 17 | */ 18 | 19 | package codechicken.lib.model; 20 | 21 | import codechicken.lib.util.VertexUtils; 22 | import com.mojang.blaze3d.vertex.VertexFormat; 23 | import net.minecraft.client.renderer.block.model.BakedQuad; 24 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 25 | import net.minecraft.core.Direction; 26 | 27 | public interface IVertexConsumer { 28 | 29 | VertexFormat getVertexFormat(); 30 | 31 | void setQuadTint(int tint); 32 | 33 | void setQuadOrientation(Direction orientation); 34 | 35 | void setApplyDiffuseLighting(boolean diffuse); 36 | 37 | void setTexture(TextureAtlasSprite texture); 38 | 39 | void put(int element, float... data); 40 | 41 | /** 42 | * Assumes the data is already completely unpacked. 43 | * You must always copy the data from the quad provided to an internal cache. 44 | * basically: 45 | * this.quad.put(quad); 46 | * 47 | * @param quad The quad to copy data from. 48 | */ 49 | void put(Quad quad); 50 | 51 | default void put(BakedQuad quad) { 52 | VertexUtils.putQuad(this, quad); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/lighting/PlanarLightMatrix.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.lighting; 2 | 3 | import codechicken.lib.render.CCRenderState; 4 | import codechicken.lib.render.pipeline.IVertexOperation; 5 | import net.minecraft.client.renderer.LevelRenderer; 6 | import net.minecraft.core.BlockPos; 7 | import net.minecraft.world.level.BlockAndTintGetter; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | public class PlanarLightMatrix extends PlanarLightModel { 13 | 14 | public static final int operationIndex = IVertexOperation.registerOperation(); 15 | public static PlanarLightMatrix instance = new PlanarLightMatrix(); 16 | 17 | public @Nullable BlockAndTintGetter access; 18 | public BlockPos pos = BlockPos.ZERO; 19 | 20 | private int sampled = 0; 21 | public int[] brightness = new int[6]; 22 | 23 | public PlanarLightMatrix() { 24 | super(PlanarLightModel.standardLightModel.colours); 25 | } 26 | 27 | public PlanarLightMatrix locate(BlockAndTintGetter a, BlockPos bPos) { 28 | access = a; 29 | pos = bPos; 30 | sampled = 0; 31 | return this; 32 | } 33 | 34 | public int brightness(int side) { 35 | requireNonNull(access, "PlanarLightMatrix must be located first."); 36 | if ((sampled & 1 << side) == 0) { 37 | brightness[side] = LevelRenderer.getLightColor(access, pos); 38 | sampled |= 1 << side; 39 | } 40 | return brightness[side]; 41 | } 42 | 43 | @Override 44 | public boolean load(CCRenderState ccrs) { 45 | ccrs.pipeline.addDependency(ccrs.sideAttrib); 46 | return true; 47 | } 48 | 49 | @Override 50 | public void operate(CCRenderState ccrs) { 51 | super.operate(ccrs); 52 | ccrs.brightness = brightness(ccrs.side); 53 | } 54 | 55 | @Override 56 | public int operationID() { 57 | return operationIndex; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/gui/modular/lib/ColourState.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.gui.modular.lib; 2 | 3 | import codechicken.lib.colour.Colour; 4 | import codechicken.lib.colour.ColourARGB; 5 | 6 | import java.util.Locale; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * Created by brandon3055 on 19/11/2023 12 | */ 13 | public interface ColourState { 14 | 15 | int get(); 16 | 17 | default ColourARGB getColour() { 18 | return new ColourARGB(get()); 19 | } 20 | 21 | void set(int colour); 22 | 23 | default void set(Colour colour) { 24 | set(colour.argb()); 25 | } 26 | 27 | default String getHexColour() { 28 | return Integer.toHexString(get()).toUpperCase(Locale.ROOT); 29 | } 30 | 31 | default void setHexColour(String hexColour) { 32 | try { 33 | set(Integer.parseUnsignedInt(hexColour, 16)); 34 | } catch (Throwable e) { 35 | set(0); 36 | } 37 | } 38 | 39 | static ColourState create() { 40 | return create(null); 41 | } 42 | 43 | static ColourState create(Consumer listener) { 44 | return new ColourState() { 45 | int colour = 0; 46 | @Override 47 | public int get() { 48 | return colour; 49 | } 50 | 51 | @Override 52 | public void set(int colour) { 53 | this.colour = colour; 54 | if (listener != null) listener.accept(colour); 55 | } 56 | }; 57 | } 58 | 59 | static ColourState create(Supplier getter, Consumer setter) { 60 | return new ColourState() { 61 | @Override 62 | public int get() { 63 | return getter.get(); 64 | } 65 | 66 | @Override 67 | public void set(int colour) { 68 | setter.accept(colour); 69 | } 70 | }; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/CCRenderEventHandler.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render; 2 | 3 | import codechicken.lib.raytracer.VoxelShapeBlockHitResult; 4 | import codechicken.lib.vec.Matrix4; 5 | import net.covers1624.quack.util.CrashLock; 6 | import net.minecraft.world.phys.BlockHitResult; 7 | import net.neoforged.bus.api.EventPriority; 8 | import net.neoforged.neoforge.client.event.ClientTickEvent; 9 | import net.neoforged.neoforge.client.event.RenderFrameEvent; 10 | import net.neoforged.neoforge.client.event.RenderHighlightEvent; 11 | import net.neoforged.neoforge.common.NeoForge; 12 | 13 | public class CCRenderEventHandler { 14 | 15 | private static final CrashLock LOCK = new CrashLock("Already Initialized"); 16 | 17 | public static int renderTime; 18 | public static float renderFrame; 19 | 20 | public static void init() { 21 | LOCK.lock(); 22 | NeoForge.EVENT_BUS.addListener(CCRenderEventHandler::clientTick); 23 | NeoForge.EVENT_BUS.addListener(CCRenderEventHandler::renderTick); 24 | NeoForge.EVENT_BUS.addListener(EventPriority.LOW, CCRenderEventHandler::onBlockHighlight); 25 | } 26 | 27 | private static void clientTick(ClientTickEvent.Post event) { 28 | renderTime++; 29 | } 30 | 31 | private static void renderTick(RenderFrameEvent.Pre event) { 32 | renderFrame = event.getPartialTick().getGameTimeDeltaPartialTick(true); 33 | } 34 | 35 | private static void onBlockHighlight(RenderHighlightEvent.Block event) { 36 | //We have found a CuboidRayTraceResult, Lets render it properly.. 37 | BlockHitResult hit = event.getTarget(); 38 | if (hit instanceof VoxelShapeBlockHitResult voxelHit) { 39 | event.setCanceled(true); 40 | Matrix4 mat = new Matrix4(event.getPoseStack()); 41 | mat.translate(voxelHit.getBlockPos()); 42 | RenderUtils.bufferShapeHitBox(mat, event.getMultiBufferSource(), event.getCamera(), voxelHit.shape); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/render/particle/CustomBreakingParticle.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.render.particle; 2 | 3 | import net.minecraft.client.multiplayer.ClientLevel; 4 | import net.minecraft.client.particle.ParticleRenderType; 5 | import net.minecraft.client.particle.TextureSheetParticle; 6 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 7 | 8 | public class CustomBreakingParticle extends TextureSheetParticle { 9 | 10 | private final float uo; 11 | private final float vo; 12 | 13 | public CustomBreakingParticle(ClientLevel world, double x, double y, double z, double dx, double dy, double dz, TextureAtlasSprite icon) { 14 | super(world, x, y, z, dx, dy, dz); 15 | setSprite(icon); 16 | gravity = 1; 17 | rCol = gCol = bCol = 0.6F; 18 | quadSize /= 2.0F; 19 | uo = random.nextFloat() * 3.0F; 20 | vo = random.nextFloat() * 3.0F; 21 | } 22 | 23 | public static CustomBreakingParticle newLandingParticle(ClientLevel world, double x, double y, double z, double dx, double dy, double dz, TextureAtlasSprite icon) { 24 | CustomBreakingParticle particle = new CustomBreakingParticle(world, x, y, z, dx, dy, dz, icon); 25 | particle.xd = dx; 26 | particle.yd = dy; 27 | particle.zd = dz; 28 | return particle; 29 | } 30 | 31 | public ParticleRenderType getRenderType() { 32 | return ParticleRenderType.TERRAIN_SHEET; 33 | } 34 | 35 | protected float getU0() { 36 | return sprite.getU((uo + 1.0F) / 4.0F); 37 | } 38 | 39 | protected float getU1() { 40 | return sprite.getU(uo / 4.0F); 41 | } 42 | 43 | protected float getV0() { 44 | return sprite.getV(vo / 4.0F); 45 | } 46 | 47 | protected float getV1() { 48 | return sprite.getV((vo + 1.0F) / 4.0F); 49 | } 50 | 51 | public void setScale(float scale) { 52 | quadSize = scale; 53 | } 54 | 55 | public float getScale() { 56 | return quadSize; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/Line3.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | import codechicken.lib.util.Copyable; 4 | 5 | public class Line3 implements Copyable { 6 | 7 | public static final double tol = 0.0001D; 8 | 9 | public Vector3 pt1; 10 | public Vector3 pt2; 11 | 12 | public Line3(Vector3 pt1, Vector3 pt2) { 13 | this.pt1 = pt1; 14 | this.pt2 = pt2; 15 | } 16 | 17 | public Line3() { 18 | this(new Vector3(), new Vector3()); 19 | } 20 | 21 | public Line3(double x1, double y1, double z1, double x2, double y2, double z2) { 22 | this(new Vector3(x1, y1, z1), new Vector3(x2, y2, z2)); 23 | } 24 | 25 | public Line3(Line3 other) { 26 | this(other.pt1.copy(), other.pt2.copy()); 27 | } 28 | 29 | public static boolean intersection2D(Line3 line1, Line3 line2, Vector3 store) { 30 | // calculate differences 31 | double xD1 = line1.pt2.x - line1.pt1.x; 32 | double zD1 = line1.pt2.z - line1.pt1.z; 33 | double xD2 = line2.pt2.x - line2.pt1.x; 34 | double zD2 = line2.pt2.z - line2.pt1.z; 35 | 36 | double xD3 = line1.pt1.x - line2.pt1.x; 37 | double zD3 = line1.pt1.z - line2.pt1.z; 38 | 39 | double div = zD2 * xD1 - xD2 * zD1; 40 | if (div == 0) return false; //lines are parallel 41 | 42 | double ua = (xD2 * zD3 - zD2 * xD3) / div; 43 | store.set(line1.pt1.x + ua * xD1, 0, line1.pt1.z + ua * zD1); 44 | 45 | return store.x >= Math.min(line1.pt1.x, line1.pt2.x) - tol && store.x >= Math.min(line2.pt1.x, line2.pt2.x) - tol && store.z >= Math.min(line1.pt1.z, line1.pt2.z) - tol && store.z >= Math.min(line2.pt1.z, line2.pt2.z) - tol && store.x <= Math.max(line1.pt1.x, line1.pt2.x) + tol && store.x <= Math.max(line2.pt1.x, line2.pt2.x) + tol && store.z <= Math.max(line1.pt1.z, line1.pt2.z) + tol && store.z <= Math.max(line2.pt1.z, line2.pt2.z) + tol; 46 | 47 | } 48 | 49 | @Override 50 | public Line3 copy() { 51 | return new Line3(this); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/CodeChickenLib.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib; 2 | 3 | import codechicken.lib.config.ConfigCategory; 4 | import codechicken.lib.config.ConfigFile; 5 | import codechicken.lib.config.ConfigSyncManager; 6 | import codechicken.lib.internal.ClientInit; 7 | import codechicken.lib.internal.DataGenerators; 8 | import codechicken.lib.internal.TileChunkLoadHook; 9 | import codechicken.lib.internal.command.CCLCommands; 10 | import codechicken.lib.internal.network.CCLNetwork; 11 | import net.neoforged.bus.api.IEventBus; 12 | import net.neoforged.fml.ModContainer; 13 | import net.neoforged.fml.common.Mod; 14 | import net.neoforged.fml.loading.FMLConfig; 15 | import net.neoforged.fml.loading.FMLEnvironment; 16 | import org.jetbrains.annotations.Nullable; 17 | 18 | import java.nio.file.Paths; 19 | 20 | import static java.util.Objects.requireNonNull; 21 | 22 | /** 23 | * Created by covers1624 on 12/10/2016. 24 | */ 25 | @Mod (CodeChickenLib.MOD_ID) 26 | public class CodeChickenLib { 27 | 28 | static { 29 | if (Boolean.getBoolean("ccl.noModUpdateChecking")) { 30 | FMLConfig.updateConfig(FMLConfig.ConfigValue.VERSION_CHECK, false); 31 | } 32 | } 33 | 34 | public static final String MOD_ID = "codechickenlib"; 35 | 36 | private static @Nullable ModContainer container; 37 | 38 | public static ConfigCategory config; 39 | 40 | public CodeChickenLib(ModContainer container, IEventBus modBus) { 41 | CodeChickenLib.container = container; 42 | config = new ConfigFile(MOD_ID) 43 | .path(Paths.get("config/ccl.cfg")) 44 | .load(); 45 | if (FMLEnvironment.dist.isClient()) { 46 | ClientInit.init(modBus); 47 | } 48 | 49 | ConfigSyncManager.init(modBus); 50 | 51 | CCLCommands.init(); 52 | CCLNetwork.init(modBus); 53 | TileChunkLoadHook.init(); 54 | // ConditionalIngredient.Serializer.init(); 55 | DataGenerators.init(modBus); 56 | } 57 | 58 | public static ModContainer container() { 59 | return requireNonNull(container); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/datagen/recipe/SpecialCraftingRecipeBuilder.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.datagen.recipe; 2 | 3 | import net.minecraft.core.registries.BuiltInRegistries; 4 | import net.minecraft.resources.ResourceLocation; 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.item.crafting.Recipe; 7 | import net.minecraft.world.level.ItemLike; 8 | 9 | import java.util.List; 10 | import java.util.function.Supplier; 11 | 12 | /** 13 | * Created by covers1624 on 25/3/21. 14 | */ 15 | public class SpecialCraftingRecipeBuilder implements RecipeBuilder { 16 | 17 | protected final ResourceLocation id; 18 | 19 | private final Factory factory; 20 | 21 | public SpecialCraftingRecipeBuilder(ResourceLocation id, Factory factory) { 22 | this.id = id; 23 | this.factory = factory; 24 | } 25 | 26 | public static SpecialCraftingRecipeBuilder builder(ItemLike id, Factory factory) { 27 | return builder(BuiltInRegistries.ITEM.getKey(id.asItem()), factory); 28 | } 29 | 30 | public static SpecialCraftingRecipeBuilder builder(Supplier id, Factory factory) { 31 | return builder(id.get(), factory); 32 | } 33 | 34 | public static SpecialCraftingRecipeBuilder builder(ItemStack id, Factory factory) { 35 | return builder(id.getItem(), factory); 36 | } 37 | 38 | public static SpecialCraftingRecipeBuilder builder(String id, Factory factory) { 39 | return builder(ResourceLocation.parse(id), factory); 40 | } 41 | 42 | public static SpecialCraftingRecipeBuilder builder(ResourceLocation id, Factory factory) { 43 | return new SpecialCraftingRecipeBuilder(id, factory); 44 | } 45 | 46 | @Override 47 | public ResourceLocation getId() { 48 | return id; 49 | } 50 | 51 | @Override 52 | public BuiltRecipe build() { 53 | return new BuiltRecipe( 54 | factory.build(), 55 | null, 56 | List.of() 57 | ); 58 | } 59 | 60 | public interface Factory { 61 | 62 | Recipe build(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/Translation.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec; 2 | 3 | import net.minecraft.core.Vec3i; 4 | 5 | import java.math.BigDecimal; 6 | import java.math.MathContext; 7 | import java.math.RoundingMode; 8 | 9 | public class Translation extends Transformation { 10 | 11 | public static final Translation CENTER = new Translation(Vector3.CENTER); 12 | 13 | public Vector3 vec; 14 | 15 | public Translation(Vector3 vec) { 16 | this.vec = vec; 17 | } 18 | 19 | public Translation(Vec3i vec) { 20 | this.vec = Vector3.fromVec3i(vec); 21 | } 22 | 23 | public Translation(double x, double y, double z) { 24 | this(new Vector3(x, y, z)); 25 | } 26 | 27 | public Translation(Translation trans) { 28 | this(trans.vec.copy()); 29 | } 30 | 31 | @Override 32 | public void apply(Vector3 vec) { 33 | vec.add(this.vec); 34 | } 35 | 36 | @Override 37 | public void applyN(Vector3 normal) { 38 | } 39 | 40 | @Override 41 | public void apply(Matrix4 mat) { 42 | mat.translate(vec); 43 | } 44 | 45 | @Override 46 | public Transformation at(Vector3 point) { 47 | return this; 48 | } 49 | 50 | @Override 51 | public Transformation inverse() { 52 | return new Translation(-vec.x, -vec.y, -vec.z); 53 | } 54 | 55 | @Override 56 | public Transformation merge(Transformation next) { 57 | if (next instanceof Translation t) { 58 | return new Translation(vec.copy().add(t.vec)); 59 | } 60 | 61 | return null; 62 | } 63 | 64 | @Override 65 | public boolean isRedundant() { 66 | return vec.equalsT(Vector3.ZERO); 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 72 | return "Translation(" + new BigDecimal(vec.x, cont) + ", " + new BigDecimal(vec.y, cont) + ", " + new BigDecimal(vec.z, cont) + ")"; 73 | } 74 | 75 | @Override 76 | public Translation copy() { 77 | return new Translation(this); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/codechicken/lib/vec/uv/UV.java: -------------------------------------------------------------------------------- 1 | package codechicken.lib.vec.uv; 2 | 3 | import codechicken.lib.util.Copyable; 4 | 5 | import java.math.BigDecimal; 6 | import java.math.MathContext; 7 | import java.math.RoundingMode; 8 | 9 | public class UV implements Copyable { 10 | 11 | public double u; 12 | public double v; 13 | public int tex; 14 | 15 | public UV() { 16 | } 17 | 18 | public UV(double u, double v) { 19 | this(u, v, 0); 20 | } 21 | 22 | public UV(double u, double v, int tex) { 23 | this.u = u; 24 | this.v = v; 25 | this.tex = tex; 26 | } 27 | 28 | public UV(UV uv) { 29 | this(uv.u, uv.v, uv.tex); 30 | } 31 | 32 | public UV set(double u, double v, int tex) { 33 | this.u = u; 34 | this.v = v; 35 | this.tex = tex; 36 | return this; 37 | } 38 | 39 | public UV set(double u, double v) { 40 | return set(u, v, tex); 41 | } 42 | 43 | public UV set(UV uv) { 44 | return set(uv.u, uv.v, uv.tex); 45 | } 46 | 47 | public UV set(double[] da) { 48 | return set(da[0], da[1]); 49 | } 50 | 51 | public UV set(float[] fa) { 52 | return set(fa[0], fa[1]); 53 | } 54 | 55 | @Override 56 | public UV copy() { 57 | return new UV(this); 58 | } 59 | 60 | public UV add(UV uv) { 61 | u += uv.u; 62 | v += uv.v; 63 | return this; 64 | } 65 | 66 | public UV multiply(double d) { 67 | u *= d; 68 | v *= d; 69 | return this; 70 | } 71 | 72 | public String toString() { 73 | MathContext cont = new MathContext(4, RoundingMode.HALF_UP); 74 | return "UV(" + new BigDecimal(u, cont) + ", " + new BigDecimal(v, cont) + ")"; 75 | } 76 | 77 | public UV apply(UVTransformation t) { 78 | t.apply(this); 79 | return this; 80 | } 81 | 82 | @Override 83 | public boolean equals(Object o) { 84 | if (!(o instanceof UV uv)) { 85 | return false; 86 | } 87 | return u == uv.u && v == uv.v; 88 | } 89 | } 90 | --------------------------------------------------------------------------------