mirror of
https://github.com/Minestom/Minestom.git
synced 2025-04-09 13:46:46 +02:00
Added options for the pathfinder
This commit is contained in:
parent
5a6afbbb89
commit
91711401c0
@ -13,6 +13,15 @@ public class PFPathingEntity implements IPathingEntity {
|
|||||||
private float searchRange;
|
private float searchRange;
|
||||||
private Position targetPosition;
|
private Position targetPosition;
|
||||||
|
|
||||||
|
// Capacities
|
||||||
|
private boolean fireResistant;
|
||||||
|
private boolean cautious;
|
||||||
|
private boolean climber;
|
||||||
|
private boolean swimmer;
|
||||||
|
private boolean aquaphobic;
|
||||||
|
private boolean avoidsDoorways;
|
||||||
|
private boolean opensDoors;
|
||||||
|
|
||||||
public PFPathingEntity(EntityCreature entity) {
|
public PFPathingEntity(EntityCreature entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.searchRange = entity.getAttributeValue(Attribute.FOLLOW_RANGE);
|
this.searchRange = entity.getAttributeValue(Attribute.FOLLOW_RANGE);
|
||||||
@ -41,6 +50,62 @@ public class PFPathingEntity implements IPathingEntity {
|
|||||||
this.searchRange = searchRange;
|
this.searchRange = searchRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFireResistant() {
|
||||||
|
return fireResistant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFireResistant(boolean fireResistant) {
|
||||||
|
this.fireResistant = fireResistant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCautious() {
|
||||||
|
return cautious;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCautious(boolean cautious) {
|
||||||
|
this.cautious = cautious;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClimber() {
|
||||||
|
return climber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClimber(boolean climber) {
|
||||||
|
this.climber = climber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSwimmer() {
|
||||||
|
return swimmer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSwimmer(boolean swimmer) {
|
||||||
|
this.swimmer = swimmer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAquaphobic() {
|
||||||
|
return aquaphobic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAquaphobic(boolean aquaphobic) {
|
||||||
|
this.aquaphobic = aquaphobic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAvoidsDoorways() {
|
||||||
|
return avoidsDoorways;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvoidsDoorways(boolean avoidsDoorways) {
|
||||||
|
this.avoidsDoorways = avoidsDoorways;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOpensDoors() {
|
||||||
|
return opensDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpensDoors(boolean opensDoors) {
|
||||||
|
this.opensDoors = opensDoors;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capabilities capabilities() {
|
public Capabilities capabilities() {
|
||||||
return new Capabilities() {
|
return new Capabilities() {
|
||||||
@ -51,37 +116,37 @@ public class PFPathingEntity implements IPathingEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fireResistant() {
|
public boolean fireResistant() {
|
||||||
return false;
|
return fireResistant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cautious() {
|
public boolean cautious() {
|
||||||
return false;
|
return cautious;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean climber() {
|
public boolean climber() {
|
||||||
return true;
|
return climber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean swimmer() {
|
public boolean swimmer() {
|
||||||
return true;
|
return swimmer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean aquaphobic() {
|
public boolean aquaphobic() {
|
||||||
return false;
|
return aquaphobic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean avoidsDoorways() {
|
public boolean avoidsDoorways() {
|
||||||
return false;
|
return avoidsDoorways;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean opensDoors() {
|
public boolean opensDoors() {
|
||||||
return false;
|
return opensDoors;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.minestom.server.item;
|
package net.minestom.server.item;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minestom.server.chat.ColoredText;
|
import net.minestom.server.chat.ColoredText;
|
||||||
import net.minestom.server.data.Data;
|
import net.minestom.server.data.Data;
|
||||||
import net.minestom.server.data.DataContainer;
|
import net.minestom.server.data.DataContainer;
|
||||||
@ -65,6 +64,11 @@ public class ItemStack implements DataContainer {
|
|||||||
this(material, amount, (short) 0);
|
this(material, amount, (short) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a new air item
|
||||||
|
*
|
||||||
|
* @return an air item
|
||||||
|
*/
|
||||||
public static ItemStack getAirItem() {
|
public static ItemStack getAirItem() {
|
||||||
return new ItemStack(Material.AIR, (byte) 0);
|
return new ItemStack(Material.AIR, (byte) 0);
|
||||||
}
|
}
|
||||||
@ -145,10 +149,24 @@ public class ItemStack implements DataContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item damage (durability)
|
||||||
|
*
|
||||||
|
* @return the item damagel
|
||||||
|
*/
|
||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the item damage (durability)
|
||||||
|
*
|
||||||
|
* @param damage the item damage
|
||||||
|
*/
|
||||||
|
public void setDamage(int damage) {
|
||||||
|
this.damage = damage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the item amount
|
* Get the item amount
|
||||||
* <p>
|
* <p>
|
||||||
@ -173,10 +191,6 @@ public class ItemStack implements DataContainer {
|
|||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDamage(int damage) {
|
|
||||||
this.damage = damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the special meta object for this item
|
* Get the special meta object for this item
|
||||||
* <p>
|
* <p>
|
||||||
@ -406,7 +420,7 @@ public class ItemStack implements DataContainer {
|
|||||||
* @return true if the item has the flag {@code flag}, false otherwise
|
* @return true if the item has the flag {@code flag}, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean hasItemFlag(ItemFlag flag) {
|
public boolean hasItemFlag(ItemFlag flag) {
|
||||||
int bitModifier = getBitModifier(flag);
|
final int bitModifier = getBitModifier(flag);
|
||||||
return (this.hideFlag & bitModifier) == bitModifier;
|
return (this.hideFlag & bitModifier) == bitModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,7 +534,7 @@ public class ItemStack implements DataContainer {
|
|||||||
* @throws NullPointerException if {@code stackingRule} is null
|
* @throws NullPointerException if {@code stackingRule} is null
|
||||||
*/
|
*/
|
||||||
public void setStackingRule(StackingRule stackingRule) {
|
public void setStackingRule(StackingRule stackingRule) {
|
||||||
Check.notNull(stackingRule, "StackingRule cannot be null!");
|
Check.notNull(stackingRule, "The stacking rule cannot be null!");
|
||||||
this.stackingRule = stackingRule;
|
this.stackingRule = stackingRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,29 +557,6 @@ public class ItemStack implements DataContainer {
|
|||||||
return (byte) (1 << hideFlag.ordinal());
|
return (byte) (1 << hideFlag.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the item into a readable Json object
|
|
||||||
* <p>
|
|
||||||
* Mainly used to show an item in a message hover
|
|
||||||
*
|
|
||||||
* @return a {@link JsonObject} containing the item data
|
|
||||||
*/
|
|
||||||
public synchronized JsonObject toJsonObject() {
|
|
||||||
JsonObject object = new JsonObject();
|
|
||||||
object.addProperty("id", material.getId());
|
|
||||||
object.addProperty("Damage", getDamage());
|
|
||||||
object.addProperty("Count", getAmount());
|
|
||||||
|
|
||||||
if (hasDisplayName() || hasLore()) {
|
|
||||||
JsonObject tagObject = new JsonObject();
|
|
||||||
if (hasDisplayName()) {
|
|
||||||
tagObject.addProperty("display", getDisplayName().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the item meta based on the material type
|
* Find the item meta based on the material type
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user