use of net.minecraft.server.v1_10_R1.ItemStack in project MyPet by xXKeyleXx.
the class ItemStackComparator method compareTagData.
public static boolean compareTagData(ItemStack i1, ItemStack i2) {
if (i1.hasItemMeta() && i2.hasItemMeta()) {
NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag();
NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag();
return tag1 != null && tag2 != null && tag1.equals(tag2);
}
return i1.hasItemMeta() == i2.hasItemMeta();
}
use of net.minecraft.server.v1_10_R1.ItemStack in project acidisland 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 acidisland by tastybento.
the class NMSHandler method isPotion.
/* (non-Javadoc)
* @see com.wasteofplastic.askyblock.nms.NMSAbstraction#isPotion(org.bukkit.inventory.ItemStack)
*/
@Override
public boolean isPotion(ItemStack item) {
// Bukkit.getLogger().info("DEBUG:item = " + item);
if (item.getType().equals(Material.POTION)) {
net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = stack.getTag();
/*
for (String list : tag.c()) {
Bukkit.getLogger().info("DEBUG: list = " + list);
}*/
if (tag != null && (!tag.getString("Potion").equalsIgnoreCase("minecraft:water") || tag.getString("Potion").isEmpty())) {
return true;
}
}
return false;
}
use of net.minecraft.server.v1_10_R1.ItemStack in project acidisland by tastybento.
the class NMSHandler method setFlowerPotBlock.
/* (non-Javadoc)
* @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
* Credis: Mister_Frans (THANK YOU VERY MUCH !)
*/
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
Location loc = block.getLocation();
CraftWorld cw = (CraftWorld) block.getWorld();
BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
// Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
net.minecraft.server.v1_10_R1.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
te.a(cis.getItem(), cis.getData());
te.update();
}
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;
}
Aggregations