-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed unused method from IAnimationTickable
Wrote documentation for the example entity
- Loading branch information
Goodbird
committed
Mar 19, 2024
1 parent
62292bf
commit db6f460
Showing
6 changed files
with
52 additions
and
117 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
core/src/main/java/software/bernie/geckolib3/core/IAnimationTickable.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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package software.bernie.geckolib3.core; | ||
|
||
public interface IAnimationTickable { | ||
public void tick(); | ||
|
||
public int tickTimer(); | ||
} |
20 changes: 13 additions & 7 deletions
20
src/main/java/software/bernie/example/client/model/entity/ExampleEntityModel.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
69 changes: 14 additions & 55 deletions
69
src/main/java/software/bernie/example/client/renderer/entity/ExampleGeoRenderer.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 |
---|---|---|
@@ -1,66 +1,25 @@ | ||
package software.bernie.example.client.renderer.entity; | ||
package software.bernie.example.client.renderer.entity; //The package our class is located in | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.OpenGlHelper; | ||
import net.minecraft.client.renderer.RenderHelper; | ||
import net.minecraft.client.renderer.entity.Render; | ||
import net.minecraft.client.renderer.entity.RenderEntity; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.entity.Entity; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.lwjgl.opengl.GL11; | ||
import org.lwjgl.opengl.GL12; | ||
//Imports of the classes used in this class description | ||
import software.bernie.example.client.model.entity.ExampleEntityModel; | ||
import software.bernie.example.entity.GeoExampleEntity; | ||
import software.bernie.geckolib3.geo.render.built.GeoModel; | ||
import software.bernie.geckolib3.particles.emitter.BedrockEmitter; | ||
import software.bernie.geckolib3.core.util.Color; | ||
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; | ||
import software.bernie.geckolib3.util.MatrixStack; | ||
|
||
import javax.vecmath.Matrix3f; | ||
import javax.vecmath.Matrix4f; | ||
import javax.vecmath.Vector3d; | ||
import javax.vecmath.Vector3f; | ||
|
||
//The model class is derived from the GeoEntityRenderer with the template argument(<>) set to the previously made entity class | ||
public class ExampleGeoRenderer extends GeoEntityRenderer<GeoExampleEntity> { | ||
|
||
//The constructor defines the model which will be used | ||
public ExampleGeoRenderer() { | ||
super(new ExampleEntityModel()); | ||
super(new ExampleEntityModel()); // Here we pass the previously made model into the super-constructor | ||
} | ||
|
||
@Override | ||
public void renderAfter(GeoModel model, GeoExampleEntity animatable, float ticks, float red, float green, float blue, float alpha) { | ||
BedrockEmitter emitter = animatable.emitter; | ||
emitter.prevGlobal.x=emitter.lastGlobal.x; | ||
emitter.prevGlobal.y=emitter.lastGlobal.y; | ||
emitter.prevGlobal.z=emitter.lastGlobal.z; | ||
|
||
emitter.lastGlobal.x=animatable.posX; | ||
emitter.lastGlobal.y=animatable.posY; | ||
emitter.lastGlobal.z=animatable.posZ; | ||
RenderHelper.disableStandardItemLighting(); | ||
|
||
boolean shouldSit = (animatable.ridingEntity != null && animatable.ridingEntity.shouldRiderSit()); | ||
Pair<Float,Float> rotations = calculateRotations(animatable,ticks,shouldSit); | ||
deapplyRotations(animatable,this.handleRotationFloat(animatable, ticks),rotations.getKey(),ticks); | ||
|
||
GL11.glTranslated(-animatable.posX,-animatable.posY,-animatable.posZ); | ||
emitter.rotation.setIdentity(); | ||
|
||
MATRIX_STACK.push(); | ||
//MATRIX_STACK.rotateY((float) (Math.PI/2)); | ||
// MATRIX_STACK.translate(1,1,0); | ||
// MATRIX_STACK.rotateY((float) (Math.PI/2)); | ||
// MATRIX_STACK.scale(5,5,5); | ||
|
||
Matrix4f full = MATRIX_STACK.getModelMatrix(); | ||
emitter.rotation = new Matrix3f(full.m00,full.m01,full.m02,full.m10,full.m11,full.m12,full.m20,full.m21,full.m22); | ||
emitter.lastGlobal.x+=full.m03; | ||
emitter.lastGlobal.y+=full.m13; | ||
emitter.lastGlobal.z+=full.m23; | ||
|
||
MATRIX_STACK.pop(); | ||
emitter.render(ticks); | ||
RenderHelper.enableStandardItemLighting(); | ||
} | ||
//This function specifiec the color/tint of the model rendered | ||
//By default the model does not color red when hurt. If you want change that, you can do it like that | ||
public Color getRenderColor(GeoExampleEntity animatable, float partialTicks) { | ||
if(animatable.hurtTime>0 || animatable.deathTime > 0) { //If the hurt or death timers are greater then zero, then | ||
return Color.ofRGBA(255, 153, 153, 255); //We say that the model should be colored red (you can set here any RGBA color) | ||
} | ||
return Color.ofRGBA(255,255,255,255); //Else we return the regular white color (and again, here can be any color you want) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,4 @@ public int tickTimer() { | |
return ticksExisted; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.onUpdate(); | ||
} | ||
} |
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