Skip to content

Commit

Permalink
v3.0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
AzureZhen committed Jul 28, 2022
1 parent 78fe598 commit f5010e0
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 7 deletions.
7 changes: 2 additions & 5 deletions changelog.txt
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mod_version=3.0.29
mod_version=3.0.30
archives_base_name=geckolib-forge-1.12.2
geckolib_core_version=1.0.4
maven_group=software.bernie.geckolib
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/software/bernie/geckolib3/GeckoLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GeckoLib {
public static final Logger LOGGER = LogManager.getLogger();
public static final String ModID = "geckolib3";
public static boolean hasInitialized;
public static final String VERSION = "3.0.29";
public static final String VERSION = "3.0.30";

/**
* This method MUST be called in your mod's constructor or during
Expand Down
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);
}

}

0 comments on commit f5010e0

Please sign in to comment.