Skip to content

Commit

Permalink
Fix mor compile errors. Mainly AI package.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Sanders <zidane@spongepowered.org>
  • Loading branch information
Zidane committed Dec 16, 2019
1 parent e7fbcd1 commit 79c22f1
Show file tree
Hide file tree
Showing 35 changed files with 289 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public boolean shouldContinueExecuting() {
return this.continueUpdating();
}

@Override
public boolean isPreemptible() {
return this.canBeInterrupted();
}

@Override
public void startExecuting() {
this.start();
Expand All @@ -53,11 +58,6 @@ public void tick() {
this.update();
}

@Override
public boolean isInterruptible() {
return this.canBeInterrupted();
}

public abstract boolean canBeInterrupted();

public abstract void start();
Expand All @@ -69,6 +69,4 @@ public boolean isInterruptible() {
public abstract boolean continueUpdating();

public abstract void reset();

}

Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,35 @@
package org.spongepowered.common.entity.ai;

import com.google.common.base.MoreObjects;
import org.spongepowered.api.CatalogKey;
import org.spongepowered.api.entity.ai.GoalExecutor;
import org.spongepowered.api.entity.ai.GoalExecutorType;

public final class SpongeGoalExecutorType implements GoalExecutorType {
private final String id, name;
private final Class<? extends GoalExecutor<?>> goalClass;

public SpongeGoalExecutorType(String id, String name, Class<? extends GoalExecutor<?>> goalClass) {
this.id = id;
this.name = name;
this.goalClass = goalClass;
}
private final CatalogKey key;
private final Class<? extends GoalExecutor<?>> goalExecutorClass;

@Override
public Class<? extends GoalExecutor<?>> getGoalClass() {
return this.goalClass;
public SpongeGoalExecutorType(CatalogKey key, Class<? extends GoalExecutor<?>> goalExecutorClass) {
this.key = key;
this.goalExecutorClass = goalExecutorClass;
}

@Override
public String getId() {
return this.id;
public CatalogKey getKey() {
return this.key;
}

@Override
public String getName() {
return this.name;
public Class<? extends GoalExecutor<?>> getGoalExecutorClass() {
return this.goalExecutorClass;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.addValue(this.id)
.addValue(this.name)
.add("goalClass", this.goalClass)
.addValue(this.key)
.add("goalExecutorClass", this.goalExecutorClass)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

import com.google.common.base.Preconditions;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.goal.LookAtGoal;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.ai.goal.builtin.WatchClosestGoal;
import org.spongepowered.api.entity.ai.goal.builtin.LookAtGoal;
import org.spongepowered.api.entity.living.Agent;
import org.spongepowered.api.entity.living.Living;

public final class SpongeWatchClosestAIBuilder implements WatchClosestGoal.Builder {
@SuppressWarnings({"unchecked", "rawtypes"})
public final class SpongeWatchClosestAIBuilder implements LookAtGoal.Builder {

private Class<? extends Entity> watchedClass;
private Class<? extends Living> watchedClass;
private float maxDistance;
private float chance;

Expand All @@ -42,42 +42,41 @@ public SpongeWatchClosestAIBuilder() {
}

@Override
public WatchClosestGoal.Builder watch(Class<? extends Entity> watchedClass) {
public LookAtGoal.Builder watch(Class<? extends Living> watchedClass) {
this.watchedClass = watchedClass;
return this;
}

@Override
public WatchClosestGoal.Builder maxDistance(float maxDistance) {
public LookAtGoal.Builder maxDistance(float maxDistance) {
this.maxDistance = maxDistance;
return this;
}

@Override
public WatchClosestGoal.Builder chance(float chance) {
public LookAtGoal.Builder chance(float chance) {
this.chance = chance;
return this;
}

@Override
public WatchClosestGoal.Builder from(WatchClosestGoal value) {
public LookAtGoal.Builder from(LookAtGoal value) {
return this.watch(value.getWatchedClass())
.maxDistance(value.getMaxDistance())
.chance(value.getChance());
}

@Override
public WatchClosestGoal.Builder reset() {
public LookAtGoal.Builder reset() {
this.watchedClass = null;
this.maxDistance = 8;
this.chance = 0.02f;
return this;
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public WatchClosestGoal build(Agent owner) {
public LookAtGoal build(Agent owner) {
Preconditions.checkNotNull(this.watchedClass);
return (WatchClosestGoal) new LookAtGoal((MobEntity) owner, (Class) this.watchedClass, this.maxDistance, this.chance);
return (LookAtGoal) new net.minecraft.entity.ai.goal.LookAtGoal((MobEntity) owner, (Class) this.watchedClass, this.maxDistance, this.chance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,39 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.entity.ai;
package org.spongepowered.common.entity.ai.goal;

import com.google.common.base.MoreObjects;
import org.spongepowered.api.CatalogKey;
import org.spongepowered.api.entity.ai.goal.Goal;
import org.spongepowered.api.entity.ai.goal.GoalType;
import org.spongepowered.api.entity.living.Agent;

public final class SpongeGoalType implements GoalType {
private final String id, name;
private final Class<? extends Goal<? extends Agent>> aiClass;

public SpongeAITaskType(String id, String name, Class<? extends Goal<? extends Agent>> aiClass) {
this.id = id;
this.name = name;
this.aiClass = aiClass;
}
private final CatalogKey key;
private final Class<? extends Goal<? extends Agent>> goalClass;

@Override
public Class<? extends Goal<? extends Agent>> getAIClass() {
return this.aiClass;
public SpongeGoalType(CatalogKey key, Class<? extends Goal<? extends Agent>> goalClass) {
this.key = key;
this.goalClass = goalClass;
}

@Override
public String getId() {
return this.id;
public CatalogKey getKey() {
return this.key;
}

@Override
public String getName() {
return this.name;
public Class<? extends Goal<?>> getGoalClass() {
return this.goalClass;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.addValue(this.id)
.addValue(this.name)
.add("aiClass", this.aiClass)
.toString();
.addValue(this.key)
.add("goalClass", this.goalClass)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,30 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.entity.ai;
package org.spongepowered.common.entity.ai.goal.builtin;

import static com.google.common.base.Preconditions.checkNotNull;

import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import org.spongepowered.api.entity.ai.goal.builtin.LookIdleGoal;
import org.spongepowered.api.entity.ai.goal.builtin.LookRandomlyGoal;
import org.spongepowered.api.entity.living.Agent;

public final class SpongeLookIdleAIBuilder implements LookIdleGoal.Builder {
public final class SpongeLookRandomlyGoalBuilder implements LookRandomlyGoal.Builder {

@Override
public LookIdleGoal.Builder from(LookIdleGoal value) {
public LookRandomlyGoal.Builder from(LookRandomlyGoal value) {
return this;
}

@Override
public LookIdleGoal.Builder reset() {
public LookRandomlyGoal.Builder reset() {
return this;
}

@Override
public LookIdleGoal build(Agent owner) {
public LookRandomlyGoal build(Agent owner) {
checkNotNull(owner);

return (LookIdleGoal) new LookRandomlyGoal((MobEntity) owner);
return (LookRandomlyGoal) new net.minecraft.entity.ai.goal.LookRandomlyGoal((MobEntity) owner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,44 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.entity.ai;
package org.spongepowered.common.entity.ai.goal.builtin;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Preconditions;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.goal.SwimGoal;
import org.spongepowered.api.entity.ai.goal.builtin.SwimmingGoal;
import org.spongepowered.api.entity.ai.goal.builtin.SwimGoal;
import org.spongepowered.api.entity.living.Agent;

public final class SpongeSwimmingAIBuilder implements SwimmingGoal.Builder {
public final class SpongeSwimGoalBuilder implements SwimGoal.Builder {

float chance = 0.8f;
private float chance;

public SpongeSwimmingAIBuilder() {
public SpongeSwimGoalBuilder() {
this.reset();
}

@Override
public SwimmingGoal.Builder swimChance(float chance) {
public SwimGoal.Builder swimChance(float chance) {
this.chance = chance;
return this;
}

@Override
public SwimmingGoal.Builder from(SwimmingGoal value) {
public SwimGoal.Builder from(SwimGoal value) {
checkNotNull(value);
return this.swimChance(value.getSwimChance());
}

@Override
public SwimmingGoal.Builder reset() {
public SwimGoal.Builder reset() {
this.chance = 0.8f;
return this;
}

@Override
public SwimmingGoal build(Agent owner) {
Preconditions.checkNotNull(owner);
final SwimmingGoal task = (SwimmingGoal) new SwimGoal((MobEntity) owner);
public SwimGoal build(Agent owner) {
checkNotNull(owner);
final SwimGoal task = (SwimGoal) new net.minecraft.entity.ai.goal.SwimGoal((MobEntity) owner);
task.setSwimChance(this.chance);
return task;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.entity.ai;
package org.spongepowered.common.entity.ai.goal.builtin.creature;

import com.google.common.base.Preconditions;
import net.minecraft.entity.CreatureEntity;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import org.spongepowered.api.entity.ai.goal.builtin.creature.AttackLivingGoal;
import org.spongepowered.api.entity.living.Creature;

public final class SpongeAttackLivingAIBuilder implements AttackLivingGoal.Builder {
public final class SpongeAttackLivingGoalBuilder implements AttackLivingGoal.Builder {

private double speed;
private boolean longMemory;

public SpongeAttackLivingAIBuilder() {
public SpongeAttackLivingGoalBuilder() {
this.reset();
}

Expand Down

0 comments on commit 79c22f1

Please sign in to comment.