From 356fa4eda0043313db9dde57069b7277823a5bfc Mon Sep 17 00:00:00 2001 From: Noir <60018820+sZeta99@users.noreply.github.com> Date: Sun, 12 May 2024 22:41:39 +0200 Subject: [PATCH] Working on Flee, still stuck on Rendering --- .../entity/client/GoblinModel.java | 7 +- .../entity/client/GoblinRenderer.java | 4 +- .../entity/custom/GoblinEntity.java | 15 +- .../item/ItemRegistry.java | 6 - goblin.animation.json | 161 ------------------ gradle.properties | 1 + 6 files changed, 18 insertions(+), 176 deletions(-) delete mode 100644 goblin.animation.json diff --git a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinModel.java b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinModel.java index c73569e..00ddfd9 100644 --- a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinModel.java +++ b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinModel.java @@ -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 { @Override @@ -39,4 +34,6 @@ public void setCustomAnimations(GoblinEntity animatable, long instanceId, Animat } + + } diff --git a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinRenderer.java b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinRenderer.java index 0da891c..ed4b70b 100644 --- a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinRenderer.java +++ b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/client/GoblinRenderer.java @@ -15,7 +15,7 @@ public class GoblinRenderer extends GeoEntityRenderer { public GoblinRenderer(EntityRendererProvider.Context renderManager) { super(renderManager, new GoblinModel()); - addRenderLayer(new HumanoidArmorLayer(this)); + //addRenderLayer(new HumanoidArmorLayer(this)); } @Override @@ -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())); } } diff --git a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/custom/GoblinEntity.java b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/custom/GoblinEntity.java index a64558e..01d3d16 100644 --- a/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/custom/GoblinEntity.java +++ b/fabric/src/main/java/it/crystalnest/goblin_fabrications/entity/custom/GoblinEntity.java @@ -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 { @@ -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(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)); @@ -61,13 +62,23 @@ protected void registerGoals() { @Override public void registerControllers(AnimatableManager.ControllerRegistrar controllers) { controllers.add(new AnimationController(this, "controller", this::predicate)); + controllers.add(new AnimationController(this, "fleeController", this::fleePredicte)); + } + + private PlayState fleePredicte(AnimationState 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 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; diff --git a/fabric/src/main/java/it/crystalnest/goblin_fabrications/item/ItemRegistry.java b/fabric/src/main/java/it/crystalnest/goblin_fabrications/item/ItemRegistry.java index 56c5623..6f775f5 100644 --- a/fabric/src/main/java/it/crystalnest/goblin_fabrications/item/ItemRegistry.java +++ b/fabric/src/main/java/it/crystalnest/goblin_fabrications/item/ItemRegistry.java @@ -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; diff --git a/goblin.animation.json b/goblin.animation.json deleted file mode 100644 index 89a6b60..0000000 --- a/goblin.animation.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "format_version": "1.8.0", - "animations": { - "Idle": { - "animation_length": 6, - "bones": { - "head": { - "rotation": { - "vector": ["math.sin(query.anim_time * 30) * 3", 0, "math.sin(query.anim_time * 60) * 5"] - } - }, - "Left_arm": { - "rotation": { - "vector": ["math.sin(query.anim_time * 60) * 3", 0, "-5+math.sin(query.anim_time * 120) * 5"] - } - }, - "Right_arm": { - "rotation": { - "vector": ["math.sin(query.anim_time * 30) * 3", 0, "5+math.sin(query.anim_time * 60) * 5"] - } - }, - "spear1": { - "rotation": { - "vector": ["math.sin(query.anim_time * 30) * 3", 0, "math.sin(query.anim_time * 60) * 3"] - } - }, - "spear2": { - "rotation": { - "vector": ["math.sin(query.anim_time * 30) * 3", 0, "math.sin(query.anim_time * 30) * 3"] - } - }, - "spear3": { - "rotation": { - "vector": ["math.sin(query.anim_time * 60) * 3", 0, "math.sin(query.anim_time * 30) * 3"] - } - } - } - }, - "walk": { - "loop": true, - "animation_length": 2, - "bones": { - "head": { - "rotation": { - "vector": [0, 0, "math.sin(query.anim_time * 180) * 12"] - } - }, - "Left_arm": { - "rotation": { - "vector": ["math.sin(query.anim_time * 360) * 25", 0, -5] - } - }, - "Right_arm": { - "rotation": { - "vector": ["5+math.sin(query.anim_time * - 360) * 25", 0, 5] - } - }, - "Left_leg": { - "rotation": { - "vector": ["math.sin(query.anim_time * -360) * 25", 0, 0] - } - }, - "Righ_leg": { - "rotation": { - "vector": ["math.sin(query.anim_time * 360) * 25", 0, 0] - } - }, - "backpack": { - "rotation": { - "vector": ["math.sin(query.anim_time * 360) * 0.3", 0, "math.sin(query.anim_time * 360) * 0.3 "] - } - }, - "spear1": { - "rotation": { - "vector": ["math.sin(query.anim_time * -360) * 4 ", 0, "math.sin(query.anim_time * 360) * 5"] - } - }, - "spear2": { - "rotation": { - "vector": ["math.sin(query.anim_time * 360) * 2 ", 0, "math.sin(query.anim_time * 360) * 2"] - } - }, - "spear3": { - "rotation": { - "vector": ["math.sin(query.anim_time * 360) * 4", 0, "math.sin(query.anim_time * 360) * 8"] - } - } - } - }, - "Flee": { - "loop": true, - "animation_length": 2, - "bones": { - "head": { - "rotation": { - "vector": [0, 0, "math.sin(query.anim_time * 1500) * 2"] - } - }, - "fronte": { - "rotation": { - "1.6667": { - "pre": { - "vector": ["-(40)+math.sin(query.anim_time * 720) * 25", 0, 0] - }, - "post": { - "vector": ["-(40)+math.sin(query.anim_time * 720) * 25", 0, 0] - }, - "lerp_mode": "catmullrom" - } - } - }, - "Left_arm": { - "rotation": { - "vector": ["math.sin(query.anim_time * 720) * -25", 0, -120] - } - }, - "Right_arm": { - "rotation": { - "vector": ["math.sin(query.anim_time * 720) * 25", 0, 120] - } - }, - "Righ_leg": { - "rotation": { - "vector": ["math.sin(query.anim_time * 1080) * -50", 0, 0] - } - }, - "torso": { - "rotation": { - "vector": [0, 0, "math.sin(query.anim_time * 1500) * 2"] - } - }, - "backpack": { - "rotation": { - "vector": ["math.sin(query.anim_time * -360) * 4 ", 0, "-10+math.sin(query.anim_time * 720) * 3"] - } - }, - "spear1": { - "rotation": { - "vector": ["-20+math.sin(query.anim_time * -720) * 6 ", 0, "math.sin(query.anim_time * 720) * 7"] - } - }, - "spear2": { - "rotation": { - "vector": ["-25+math.sin(query.anim_time * -720) * 2 ", 0, "math.sin(query.anim_time * 720) * 3"] - } - }, - "spear3": { - "rotation": { - "vector": ["-25+math.sin(query.anim_time * -720) * 4 ", 0, "math.sin(query.anim_time * 720) * 5"] - } - }, - "Left_leg": { - "rotation": { - "vector": ["math.sin(query.anim_time * 1080) * 50", 0, 0] - } - } - } - } - }, - "geckolib_format_version": 2 -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d1a87e7..96d3414 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,3 +35,4 @@ geckolib_version=4.4.4 # Gradle org.gradle.jvmargs = -Xmx4G org.gradle.daemon = false +