
- SPIGOT-5732: Fix issue with spawning leash hitches and painting, by using the right block faces - SPIGOT-6387: Allow hanging entities to be spawned mid air - Use randomize parameter to determine if a random painting should be chosen or not - Return BlockFace self by leash hitches entity - Throw a standardised exception when trying to set a BlockFace to a hanging entity which the entity does not support, instead of using BlockFace south or throwing a null pointer
43 lines
1.1 KiB
Java
43 lines
1.1 KiB
Java
package org.bukkit.craftbukkit.entity;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import net.minecraft.world.entity.decoration.EntityLeash;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.LeashHitch;
|
|
|
|
public class CraftLeash extends CraftHanging implements LeashHitch {
|
|
public CraftLeash(CraftServer server, EntityLeash entity) {
|
|
super(server, entity);
|
|
}
|
|
|
|
@Override
|
|
public boolean setFacingDirection(BlockFace face, boolean force) {
|
|
Preconditions.checkArgument(face == BlockFace.SELF, "%s is not a valid facing direction", face);
|
|
|
|
return force || getHandle().generation || getHandle().survives();
|
|
}
|
|
|
|
@Override
|
|
public BlockFace getFacing() {
|
|
// Leash hitch has no facing direction, so we return self
|
|
return BlockFace.SELF;
|
|
}
|
|
|
|
@Override
|
|
public EntityLeash getHandle() {
|
|
return (EntityLeash) entity;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "CraftLeash";
|
|
}
|
|
|
|
@Override
|
|
public EntityType getType() {
|
|
return EntityType.LEASH_HITCH;
|
|
}
|
|
}
|