Skip to content

Commit

Permalink
Fixed all compiler warnings except for deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
haslo committed Oct 11, 2023
1 parent acbf7b9 commit 034e110
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 129 deletions.
37 changes: 14 additions & 23 deletions src/client/java/ch/haslo/bluegrass/BlueGrassClient.java
Original file line number Diff line number Diff line change
@@ -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;
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public class ExampleClientMixin {
private void run(CallbackInfo info) {
System.out.println("Hello, World! Bluegrass mod is loaded.");
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Identifier> getModelDependencies() {
return Collections.emptyList();
Expand Down Expand Up @@ -66,6 +58,7 @@ public BakedModel bake(Baker baker, Function<SpriteIdentifier, Sprite> textureGe
debugSprite(bottomSprite);

Renderer renderer = RendererAccess.INSTANCE.getRenderer();
assert renderer != null;
MeshBuilder builder = renderer.meshBuilder();
QuadEmitter emitter = builder.getEmitter();

Expand All @@ -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);
}
Expand All @@ -106,4 +98,5 @@ void emitQuadsForDirections(QuadEmitter emitter, Sprite topSprite, Sprite sideSp
emitter.spriteColor(0, color, color, color, color);
emitter.emit();
}
}}
}
}

This file was deleted.

Binary file not shown.
20 changes: 10 additions & 10 deletions src/client/resources/bluegrass.client.mixins.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"required": true,
"package": "ch.haslo.bluegrass.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
"ExampleClientMixin"
],
"injectors": {
"defaultRequire": 1
}
}
"required": true,
"package": "ch.haslo.bluegrass.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
"ExampleClientMixin"
],
"injectors": {
"defaultRequire": 1
}
}
11 changes: 0 additions & 11 deletions src/main/resources/bluegrass.mixins.json

This file was deleted.

85 changes: 42 additions & 43 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
"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"
]
}

0 comments on commit 034e110

Please sign in to comment.