-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add renderer support for GeoEntity entities from GeckoLib
- Loading branch information
1 parent
47af00f
commit a217f85
Showing
8 changed files
with
85 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/lopymine/patpat/mixin/GeoEntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.lopymine.patpat.mixin; | ||
|
||
// TODO Отключить класс из версий, в которых GeckoLib не создан (например 1.21.2) | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.*; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import software.bernie.geckolib.renderer.GeoEntityRenderer; | ||
|
||
import net.lopymine.patpat.renderer.PatAnimationRenderer; | ||
|
||
|
||
//? >=1.21.2 { | ||
import net.minecraft.client.render.entity.state.EntityRenderState; | ||
import net.lopymine.patpat.utils.mixin.EntityRenderStateWithParent; | ||
//?} | ||
|
||
@Mixin(GeoEntityRenderer.class) | ||
public abstract class GeoEntityRendererMixin { | ||
|
||
//? <1.21.2 { | ||
/*@Inject(at=@At(value = "HEAD"), method = "render") | ||
private void render(Entity entity, float entityYaw, float partialTick, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { | ||
*///?} else { | ||
@Inject(at = @At(value = "HEAD"), method = "render") | ||
private void render(EntityRenderState entityRenderState, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { | ||
Entity entity = ((EntityRenderStateWithParent) entityRenderState).patPat$getEntity(); | ||
//?} | ||
if (!(entity instanceof LivingEntity livingEntity)) { | ||
return; | ||
} | ||
PatAnimationRenderer.scaleEntityIfPatted(livingEntity, matrixStack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/net/lopymine/patpat/renderer/PatAnimationRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.lopymine.patpat.renderer; | ||
|
||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.LivingEntity; | ||
|
||
import net.lopymine.patpat.entity.PatEntity; | ||
import net.lopymine.patpat.manager.client.PatPatClientManager; | ||
|
||
public class PatAnimationRenderer { | ||
|
||
public static void scaleEntityIfPatted(LivingEntity livingEntity, MatrixStack matrixStack){ | ||
PatEntity patEntity = PatPatClientManager.getPatEntity(livingEntity); | ||
if (patEntity == null) { | ||
return; | ||
} | ||
|
||
if (PatPatClientManager.expired(patEntity)) { | ||
PatPatClientManager.removePatEntity(patEntity); | ||
return; | ||
} | ||
|
||
matrixStack.scale(1F, PatPatClientManager.getAnimationProgress(patEntity), 1F); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters