Skip to content

Commit f382fd8

Browse files
Cleanup & Fix Wrong Emissives
1 parent 4a2b45f commit f382fd8

File tree

12 files changed

+66
-88
lines changed

12 files changed

+66
-88
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Mod Properties
1818
mod_id = glowtone
19-
mod_version = 1.0
19+
mod_version = 1.0.1
2020
maven_group = net.frozenblock
2121
archives_base_name = Glowtone
2222

src/main/java/net/frozenblock/glowtone/GlowtoneClient.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package net.frozenblock.glowtone;
1919

2020
import net.fabricmc.api.ClientModInitializer;
21-
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
22-
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
21+
import net.fabricmc.fabric.api.resource.v1.ResourceLoader;
22+
import net.fabricmc.fabric.api.resource.v1.pack.PackActivationType;
2323
import net.fabricmc.loader.api.FabricLoader;
2424
import net.fabricmc.loader.api.ModContainer;
2525
import net.frozenblock.glowtone.render_type.impl.BlockRenderTypeOverwriteManager;
@@ -31,24 +31,27 @@ public final class GlowtoneClient implements ClientModInitializer {
3131

3232
@Override
3333
public void onInitializeClient() {
34-
Optional<ModContainer> modContainer = FabricLoader.getInstance().getModContainer(GlowtoneConstants.MOD_ID);
35-
if (modContainer.isEmpty()) return;
36-
final ModContainer container = modContainer.get();
34+
final Optional<ModContainer> optionalModContainer = FabricLoader.getInstance().getModContainer(GlowtoneConstants.MOD_ID);
35+
if (optionalModContainer.isEmpty()) return;
36+
final ModContainer modContainer = optionalModContainer.get();
3737

38-
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(BlockRenderTypeOverwriteManager.INSTANCE);
38+
ResourceLoader.get(PackType.CLIENT_RESOURCES).registerReloader(
39+
GlowtoneConstants.id("block_render_type_overwrite_manager"),
40+
BlockRenderTypeOverwriteManager.INSTANCE
41+
);
3942

40-
ResourceManagerHelper.registerBuiltinResourcePack(
43+
ResourceLoader.registerBuiltinPack(
4144
GlowtoneConstants.id("glowtone_shading"),
42-
container,
45+
modContainer,
4346
Component.translatable("pack.glowtone.glowtone_shading"),
44-
ResourcePackActivationType.NORMAL
47+
PackActivationType.NORMAL
4548
);
4649

47-
ResourceManagerHelper.registerBuiltinResourcePack(
50+
ResourceLoader.registerBuiltinPack(
4851
GlowtoneConstants.id("glowtone_emissives"),
49-
container,
52+
modContainer,
5053
Component.translatable("pack.glowtone.glowtone_emissives"),
51-
ResourcePackActivationType.DEFAULT_ENABLED
54+
PackActivationType.DEFAULT_ENABLED
5255
);
5356
}
5457

src/main/java/net/frozenblock/glowtone/mixin/client/FaceBakeryMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class FaceBakeryMixin {
4949

5050
final Optional<EmissiveMetadataSection> optionalEmissiveMetadata = contents.getAdditionalMetadata(EmissiveMetadataSection.TYPE);
5151
if (optionalEmissiveMetadata.isPresent()) {
52-
EmissiveMetadataSection emissiveMetadata = optionalEmissiveMetadata.get();
52+
final EmissiveMetadataSection emissiveMetadata = optionalEmissiveMetadata.get();
5353
shade.set(emissiveMetadata.shade().orElse(shade.get()));
5454
lightEmission.set(emissiveMetadata.lightEmission());
5555
} else {

src/main/java/net/frozenblock/glowtone/mixin/client/ModelManagerMixin.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@ public class ModelManagerMixin {
4141
)
4242
public ResourceManager glowtone$toggleShading(ResourceManager resourceManager) {
4343
GlowtoneConstants.GLOWTONE_EMISSIVES = resourceManager.listPacks().anyMatch(packResources -> {
44-
if (packResources.knownPackInfo().isPresent()) {
45-
return packResources.knownPackInfo().get().id().equals(GlowtoneConstants.string("glowtone_emissives"));
46-
}
47-
return false;
44+
if (!packResources.knownPackInfo().isPresent()) return false;
45+
return packResources.knownPackInfo().get().id().equals(GlowtoneConstants.string("glowtone_emissives"));
4846
});
4947
GlowtoneConstants.GLOWTONE_SHADING = resourceManager.listPacks().anyMatch(packResources -> {
50-
if (packResources.knownPackInfo().isPresent()) {
51-
return packResources.knownPackInfo().get().id().equals(GlowtoneConstants.string("glowtone_shading"));
52-
}
53-
return false;
48+
if (!packResources.knownPackInfo().isPresent()) return false;
49+
return packResources.knownPackInfo().get().id().equals(GlowtoneConstants.string("glowtone_shading"));
5450
});
5551
return resourceManager;
5652
}

src/main/java/net/frozenblock/glowtone/mixin/client/SimpleUnbakedGeometryMixin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ public abstract class SimpleUnbakedGeometryMixin {
5858
TextureAtlasSprite original,
5959
@Local(argsOnly = true) ModelBaker modelBaker,
6060
@Local(argsOnly = true) ModelDebugName modelDebugName,
61-
@Share("glowtone$emissiveSprite") LocalRef<TextureAtlasSprite> emissiveSpriteRef
61+
@Share("glowtone$emissiveSprite") LocalRef<TextureAtlasSprite> emissiveSpriteRef,
62+
@Share("glowtone$emissiveQuad") LocalRef<BakedQuad> emissiveQuadRef
6263
) {
64+
emissiveSpriteRef.set(null);
65+
emissiveQuadRef.set(null);
6366
if (!GlowtoneConstants.GLOWTONE_EMISSIVES) return original;
6467

6568
final Identifier location = original.contents().name();

src/main/java/net/frozenblock/glowtone/mixin/client/redstone_dust_particle/DustColorTransitionParticleMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class DustColorTransitionParticleMixin implements GlowingDustParticleInte
4747
SpriteSet sprites,
4848
CallbackInfo info
4949
) {
50-
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(options instanceof GlowingDustParticleInterface glowingDustParticleInterface))return;
51-
this.glowtone$lightEmission = glowingDustParticleInterface.glowtone$getLightEmission();
50+
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(options instanceof GlowingDustParticleInterface glowingInterface))return;
51+
this.glowtone$lightEmission = glowingInterface.glowtone$getLightEmission();
5252
}
5353

5454
@Unique

src/main/java/net/frozenblock/glowtone/mixin/client/redstone_dust_particle/DustParticleMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class DustParticleMixin implements GlowingDustParticleInterface {
4747
SpriteSet sprites,
4848
CallbackInfo info
4949
) {
50-
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(options instanceof GlowingDustParticleInterface glowingDustParticleInterface)) return;
51-
this.glowtone$lightEmission = glowingDustParticleInterface.glowtone$getLightEmission();
50+
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(options instanceof GlowingDustParticleInterface glowingInterface)) return;
51+
this.glowtone$lightEmission = glowingInterface.glowtone$getLightEmission();
5252
}
5353

5454
@Unique

src/main/java/net/frozenblock/glowtone/mixin/client/redstone_dust_particle/ParticleMixin.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@
3030
@Mixin(Particle.class)
3131
public class ParticleMixin {
3232

33-
@ModifyReturnValue(method = "getLightColor", at = @At(value = "RETURN"))
33+
@ModifyReturnValue(method = "getLightColor", at = @At("RETURN"))
3434
public int glowtone$renderDustWithEmission(int original) {
35-
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(Particle.class.cast(this) instanceof GlowingDustParticleInterface glowingParticle)) return original;
35+
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(Particle.class.cast(this) instanceof GlowingDustParticleInterface glowingInterface)) return original;
3636

37-
final int emission = glowingParticle.glowtone$getLightEmission();
37+
final int emission = glowingInterface.glowtone$getLightEmission();
3838
if (emission == 0) return original;
3939

40-
int j = Math.max(original & 255, emission * 16);
41-
int k = original >> 16 & 255;
42-
if (j > 240) j = 240;
43-
40+
final int j = Math.min(Math.max(original & 255, emission * 16), 240);
41+
final int k = original >> 16 & 255;
4442
return j | k << 16;
4543
}
4644
}

src/main/java/net/frozenblock/glowtone/mixin/client/redstone_dust_particle/RedstoneWireBlockMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public class RedstoneWireBlockMixin {
4949
DustParticleOptions original,
5050
@Local(argsOnly = true) int color
5151
) {
52-
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(original instanceof GlowingDustParticleInterface glowingDustParticleInterface)) return original;
52+
if (!GlowtoneConstants.GLOWTONE_EMISSIVES || !(original instanceof GlowingDustParticleInterface glowingInterface)) return original;
5353

5454
for (int i = 1; i <= 15; i++) {
5555
if (COLORS[i] != color) continue;
56-
glowingDustParticleInterface.glowtone$setLightEmission(i);
56+
glowingInterface.glowtone$setLightEmission(i);
5757
break;
5858
}
5959

src/main/java/net/frozenblock/glowtone/render_type/impl/BlockRenderTypeOverwrite.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,15 @@
2525
import net.minecraft.util.StringRepresentable;
2626
import net.minecraft.world.level.block.Block;
2727
import org.jetbrains.annotations.ApiStatus;
28-
import org.jetbrains.annotations.NotNull;
2928

3029
import java.util.function.Supplier;
3130

3231
@ApiStatus.Internal
3332
@Environment(EnvType.CLIENT)
34-
public class BlockRenderTypeOverwrite {
35-
private final Block block;
36-
private final RenderTypeOverwrite renderTypeOverwrite;
37-
38-
public BlockRenderTypeOverwrite(Block block, RenderTypeOverwrite renderTypeOverwrite) {
39-
this.block = block;
40-
this.renderTypeOverwrite = renderTypeOverwrite;
41-
}
42-
43-
public Block getBlock() {
44-
return this.block;
45-
}
46-
47-
public RenderTypeOverwrite getRenderTypeOverwrite() {
48-
return this.renderTypeOverwrite;
49-
}
33+
public record BlockRenderTypeOverwrite(Block block, RenderTypeOverwrite renderTypeOverwrite) {
5034

5135
public ChunkSectionLayer getRenderType() {
52-
return this.getRenderTypeOverwrite().get();
36+
return this.renderTypeOverwrite().get();
5337
}
5438

5539
protected record RenderTypeOverwriteHolder(RenderTypeOverwrite renderTypeOverwrite) {
@@ -80,7 +64,7 @@ public ChunkSectionLayer get() {
8064
}
8165

8266
@Override
83-
public @NotNull String getSerializedName() {
67+
public String getSerializedName() {
8468
return this.name;
8569
}
8670
}

0 commit comments

Comments
 (0)