@@ -0,0 +1,138 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EntityAreaEffectCloud;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.craftbukkit.CraftParticle;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud {
|
||||
|
||||
public CraftAreaEffectCloud(CraftServer server, EntityAreaEffectCloud entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityAreaEffectCloud getHandle() {
|
||||
return (EntityAreaEffectCloud) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.AREA_EFFECT_CLOUD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDuration() {
|
||||
return getHandle().getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(int duration) {
|
||||
getHandle().setDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitTime() {
|
||||
return getHandle().waitTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaitTime(int waitTime) {
|
||||
getHandle().setWaitTime(waitTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReapplicationDelay() {
|
||||
return getHandle().reapplicationDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReapplicationDelay(int delay) {
|
||||
getHandle().reapplicationDelay = delay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurationOnUse() {
|
||||
return getHandle().durationOnUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDurationOnUse(int duration) {
|
||||
getHandle().durationOnUse = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRadius() {
|
||||
return getHandle().getRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadius(float radius) {
|
||||
getHandle().setRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRadiusOnUse() {
|
||||
return getHandle().radiusOnUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadiusOnUse(float radius) {
|
||||
getHandle().setRadiusOnUse(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRadiusPerTick() {
|
||||
return getHandle().radiusPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadiusPerTick(float radius) {
|
||||
getHandle().setRadiusPerTick(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle getParticle() {
|
||||
return CraftParticle.toBukkit(getHandle().getParticle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParticle(Particle particle) {
|
||||
getHandle().setParticle(CraftParticle.toNMS(particle));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffect(PotionEffect effect) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEffect(PotionEffect effect) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEffects(List<PotionEffect> effects) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor() {
|
||||
return Color.fromRGB(getHandle().getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
getHandle().setColor(color.asRGB());
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,7 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
@Override
|
||||
public void setGravity(boolean gravity) {
|
||||
getHandle().setGravity(!gravity);
|
||||
getHandle().noclip = !gravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,13 +208,11 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
|
||||
@Override
|
||||
public boolean isMarker() {
|
||||
// PAIL
|
||||
return getHandle().s();
|
||||
return getHandle().isMarker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker(boolean marker) {
|
||||
// PAIL
|
||||
getHandle().n(marker);
|
||||
getHandle().setMarker(marker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityDragonFireball;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.DragonFireball;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftDragonFireball extends CraftFireball implements DragonFireball {
|
||||
public CraftDragonFireball(CraftServer server, EntityDragonFireball entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.DRAGON_FIREBALL;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -39,7 +37,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protected final CraftServer server;
|
||||
protected Entity entity;
|
||||
private EntityDamageEvent lastDamageEvent;
|
||||
@@ -108,6 +106,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityGolem) {
|
||||
if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntitySnowman) entity); }
|
||||
else if (entity instanceof EntityIronGolem) { return new CraftIronGolem(server, (EntityIronGolem) entity); }
|
||||
else if (entity instanceof EntityShulker) { return new CraftShulker(server, (EntityShulker) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); }
|
||||
else { return new CraftCreature(server, (EntityCreature) entity); }
|
||||
@@ -153,6 +152,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntitySmallFireball) { return new CraftSmallFireball(server, (EntitySmallFireball) entity); }
|
||||
else if (entity instanceof EntityLargeFireball) { return new CraftLargeFireball(server, (EntityLargeFireball) entity); }
|
||||
else if (entity instanceof EntityWitherSkull) { return new CraftWitherSkull(server, (EntityWitherSkull) entity); }
|
||||
else if (entity instanceof EntityDragonFireball) { return new CraftDragonFireball(server, (EntityDragonFireball) entity); }
|
||||
else { return new CraftFireball(server, (EntityFireball) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityEnderSignal) { return new CraftEnderSignal(server, (EntityEnderSignal) entity); }
|
||||
@@ -179,6 +179,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
|
||||
else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); }
|
||||
else if (entity instanceof EntityShulkerBullet) { return new CraftShulkerBullet(server, (EntityShulkerBullet) entity); }
|
||||
else if (entity instanceof EntityAreaEffectCloud) { return new CraftAreaEffectCloud(server, (EntityAreaEffectCloud) entity); }
|
||||
|
||||
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
|
||||
}
|
||||
@@ -227,12 +229,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public boolean teleport(Location location, TeleportCause cause) {
|
||||
if (entity.passenger != null || entity.dead) {
|
||||
if (entity.isVehicle() || entity.dead) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this entity is riding another entity, we must dismount before teleporting.
|
||||
entity.mount(null);
|
||||
entity.stopRiding();
|
||||
|
||||
entity.world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
@@ -299,13 +301,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public org.bukkit.entity.Entity getPassenger() {
|
||||
return isEmpty() ? null : getHandle().passenger.getBukkitEntity();
|
||||
return isEmpty() ? null : getHandle().passengers.get(0).getBukkitEntity();
|
||||
}
|
||||
|
||||
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
|
||||
Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself.");
|
||||
if (passenger instanceof CraftEntity) {
|
||||
((CraftEntity) passenger).getHandle().mount(getHandle());
|
||||
eject();
|
||||
((CraftEntity) passenger).getHandle().startRiding(getHandle());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -313,15 +316,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getHandle().passenger == null;
|
||||
return !getHandle().isVehicle();
|
||||
}
|
||||
|
||||
public boolean eject() {
|
||||
if (getHandle().passenger == null) {
|
||||
if (isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHandle().passenger.mount(null);
|
||||
getPassenger().leaveVehicle();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -409,24 +412,24 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public boolean isInsideVehicle() {
|
||||
return getHandle().vehicle != null;
|
||||
return getHandle().isPassenger();
|
||||
}
|
||||
|
||||
public boolean leaveVehicle() {
|
||||
if (getHandle().vehicle == null) {
|
||||
if (!isInsideVehicle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHandle().mount(null);
|
||||
getHandle().stopRiding();
|
||||
return true;
|
||||
}
|
||||
|
||||
public org.bukkit.entity.Entity getVehicle() {
|
||||
if (getHandle().vehicle == null) {
|
||||
if (!isInsideVehicle()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getHandle().vehicle.getBukkitEntity();
|
||||
return getHandle().getVehicle().getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -538,4 +541,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public void setOp(boolean value) {
|
||||
perm.setOp(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowing(boolean flag) {
|
||||
getHandle().glowing = flag;
|
||||
Entity e = getHandle();
|
||||
if (e.getFlag(6) != flag) {
|
||||
e.setFlag(6, flag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlowing() {
|
||||
return getHandle().glowing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ public class CraftFirework extends CraftEntity implements Firework {
|
||||
public CraftFirework(CraftServer server, EntityFireworks entity) {
|
||||
super(server, entity);
|
||||
|
||||
ItemStack item = getHandle().getDataWatcher().getItemStack(FIREWORK_ITEM_INDEX);
|
||||
ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.FIREWORK_ITEM).orNull();
|
||||
|
||||
if (item == null) {
|
||||
item = new ItemStack(Items.FIREWORKS);
|
||||
getHandle().getDataWatcher().watch(FIREWORK_ITEM_INDEX, item);
|
||||
getHandle().getDataWatcher().register(EntityFireworks.FIREWORK_ITEM, item);
|
||||
}
|
||||
|
||||
this.item = CraftItemStack.asCraftMirror(item);
|
||||
@@ -64,7 +64,7 @@ public class CraftFirework extends CraftEntity implements Firework {
|
||||
// Copied from EntityFireworks constructor, update firework lifetime/power
|
||||
getHandle().expectedLifespan = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7);
|
||||
|
||||
getHandle().getDataWatcher().update(FIREWORK_ITEM_INDEX);
|
||||
getHandle().getDataWatcher().markDirty(EntityFireworks.FIREWORK_ITEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityHorse;
|
||||
import net.minecraft.server.EnumHorseType;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryHorse;
|
||||
@@ -23,12 +24,12 @@ public class CraftHorse extends CraftAnimals implements Horse {
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return Variant.values()[getHandle().getType()];
|
||||
return Variant.values()[getHandle().getType().ordinal()];
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
Validate.notNull(variant, "Variant cannot be null");
|
||||
getHandle().setType(variant.ordinal());
|
||||
getHandle().setType(EnumHorseType.values()[variant.ordinal()]);
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
@@ -89,7 +90,7 @@ public class CraftHorse extends CraftAnimals implements Horse {
|
||||
|
||||
@Override
|
||||
public boolean isTamed() {
|
||||
return getHandle().isTame();
|
||||
return getHandle().isTamed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,19 +117,11 @@ public class CraftHorse extends CraftAnimals implements Horse {
|
||||
}
|
||||
|
||||
public UUID getOwnerUUID() {
|
||||
try {
|
||||
return UUID.fromString(getHandle().getOwnerUUID());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
return getHandle().getOwnerUUID();
|
||||
}
|
||||
|
||||
public void setOwnerUUID(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
getHandle().setOwnerUUID("");
|
||||
} else {
|
||||
getHandle().setOwnerUUID(uuid.toString());
|
||||
}
|
||||
getHandle().setOwnerUUID(uuid);
|
||||
}
|
||||
|
||||
public HorseInventory getInventory() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.*;
|
||||
@@ -21,6 +22,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@@ -347,6 +349,23 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openMerchant(Villager villager, boolean force) {
|
||||
Preconditions.checkNotNull(villager, "villager cannot be null");
|
||||
if (!force && villager.isTrading()) {
|
||||
return null;
|
||||
} else if (villager.isTrading()) {
|
||||
// we're not supposed to have multiple people using the same villager, so we have to close it.
|
||||
villager.getTrader().closeInventory();
|
||||
}
|
||||
|
||||
EntityVillager ev = ((CraftVillager) villager).getHandle();
|
||||
ev.setTradingPlayer(this.getHandle());
|
||||
this.getHandle().openTrade(ev);
|
||||
|
||||
return this.getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
public void closeInventory() {
|
||||
getHandle().closeInventory();
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.EntityArmorStand;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import net.minecraft.server.EntityDragonFireball;
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import net.minecraft.server.EntityEnderDragon;
|
||||
import net.minecraft.server.EntityEnderPearl;
|
||||
import net.minecraft.server.EntityFishingHook;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
@@ -24,6 +23,7 @@ import net.minecraft.server.EntityPotion;
|
||||
import net.minecraft.server.EntitySmallFireball;
|
||||
import net.minecraft.server.EntitySnowball;
|
||||
import net.minecraft.server.EntityThrownExpBottle;
|
||||
import net.minecraft.server.EntityTippedArrow;
|
||||
import net.minecraft.server.EntityWither;
|
||||
import net.minecraft.server.EntityWitherSkull;
|
||||
import net.minecraft.server.GenericAttributes;
|
||||
@@ -33,12 +33,15 @@ import net.minecraft.server.MobEffectList;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftEntityEquipment;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.DragonFireball;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -108,16 +111,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
setMaxHealth(getHandle().getMaxHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Egg throwEgg() {
|
||||
return launchProjectile(Egg.class);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Snowball throwSnowball() {
|
||||
return launchProjectile(Snowball.class);
|
||||
}
|
||||
|
||||
public double getEyeHeight() {
|
||||
return getHandle().getHeadHeight();
|
||||
}
|
||||
@@ -204,11 +197,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return getLineOfSight(transparent, maxDistance, 2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Arrow shootArrow() {
|
||||
return launchProjectile(Arrow.class);
|
||||
}
|
||||
|
||||
public int getRemainingAir() {
|
||||
return getHandle().getAirTicks();
|
||||
}
|
||||
@@ -300,7 +288,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
removePotionEffect(effect.getType());
|
||||
}
|
||||
getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -313,20 +301,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public boolean hasPotionEffect(PotionEffectType type) {
|
||||
return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
|
||||
return getHandle().hasEffect(MobEffectList.fromId(type.getId()));
|
||||
}
|
||||
|
||||
public void removePotionEffect(PotionEffectType type) {
|
||||
getHandle().removeEffect(type.getId());
|
||||
getHandle().removeEffect(MobEffectList.fromId(type.getId()));
|
||||
}
|
||||
|
||||
public Collection<PotionEffect> getActivePotionEffects() {
|
||||
List<PotionEffect> effects = new ArrayList<PotionEffect>();
|
||||
for (Object raw : getHandle().effects.values()) {
|
||||
if (!(raw instanceof MobEffect))
|
||||
continue;
|
||||
MobEffect handle = (MobEffect) raw;
|
||||
effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
|
||||
for (MobEffect handle : getHandle().effects.values()) {
|
||||
effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
|
||||
}
|
||||
return effects;
|
||||
}
|
||||
@@ -347,7 +332,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityEnderPearl(world, getHandle());
|
||||
} else if (Arrow.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityArrow(world, getHandle(), 1);
|
||||
launch = new EntityTippedArrow(world, getHandle());
|
||||
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
|
||||
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
|
||||
@@ -362,6 +347,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
|
||||
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
|
||||
} else if (DragonFireball.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
|
||||
} else {
|
||||
launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
|
||||
}
|
||||
@@ -500,4 +487,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public void _INVALID_setMaxHealth(int health) {
|
||||
setMaxHealth(health);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeInstance getAttribute(Attribute attribute) {
|
||||
return getHandle().craftAttributes.getAttribute(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
}
|
||||
|
||||
public void setDisplayBlockOffset(int offset) {
|
||||
getHandle().SetDisplayBlockOffset(offset);
|
||||
getHandle().setDisplayBlockOffset(offset);
|
||||
}
|
||||
|
||||
public int getDisplayBlockOffset() {
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
|
||||
import org.bukkit.craftbukkit.CraftParticle;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
||||
import org.bukkit.craftbukkit.CraftEffect;
|
||||
@@ -264,7 +265,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,7 +291,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
break;
|
||||
}
|
||||
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -309,7 +310,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
double y = loc.getBlockY() + 0.5;
|
||||
double z = loc.getBlockZ() + 0.5;
|
||||
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(sound, x, y, z, volume, pitch);
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), SoundCategory.MASTER, x, y, z, volume, pitch);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -415,7 +416,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), icons, data.buffer, 0, 0, 0, 0);
|
||||
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 0, 0);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -431,7 +432,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entity.passenger != null) {
|
||||
if (entity.isVehicle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -449,7 +450,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
// If this player is riding another entity, we must dismount before teleporting.
|
||||
entity.mount(null);
|
||||
entity.stopRiding();
|
||||
|
||||
// Update the From Location
|
||||
from = event.getFrom();
|
||||
@@ -1288,7 +1289,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
injectScaledMaxHealth(set, true);
|
||||
|
||||
getHandle().getDataWatcher().watch(6, (float) getScaledHealth());
|
||||
getHandle().getDataWatcher().set(EntityLiving.HEALTH, (float) getScaledHealth());
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
|
||||
|
||||
@@ -1312,7 +1313,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getSpectatorTarget() {
|
||||
Entity followed = getHandle().C(); // PAIL
|
||||
Entity followed = getHandle().getSpecatorTarget();
|
||||
return followed == getHandle() ? null : followed.getBukkitEntity();
|
||||
}
|
||||
|
||||
@@ -1340,4 +1341,69 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
PacketPlayOutTitle packetReset = new PacketPlayOutTitle(EnumTitleAction.RESET, null);
|
||||
getHandle().playerConnection.sendPacket(packetReset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location location, int count) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, double x, double y, double z, int count) {
|
||||
spawnParticle(particle, x, y, z, count, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
|
||||
spawnParticle(particle, x, y, z, count, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
|
||||
spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
|
||||
spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, 1, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
|
||||
spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, extra, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
|
||||
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
|
||||
if (data != null && !particle.getDataType().isInstance(data)) {
|
||||
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
|
||||
}
|
||||
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, CraftParticle.toData(particle, data));
|
||||
getHandle().playerConnection.sendPacket(packetplayoutworldparticles);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityGolem;
|
||||
import net.minecraft.server.EntityShulker;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Shulker;
|
||||
|
||||
public class CraftShulker extends CraftGolem implements Shulker {
|
||||
|
||||
public CraftShulker(CraftServer server, EntityShulker entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SHULKER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityShulker getHandle() {
|
||||
return (EntityShulker) entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityShulkerBullet;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.ShulkerBullet;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
public class CraftShulkerBullet extends CraftEntity implements ShulkerBullet {
|
||||
|
||||
public CraftShulkerBullet(CraftServer server, EntityShulkerBullet entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
if (shooter instanceof LivingEntity) {
|
||||
getHandle().setShooter(((CraftLivingEntity) shooter).getHandle());
|
||||
} else {
|
||||
getHandle().setShooter(null);
|
||||
}
|
||||
getHandle().projectileSource = shooter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getTarget() {
|
||||
return getHandle().getTarget() != null ? getHandle().getTarget().getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(org.bukkit.entity.Entity target) {
|
||||
getHandle().setTarget(target == null ? null : ((CraftEntity) target).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SHULKER_BULLET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityShulkerBullet getHandle() {
|
||||
return (EntityShulkerBullet) entity;
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,11 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
||||
}
|
||||
|
||||
public int getFuseTicks() {
|
||||
return getHandle().fuseTicks;
|
||||
return getHandle().getFuseTicks();
|
||||
}
|
||||
|
||||
public void setFuseTicks(int fuseTicks) {
|
||||
getHandle().fuseTicks = fuseTicks;
|
||||
getHandle().setFuseTicks(fuseTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,18 +20,14 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
||||
|
||||
public UUID getOwnerUUID() {
|
||||
try {
|
||||
return UUID.fromString(getHandle().getOwnerUUID());
|
||||
return getHandle().getOwnerUUID();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOwnerUUID(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
getHandle().setOwnerUUID("");
|
||||
} else {
|
||||
getHandle().setOwnerUUID(uuid.toString());
|
||||
}
|
||||
getHandle().setOwnerUUID(uuid);
|
||||
}
|
||||
|
||||
public AnimalTamer getOwner() {
|
||||
|
||||
@@ -22,14 +22,11 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
|
||||
// TODO: This one does not handle custom NBT potion effects does it?
|
||||
// In that case this method could be said to be misleading or incorrect
|
||||
public Collection<PotionEffect> getEffects() {
|
||||
return Potion.getBrewer().getEffectsFromDamage(getHandle().getPotionValue());
|
||||
return Potion.getBrewer().getEffectsFromDamage(getHandle().getItem().getData());
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
// We run this method once since it will set the item stack if there is none.
|
||||
getHandle().getPotionValue();
|
||||
|
||||
return CraftItemStack.asBukkitCopy(getHandle().item);
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getItem());
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
@@ -39,7 +36,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
|
||||
// The ItemStack must be a potion.
|
||||
Validate.isTrue(item.getType() == Material.POTION, "ItemStack must be a potion. This item stack was " + item.getType() + ".");
|
||||
|
||||
getHandle().item = CraftItemStack.asNMSCopy(item);
|
||||
getHandle().setItem(CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityVillager;
|
||||
import net.minecraft.server.MerchantRecipeList;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
|
||||
public class CraftVillager extends CraftAgeable implements Villager, InventoryHolder {
|
||||
|
||||
public CraftVillager(CraftServer server, EntityVillager entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
@@ -41,4 +51,59 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo
|
||||
public Inventory getInventory() {
|
||||
return new CraftInventory(getHandle().inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MerchantRecipe> getRecipes() {
|
||||
return Collections.unmodifiableList(Lists.transform(getHandle().getOffers(null), new Function<net.minecraft.server.MerchantRecipe, MerchantRecipe>() {
|
||||
@Override
|
||||
public MerchantRecipe apply(net.minecraft.server.MerchantRecipe recipe) {
|
||||
return recipe.asBukkit();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipes(List<MerchantRecipe> list) {
|
||||
MerchantRecipeList recipes = getHandle().getOffers(null);
|
||||
recipes.clear();
|
||||
for (MerchantRecipe m : list) {
|
||||
recipes.add(CraftMerchantRecipe.fromBukkit(m).toMinecraft());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantRecipe getRecipe(int i) {
|
||||
return getHandle().getOffers(null).get(i).asBukkit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(int i, MerchantRecipe merchantRecipe) {
|
||||
getHandle().getOffers(null).set(i, CraftMerchantRecipe.fromBukkit(merchantRecipe).toMinecraft());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeCount() {
|
||||
return getHandle().getOffers(null).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrading() {
|
||||
return getTrader() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HumanEntity getTrader() {
|
||||
EntityHuman eh = getHandle().t_(); // PAIL: rename t_ -> getTrader
|
||||
return eh == null ? null : eh.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRiches() {
|
||||
return getHandle().riches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRiches(int riches) {
|
||||
getHandle().riches = riches;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.server.EntityZombie;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
public class CraftZombie extends CraftMonster implements Zombie {
|
||||
@@ -39,6 +40,21 @@ public class CraftZombie extends CraftMonster implements Zombie {
|
||||
}
|
||||
|
||||
public void setVillager(boolean flag) {
|
||||
getHandle().setVillager(flag);
|
||||
getHandle().setVillagerType(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVillagerProfession(Villager.Profession profession) {
|
||||
if (profession == null) {
|
||||
getHandle().clearVillagerType();
|
||||
} else {
|
||||
getHandle().setVillagerType(profession.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Villager.Profession getVillagerProfession() {
|
||||
if (!isVillager()) return null;
|
||||
return Villager.Profession.getProfession(getHandle().getVillagerType());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user