-
-
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
Dec 21, 2021
1 parent
47c0a74
commit d22a9c2
Showing
18 changed files
with
1,122 additions
and
530 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
25 changes: 25 additions & 0 deletions
25
src/main/java/software/bernie/example/client/model/entity/LEModel.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,25 @@ | ||
package software.bernie.example.client.model.entity; | ||
|
||
import net.minecraft.util.Identifier; | ||
import software.bernie.example.entity.LEEntity; | ||
import software.bernie.geckolib3.GeckoLib; | ||
import software.bernie.geckolib3.model.AnimatedTickingGeoModel; | ||
|
||
public class LEModel extends AnimatedTickingGeoModel<LEEntity> { | ||
|
||
@Override | ||
public Identifier getModelLocation(LEEntity object) { | ||
return new Identifier(GeckoLib.ModID, "geo/le.geo.json"); | ||
} | ||
|
||
@Override | ||
public Identifier getTextureLocation(LEEntity object) { | ||
return new Identifier(GeckoLib.ModID, "textures/entity/le.png"); | ||
} | ||
|
||
@Override | ||
public Identifier getAnimationFileLocation(LEEntity animatable) { | ||
return new Identifier(GeckoLib.ModID, "animations/le.animations.json"); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/software/bernie/example/client/renderer/entity/LERenderer.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,18 @@ | ||
package software.bernie.example.client.renderer.entity; | ||
|
||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import software.bernie.example.client.model.entity.LEModel; | ||
import software.bernie.example.client.renderer.entity.layer.GeoExampleLayer; | ||
import software.bernie.example.entity.LEEntity; | ||
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; | ||
|
||
public class LERenderer extends GeoEntityRenderer<LEEntity> { | ||
|
||
@SuppressWarnings("unchecked") | ||
public LERenderer(EntityRendererFactory.Context renderManager) { | ||
super(renderManager, new LEModel()); | ||
this.addLayer(new GeoExampleLayer(this)); | ||
this.shadowRadius = 0.25f; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/software/bernie/example/client/renderer/entity/layer/GeoExampleLayer.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 software.bernie.example.client.renderer.entity.layer; | ||
|
||
import net.minecraft.client.render.OverlayTexture; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.Identifier; | ||
import software.bernie.geckolib3.GeckoLib; | ||
import software.bernie.geckolib3.renderers.geo.GeoLayerRenderer; | ||
import software.bernie.geckolib3.renderers.geo.IGeoRenderer; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class GeoExampleLayer extends GeoLayerRenderer { | ||
// A resource location for the texture of the layer. This will be applied onto pre-existing cubes on the model | ||
private static final Identifier LAYER = new Identifier(GeckoLib.ModID, "textures/entity/le_glasses.png"); | ||
// A resource location for the model of the entity. This model is put on top of the normal one, which is then given the texture | ||
private static final Identifier MODEL = new Identifier(GeckoLib.ModID, "geo/le.geo.json"); | ||
|
||
@SuppressWarnings("unchecked") | ||
public GeoExampleLayer(IGeoRenderer<?> entityRendererIn) { | ||
super(entityRendererIn); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, Entity entityLivingBaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { | ||
RenderLayer cameo = RenderLayer.getArmorCutoutNoCull(LAYER); | ||
matrixStackIn.push(); | ||
//Move or scale the model as you see fit | ||
matrixStackIn.scale(1.0f, 1.0f, 1.0f); | ||
matrixStackIn.translate(0.0d, 0.0d, 0.0d); | ||
this.getRenderer().render(this.getEntityModel().getModel(MODEL), entityLivingBaseIn, partialTicks, cameo, matrixStackIn, bufferIn, | ||
bufferIn.getBuffer(cameo), packedLightIn, OverlayTexture.DEFAULT_UV, 1f, 1f, 1f, 1f); | ||
matrixStackIn.pop(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/software/bernie/example/entity/LEEntity.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,49 @@ | ||
package software.bernie.example.entity; | ||
|
||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.ai.goal.LookAtEntityGoal; | ||
import net.minecraft.entity.mob.PathAwareEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.world.World; | ||
import software.bernie.geckolib3.core.IAnimatable; | ||
import software.bernie.geckolib3.core.IAnimationTickable; | ||
import software.bernie.geckolib3.core.PlayState; | ||
import software.bernie.geckolib3.core.builder.AnimationBuilder; | ||
import software.bernie.geckolib3.core.controller.AnimationController; | ||
import software.bernie.geckolib3.core.event.predicate.AnimationEvent; | ||
import software.bernie.geckolib3.core.manager.AnimationData; | ||
import software.bernie.geckolib3.core.manager.AnimationFactory; | ||
|
||
public class LEEntity extends PathAwareEntity implements IAnimatable, IAnimationTickable { | ||
private AnimationFactory factory = new AnimationFactory(this); | ||
|
||
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { | ||
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.geoLayerEntity.idle", true)); | ||
return PlayState.CONTINUE; | ||
} | ||
|
||
public LEEntity(EntityType<? extends PathAwareEntity> type, World worldIn) { | ||
super(type, worldIn); | ||
} | ||
|
||
@Override | ||
public void registerControllers(AnimationData data) { | ||
data.addAnimationController(new AnimationController<LEEntity>(this, "controller", 5, this::predicate)); | ||
} | ||
|
||
@Override | ||
public AnimationFactory getFactory() { | ||
return this.factory; | ||
} | ||
|
||
@Override | ||
protected void initGoals() { | ||
this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); | ||
super.initGoals(); | ||
} | ||
|
||
@Override | ||
public int tickTimer() { | ||
return age; | ||
} | ||
} |
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
50 changes: 25 additions & 25 deletions
50
src/main/resources/assets/geckolib3/animations/bike.animation.json
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,27 +1,27 @@ | ||
{ | ||
"format_version": "1.8.0", | ||
"animations": { | ||
"animation.bike.idle": { | ||
"loop": true, | ||
"bones": { | ||
"body": { | ||
"rotation": ["math.cos(query.anim_time * 200) * 0.5", 0, "(math.sin(query.anim_time * 200) * 0.5) + math.clamp(query.yaw_speed * -20, -20, 20)"], | ||
"position": [0, "math.cos(query.anim_time * 100) * 0.5", 0], | ||
"scale": ["Math.clamp(query.distance_from_camera / 5, 1, 6)", "Math.clamp(query.distance_from_camera / 5, 1, 6)", "Math.clamp(query.distance_from_camera / 5, 1, 6)"] | ||
}, | ||
"lfin1": { | ||
"rotation": [0, 0, "-35+math.sin(query.anim_time*400*query.actor_count)*25"] | ||
}, | ||
"lfin2": { | ||
"rotation": [0, 0, "-35+math.sin(query.anim_time*300*query.actor_count)*20"] | ||
}, | ||
"rfin1": { | ||
"rotation": [0, 0, "35+math.sin(query.anim_time*400*query.actor_count)*-25"] | ||
}, | ||
"rfin2": { | ||
"rotation": [0, 0, "35+math.sin(query.anim_time*300*query.actor_count)*-20"] | ||
} | ||
} | ||
} | ||
} | ||
"format_version": "1.8.0", | ||
"animations": { | ||
"animation.bike.idle": { | ||
"loop": true, | ||
"bones": { | ||
"body": { | ||
"rotation": ["math.cos(query.anim_time * 200) * 0.5", 0, "(math.sin(query.anim_time * 200) * 0.5) + math.clamp(query.yaw_speed * -20, -20, 20)"], | ||
"position": [0, "math.cos(query.anim_time * 100) * 0.5", 0], | ||
"scale": ["Math.clamp(query.distance_from_camera / 5, 1, 6)", "Math.clamp(query.distance_from_camera / 5, 1, 6)", "Math.clamp(query.distance_from_camera / 5, 1, 6)"] | ||
}, | ||
"lfin1": { | ||
"rotation": [0, 0, "-35+math.sin(query.anim_time*400*query.actor_count)*25"] | ||
}, | ||
"lfin2": { | ||
"rotation": [0, 0, "-35+math.sin(query.anim_time*300*query.actor_count)*20"] | ||
}, | ||
"rfin1": { | ||
"rotation": [0, 0, "35+math.sin(query.anim_time*400*query.actor_count)*-25"] | ||
}, | ||
"rfin2": { | ||
"rotation": [0, 0, "35+math.sin(query.anim_time*300*query.actor_count)*-20"] | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.