@@ -0,0 +1,34 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.animal.allay.Allay;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay {
|
||||
|
||||
public CraftAllay(CraftServer server, Allay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Allay getHandle() {
|
||||
return (Allay) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftAllay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ALLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return new CraftInventory(getHandle().getInventory());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.entity.animal.CatVariant;
|
||||
import net.minecraft.world.entity.animal.EntityCat;
|
||||
import net.minecraft.world.item.EnumColor;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -32,14 +34,14 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
|
||||
|
||||
@Override
|
||||
public Type getCatType() {
|
||||
return Type.values()[getHandle().getCatType()];
|
||||
return Type.values()[IRegistry.CAT_VARIANT.getId(getHandle().getCatVariant())];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatType(Type type) {
|
||||
Preconditions.checkArgument(type != null, "Cannot have null Type");
|
||||
|
||||
getHandle().setCatType(type.ordinal());
|
||||
getHandle().setCatVariant(IRegistry.CAT_VARIANT.byId(type.ordinal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.entity.vehicle.ChestBoat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.loot.LootTable;
|
||||
|
||||
public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat {
|
||||
|
||||
private final Inventory inventory;
|
||||
|
||||
public CraftChestBoat(CraftServer server, ChestBoat entity) {
|
||||
super(server, entity);
|
||||
inventory = new CraftInventory(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChestBoat getHandle() {
|
||||
return (ChestBoat) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftChestBoat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.CHEST_BOAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLootTable(LootTable table) {
|
||||
setLootTable(table, getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable() {
|
||||
MinecraftKey nmsTable = getHandle().getLootTable();
|
||||
if (nmsTable == null) {
|
||||
return null; // return empty loot table?
|
||||
}
|
||||
|
||||
NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
|
||||
return Bukkit.getLootTable(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
setLootTable(getLootTable(), seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return getHandle().getLootTableSeed();
|
||||
}
|
||||
|
||||
private void setLootTable(LootTable table, long seed) {
|
||||
MinecraftKey newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
getHandle().setLootTable(newKey);
|
||||
getHandle().setLootTableSeed(seed);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,10 @@ import net.minecraft.world.entity.animal.EntityTropicalFish;
|
||||
import net.minecraft.world.entity.animal.EntityTurtle;
|
||||
import net.minecraft.world.entity.animal.EntityWaterAnimal;
|
||||
import net.minecraft.world.entity.animal.EntityWolf;
|
||||
import net.minecraft.world.entity.animal.allay.Allay;
|
||||
import net.minecraft.world.entity.animal.axolotl.Axolotl;
|
||||
import net.minecraft.world.entity.animal.frog.Frog;
|
||||
import net.minecraft.world.entity.animal.frog.Tadpole;
|
||||
import net.minecraft.world.entity.animal.goat.Goat;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorse;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorseAbstract;
|
||||
@@ -118,6 +121,7 @@ import net.minecraft.world.entity.monster.hoglin.EntityHoglin;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglin;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglinAbstract;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglinBrute;
|
||||
import net.minecraft.world.entity.monster.warden.Warden;
|
||||
import net.minecraft.world.entity.npc.EntityVillager;
|
||||
import net.minecraft.world.entity.npc.EntityVillagerAbstract;
|
||||
import net.minecraft.world.entity.npc.EntityVillagerTrader;
|
||||
@@ -143,6 +147,7 @@ import net.minecraft.world.entity.projectile.EntityThrownExpBottle;
|
||||
import net.minecraft.world.entity.projectile.EntityThrownTrident;
|
||||
import net.minecraft.world.entity.projectile.EntityTippedArrow;
|
||||
import net.minecraft.world.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.world.entity.vehicle.ChestBoat;
|
||||
import net.minecraft.world.entity.vehicle.EntityBoat;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartChest;
|
||||
@@ -218,6 +223,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityPufferFish) { return new CraftPufferFish(server, (EntityPufferFish) entity); }
|
||||
else if (entity instanceof EntitySalmon) { return new CraftSalmon(server, (EntitySalmon) entity); }
|
||||
else if (entity instanceof EntityTropicalFish) { return new CraftTropicalFish(server, (EntityTropicalFish) entity); }
|
||||
else if (entity instanceof Tadpole) { return new CraftTadpole(server, (Tadpole) entity); }
|
||||
else { return new CraftFish(server, (EntityFish) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityDolphin) { return new CraftDolphin(server, (EntityDolphin) entity); }
|
||||
@@ -259,6 +265,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityStrider) { return new CraftStrider(server, (EntityStrider) 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 { return new CraftAnimals(server, (EntityAnimal) entity); }
|
||||
}
|
||||
// Monsters
|
||||
@@ -309,6 +316,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else { return new CraftPiglinAbstract(server, (EntityPiglinAbstract) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityZoglin) { return new CraftZoglin(server, (EntityZoglin) entity); }
|
||||
else if (entity instanceof Warden) { return new CraftWarden(server, (Warden) entity); }
|
||||
|
||||
else { return new CraftMonster(server, (EntityMonster) entity); }
|
||||
}
|
||||
@@ -322,6 +330,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityVillagerTrader) { return new CraftWanderingTrader(server, (EntityVillagerTrader) entity); }
|
||||
else { return new CraftAbstractVillager(server, (EntityVillagerAbstract) entity); }
|
||||
}
|
||||
else if (entity instanceof Allay) { return new CraftAllay(server, (Allay) entity); }
|
||||
else { return new CraftCreature(server, (EntityCreature) entity); }
|
||||
}
|
||||
// Slimes are a special (and broken) case
|
||||
@@ -358,7 +367,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityThrownTrident) { return new CraftTrident(server, (EntityThrownTrident) entity); }
|
||||
else { return new CraftArrow(server, (EntityArrow) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityBoat) { return new CraftBoat(server, (EntityBoat) entity); }
|
||||
else if (entity instanceof EntityBoat) {
|
||||
if (entity instanceof ChestBoat) { return new CraftChestBoat(server, (ChestBoat) entity); }
|
||||
else { return new CraftBoat(server, (EntityBoat) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityProjectile) {
|
||||
if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); }
|
||||
else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); }
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.entity.animal.frog.Frog;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog {
|
||||
|
||||
public CraftFrog(CraftServer server, Frog entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Frog getHandle() {
|
||||
return (Frog) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftFrog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.FROG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getTongueTarget() {
|
||||
return getHandle().getTongueTarget().map(net.minecraft.world.entity.Entity::getBukkitEntity).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTongueTarget(Entity target) {
|
||||
if (target == null) {
|
||||
getHandle().eraseTongueTarget();
|
||||
} else {
|
||||
getHandle().setTongueTarget(((CraftEntity) target).getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Variant getVariant() {
|
||||
return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(IRegistry.FROG_VARIANT.getKey(getHandle().getVariant())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(Variant variant) {
|
||||
Preconditions.checkArgument(variant != null, "variant");
|
||||
|
||||
getHandle().setVariant(IRegistry.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey())));
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,26 @@ public class CraftGoat extends CraftAnimals implements Goat {
|
||||
return "CraftGoat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLeftHorn() {
|
||||
return getHandle().hasLeftHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftHorn(boolean hasHorn) {
|
||||
getHandle().getEntityData().set(net.minecraft.world.entity.animal.goat.Goat.DATA_HAS_LEFT_HORN, hasHorn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRightHorn() {
|
||||
return getHandle().hasRightHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightHorn(boolean hasHorn) {
|
||||
getHandle().getEntityData().set(net.minecraft.world.entity.animal.goat.Goat.DATA_HAS_RIGHT_HORN, hasHorn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScreaming() {
|
||||
return getHandle().isScreamingGoat();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.decoration.EntityPainting;
|
||||
import net.minecraft.world.entity.decoration.Paintings;
|
||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftArt;
|
||||
@@ -17,7 +18,7 @@ public class CraftPainting extends CraftHanging implements Painting {
|
||||
|
||||
@Override
|
||||
public Art getArt() {
|
||||
Paintings art = getHandle().motive;
|
||||
Holder<PaintingVariant> art = getHandle().getVariant();
|
||||
return CraftArt.NotchToBukkit(art);
|
||||
}
|
||||
|
||||
@@ -29,12 +30,12 @@ public class CraftPainting extends CraftHanging implements Painting {
|
||||
@Override
|
||||
public boolean setArt(Art art, boolean force) {
|
||||
EntityPainting painting = this.getHandle();
|
||||
Paintings oldArt = painting.motive;
|
||||
painting.motive = CraftArt.BukkitToNotch(art);
|
||||
Holder<PaintingVariant> oldArt = painting.getVariant();
|
||||
painting.setVariant(CraftArt.BukkitToNotch(art));
|
||||
painting.setDirection(painting.getDirection());
|
||||
if (!force && !getHandle().generation && !painting.survives()) {
|
||||
// Revert painting since it doesn't fit
|
||||
painting.motive = oldArt;
|
||||
painting.setVariant(oldArt);
|
||||
painting.setDirection(painting.getDirection());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketDataSerializer;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.ChatMessageType;
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket;
|
||||
@@ -45,7 +45,6 @@ import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
|
||||
@@ -85,7 +84,6 @@ import net.minecraft.world.level.border.IWorldBorderListener;
|
||||
import net.minecraft.world.level.saveddata.maps.MapIcon;
|
||||
import net.minecraft.world.level.saveddata.maps.WorldMap;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -231,7 +229,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
|
||||
getHandle().sendSystemMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +238,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender));
|
||||
getHandle().sendSystemMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +333,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private void updatePlayerListHeaderFooter() {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader, (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter);
|
||||
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? IChatBaseComponent.empty() : this.playerListHeader, (this.playerListFooter == null) ? IChatBaseComponent.empty() : this.playerListFooter);
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -430,7 +428,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,7 +490,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
break;
|
||||
}
|
||||
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -509,7 +507,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch);
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -517,7 +515,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch);
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -530,7 +528,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.animal.frog.Tadpole;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole {
|
||||
|
||||
public CraftTadpole(CraftServer server, Tadpole entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tadpole getHandle() {
|
||||
return (Tadpole) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftTadpole";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.TADPOLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return getHandle().age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
getHandle().age = age;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.entity.monster.warden.Warden;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warden {
|
||||
|
||||
public CraftWarden(CraftServer server, Warden entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warden getHandle() {
|
||||
return (Warden) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftWarden";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.WARDEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnger(Entity entity) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
return getHandle().getAngerManagement().getActiveAnger(((CraftEntity) entity).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseAnger(Entity entity, int increase) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
getHandle().getAngerManagement().increaseAnger(((CraftEntity) entity).getHandle(), increase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnger(Entity entity, int anger) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
getHandle().clearAnger(((CraftEntity) entity).getHandle());
|
||||
getHandle().getAngerManagement().increaseAnger(((CraftEntity) entity).getHandle(), anger);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user