use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project MyPet by xXKeyleXx.
the class PlatformHelper method applyTagToEntity.
@Override
public void applyTagToEntity(TagCompound tag, Entity bukkitEntity) {
net.minecraft.server.v1_12_R1.Entity entity = ((CraftEntity) bukkitEntity).getHandle();
NBTTagCompound vanillaNBT = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag);
// Just a temporary fix until I come up with a better solution
if (bukkitEntity instanceof Villager) {
EntityVillager villager = (EntityVillager) entity;
villager.setProfession(vanillaNBT.getInt("Profession"));
villager.riches = vanillaNBT.getInt("Riches");
ReflectionUtil.setFieldValue("bK", villager, vanillaNBT.getInt("Career"));
ReflectionUtil.setFieldValue("bL", villager, vanillaNBT.getInt("CareerLevel"));
ReflectionUtil.setFieldValue("bH", villager, vanillaNBT.getBoolean("Willing"));
if (vanillaNBT.hasKeyOfType("Offers", 10)) {
NBTTagCompound nbttaglist = vanillaNBT.getCompound("Offers");
ReflectionUtil.setFieldValue("trades", villager, new MerchantRecipeList(nbttaglist));
}
NBTTagList invTag = vanillaNBT.getList("Inventory", 10);
for (int i = 0; i < invTag.size(); ++i) {
ItemStack itemstack = new ItemStack(invTag.get(i));
villager.inventory.a(itemstack);
}
villager.m(true);
if (villager.isBaby()) {
villager.goalSelector.a(8, new PathfinderGoalPlay(villager, 0.32D));
} else if (villager.getProfession() == 0) {
villager.goalSelector.a(6, new PathfinderGoalVillagerFarm(villager, 0.6D));
}
}
// can not be used in 1.10
// entity.f(vanillaNBT);
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyCurrentHpOnceSpellEffect.
private void applyCurrentHpOnceSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int caster_level) {
if (getLivingEntity().isDead())
return;
if (Bukkit.getEntity(getSourceUuid()) == null)
return;
Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
if (sourceEntity == null)
return;
if (!(sourceEntity instanceof LivingEntity))
return;
LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
int instrument_mod = 0;
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
if (sourceSoliniaLivingEntity != null) {
instrument_mod = sourceSoliniaLivingEntity.getInstrumentMod(this.getSpell());
}
} catch (CoreStateInitException e) {
// just skip it
}
// HP spells also get calculated based on the caster and the recipient
int hpToAdd = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), caster_level, getTicksLeft(), instrument_mod);
// hpToRemove should really be called hpToAdd
if (hpToAdd < 0) {
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
// reverse to positive then pass it back reversed
hpToAdd = (sourceSoliniaLivingEntity.getActSpellDamage(soliniaSpell, (hpToAdd * -1), spellEffect, targetSoliniaLivingEntity) * -1);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
hpToAdd = hpToAdd * -1;
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
source.setMagic();
source.ignoresArmor();
((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToAdd);
// getLivingEntity().damage(hpToRemove, Bukkit.getEntity(getSourceUuid()));
if (soliniaSpell.isLifetapSpell()) {
if (!(sourceEntity instanceof LivingEntity))
return;
int amount = (int) Math.round(sourceLivingEntity.getHealth()) + hpToAdd;
if (amount > sourceLivingEntity.getMaxHealth()) {
amount = (int) Math.round(sourceLivingEntity.getMaxHealth());
}
if (amount < 0)
amount = 0;
sourceLivingEntity.setHealth(amount);
}
} else // Heal
{
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
hpToAdd = sourceSoliniaLivingEntity.getActSpellHealing(soliniaSpell, hpToAdd, spellEffect, targetSoliniaLivingEntity);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
int amount = (int) Math.round(getLivingEntity().getHealth()) + hpToAdd;
if (amount > getLivingEntity().getMaxHealth()) {
amount = (int) Math.round(getLivingEntity().getMaxHealth());
}
if (amount < 0)
amount = 0;
getLivingEntity().setHealth(amount);
}
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class NMSImpl method removeFromWorld.
@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
Preconditions.checkNotNull(entity);
Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.world.removeEntity(nmsEntity);
}
Aggregations