diff --git a/build.gradle b/build.gradle index d1e8a5b..9a1a73f 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,8 @@ dependencies { // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" - implementation 'org.spongepowered:mixin:0.8.+' - modImplementation "net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.1+2034447cb2" + + // implementation 'org.spongepowered:mixin:0.8.5' // BREAKS EVERYTHING DO NOT USE } processResources { 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 ea1bd5b..a6d4d23 100644 --- a/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java +++ b/src/client/java/ch/haslo/bluegrass/mixin/client/ExampleClientMixin.java @@ -10,6 +10,6 @@ public class ExampleClientMixin { @Inject(at = @At("HEAD"), method = "run") private void run(CallbackInfo info) { - // This code is injected into the start of MinecraftClient.run()V + System.out.println("Hello, World! Bluegrass mod is loaded."); } } \ No newline at end of file diff --git a/src/client/java/ch/haslo/bluegrass/mixin/client/GrassBlockMixin.java b/src/client/java/ch/haslo/bluegrass/mixin/client/GrassBlockMixin.java index c522fa1..ade0af3 100644 --- a/src/client/java/ch/haslo/bluegrass/mixin/client/GrassBlockMixin.java +++ b/src/client/java/ch/haslo/bluegrass/mixin/client/GrassBlockMixin.java @@ -6,9 +6,7 @@ import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModelManager; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.ModelIdentifier; -import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -21,11 +19,13 @@ public class GrassBlockMixin { @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) public void getModel(ModelIdentifier id, CallbackInfoReturnable cir) { - if (id.equals(new Identifier("minecraft", "grass_block_side"))) { + System.out.println("Requested model: " + id.toString()); + if ("minecraft".equals(id.getNamespace()) && "grass_block".equals(id.getPath())) { Identifier blockAtlasId = new Identifier("minecraft", "textures/atlas/blocks.png"); Function spriteGetter = MinecraftClient.getInstance().getSpriteAtlas(blockAtlasId); BakedModel customModel = new BlueGrassSideModel(spriteGetter); cir.setReturnValue(customModel); + System.out.println("Mixin applied!"); } } } diff --git a/src/client/java/ch/haslo/bluegrass/models/BlueGrassSideModel.java b/src/client/java/ch/haslo/bluegrass/models/BlueGrassSideModel.java index b3c4f86..0feee60 100644 --- a/src/client/java/ch/haslo/bluegrass/models/BlueGrassSideModel.java +++ b/src/client/java/ch/haslo/bluegrass/models/BlueGrassSideModel.java @@ -8,8 +8,6 @@ import net.minecraft.client.render.model.json.ModelOverrideList; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; @@ -25,13 +23,19 @@ public class BlueGrassSideModel implements BakedModel { public BlueGrassSideModel(Function spriteGetter) { Identifier identifier = new Identifier("bluegrass", "block/grass_block_side"); this.sprite = spriteGetter.apply(identifier); + if (this.sprite == null) { + System.out.println("Sprite is null"); + } else { + System.out.println("Sprite loaded"); + } } @Override public List getQuads(@Nullable BlockState state, @Nullable Direction face, Random random) { + System.out.println("Getting quads for " + state + " / " + face + " / " + random); BakedModel originalModel = MinecraftClient.getInstance().getBakedModelManager().getModel(new ModelIdentifier(new Identifier("minecraft", "grass_block"), "")); List quads = new ArrayList<>(originalModel.getQuads(state, face, random)); - if (face == null) { + if (face == null || face == Direction.DOWN) { return originalModel.getQuads(state, face, random); } if (face == Direction.UP) { @@ -44,12 +48,10 @@ public List getQuads(@Nullable BlockState state, @Nullable Direction int red = color >> 16 & 255; int green = color >> 8 & 255; int blue = color & 255; - - // Multiply to apply blue tint blue = Math.min(255, blue * 2); // Multiply blue component by 2, capped at 255 - int newColor = (alpha << 24) | (red << 16) | (green << 8) | blue; vertexData[i + 3] = newColor; + System.out.println("Blue tint applied to " + i); } BakedQuad newQuad = new BakedQuad(vertexData, -1, quad.getFace(), quad.getSprite(), quad.hasShade()); newQuads.add(newQuad); @@ -69,6 +71,11 @@ public List getQuads(@Nullable BlockState state, @Nullable Direction quads.add(customQuad); } // south, noop + if (quads.isEmpty()) { + System.out.println("No quads generated for " + face); + } else { + System.out.println("Quads generated for " + face); + } return quads; }