All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.parzivail.pswg.mixin.EntityRenderDispatcherMixin Maven / Gradle / Ivy

There is a newer version: 0.0.114+1.20.2
Show newest version
package com.parzivail.pswg.mixin;

import com.parzivail.pswg.character.SwgSpecies;
import com.parzivail.pswg.component.PersistentPublicPlayerData;
import com.parzivail.pswg.component.PlayerData;
import com.parzivail.util.client.render.HitboxHelper;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_1007;
import net.minecraft.class_1297;
import net.minecraft.class_1657;
import net.minecraft.class_4587;
import net.minecraft.class_4588;
import net.minecraft.class_897;
import net.minecraft.class_898;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Map;

@Mixin(class_898.class)
@Environment(EnvType.CLIENT)
public class EntityRenderDispatcherMixin
{
	@Shadow
	private Map modelRenderers;

	@SuppressWarnings("unchecked")
	@Inject(method = "getRenderer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;model()Lnet/minecraft/client/util/SkinTextures$Model;"), cancellable = true)
	private  void getRenderer(T entity, CallbackInfoReturnable> cir)
	{
		if (!(entity instanceof class_1657))
			return;

		var pc = PlayerData.getPersistentPublic((class_1657)entity);

		var species = pc.getCharacter();
		if (species == null)
			return;

		var renderer = (class_897)modelRenderers.get(species.getModel().toString());

		cir.setReturnValue(renderer);
		cir.cancel();
	}

	@Inject(method = "renderHitbox(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/entity/Entity;F)V", at = @At("TAIL"))
	private static void renderHitbox(class_4587 matrices, class_4588 vertices, class_1297 entity, float tickDelta, CallbackInfo ci)
	{
		HitboxHelper.render(matrices, vertices, entity, tickDelta);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy