@@ -70,7 +70,7 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay
|
||||
public void startDancing(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
Preconditions.checkArgument(location.getBlock().getType().equals(Material.JUKEBOX), "The Block in the Location need to be a JukeBox");
|
||||
getHandle().setJukeboxPlaying(new BlockPosition(location.getX(), location.getY(), location.getZ()), true);
|
||||
getHandle().setJukeboxPlaying(BlockPosition.containing(location.getX(), location.getY(), location.getZ()), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay {
|
||||
|
||||
public CraftBlockDisplay(CraftServer server, net.minecraft.world.entity.Display.BlockDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.BlockDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.BlockDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftBlockDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.BLOCK_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlock() {
|
||||
return CraftBlockData.fromData(getHandle().getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockData block) {
|
||||
Preconditions.checkArgument(block != null, "Block cannot be null");
|
||||
|
||||
getHandle().setBlockState(((CraftBlockData) block).getState());
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
||||
case OAK -> Type.OAK;
|
||||
case BIRCH -> Type.BIRCH;
|
||||
case ACACIA -> Type.ACACIA;
|
||||
case CHERRY -> Type.CHERRY;
|
||||
case JUNGLE -> Type.JUNGLE;
|
||||
case SPRUCE -> Type.SPRUCE;
|
||||
case DARK_OAK -> Type.DARK_OAK;
|
||||
@@ -123,6 +124,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
||||
case SPRUCE -> EntityBoat.EnumBoatType.SPRUCE;
|
||||
case DARK_OAK -> EntityBoat.EnumBoatType.DARK_OAK;
|
||||
case JUNGLE -> EntityBoat.EnumBoatType.JUNGLE;
|
||||
case CHERRY -> EntityBoat.EnumBoatType.CHERRY;
|
||||
case ACACIA -> EntityBoat.EnumBoatType.ACACIA;
|
||||
case BIRCH -> EntityBoat.EnumBoatType.BIRCH;
|
||||
case OAK -> EntityBoat.EnumBoatType.OAK;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.EntityPose;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Camel;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -43,7 +44,7 @@ public class CraftCamel extends CraftAbstractHorse implements Camel {
|
||||
|
||||
@Override
|
||||
public boolean isSitting() {
|
||||
return getHandle().isPoseSitting();
|
||||
return getHandle().getPose() == EntityPose.SITTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.util.Transformation;
|
||||
|
||||
public class CraftDisplay extends CraftEntity implements Display {
|
||||
|
||||
public CraftDisplay(CraftServer server, net.minecraft.world.entity.Display entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display getHandle() {
|
||||
return (net.minecraft.world.entity.Display) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transformation getTransformation() {
|
||||
com.mojang.math.Transformation nms = net.minecraft.world.entity.Display.createTransformation(getHandle().getEntityData());
|
||||
|
||||
return new Transformation(nms.getTranslation(), nms.getLeftRotation(), nms.getScale(), nms.getRightRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransformation(Transformation transformation) {
|
||||
Preconditions.checkArgument(transformation != null, "Transformation cannot be null");
|
||||
|
||||
getHandle().setTransformation(new com.mojang.math.Transformation(transformation.getTranslation(), transformation.getLeftRotation(), transformation.getScale(), transformation.getRightRotation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterpolationDuration() {
|
||||
return getHandle().getInterpolationDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolationDuration(int duration) {
|
||||
getHandle().setInterpolationDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getViewRange() {
|
||||
return getHandle().getViewRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewRange(float range) {
|
||||
getHandle().setViewRange(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowRadius() {
|
||||
return getHandle().getShadowRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowRadius(float radius) {
|
||||
getHandle().setShadowRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowStrength() {
|
||||
return getHandle().getShadowStrength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowStrength(float strength) {
|
||||
getHandle().setShadowStrength(strength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDisplayWidth() {
|
||||
return getHandle().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayWidth(float width) {
|
||||
getHandle().setWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDisplayHeight() {
|
||||
return getHandle().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayHeight(float height) {
|
||||
getHandle().setHeight(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterpolationDelay() {
|
||||
return getHandle().getInterpolationDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolationDelay(int ticks) {
|
||||
getHandle().setInterpolationDelay(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Billboard getBillboard() {
|
||||
return Billboard.valueOf(getHandle().getBillboardConstraints().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBillboard(Billboard billboard) {
|
||||
Preconditions.checkArgument(billboard != null, "Billboard cannot be null");
|
||||
|
||||
getHandle().setBillboardConstraints(net.minecraft.world.entity.Display.BillboardConstraints.valueOf(billboard.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getGlowColorOverride() {
|
||||
int color = getHandle().getGlowColorOverride();
|
||||
|
||||
return (color == -1) ? null : Color.fromRGB(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowColorOverride(Color color) {
|
||||
if (color == null) {
|
||||
getHandle().setGlowColorOverride(-1);
|
||||
} else {
|
||||
getHandle().setGlowColorOverride(color.asRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Brightness getBrightness() {
|
||||
net.minecraft.util.Brightness nms = getHandle().getBrightnessOverride();
|
||||
|
||||
return (nms != null) ? new Brightness(nms.block(), nms.sky()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrightness(Brightness brightness) {
|
||||
if (brightness != null) {
|
||||
getHandle().setBrightnessOverride(new net.minecraft.util.Brightness(brightness.getBlockLight(), brightness.getSkyLight()));
|
||||
} else {
|
||||
getHandle().setBrightnessOverride(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
|
||||
@Override
|
||||
public void setTargetLocation(Location location) {
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
|
||||
getHandle().signalTo(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
getHandle().signalTo(BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -15,8 +14,7 @@ import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerChunkMap;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Display;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityAreaEffectCloud;
|
||||
import net.minecraft.world.entity.EntityCreature;
|
||||
@@ -26,6 +24,7 @@ import net.minecraft.world.entity.EntityLightning;
|
||||
import net.minecraft.world.entity.EntityLiving;
|
||||
import net.minecraft.world.entity.EntityTameableAnimal;
|
||||
import net.minecraft.world.entity.GlowSquid;
|
||||
import net.minecraft.world.entity.Interaction;
|
||||
import net.minecraft.world.entity.Marker;
|
||||
import net.minecraft.world.entity.ambient.EntityAmbient;
|
||||
import net.minecraft.world.entity.ambient.EntityBat;
|
||||
@@ -71,6 +70,7 @@ import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorseZombie;
|
||||
import net.minecraft.world.entity.animal.horse.EntityLlama;
|
||||
import net.minecraft.world.entity.animal.horse.EntityLlamaTrader;
|
||||
import net.minecraft.world.entity.animal.sniffer.Sniffer;
|
||||
import net.minecraft.world.entity.boss.EntityComplexPart;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EntityEnderCrystal;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
|
||||
@@ -273,6 +273,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof Axolotl) { return new CraftAxolotl(server, (Axolotl) entity); }
|
||||
else if (entity instanceof Goat) { return new CraftGoat(server, (Goat) entity); }
|
||||
else if (entity instanceof Frog) { return new CraftFrog(server, (Frog) entity); }
|
||||
else if (entity instanceof Sniffer) { return new CraftSniffer(server, (Sniffer) entity); }
|
||||
else { return new CraftAnimals(server, (EntityAnimal) entity); }
|
||||
}
|
||||
// Monsters
|
||||
@@ -422,6 +423,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityEvokerFangs) { return new CraftEvokerFangs(server, (EntityEvokerFangs) entity); }
|
||||
else if (entity instanceof EntityLlamaSpit) { return new CraftLlamaSpit(server, (EntityLlamaSpit) entity); }
|
||||
else if (entity instanceof Marker) { return new CraftMarker(server, (Marker) entity); }
|
||||
else if (entity instanceof Interaction) { return new CraftInteraction(server, (Interaction) entity); }
|
||||
else if (entity instanceof Display) {
|
||||
if (entity instanceof Display.BlockDisplay) { return new CraftBlockDisplay(server, (Display.BlockDisplay) entity); }
|
||||
else if (entity instanceof Display.ItemDisplay) { return new CraftItemDisplay(server, (Display.ItemDisplay) entity); }
|
||||
else if (entity instanceof Display.TextDisplay) { return new CraftTextDisplay(server, (Display.TextDisplay) entity); }
|
||||
else { return new CraftDisplay(server, (Display) entity); }
|
||||
}
|
||||
// CHECKSTYLE:ON
|
||||
|
||||
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
|
||||
@@ -1012,7 +1020,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
return getHandle().isInvulnerableTo(DamageSource.GENERIC);
|
||||
return getHandle().isInvulnerableTo(getHandle().damageSources().generic());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Interaction;
|
||||
|
||||
public class CraftInteraction extends CraftEntity implements Interaction {
|
||||
|
||||
public CraftInteraction(CraftServer server, net.minecraft.world.entity.Interaction entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Interaction getHandle() {
|
||||
return (net.minecraft.world.entity.Interaction) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftInteraction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.INTERACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInteractionWidth() {
|
||||
return getHandle().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractionWidth(float width) {
|
||||
getHandle().setWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInteractionHeight() {
|
||||
return getHandle().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractionHeight(float height) {
|
||||
getHandle().setHeight(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return getHandle().getResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean response) {
|
||||
getHandle().setResponse(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviousInteraction getLastAttack() {
|
||||
net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().attack;
|
||||
|
||||
return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviousInteraction getLastInteraction() {
|
||||
net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().interaction;
|
||||
|
||||
return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null;
|
||||
}
|
||||
|
||||
private static class CraftPreviousInteraction implements PreviousInteraction {
|
||||
|
||||
private final UUID uuid;
|
||||
private final long timestamp;
|
||||
|
||||
public CraftPreviousInteraction(UUID uuid, long timestamp) {
|
||||
this.uuid = uuid;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getPlayer() {
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,12 +68,12 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
|
||||
@Override
|
||||
public void setOwner(UUID uuid) {
|
||||
item.setOwner(uuid);
|
||||
item.setTarget(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
return item.getOwner();
|
||||
return item.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +83,7 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
|
||||
@Override
|
||||
public UUID getThrower() {
|
||||
return item.getThrower();
|
||||
return item.thrower;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftItemDisplay extends CraftDisplay implements ItemDisplay {
|
||||
|
||||
public CraftItemDisplay(CraftServer server, net.minecraft.world.entity.Display.ItemDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.ItemDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.ItemDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftItemDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ITEM_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getItemStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack item) {
|
||||
getHandle().setItemStack(CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDisplayTransform getItemDisplayTransform() {
|
||||
return ItemDisplayTransform.values()[getHandle().getItemTransform().ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemDisplayTransform(ItemDisplayTransform display) {
|
||||
Preconditions.checkArgument(display != null, "Display cannot be null");
|
||||
|
||||
getHandle().setItemTransform(ItemDisplayContext.BY_ID.apply(display.ordinal()));
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
getHandle().setHealth((float) health);
|
||||
|
||||
if (health == 0) {
|
||||
getHandle().die(DamageSource.GENERIC);
|
||||
getHandle().die(getHandle().damageSources().generic());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public void damage(double amount, org.bukkit.entity.Entity source) {
|
||||
Preconditions.checkState(!getHandle().generation, "Cannot damage entity during world generation");
|
||||
|
||||
DamageSource reason = DamageSource.GENERIC;
|
||||
DamageSource reason = getHandle().damageSources().generic();
|
||||
|
||||
if (source instanceof HumanEntity) {
|
||||
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
|
||||
reason = getHandle().damageSources().playerAttack(((CraftHumanEntity) source).getHandle());
|
||||
} else if (source instanceof LivingEntity) {
|
||||
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
reason = getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
}
|
||||
|
||||
entity.hurt(reason, (float) amount);
|
||||
@@ -702,7 +702,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
|
||||
@Override
|
||||
public Sound getHurtSound() {
|
||||
SoundEffect sound = getHandle().getHurtSound0(DamageSource.GENERIC);
|
||||
SoundEffect sound = getHandle().getHurtSound0(getHandle().damageSources().generic());
|
||||
return (sound != null) ? CraftSound.getBukkit(sound) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CraftPig extends CraftAnimals implements Pig {
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0;
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class CraftPig extends CraftAnimals implements Pig {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().steering.boostTimeTotal;
|
||||
int max = getHandle().steering.boostTimeTotal();
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().steering.boostTime = ticks;
|
||||
|
||||
@@ -216,7 +216,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public InetSocketAddress getAddress() {
|
||||
if (getHandle().connection == null) return null;
|
||||
|
||||
SocketAddress addr = getHandle().connection.connection.getRemoteAddress();
|
||||
SocketAddress addr = getHandle().connection.getRemoteAddress();
|
||||
if (addr instanceof InetSocketAddress) {
|
||||
return (InetSocketAddress) addr;
|
||||
} else {
|
||||
@@ -842,20 +842,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void addCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.ADD);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.REMOVE);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.REMOVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.SET);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.SET);
|
||||
}
|
||||
|
||||
private void sendCustomChatCompletionPacket(Collection<String> completions, ClientboundCustomChatCompletionsPacket.a action) { // PAIL rename Action
|
||||
private void sendCustomChatCompletionPacket(Collection<String> completions, ClientboundCustomChatCompletionsPacket.Action action) {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
ClientboundCustomChatCompletionsPacket packet = new ClientboundCustomChatCompletionsPacket(action, new ArrayList<>(completions));
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Sniffer;
|
||||
|
||||
public class CraftSniffer extends CraftAnimals implements Sniffer {
|
||||
|
||||
public CraftSniffer(CraftServer server, net.minecraft.world.entity.animal.sniffer.Sniffer entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.animal.sniffer.Sniffer getHandle() {
|
||||
return (net.minecraft.world.entity.animal.sniffer.Sniffer) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftSniffer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SNIFFER;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class CraftStrider extends CraftAnimals implements Strider {
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0;
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +56,7 @@ public class CraftStrider extends CraftAnimals implements Strider {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().steering.boostTimeTotal;
|
||||
int max = getHandle().steering.boostTimeTotal();
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().steering.boostTime = ticks;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.entity.Display;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
|
||||
public class CraftTextDisplay extends CraftDisplay implements TextDisplay {
|
||||
|
||||
public CraftTextDisplay(CraftServer server, net.minecraft.world.entity.Display.TextDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.TextDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.TextDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftTextDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.TEXT_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return CraftChatMessage.fromComponent(getHandle().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
getHandle().setText(CraftChatMessage.fromString(text, true)[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLineWidth() {
|
||||
return getHandle().getLineWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineWidth(int width) {
|
||||
getHandle().setLineWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackgroundColor() {
|
||||
int color = getHandle().getBackgroundColor();
|
||||
|
||||
return (color == -1) ? null : Color.fromRGB(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(Color color) {
|
||||
if (color == null) {
|
||||
getHandle().setBackgroundColor(-1);
|
||||
} else {
|
||||
getHandle().setBackgroundColor(color.asRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTextOpacity() {
|
||||
return getHandle().getTextOpacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextOpacity(byte opacity) {
|
||||
getHandle().setTextOpacity(opacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShadowed() {
|
||||
return getFlag(Display.TextDisplay.FLAG_SHADOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowed(boolean shadow) {
|
||||
setFlag(Display.TextDisplay.FLAG_SHADOW, shadow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeeThrough() {
|
||||
return getFlag(Display.TextDisplay.FLAG_SEE_THROUGH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeeThrough(boolean seeThrough) {
|
||||
setFlag(Display.TextDisplay.FLAG_SEE_THROUGH, seeThrough);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBackground() {
|
||||
return getFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultBackground(boolean defaultBackground) {
|
||||
setFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND, defaultBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAligment getAlignment() {
|
||||
Display.TextDisplay.Align nms = Display.TextDisplay.getAlign(getHandle().getFlags());
|
||||
return TextAligment.valueOf(nms.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlignment(TextAligment alignment) {
|
||||
Preconditions.checkArgument(alignment != null, "Alignment cannot be null");
|
||||
|
||||
switch (alignment) {
|
||||
case LEFT:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, true);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false);
|
||||
break;
|
||||
case RIGHT:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, true);
|
||||
break;
|
||||
case CENTER:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown alignment " + alignment);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getFlag(int flag) {
|
||||
return (getHandle().getFlags() & flag) != 0;
|
||||
}
|
||||
|
||||
private void setFlag(int flag, boolean set) {
|
||||
byte flagBits = getHandle().getFlags();
|
||||
|
||||
if (set) {
|
||||
flagBits |= flag;
|
||||
} else {
|
||||
flagBits &= ~flag;
|
||||
}
|
||||
|
||||
getHandle().setFlags(flagBits);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde
|
||||
public void setDisturbanceLocation(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
|
||||
WardenAi.setDisturbanceLocation(getHandle(), new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
WardenAi.setDisturbanceLocation(getHandle(), BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,6 +51,6 @@ public final class CraftMemoryMapper {
|
||||
}
|
||||
|
||||
public static GlobalPos toNms(Location location) {
|
||||
return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user