Skip to content

Commit

Permalink
Fixes for forge and some loading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Dec 26, 2021
1 parent 8bd92e3 commit 0c82049
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@
import dev.itsmeow.whisperwoods.entity.EntityHidebehind;
import dev.itsmeow.whisperwoods.init.*;
import me.shedaniel.architectury.registry.BlockEntityRenderers;
import me.shedaniel.architectury.registry.ParticleProviderRegistry;
import me.shedaniel.architectury.registry.RenderTypes;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Pose;
import org.apache.logging.log4j.LogManager;

import java.util.function.BiConsumer;
import java.util.function.Function;

public class ClientLifecycleHandler {

public static RenderFactory R = IMDLibClient.getRenderRegistry(WhisperwoodsMod.MODID);
Expand Down Expand Up @@ -68,12 +73,14 @@ public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int pack
BlockEntityRenderers.registerRenderer(ModBlockEntities.HAND_OF_FATE.get(), RenderTileHandOfFate::new);

RenderTypes.register(RenderType.translucent(), ModBlocks.WISP_LANTERN_BLUE.get(), ModBlocks.WISP_LANTERN_GREEN.get(), ModBlocks.WISP_LANTERN_ORANGE.get(), ModBlocks.WISP_LANTERN_PURPLE.get(), ModBlocks.WISP_LANTERN_YELLOW.get());
ParticleProviderRegistry.register(ModParticles.WISP.get(), WispParticle.WispFactory::new);
ParticleProviderRegistry.register(ModParticles.FLAME.get(), FlameParticle.FlameFactory::new);

LogManager.getLogger().info("Increasing wispiness of wisps...");
}

public static void registerParticles(BiConsumer<ParticleType<?>, Function<SpriteSet, ParticleProvider<?>>> register) {
register.accept(ModParticles.WISP.get(), WispParticle.WispFactory::new);
register.accept(ModParticles.FLAME.get(), FlameParticle.FlameFactory::new);
}

public static class RenderTypeAddition extends RenderType {
public RenderTypeAddition() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dev.itsmeow.whisperwoods.mixin;

import dev.itsmeow.whisperwoods.client.init.ClientLifecycleHandler;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ParticleEngine.class)
public abstract class ParticleEngineMixin {

@Shadow
public abstract <T extends ParticleOptions> void register(ParticleType<T> particleType, ParticleEngine.SpriteParticleRegistration<T> spriteParticleRegistration);

@Inject(at = @At("RETURN"), method = "registerProviders()V")
private void registerProviders(CallbackInfo callback) {
ClientLifecycleHandler.registerParticles((type, provider) -> this.register(type, (ParticleEngine.SpriteParticleRegistration) spriteSet -> provider.apply(spriteSet)));
}

}
3 changes: 2 additions & 1 deletion common/src/main/resources/whisperwoods.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ accessible field com/mojang/math/Matrix4f m13 F
accessible field com/mojang/math/Matrix4f m23 F
accessible field net/minecraft/server/level/ChunkMap entityMap Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;
accessible field net/minecraft/server/level/ChunkMap$TrackedEntity seenBy Ljava/util/Set;
accessible field net/minecraft/world/entity/ai/navigation/PathNavigation nodeEvaluator Lnet/minecraft/world/level/pathfinder/NodeEvaluator;
accessible field net/minecraft/world/entity/ai/navigation/PathNavigation nodeEvaluator Lnet/minecraft/world/level/pathfinder/NodeEvaluator;
accessible class net/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration
3 changes: 2 additions & 1 deletion common/src/main/resources/whisperwoods.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mixins": [
"EntityMixin",
"LivingEntityMixin",
"GroundPathNavigationMixin"
"GroundPathNavigationMixin",
"ParticleEngineMixin"
],
"client": [],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
import dev.itsmeow.whisperwoods.item.ItemBlockHirschgeistSkull;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.inventory.InventoryMenu;

public class WhisperwoodsClientFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientLifecycleHandler.clientInit();

ClientSpriteRegistryCallback.event(InventoryMenu.BLOCK_ATLAS).register(((atlasTexture, registry) -> {
registry.register(new ResourceLocation(WhisperwoodsMod.MODID, "particle/flame"));
for(int i = 0; i < 6; i++) {
registry.register(new ResourceLocation(WhisperwoodsMod.MODID, "particle/wisp_" + i));
}
}));
ItemBlockHirschgeistSkull armor = ModItems.HIRSCHGEIST_SKULL.get();
ArmorRenderingRegistry.registerModel((entity, stack, slot, defaultModel) -> {
HumanoidModel<LivingEntity> model = armor.getArmorModel(entity, stack, slot, defaultModel);
Expand Down
6 changes: 6 additions & 0 deletions fabric/src/main/resources/data/c/tags/items/iron_nuggets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:iron_nugget"
]
}
6 changes: 6 additions & 0 deletions fabric/src/main/resources/data/c/tags/items/stone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:stone"
]
}
3 changes: 2 additions & 1 deletion fabric/src/main/resources/whisperwoods.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ accessible field com/mojang/math/Matrix4f m13 F
accessible field com/mojang/math/Matrix4f m23 F
accessible field net/minecraft/server/level/ChunkMap entityMap Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;
accessible field net/minecraft/server/level/ChunkMap$TrackedEntity seenBy Ljava/util/Set;
accessible field net/minecraft/world/entity/ai/navigation/PathNavigation nodeEvaluator Lnet/minecraft/world/level/pathfinder/NodeEvaluator;
accessible field net/minecraft/world/entity/ai/navigation/PathNavigation nodeEvaluator Lnet/minecraft/world/level/pathfinder/NodeEvaluator;
accessible class net/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration
3 changes: 2 additions & 1 deletion forge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public net.minecraft.util.math.vector.Matrix4f field_226582_h_ # m13
public net.minecraft.util.math.vector.Matrix4f field_226586_l_ # m23
public net.minecraft.world.server.ChunkManager field_219272_z # entities
public net.minecraft.world.server.ChunkManager$EntityTracker field_219406_f # trackingPlayers
public net.minecraft.pathfinding.PathNavigator field_179695_a # nodeProcessor
public net.minecraft.pathfinding.PathNavigator field_179695_a # nodeProcessor
public net.minecraft.client.particle.ParticleManager$IParticleMetaFactory

0 comments on commit 0c82049

Please sign in to comment.