From 034e110e5b3b12a41136fed5acf417717030dc98 Mon Sep 17 00:00:00 2001 From: Guido Gloor Date: Wed, 11 Oct 2023 22:13:09 +0200 Subject: [PATCH] Fixed all compiler warnings except for deprecations --- .../ch/haslo/bluegrass/BlueGrassClient.java | 37 +++----- .../mixin/client/ExampleClientMixin.java | 2 +- .../bluegrass/models/BakedBlueGrassModel.java | 9 -- .../models/UnbakedBlueGrassModel.java | 13 +-- .../bluegrass/models/block/grass_block.json | 22 ----- .../textures/block/grass_block_side.png | Bin 685 -> 0 bytes .../resources/bluegrass.client.mixins.json | 20 ++--- src/main/resources/bluegrass.mixins.json | 11 --- src/main/resources/fabric.mod.json | 85 +++++++++--------- 9 files changed, 70 insertions(+), 129 deletions(-) delete mode 100644 src/client/resources/assets/bluegrass/models/block/grass_block.json delete mode 100644 src/client/resources/assets/bluegrass/textures/block/grass_block_side.png delete mode 100644 src/main/resources/bluegrass.mixins.json diff --git a/src/client/java/ch/haslo/bluegrass/BlueGrassClient.java b/src/client/java/ch/haslo/bluegrass/BlueGrassClient.java index bdf3a84..bb8cbfc 100644 --- a/src/client/java/ch/haslo/bluegrass/BlueGrassClient.java +++ b/src/client/java/ch/haslo/bluegrass/BlueGrassClient.java @@ -1,34 +1,25 @@ package ch.haslo.bluegrass; -import ch.haslo.bluegrass.models.BakedBlueGrassModel; import ch.haslo.bluegrass.models.UnbakedBlueGrassModel; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; import net.fabricmc.fabric.api.client.model.loading.v1.ModelModifier; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.ModelIdentifier; -import net.minecraft.util.Identifier; - -import java.util.function.Function; public class BlueGrassClient implements ClientModInitializer { - @Override - public void onInitializeClient() { - // Register your ModelLoadingPlugin - ModelLoadingPlugin.register(pluginCtx -> { - pluginCtx.modifyModelOnLoad().register(ModelModifier.WRAP_PHASE, (model, context) -> { - if (context.id() instanceof ModelIdentifier modelId) { - System.out.println("Model ID: " + modelId); // Debug print + @Override + public void onInitializeClient() { + // Register your ModelLoadingPlugin + ModelLoadingPlugin.register(pluginCtx -> pluginCtx.modifyModelOnLoad().register(ModelModifier.WRAP_PHASE, (model, context) -> { + if (context.id() instanceof ModelIdentifier modelId) { + System.out.println("Model ID: " + modelId); // Debug print - if (modelId.getNamespace().equals("minecraft") && modelId.getPath().equals("grass_block") && modelId.getVariant().equals("snowy=false")) { - System.out.println("Inside non-snowy grass block logic"); - return new UnbakedBlueGrassModel(modelId); - } - } - return model; - }); - }); - } + if (modelId.getNamespace().equals("minecraft") && modelId.getPath().equals("grass_block") && modelId.getVariant().equals("snowy=false")) { + System.out.println("Inside non-snowy grass block logic"); + return new UnbakedBlueGrassModel(); + } + } + return model; + })); + } } diff --git a/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java b/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java index a6d4d23..6e07342 100644 --- a/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java +++ b/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java @@ -12,4 +12,4 @@ public class ExampleClientMixin { private void run(CallbackInfo info) { System.out.println("Hello, World! Bluegrass mod is loaded."); } -} \ No newline at end of file +} diff --git a/src/client/java/ch/haslo/bluegrass/models/BakedBlueGrassModel.java b/src/client/java/ch/haslo/bluegrass/models/BakedBlueGrassModel.java index 3ed9349..ea57cc7 100644 --- a/src/client/java/ch/haslo/bluegrass/models/BakedBlueGrassModel.java +++ b/src/client/java/ch/haslo/bluegrass/models/BakedBlueGrassModel.java @@ -1,30 +1,21 @@ package ch.haslo.bluegrass.models; -import net.fabricmc.fabric.api.renderer.v1.Renderer; -import net.fabricmc.fabric.api.renderer.v1.RendererAccess; -import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder; -import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView; -import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter; import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.ModelIdentifier; import net.minecraft.block.BlockState; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.json.ModelOverrideList; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; import net.minecraft.world.BlockRenderView; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Supplier; diff --git a/src/client/java/ch/haslo/bluegrass/models/UnbakedBlueGrassModel.java b/src/client/java/ch/haslo/bluegrass/models/UnbakedBlueGrassModel.java index 1367fff..8f88901 100644 --- a/src/client/java/ch/haslo/bluegrass/models/UnbakedBlueGrassModel.java +++ b/src/client/java/ch/haslo/bluegrass/models/UnbakedBlueGrassModel.java @@ -8,10 +8,8 @@ import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder; import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView; import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.model.*; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteContents; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; @@ -24,12 +22,6 @@ @Environment(EnvType.CLIENT) public class UnbakedBlueGrassModel implements UnbakedModel { - private final Identifier textureId; - - public UnbakedBlueGrassModel(Identifier textureId) { - this.textureId = textureId; - } - @Override public Collection getModelDependencies() { return Collections.emptyList(); @@ -66,6 +58,7 @@ public BakedModel bake(Baker baker, Function textureGe debugSprite(bottomSprite); Renderer renderer = RendererAccess.INSTANCE.getRenderer(); + assert renderer != null; MeshBuilder builder = renderer.meshBuilder(); QuadEmitter emitter = builder.getEmitter(); @@ -83,7 +76,6 @@ void debugSprite(Sprite sprite) { SpriteContents contents = sprite.getContents(); if (contents == null) { System.out.println("Contents are null"); - return; } else { System.out.println("Contents are " + contents); } @@ -106,4 +98,5 @@ void emitQuadsForDirections(QuadEmitter emitter, Sprite topSprite, Sprite sideSp emitter.spriteColor(0, color, color, color, color); emitter.emit(); } - }} + } +} diff --git a/src/client/resources/assets/bluegrass/models/block/grass_block.json b/src/client/resources/assets/bluegrass/models/block/grass_block.json deleted file mode 100644 index 6d09d43..0000000 --- a/src/client/resources/assets/bluegrass/models/block/grass_block.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "parent": "block/block", - "textures": { - "side": "bluegrass:block/grass_block_side", - "top": "minecraft:block/grass_block_top", - "bottom": "minecraft:block/dirt" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "down": {"uv": [0, 0, 16, 16], "texture": "#bottom"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#top"}, - "north": {"uv": [0, 0, 16, 16], "texture": "#side"}, - "south": {"uv": [0, 0, 16, 16], "texture": "#side"}, - "west": {"uv": [0, 0, 16, 16], "texture": "#side"}, - "east": {"uv": [0, 0, 16, 16], "texture": "#side"} - } - } - ] -} diff --git a/src/client/resources/assets/bluegrass/textures/block/grass_block_side.png b/src/client/resources/assets/bluegrass/textures/block/grass_block_side.png deleted file mode 100644 index 88e58371b511a0760ce2fd14aa79fa7ec33f851d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 685 zcmV;e0#f~nP)kQ51&18Eq=58Ye=WSR`r^T80)yDQN=|X;a9e zLO0!%Lh~BkWz#3hrd<>S+eHb8W)UcK%)qqjB+;2zbxfj}E@TGHSsl(j_x|_$&k-KI zaU8)1w>My4i~(2(`578b0?|0(HMqJ2y92j34x&%sX3)XDs32{=MR;6toU0zhSHQMF z^ugvp;m7!dv2EduhdkMiGr5L8XVCxK;eI5_c;w()5D-^F@cdR`WdqK-L(Y3le-VV8 z&^F;@obziC{jjkCJK+NV^drW@GhU$Jf2b=&Gq31;S12sP(c%dV;n_$5prN0#$nAR)+itGZgHJJ)wR4HUqRO+Vy_;tfV zYnvou5!6D7h~8jCA{GHa zbdz$ef!gYN>@J3GSQIiTfVs0u{S@7>rXD0>5ziF&aF%`c;$0MR)~I4O?V;@NK0Yi$#?)kSS}3Fk`ahK29_%clpf!o+bf`!>1FIOSS{rC@-8oX6j9V)kuBLEu~!viiy{JZi_^HcMmH?fR@ZyX#c+3{m`!^q zqB~Q!>E2}MxnHTDQp~2=-^)|3HN0ue{><+t`+NC0)o`vvvU-Tx>Uzzyh_2{=QH(jc TJ)ml-00000NkvXXu0mjf{SQRH diff --git a/src/client/resources/bluegrass.client.mixins.json b/src/client/resources/bluegrass.client.mixins.json index 9c0dc0d..9712a20 100644 --- a/src/client/resources/bluegrass.client.mixins.json +++ b/src/client/resources/bluegrass.client.mixins.json @@ -1,11 +1,11 @@ { - "required": true, - "package": "ch.haslo.bluegrass.mixin.client", - "compatibilityLevel": "JAVA_17", - "client": [ - "ExampleClientMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file + "required": true, + "package": "ch.haslo.bluegrass.mixin.client", + "compatibilityLevel": "JAVA_17", + "client": [ + "ExampleClientMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/bluegrass.mixins.json b/src/main/resources/bluegrass.mixins.json deleted file mode 100644 index eb84b98..0000000 --- a/src/main/resources/bluegrass.mixins.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "required": true, - "package": "ch.haslo.bluegrass.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "ExampleMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index cc6a00d..61e6b79 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,44 +1,43 @@ { - "schemaVersion": 1, - "id": "bluegrass", - "version": "${version}", - "name": "BlueGrass", - "description": "This is an example description! Tell everyone what your mod is about!", - "authors": [ - "Me!" - ], - "contact": { - "homepage": "https://fabricmc.net/", - "sources": "https://github.com/FabricMC/fabric-example-mod" - }, - "license": "CC0-1.0", - "icon": "assets/bluegrass/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "ch.haslo.bluegrass.BlueGrass" - ], - "client": [ - "ch.haslo.bluegrass.BlueGrassClient" - ] - }, - "mixins": [ - "bluegrass.mixins.json", - { - "config": "bluegrass.client.mixins.json", - "environment": "client" - } - ], - "depends": { - "fabricloader": ">=0.14.22", - "minecraft": "~1.20.2", - "java": ">=17", - "fabric-api": "*" - }, - "suggests": { - "another-mod": "*" - }, - "resources": [ - "assets/bluegrass" - ] -} \ No newline at end of file + "schemaVersion": 1, + "id": "bluegrass", + "version": "${version}", + "name": "BlueGrass", + "description": "This is an example description! Tell everyone what your mod is about!", + "authors": [ + "Me!" + ], + "contact": { + "homepage": "https://fabricmc.net/", + "sources": "https://github.com/FabricMC/fabric-example-mod" + }, + "license": "CC0-1.0", + "icon": "assets/bluegrass/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "ch.haslo.bluegrass.BlueGrass" + ], + "client": [ + "ch.haslo.bluegrass.BlueGrassClient" + ] + }, + "mixins": [ + { + "config": "bluegrass.client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.14.22", + "minecraft": "~1.20.2", + "java": ">=17", + "fabric-api": "*" + }, + "suggests": { + "another-mod": "*" + }, + "resources": [ + "assets/bluegrass" + ] +}