Skip to content

Commit

Permalink
feat: configurable walk speed
Browse files Browse the repository at this point in the history
  • Loading branch information
t2pellet committed Jun 24, 2024
1 parent 7f82254 commit 7d73e11
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.t2pellet.strawgolem;

import com.t2pellet.tlib.config.api.Config;
import com.t2pellet.tlib.config.api.property.BoolProperty;
import com.t2pellet.tlib.config.api.property.IntProperty;
import com.t2pellet.tlib.config.api.property.ListProperty;
import com.t2pellet.tlib.config.api.property.StringProperty;
import com.t2pellet.tlib.config.api.property.*;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;

Expand Down Expand Up @@ -76,6 +73,10 @@ public static class Behaviour {
public static final BoolProperty golemsPanicWhenHurt = new BoolProperty(true);
@Entry(comment = "How far the golem can wander")
public static final IntProperty golemWanderRange = new IntProperty(24, 8, 48);
@Entry(comment = "Walk speed for straw golem")
public static final FloatProperty golemWalkSpeed = new FloatProperty(0.5F);
@Entry(comment = "Walk speed for straw golem")
public static final FloatProperty golemRunSpeed = new FloatProperty(0.8F);
}

@Section(name = "Visual", description = "Visual related settings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ protected void defineSynchedData() {

@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Monster.class, 8.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Evoker.class, 12.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Vindicator.class, 8.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Vex.class, 8.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Raider.class, 15.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Illusioner.class, 12.0F, 0.5D, 0.7D, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Sheep.class, 8.0F, 0.4D, 0.6D, false));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Cow.class, 8.0F, 0.4D, 0.6D, false));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Monster.class, 8.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Evoker.class, 12.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Vindicator.class, 8.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Vex.class, 8.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Raider.class, 15.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Illusioner.class, 12.0F, true));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Sheep.class, 8.0F, false));
this.goalSelector.addGoal(1, new GolemFleeEntityGoal<>(this, Cow.class, 8.0F, false));
this.goalSelector.addGoal(1, new GolemPanicGoal(this));
this.goalSelector.addGoal(2, new GolemTemptGoal(this));
this.goalSelector.addGoal(2, new GolemBeShyGoal(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DeliverCropGoal extends MoveToBlockGoal {
private final ServerLevel level;

public DeliverCropGoal(StrawGolem golem) {
super(golem, 0.5, StrawgolemConfig.Harvesting.harvestRange.get());
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), StrawgolemConfig.Harvesting.harvestRange.get());
this.golem = golem;
this.level = (ServerLevel) golem.level;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class GolemBeShyGoal extends GolemFleeEntityGoal<Player> {

public GolemBeShyGoal(StrawGolem golem) {
super(golem, Player.class, 2.0F, 0.4D, 0.6D, false);
super(golem, Player.class, 2.0F, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class GolemFleeEntityGoal<T extends LivingEntity> extends AvoidEntityGoal
private final StrawGolem golem;
private final boolean panic;

public GolemFleeEntityGoal(StrawGolem mob, Class<T> clazz, float distance, double walkSpeed, double sprintSpeed, boolean panic) {
super(mob, clazz, distance, walkSpeed, sprintSpeed);
public GolemFleeEntityGoal(StrawGolem mob, Class<T> clazz, float distance, boolean panic) {
super(mob, clazz, distance, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), StrawgolemConfig.Behaviour.golemRunSpeed.get());
this.golem = mob;
this.panic = panic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GolemPanicGoal extends PanicGoal {
private final StrawGolem golem;

public GolemPanicGoal(StrawGolem golem) {
super(golem, 0.8D);
super(golem, StrawgolemConfig.Behaviour.golemRunSpeed.get());
this.golem = golem;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.t2pellet.strawgolem.entity.goals.golem;

import com.t2pellet.strawgolem.StrawgolemConfig;
import com.t2pellet.strawgolem.entity.StrawGolem;
import com.t2pellet.strawgolem.entity.capabilities.decay.DecayState;
import com.t2pellet.strawgolem.registry.StrawgolemSounds;
Expand All @@ -25,7 +26,7 @@ public class GolemRepairSelfGoal extends MoveToBlockGoal {
private Container feeder;

public GolemRepairSelfGoal(StrawGolem golem, int range) {
super(golem, 0.5, range);
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), range);
this.golem = golem;
this.level = (ServerLevel) golem.level;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.t2pellet.strawgolem.entity.goals.golem;

import com.t2pellet.strawgolem.StrawgolemConfig;
import com.t2pellet.strawgolem.entity.StrawGolem;
import net.minecraft.world.entity.ai.goal.TemptGoal;
import net.minecraft.world.item.crafting.Ingredient;
Expand All @@ -9,7 +10,7 @@ public class GolemTemptGoal extends TemptGoal {
private final StrawGolem golem;

public GolemTemptGoal(StrawGolem golem) {
super(golem, 0.5F, Ingredient.of(StrawGolem.REPAIR_ITEM), false);
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), Ingredient.of(StrawGolem.REPAIR_ITEM), false);
this.golem = golem;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.t2pellet.strawgolem.entity.goals.golem;

import com.t2pellet.strawgolem.StrawgolemConfig;
import com.t2pellet.strawgolem.entity.StrawGolem;
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;

Expand All @@ -8,7 +9,7 @@ public class GolemWanderGoal extends WaterAvoidingRandomStrollGoal {
private final StrawGolem golem;

public GolemWanderGoal(StrawGolem golem) {
super(golem, 0.5F);
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get());
this.golem = golem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HarvestCropGoal extends MoveToBlockGoal {
private final StrawGolem golem;

public HarvestCropGoal(StrawGolem golem) {
super(golem, 0.5, StrawgolemConfig.Harvesting.harvestRange.get());
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), StrawgolemConfig.Harvesting.harvestRange.get());
this.golem = golem;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.t2pellet.strawgolem.entity.goals.golem;

import com.t2pellet.strawgolem.StrawgolemConfig;
import com.t2pellet.strawgolem.entity.StrawGolem;
import com.t2pellet.strawgolem.registry.StrawgolemSounds;
import net.minecraft.core.BlockPos;
Expand All @@ -15,7 +16,7 @@ public class ReturnToTetherGoal extends MoveToBlockGoal {
private final ServerLevel level;

public ReturnToTetherGoal(StrawGolem golem) {
super(golem, 0.5, 24);
super(golem, StrawgolemConfig.Behaviour.golemWalkSpeed.get(), 24);
this.golem = golem;
this.level = (ServerLevel) golem.level;
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 7d73e11

Please sign in to comment.