13
0
geforkt von Mirrors/Paper

#512: Expand Strider and Steerable entity API

By: Parker Hawke <hawkeboyz2@hotmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2020-06-30 09:53:40 +10:00
Ursprung e34cd0f4b9
Commit c689413d27
4 geänderte Dateien mit 138 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -3,19 +3,4 @@ package org.bukkit.entity;
/**
* Represents a Pig.
*/
public interface Pig extends Animals, Vehicle {
/**
* Check if the pig has a saddle.
*
* @return if the pig has been saddled.
*/
public boolean hasSaddle();
/**
* Sets if the pig has a saddle or not
*
* @param saddled set if the pig has a saddle or not.
*/
public void setSaddle(boolean saddled);
}
public interface Pig extends Steerable, Vehicle { }

Datei anzeigen

@ -0,0 +1,71 @@
package org.bukkit.entity;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
/**
* Represents an entity which may be saddled, ridden and steered using an item.
*/
public interface Steerable extends Animals {
/**
* Check if the pig has a saddle.
*
* @return if the pig has been saddled.
*/
public boolean hasSaddle();
/**
* Sets if the pig has a saddle or not
*
* @param saddled set if the pig has a saddle or not.
*/
public void setSaddle(boolean saddled);
/**
* Get the time in ticks this entity's movement is being increased.
*
* Movement speed is often increased as a result of using the
* {@link #getSteerMaterial()}.
*
* @return the current boost ticks
*/
public int getBoostTicks();
/**
* Set the time in ticks this entity's movement will be increased.
*
* This will reset the current boost ticks to 0
* ({@link #getCurrentBoostTicks()}).
*
* @param ticks the boost time
*/
public void setBoostTicks(int ticks);
/**
* Get the time in ticks this entity's movement has been increased as of the
* most recent boost.
*
* Current boost ticks will never be {@literal >} {@link #getBoostTicks()}.
*
* @return the current boost ticks
*/
public int getCurrentBoostTicks();
/**
* Set the time in ticks this entity's movement has been increased relative
* to the most recent boost.
*
* @param ticks the current boost ticks. Must be {@literal >=} 0 and {@literal <=}
* {@link #getBoostTicks()}
*/
public void setCurrentBoostTicks(int ticks);
/**
* Get the material used to steer this entity when ridden by a player.
*
* @return the lure material
*/
@NotNull
public Material getSteerMaterial();
}

Datei anzeigen

@ -3,4 +3,23 @@ package org.bukkit.entity;
/**
* Represents a Strider.
*/
public interface Strider extends Animals, Vehicle { }
public interface Strider extends Steerable, Vehicle {
/**
* Check whether or not this strider is out of warm blocks and shivering.
*
* @return true if shivering, false otherwise
*/
public boolean isShivering();
/**
* Set whether or not this strider is shivering.
*
* Note that the shivering state is updated frequently on the server,
* therefore this method may not affect the entity for long enough to have a
* noticeable difference.
*
* @param shivering its new shivering state
*/
public void setShivering(boolean shivering);
}

Datei anzeigen

@ -0,0 +1,46 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Strider;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a {@link Strider}'s temperature has changed as a result of
* entering or existing blocks it considers warm.
*/
public class StriderTemperatureChangeEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
private final boolean shivering;
public StriderTemperatureChangeEvent(@NotNull Strider what, boolean shivering) {
super(what);
this.shivering = shivering;
}
@NotNull
@Override
public Strider getEntity() {
return (Strider) entity;
}
/**
* Get the Strider's new shivering state.
*
* @return the new shivering state
*/
public boolean isShivering() {
return shivering;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}