Skip to content

Commit

Permalink
Working on Flee, still stuck on Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
sZeta99 committed May 12, 2024
1 parent 6273e46 commit 356fa4e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 176 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package it.crystalnest.goblin_fabrications.entity.client;

import com.eliotlash.mclib.utils.MathHelper;
import it.crystalnest.goblin_fabrications.Constants;
import it.crystalnest.goblin_fabrications.entity.custom.GoblinEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.model.data.EntityModelData;

public class GoblinModel extends GeoModel<GoblinEntity> {
@Override
Expand Down Expand Up @@ -39,4 +34,6 @@ public void setCustomAnimations(GoblinEntity animatable, long instanceId, Animat
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class GoblinRenderer extends GeoEntityRenderer<GoblinEntity> {
public GoblinRenderer(EntityRendererProvider.Context renderManager) {
super(renderManager, new GoblinModel());
addRenderLayer(new HumanoidArmorLayer(this));
//addRenderLayer(new HumanoidArmorLayer(this));
}

@Override
Expand All @@ -26,7 +26,7 @@ public ResourceLocation getTextureLocation(GoblinEntity animatable) {
@Override
public void render(GoblinEntity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
addLayer(new HumanoidArmorLayer(this, new SkeletonModel(context.bakeLayer(modelLayerLocation2)), new SkeletonModel(context.bakeLayer(modelLayerLocation3)), context.getModelManager()));
//addLayer(new HumanoidArmorLayer(this, new SkeletonModel(context.bakeLayer(modelLayerLocation2)), new SkeletonModel(context.bakeLayer(modelLayerLocation3)), context.getModelManager()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import software.bernie.geckolib.core.animation.*;
import software.bernie.geckolib.core.object.PlayState;

import java.util.Iterator;
import java.util.function.Predicate;

public class GoblinEntity extends Skeleton implements GeoEntity {
Expand All @@ -48,7 +49,7 @@ public static AttributeSupplier.Builder setAttributers() {
protected void registerGoals() {
//this.goalSelector.addGoal(2, new RestrictSunGoal(this));
//this.goalSelector.addGoal(3, new FleeSunGoal(this, 1.0));
this.goalSelector.addGoal(3, new AvoidEntityGoal<>(this, Wolf.class, 6.0F, 1.0, 1.2));
this.goalSelector.addGoal(3, new AvoidEntityGoal<Wolf>(this, Wolf.class, 6.0F, 5.0, 2.2));
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
Expand All @@ -61,13 +62,23 @@ protected void registerGoals() {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(new AnimationController<GeoAnimatable>(this, "controller", this::predicate));
controllers.add(new AnimationController<GeoAnimatable>(this, "fleeController", this::fleePredicte));
}

private PlayState fleePredicte(AnimationState<GeoAnimatable> geoAnimatableAnimationState) {
System.out.println(this.goalSelector.getRunningGoals().anyMatch(prioritizedGoal -> prioritizedGoal.getGoal().getClass() == AvoidEntityGoal.class));
//if(this.getRevan) {
// geoAnimatableAnimationState.getController().setAnimation(RawAnimation.begin().then("flee", Animation.LoopType.LOOP));
//}
return PlayState.CONTINUE;
}

private PlayState predicate(AnimationState<GeoAnimatable> geoAnimatableAnimationState) {

if(geoAnimatableAnimationState.isMoving()){
geoAnimatableAnimationState.getController().setAnimation(RawAnimation.begin().then("walk", Animation.LoopType.LOOP));

}else {
}else{
geoAnimatableAnimationState.getController().setAnimation(RawAnimation.begin().then("idle", Animation.LoopType.LOOP));
}
return PlayState.CONTINUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
import it.crystalnest.cobweb.api.registry.Register;
import it.crystalnest.goblin_fabrications.ModLoader;
import it.crystalnest.goblin_fabrications.entity.EntityRegistry;
import it.crystalnest.goblin_fabrications.entity.custom.GoblinEntity;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SpawnEggItem;

Expand Down
161 changes: 0 additions & 161 deletions goblin.animation.json

This file was deleted.

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ geckolib_version=4.4.4
# Gradle
org.gradle.jvmargs = -Xmx4G
org.gradle.daemon = false

0 comments on commit 356fa4e

Please sign in to comment.