-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AzureZhen
committed
Jul 28, 2022
1 parent
78fe598
commit f5010e0
Showing
4 changed files
with
96 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
v3.0.29 | ||
v3.0.30 | ||
|
||
- Update GeoArmor Item. | ||
- Update Core | ||
- Ticking Tweak | ||
- Update Credits | ||
- Backport GeoProjectileRender |
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
92 changes: 92 additions & 0 deletions
92
src/main/java/software/bernie/geckolib3/renderers/geo/GeoProjectilesRenderer.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,92 @@ | ||
package software.bernie.geckolib3.renderers.geo; | ||
|
||
import java.util.Collections; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.entity.Render; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.ResourceLocation; | ||
import software.bernie.geckolib3.core.IAnimatable; | ||
import software.bernie.geckolib3.core.IAnimatableModel; | ||
import software.bernie.geckolib3.core.controller.AnimationController; | ||
import software.bernie.geckolib3.core.event.predicate.AnimationEvent; | ||
import software.bernie.geckolib3.core.util.Color; | ||
import software.bernie.geckolib3.geo.render.built.GeoModel; | ||
import software.bernie.geckolib3.model.AnimatedGeoModel; | ||
import software.bernie.geckolib3.model.provider.GeoModelProvider; | ||
import software.bernie.geckolib3.model.provider.data.EntityModelData; | ||
import software.bernie.geckolib3.util.AnimationUtils; | ||
|
||
@SuppressWarnings("unchecked") | ||
public class GeoProjectilesRenderer<T extends Entity & IAnimatable> extends Render<T> implements IGeoRenderer<T> { | ||
|
||
static { | ||
AnimationController.addModelFetcher((IAnimatable object) -> { | ||
if (object instanceof Entity) { | ||
return (IAnimatableModel<Object>) AnimationUtils.getGeoModelForEntity((Entity) object); | ||
} | ||
return null; | ||
}); | ||
} | ||
|
||
private final AnimatedGeoModel<T> modelProvider; | ||
|
||
public GeoProjectilesRenderer(RenderManager renderManager, AnimatedGeoModel<T> modelProvider) { | ||
super(renderManager); | ||
this.modelProvider = modelProvider; | ||
} | ||
|
||
@Override | ||
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) { | ||
GlStateManager.pushMatrix(); | ||
GeoModel model = modelProvider.getModel(modelProvider.getModelLocation(entity)); | ||
GlStateManager.rotate( | ||
entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, | ||
1.0F, 0.0F); | ||
GlStateManager.rotate( | ||
entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, | ||
1.0F); | ||
|
||
float lastLimbDistance = 0.0F; | ||
float limbSwing = 0.0F; | ||
EntityModelData entityModelData = new EntityModelData(); | ||
AnimationEvent<T> predicate = new AnimationEvent<T>(entity, limbSwing, lastLimbDistance, partialTicks, | ||
!(lastLimbDistance > -0.15F && lastLimbDistance < 0.15F), Collections.singletonList(entityModelData)); | ||
if (modelProvider instanceof IAnimatableModel) { | ||
((IAnimatableModel<T>) modelProvider).setLivingAnimations(entity, this.getUniqueID(entity), predicate); | ||
} | ||
GlStateManager.pushMatrix(); | ||
Minecraft.getMinecraft().renderEngine.bindTexture(getTextureLocation(entity)); | ||
Color renderColor = getRenderColor(entity, partialTicks); | ||
|
||
if (!entity.isInvisibleToPlayer(Minecraft.getMinecraft().player)) | ||
render(model, entity, partialTicks, (float) renderColor.getRed() / 255f, | ||
(float) renderColor.getBlue() / 255f, (float) renderColor.getGreen() / 255f, | ||
(float) renderColor.getAlpha() / 255); | ||
GlStateManager.popMatrix(); | ||
GlStateManager.popMatrix(); | ||
} | ||
|
||
@Override | ||
public GeoModelProvider<T> getGeoModelProvider() { | ||
return this.modelProvider; | ||
} | ||
|
||
@Override | ||
public ResourceLocation getEntityTexture(T instance) { | ||
return getTextureLocation(instance); | ||
} | ||
|
||
@Override | ||
public Integer getUniqueID(T animatable) { | ||
return animatable.getUniqueID().hashCode(); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureLocation(T instance) { | ||
return this.modelProvider.getTextureLocation(instance); | ||
} | ||
|
||
} |