use of net.minecraft.server.v1_10_R1.ItemStack in project Citizens2 by CitizensDev.
the class CitizensBlockBreaker method strengthMod.
private float strengthMod(IBlockData block) {
ItemStack itemstack = getCurrentItem();
float f = itemstack.a(block);
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) entity;
if (f > 1.0F) {
int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
if (i > 0) {
f += i * i + 1;
}
}
if (handle.hasEffect(MobEffects.FASTER_DIG)) {
f *= (1.0F + (handle.getEffect(MobEffects.FASTER_DIG).getAmplifier() + 1) * 0.2F);
}
if (handle.hasEffect(MobEffects.SLOWER_DIG)) {
float f1 = 1.0F;
switch(handle.getEffect(MobEffects.SLOWER_DIG).getAmplifier()) {
case 0:
f1 = 0.3F;
break;
case 1:
f1 = 0.09F;
break;
case 2:
f1 = 0.0027F;
break;
case 3:
default:
f1 = 8.1E-4F;
}
f *= f1;
}
if ((handle.a(Material.WATER)) && (!EnchantmentManager.i(handle))) {
f /= 5.0F;
}
}
if (!entity.onGround) {
f /= 5.0F;
}
return f;
}
use of net.minecraft.server.v1_10_R1.ItemStack in project askyblock by tastybento.
the class NMSHandler method setPotion.
/* (non-Javadoc)
* @see com.wasteofplastic.acidisland.nms.NMSAbstraction#setPotion(com.wasteofplastic.org.jnbt.Tag)
*/
@SuppressWarnings({ "unchecked" })
@Override
public ItemStack setPotion(Material material, Tag itemTags, ItemStack chestItem) {
Map<String, Tag> cont = (Map<String, Tag>) ((CompoundTag) itemTags).getValue();
if (cont != null) {
if (((CompoundTag) itemTags).getValue().containsKey("tag")) {
Map<String, Tag> contents = (Map<String, Tag>) ((CompoundTag) itemTags).getValue().get("tag").getValue();
StringTag stringTag = ((StringTag) contents.get("Potion"));
if (stringTag != null) {
String tag = ((StringTag) contents.get("Potion")).getValue();
// Bukkit.getLogger().info("DEBUG: potioninfo found: " + tag);
net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(chestItem);
NBTTagCompound tagCompound = stack.getTag();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
tagCompound.setString("Potion", tag);
stack.setTag(tagCompound);
return CraftItemStack.asBukkitCopy(stack);
}
}
}
// Schematic is old, the potions do not have tags
// Set it to zero so that the potion bottles don't look like giant purple and black blocks
chestItem.setDurability((short) 0);
Bukkit.getLogger().warning("Potion in schematic is pre-V1.9 format and will just be water.");
return chestItem;
}
use of net.minecraft.server.v1_10_R1.ItemStack in project askyblock by tastybento.
the class NMSHandler method getSpawnEgg.
/**
* Get spawn egg
* @param type
* @param amount
* @return
*/
@SuppressWarnings("deprecation")
public ItemStack getSpawnEgg(EntityType type, int amount) {
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
NBTTagCompound tagCompound = stack.getTag();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
NBTTagCompound id = new NBTTagCompound();
id.setString("id", type.getName());
tagCompound.set("EntityTag", id);
stack.setTag(tagCompound);
return CraftItemStack.asBukkitCopy(stack);
}
use of net.minecraft.server.v1_10_R1.ItemStack in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelper_v1_10_R1 method setSkullSkin.
@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
if (playerProfile.hasTexture()) {
gameProfile.getProperties().get("textures").clear();
if (playerProfile.getTextureSignature() != null) {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
} else {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
}
}
net.minecraft.server.v1_10_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
nmsItemStack.setTag(tag);
return CraftItemStack.asBukkitCopy(nmsItemStack);
}
use of net.minecraft.server.v1_10_R1.ItemStack in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelper_v1_10_R1 method addNbtData.
@Override
public ItemStack addNbtData(ItemStack itemStack, String key, Tag value) {
net.minecraft.server.v1_10_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
CompoundTag compound = CompoundTag_v1_10_R1.fromNMSTag(tag).createBuilder().put(key, value).build();
nmsItemStack.setTag(((CompoundTag_v1_10_R1) compound).toNMSTag());
return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Aggregations