More items

This commit is contained in:
Vincent Lee committed 2016-03-18 20:01:50 -05:00
1 parent 3852282598
commit 663c797cf3
53 files changed
+300 -199

No files matched your search

@@ -24,9 +24,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
public class ItemBlockTinyPotato extends ItemBlockMod {
private static final List<String> TYPOS = Arrays.asList(new String[] {
"vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski"
});
private static final List<String> TYPOS = Arrays.asList("vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski");
private static final String NOT_MY_NAME[] = {
"Six letter word just to get me along",
@@ -14,14 +14,20 @@ import java.awt.Color;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
@@ -70,29 +76,28 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
}
@Override
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_));
return p_77659_1_;
public ActionResult<ItemStack> onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_, EnumHand hand) {
p_77659_3_.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, p_77659_1_);
}
@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player) {
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase living) {
if(!world.isRemote) {
for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) {
PotionEffect newEffect = new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true, true);
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
if(potion.isInstant())
potion.affectEntity(player, player, player, newEffect.getAmplifier(), 1F);
else player.addPotionEffect(newEffect);
PotionEffect newEffect = new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier(), true, true);
if(effect.getPotion().isInstant())
effect.getPotion().affectEntity(living, living, living, newEffect.getAmplifier(), 1F);
else living.addPotionEffect(newEffect);
}
if(world.rand.nextBoolean())
world.playSoundAtEntity(player, "random.burp", 1F, 1F);
world.playSound(null, living.posX, living.posY, living.posZ, SoundEvents.entity_player_burp, SoundCategory.PLAYERS, 1F, 1F);
int swigs = getSwigsLeft(stack);
if(!player.capabilities.isCreativeMode) {
if(living instanceof EntityPlayer && !((EntityPlayer) living).capabilities.isCreativeMode) {
if(swigs == 1) {
if(!player.inventory.addItemStackToInventory(baseItem.copy()))
if(!((EntityPlayer) living).inventory.addItemStackToInventory(baseItem.copy()))
return baseItem.copy();
else {
ItemStack copy = stack.copy();
@@ -142,9 +147,8 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
Brew brew = getBrew(stack);
for(PotionEffect effect : brew.getPotionEffects(stack)) {
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
TextFormatting format = potion.isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
list.add(format + I18n.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")"));
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
list.add(format + I18n.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (effect.getPotion().isInstant() ? "" : " (" + Potion.getPotionDurationString(effect, 1F) + ")"));
}
}
@@ -81,10 +81,9 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
addStringToTooltip(TextFormatting.LIGHT_PURPLE + String.format(I18n.translateToLocal("botaniamisc.brewOf"), I18n.translateToLocal(brew.getUnlocalizedName(stack))), list);
for(PotionEffect effect : brew.getPotionEffects(stack)) {
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
TextFormatting format = potion.isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
PotionEffect longEffect = new PotionEffect(effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false, true);
addStringToTooltip(" " + format + I18n.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), list);
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
PotionEffect longEffect = new PotionEffect(effect.getPotion(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false, true);
addStringToTooltip(" " + format + I18n.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + TextFormatting.GRAY + (effect.getPotion().isInstant() ? "" : " (" + Potion.getPotionDurationString(longEffect, 1F) + ")"), list);
}
}
@@ -17,6 +17,7 @@ import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
@@ -50,13 +51,13 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
private static final String TAG_PHANTOM_INK = "phantomInk";
protected ModelBiped[] models = null;
public int type;
public EntityEquipmentSlot type;
public ItemManasteelArmor(int type, String name) {
public ItemManasteelArmor(EntityEquipmentSlot type, String name) {
this(type, name, BotaniaAPI.manasteelArmorMaterial);
}
public ItemManasteelArmor(int type, String name, ArmorMaterial mat) {
public ItemManasteelArmor(EntityEquipmentSlot type, String name, ArmorMaterial mat) {
super(mat, 0, type);
this.type = type;
setCreativeTab(BotaniaCreativeTab.INSTANCE);
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelBoots extends ItemManasteelArmor {
public ItemManasteelBoots() {
super(3, LibItemNames.MANASTEEL_BOOTS);
super(EntityEquipmentSlot.FEET, LibItemNames.MANASTEEL_BOOTS);
}
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelChest extends ItemManasteelArmor {
public ItemManasteelChest() {
super(1, LibItemNames.MANASTEEL_CHEST);
super(EntityEquipmentSlot.CHEST, LibItemNames.MANASTEEL_CHEST);
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaDiscountArmor;
import vazkii.botania.common.lib.LibItemNames;
@@ -22,7 +23,7 @@ public class ItemManasteelHelm extends ItemManasteelArmor implements IManaDiscou
}
public ItemManasteelHelm(String name) {
super(0, name);
super(EntityEquipmentSlot.HEAD, name);
}
@Override
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelLegs extends ItemManasteelArmor {
public ItemManasteelLegs() {
super(2, LibItemNames.MANASTEEL_LEGS);
super(EntityEquipmentSlot.LEGS, LibItemNames.MANASTEEL_LEGS);
}
}
@@ -14,6 +14,7 @@ import java.util.List;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
@@ -32,7 +33,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchievement {
public ItemManaweaveArmor(int type, String name) {
public ItemManaweaveArmor(EntityEquipmentSlot type, String name) {
super(type, name, BotaniaAPI.manaweaveArmorMaterial);
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manaweave;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManaweaveBoots extends ItemManaweaveArmor {
public ItemManaweaveBoots() {
super(3, LibItemNames.MANAWEAVE_BOOTS);
super(EntityEquipmentSlot.FEET, LibItemNames.MANAWEAVE_BOOTS);
}
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manaweave;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManaweaveChest extends ItemManaweaveArmor {
public ItemManaweaveChest() {
super(1, LibItemNames.MANAWEAVE_CHEST);
super(EntityEquipmentSlot.CHEST, LibItemNames.MANAWEAVE_CHEST);
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.item.equipment.armor.manaweave;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -26,7 +27,7 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou
private static final int MANA_PER_DAMAGE = 30;
public ItemManaweaveHelm() {
super(0, LibItemNames.MANAWEAVE_HELM);
super(EntityEquipmentSlot.HEAD, LibItemNames.MANAWEAVE_HELM);
}
@Override
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.manaweave;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManaweaveLegs extends ItemManaweaveArmor {
public ItemManaweaveLegs() {
super(2, LibItemNames.MANAWEAVE_LEGS);
super(EntityEquipmentSlot.LEGS, LibItemNames.MANAWEAVE_LEGS);
}
}
@@ -17,6 +17,7 @@ import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
import vazkii.botania.api.BotaniaAPI;
@@ -33,7 +34,7 @@ import com.google.common.collect.Multimap;
public class ItemTerrasteelArmor extends ItemManasteelArmor {
public ItemTerrasteelArmor(int type, String name) {
public ItemTerrasteelArmor(EntityEquipmentSlot type, String name) {
super(type, name, BotaniaAPI.terrasteelArmorMaterial);
}
@@ -55,10 +56,10 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor {
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack) {
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
Multimap<String, AttributeModifier> multimap = HashMultimap.create();
UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0);
multimap.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type) / 20, 0));
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type) / 20, 0));
return multimap;
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.terrasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemTerrasteelBoots extends ItemTerrasteelArmor {
public ItemTerrasteelBoots() {
super(3, LibItemNames.TERRASTEEL_BOOTS);
super(EntityEquipmentSlot.FEET, LibItemNames.TERRASTEEL_BOOTS);
}
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.terrasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemTerrasteelChest extends ItemTerrasteelArmor {
public ItemTerrasteelChest() {
super(1, LibItemNames.TERRASTEEL_CHEST);
super(EntityEquipmentSlot.CHEST, LibItemNames.TERRASTEEL_CHEST);
}
}
@@ -18,6 +18,8 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -47,7 +49,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
}
public ItemTerrasteelHelm(String name) {
super(0, name);
super(EntityEquipmentSlot.HEAD, name);
}
@Override
@@ -122,7 +124,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
if(attacker instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) attacker;
if(hasArmorSet(player)) {
boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null;
boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(MobEffects.blindness) && !player.isRiding();
ItemStack stack = player.inventory.armorItemInSlot(3);
if(crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) {
boolean ahrim = hasAncientWill(stack, 0);
@@ -133,17 +135,17 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
boolean karil = hasAncientWill(stack, 5);
if(ahrim)
event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1));
event.entityLiving.addPotionEffect(new PotionEffect(MobEffects.weakness, 20, 1));
if(dharok)
event.ammount *= 1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F;
if(guthan)
player.heal(event.ammount * 0.25F);
if(torag)
event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1));
event.entityLiving.addPotionEffect(new PotionEffect(MobEffects.moveSlowdown, 60, 1));
if(verac)
event.source.setDamageBypassesArmor();
if(karil)
event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 60, 1));
event.entityLiving.addPotionEffect(new PotionEffect(MobEffects.wither, 60, 1));
}
}
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.equipment.armor.terrasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemTerrasteelLegs extends ItemTerrasteelArmor {
public ItemTerrasteelLegs() {
super(2, LibItemNames.TERRASTEEL_LEGS);
super(EntityEquipmentSlot.LEGS, LibItemNames.TERRASTEEL_LEGS);
}
}
@@ -18,11 +18,16 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import thaumcraft.api.items.IRunicArmor;
import vazkii.botania.api.item.ICosmeticAttachable;
import vazkii.botania.api.item.IPhantomInkable;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.entity.EntityDoppleganger;
@@ -51,9 +56,9 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(!EntityDoppleganger.isTruePlayer(par3EntityPlayer))
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.FAIL, par1ItemStack);
if(canEquip(par1ItemStack, par3EntityPlayer)) {
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer);
@@ -69,7 +74,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
if(stackInSlot != null) {
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer);
return stackInSlot.copy();
return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot.copy());
}
break;
}
@@ -77,7 +82,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
}
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
@Override
@@ -131,7 +136,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
public void onEquipped(ItemStack stack, EntityLivingBase player) {
if(player != null) {
if(!player.worldObj.isRemote)
player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.equipBauble, SoundCategory.PLAYERS, 0.1F, 1.3F);
if(player instanceof EntityPlayer)
((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1);
@@ -313,7 +313,7 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
public void renderIcon(int i) {
GlStateManager.pushMatrix();
renderStack.setItemDamage(i);
Minecraft.getMinecraft().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.THIRD_PERSON);
Minecraft.getMinecraft().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); // todo 1.9
GlStateManager.popMatrix();
}
@@ -331,12 +331,12 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.pushMatrix();
model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.THIRD_PERSON);
model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, false); // todo 1.9
GlStateManager.translate(-0.5F, -0.1F, -0.4F);
this.renderModel(model, renderStack, 0xFF00004C);
GlStateManager.cullFace(1029);
GlStateManager.cullFace(GlStateManager.CullFace.BACK);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
@@ -22,6 +22,8 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
@@ -98,8 +100,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
addStringToTooltip(TextFormatting.LIGHT_PURPLE + String.format(I18n.translateToLocal("botaniamisc.brewOf"), I18n.translateToLocal(brew.getUnlocalizedName(stack))), list);
for(PotionEffect effect : brew.getPotionEffects(stack)) {
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
TextFormatting format = potion.isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
addStringToTooltip(" " + format + I18n.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + I18n.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))), list);
}
}
@@ -118,10 +119,10 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
boolean doRand = cost < 1;
if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
PotionEffect currentEffect = player.getActivePotionEffect(GameData.getPotionRegistry().getObjectById(effect.getPotionID()));
boolean nightVision = effect.getPotionID() == Potion.nightVision.id;
PotionEffect currentEffect = player.getActivePotionEffect(effect.getPotion());
boolean nightVision = effect.getPotion() == MobEffects.nightVision;
if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) {
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true, true);
PotionEffect applyEffect = new PotionEffect(effect.getPotion(), nightVision ? 285 : 80, effect.getAmplifier(), true, true);
player.addPotionEffect(applyEffect);
}
@@ -147,8 +148,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
@Override
public ItemStack getItemForBrew(Brew brew, ItemStack stack) {
FMLControlledNamespacedRegistry<Potion> potionRegistry = GameData.getPotionRegistry();
if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || potionRegistry.getObjectById(brew.getPotionEffects(stack).get(0).getPotionID()).isInstant())
if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant())
return null;
ItemStack brewStack = new ItemStack(this);
@@ -171,7 +171,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Helper.rotateIfSneaking(player);
boolean armor = player.getCurrentArmor(2) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
@@ -22,7 +22,9 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -30,6 +32,7 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream;
import vazkii.botania.common.lib.LibItemNames;
@@ -68,7 +71,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
event.entityLiving.isDead = false;
ManaItemHandler.requestManaExact(amulet, player, cost, true);
player.worldObj.playSoundAtEntity(player, "botania:divaCharm", 1F, 1F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.divaCharm, SoundCategory.PLAYERS, 1F, 1F);
double x = event.entityLiving.posX;
double y = event.entityLiving.posY;
@@ -97,13 +100,13 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
boolean armor = player.getCurrentArmor(3) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null;
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.scale(0.8F, 0.8F, 0.8F);
GlStateManager.rotate(90, 0, 0, 1);
GlStateManager.translate(1.475F, armor ? -0.57F : -0.5F, 0.53F);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this, 1), ItemCameraTransforms.TransformType.THIRD_PERSON);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this, 1), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); // todo 1.9
}
}
@@ -15,14 +15,18 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.lib.LibItemNames;
import baubles.api.BaubleType;
import baubles.common.lib.PlayerHandler;
@@ -47,9 +51,9 @@ public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender {
if(amulet != null && amulet.getItem() == this) {
event.setCanceled(true);
player.setHealth(player.getMaxHealth());
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 6));
player.addPotionEffect(new PotionEffect(MobEffects.resistance, 300, 6));
player.addChatMessage(new TextComponentTranslation("botaniamisc.savedByLaurel"));
player.worldObj.playSoundAtEntity(player, "botania:goldenLaurel", 1F, 0.3F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.goldenLaurel, SoundCategory.PLAYERS, 1F, 0.3F);
PlayerHandler.getPlayerBaubles(player).setInventorySlotContents(0, null);
}
}
@@ -64,7 +68,7 @@ public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender {
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
boolean armor = player.getCurrentArmor(3) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null;
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.rotate(-90F, 0F, 1F, 0F);
@@ -73,7 +77,7 @@ public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender {
if(armor) {
GlStateManager.scale(1.1F, 1.1F, 1.1F);
}
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this), ItemCameraTransforms.TransformType.THIRD_PERSON);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); // todo 1.9
}
}
}
@@ -15,12 +15,15 @@ import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -79,7 +82,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) {
if(!event.source.isMagicDamage()) {
event.setCanceled(true);
player.worldObj.playSoundAtEntity(player, "botania:holyCloak", 1F, 1F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.holyCloak, SoundCategory.PLAYERS, 1F, 1F);
for(int i = 0; i < 30; i++) {
double x = player.posX + Math.random() * player.width * 2 - player.width;
double y = player.posY + Math.random() * player.height;
@@ -129,7 +132,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture());
Helper.rotateIfSneaking(player);
boolean armor = player.getCurrentArmor(2) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
GlStateManager.translate(0F, armor ? -0.07F : -0.01F, 0F);
float s = 0.1F;
@@ -25,6 +25,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
@@ -105,7 +106,7 @@ public class ItemIcePendant extends ItemBauble implements IBaubleRender {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Helper.rotateIfSneaking(player);
boolean armor = player.getCurrentArmor(2) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.rotate(-45F, 0F, 0F, 1F);
@@ -26,6 +26,7 @@ import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.AnimalChest;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -227,7 +228,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
boolean armor = player.getCurrentArmor(3) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null;
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.rotate(90F, 0F, 1F, 0F);
@@ -45,7 +45,7 @@ public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRend
@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0));
attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0));
}
@Override
@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.item.IBaubleRender;
@@ -47,7 +48,7 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Helper.rotateIfSneaking(player);
boolean armor = player.getCurrentArmor(2) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.36F, -0.24F, armor ? 0.2F : 0.15F);
GlStateManager.rotate(-45F, 0F, 0F, 1F);
@@ -12,6 +12,7 @@ package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -36,10 +37,10 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
if(!hasMana)
onUnequipped(stack, player);
else {
if(player.getActivePotionEffect(Potion.digSpeed) != null)
player.removePotionEffect(Potion.digSpeed.id);
if(player.getActivePotionEffect(MobEffects.digSpeed) != null)
player.removePotionEffect(MobEffects.digSpeed);
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 1, true, true));
player.addPotionEffect(new PotionEffect(MobEffects.digSpeed, Integer.MAX_VALUE, 1, true, true));
}
if(player.swingProgress == 0.25F)
@@ -49,9 +50,9 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(Potion.digSpeed);
PotionEffect effect = player.getActivePotionEffect(MobEffects.digSpeed);
if(effect != null && effect.getAmplifier() == 1)
player.removePotionEffect(Potion.digSpeed.id);
player.removePotionEffect(MobEffects.digSpeed);
}
@Override
@@ -23,6 +23,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
@@ -51,13 +52,13 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
@Override
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
boolean armor = player.getCurrentArmor(3) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null;
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotate(90, 0, 0, 1); // todo 1.8 could use some further refinement
GlStateManager.translate(2.88F, armor ? -0.75F : -0.63F, 0.62F);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this), ItemCameraTransforms.TransformType.THIRD_PERSON);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this), ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND); // todo 1.9
}
}
@@ -18,6 +18,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.item.IBaubleRender;
@@ -58,7 +59,7 @@ public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Helper.rotateIfSneaking(player);
boolean armor = player.getCurrentArmor(2) != null;
boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.36F, -0.24F, armor ? 0.2F : 0.15F);
GlStateManager.rotate(-45F, 0F, 0F, 1F);
@@ -12,6 +12,7 @@ package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -34,7 +35,7 @@ public class ItemSwapRing extends ItemBauble {
return;
EntityPlayer player = (EntityPlayer) entity;
ItemStack currentStack = player.getCurrentEquippedItem();
ItemStack currentStack = player.getHeldItemMainhand();
if(currentStack == null || !(currentStack.getItem() instanceof ISortableTool))
return;
@@ -44,17 +45,15 @@ public class ItemSwapRing extends ItemBauble {
ToolType typeToFind = null;
if(player.isSwingInProgress && pos != null && pos.getBlockPos() != null) {
Block block = entity.worldObj.getBlockState(pos.getBlockPos()).getBlock();
IBlockState state = entity.worldObj.getBlockState(pos.getBlockPos());
if(block != null) {
Material mat = block.getMaterial();
if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick))
typeToFind = ToolType.PICK;
else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel))
typeToFind = ToolType.SHOVEL;
else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe))
typeToFind = ToolType.AXE;
}
Material mat = state.getMaterial();
if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick))
typeToFind = ToolType.PICK;
else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel))
typeToFind = ToolType.SHOVEL;
else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe))
typeToFind = ToolType.AXE;
}
if(typeToFind == null)
@@ -18,10 +18,12 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibItemNames;
@@ -45,7 +47,7 @@ public class ItemUnholyCloak extends ItemHolyCloak {
entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.ammount);
}
player.worldObj.playSoundAtEntity(player, "botania:unholyCloak", 1F, 1F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.unholyCloak, SoundCategory.PLAYERS, 1F, 1F);
for(int i = 0; i < 90; i++) {
float rad = i * 4F * (float) Math.PI / 180F;
float xMotion = (float) Math.cos(rad) * 0.2F;
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -50,9 +51,9 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
if(changeZ)
player.motionZ = motionZ;
PotionEffect effect = player.getActivePotionEffect(Potion.nightVision);
PotionEffect effect = player.getActivePotionEffect(MobEffects.nightVision);
if(effect == null) {
PotionEffect neweffect = new PotionEffect(Potion.nightVision.id, Integer.MAX_VALUE, -42, true, true);
PotionEffect neweffect = new PotionEffect(MobEffects.nightVision, Integer.MAX_VALUE, -42, true, true);
player.addPotionEffect(neweffect);
}
@@ -66,9 +67,9 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(Potion.nightVision);
PotionEffect effect = player.getActivePotionEffect(MobEffects.nightVision);
if(effect != null && effect.getAmplifier() == -42)
player.removePotionEffect(Potion.nightVision.id);
player.removePotionEffect(MobEffects.nightVision);
}
@Override
@@ -33,7 +33,7 @@ public class ItemGlassPick extends ItemManasteelPick {
@SubscribeEvent
public void onBlockDrops(HarvestDropsEvent event) {
if(event.harvester != null && event.state != null && event.drops.isEmpty() && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() == this && event.state.getBlock().getMaterial() == Material.glass && event.state.getBlock().canSilkHarvest(event.world, event.pos, event.state, event.harvester))
if(event.harvester != null && event.state != null && event.drops.isEmpty() && event.harvester.getHeldItemMainhand() != null && event.harvester.getHeldItemMainhand().getItem() == this && event.state.getMaterial() == Material.glass && event.state.getBlock().canSilkHarvest(event.world, event.pos, event.state, event.harvester))
event.drops.add(new ItemStack(event.state.getBlock(), 1, event.state.getBlock().getMetaFromState(event.state)));
}
@@ -12,14 +12,17 @@ package vazkii.botania.common.item.equipment.tool;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.Achievement;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.achievement.ICraftAchievement;
import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.core.helper.Vector3;
@@ -41,10 +44,10 @@ public class ItemStarSword extends ItemManasteelSword implements ICraftAchieveme
super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
if(par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
PotionEffect haste = player.getActivePotionEffect(MobEffects.digSpeed);
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
if(player.getHeldItemMainhand() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
RayTraceResult pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48);
if(pos != null && pos.getBlockPos() != null) {
Vector3 posVec = new Vector3(pos.getBlockPos().getX(), pos.getBlockPos().getY(), pos.getBlockPos().getZ());
@@ -60,7 +63,7 @@ public class ItemStarSword extends ItemManasteelSword implements ICraftAchieveme
par2World.spawnEntityInWorld(star);
ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F);
par2World.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.starcaller, SoundCategory.PLAYERS, 0.4F, 1.4F);
}
}
}
@@ -18,6 +18,7 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
@@ -52,7 +53,7 @@ public final class ToolCommons {
* Pos is the actual block coordinate, posStart and posEnd are deltas from pos
*/
public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, BlockPos pos, BlockPos posStart, BlockPos posEnd, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) {
float blockHardness = block == null ? 1F : block.getBlockHardness(world, pos);
float blockHardness = block == null ? 1F : block.getBlockHardness(world.getBlockState(pos), world, pos);
for (BlockPos iterPos : BlockPos.getAllInBox(pos.add(posStart), pos.add(posEnd))) {
if (iterPos.equals(pos)) // skip original block space to avoid crash, vanilla code in the tool class will handle it
@@ -83,8 +84,8 @@ public final class ToolCommons {
if(block != null && blk != block)
return;
Material mat = world.getBlockState(pos).getBlock().getMaterial();
if(!world.isRemote && blk != null && !blk.isAir(world, pos) && blk.getPlayerRelativeBlockHardness(player, world, pos) > 0) {
Material mat = world.getBlockState(pos).getMaterial();
if(!world.isRemote && blk != null && !blk.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0) {
if(!blk.canHarvestBlock(player.worldObj, pos, player) || !isRightMaterial(mat, materialsListing)) {
return;
}
@@ -93,11 +94,11 @@ public final class ToolCommons {
IBlockState localState = world.getBlockState(pos);
blk.onBlockHarvested(world, pos, localState, player);
if(blk.removedByPlayer(world, pos, player, true)) {
if(blk.removedByPlayer(state, world, pos, player, true)) {
blk.onBlockDestroyedByPlayer(world, pos, state);
if(!dispose || !ItemElementiumPick.isDisposable(blk))
blk.harvestBlock(world, player, pos, state, world.getTileEntity(pos));
blk.harvestBlock(world, player, pos, state, world.getTileEntity(pos), stack);
}
damageItem(stack, 1, player, 80);
@@ -130,7 +131,7 @@ public final class ToolCommons {
if(item == ModItems.terraPick)
modifier = ItemTerraPick.getLevel(stack);
int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack);
int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantments.efficiency, stack);
return materialLevel * 100 + modifier * 10 + efficiency;
}
@@ -15,6 +15,7 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameData;
@@ -43,13 +44,13 @@ public class ItemCrystalBow extends ItemLivingwoodBow {
@Override
boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) {
int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_);
int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantments.infinity, p_77615_1_);
return ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity + 1), false);
}
@Override
void onFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, boolean infinity, EntityArrow arrow) {
arrow.canBePickedUp = 2;
arrow.canBePickedUp = EntityArrow.PickupStatus.CREATIVE_ONLY;
ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity ? 2 : 1), false);
}
@@ -10,6 +10,7 @@ import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
@@ -37,10 +38,10 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
@SubscribeEvent
public void onEntityDrops(LivingDropsEvent event) {
if(event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem();
ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getHeldItemMainhand();
if(weapon != null && weapon.getItem() == this) {
Random rand = event.entity.worldObj.rand;
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, weapon);
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, weapon);
if(event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting)
addDrop(event, new ItemStack(Items.skull, 1, ((EntitySkeleton)event.entityLiving).getSkeletonType()));
@@ -7,10 +7,15 @@ import com.google.common.base.Predicates;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -36,24 +41,24 @@ public class ItemElementiumShears extends ItemManasteelShears {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player, EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
if(player.worldObj.isRemote)
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
if(living.worldObj.isRemote)
return;
if(count != getMaxItemUseDuration(stack) && count % 5 == 0) {
int range = 12;
List sheep = player.worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range), Predicates.instanceOf(IShearable.class));
List sheep = living.worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range), Predicates.instanceOf(IShearable.class));
if(sheep.size() > 0) {
for(IShearable target : ((List<IShearable>) sheep)) {
Entity entity = (Entity) target;
if(target.isShearable(stack, entity.worldObj, new BlockPos(entity))) {
List<ItemStack> drops = target.onSheared(stack, entity.worldObj, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack));
List<ItemStack> drops = target.onSheared(stack, entity.worldObj, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack));
Random rand = new Random();
for(ItemStack drop : drops) {
@@ -63,7 +68,7 @@ public class ItemElementiumShears extends ItemManasteelShears {
ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
}
ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE);
ToolCommons.damageItem(stack, 1, living, MANA_PER_DAMAGE);
break;
}
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.equipment.tool.manasteel;
import java.util.regex.Pattern;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -20,6 +21,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -69,8 +72,8 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase entity) {
if (block.getBlockHardness(world, pos) != 0F)
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entity) {
if (state.getBlockHardness(world, pos) != 0F)
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
return true;
@@ -81,11 +84,11 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float sx, float sy, float sz) {
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != null && SAPLING_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
boolean did = stackAt.getItem().onItemUse(stackAt, player, world, pos, side, sx, sy, sz);
EnumActionResult did = stackAt.getItem().onItemUse(stackAt, player, world, pos, hand, side, sx, sy, sz);
if(stackAt.stackSize == 0)
player.inventory.setInventorySlotContents(i, null);
@@ -94,7 +97,7 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
}
}
return false;
return EnumActionResult.PASS;
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.equipment.tool.manasteel;
import java.util.regex.Pattern;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -20,6 +21,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -69,19 +72,19 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase entity) {
if(block.getBlockHardness(world, pos) != 0F)
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entity) {
if(state.getBlockHardness(world, pos) != 0F)
ToolCommons.damageItem(stack, 1, entity, getManaPerDmg());
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float sx, float sy, float sz) {
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != null && TORCH_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
boolean did = stackAt.getItem().onItemUse(stackAt, player, world, pos, side, sx, sy, sz);
EnumActionResult did = stackAt.getItem().onItemUse(stackAt, player, world, pos, hand, side, sx, sy, sz);
if(stackAt.stackSize == 0)
player.inventory.setInventorySlotContents(i, null);
@@ -90,7 +93,7 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
}
}
return false;
return EnumActionResult.PASS;
}
public int getManaPerDmg() {
@@ -20,10 +20,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
@@ -63,14 +65,14 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
}
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) {
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if(entity.worldObj.isRemote)
return false;
if(entity instanceof IShearable) {
IShearable target = (IShearable)entity;
if(target.isShearable(itemstack, entity.worldObj, new BlockPos(entity))) {
List<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
List<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, itemstack));
Random rand = new Random();
for(ItemStack stack : drops) {
@@ -98,7 +100,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
if(block instanceof IShearable) {
IShearable target = (IShearable)block;
if(target.isShearable(itemstack, player.worldObj, pos)) {
List<ItemStack> drops = target.onSheared(itemstack, player.worldObj, pos, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
List<ItemStack> drops = target.onSheared(itemstack, player.worldObj, pos, EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, itemstack));
Random rand = new Random();
for(ItemStack stack : drops) {
@@ -113,7 +115,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
}
ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE);
player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1);
player.addStat(StatList.getBlockStats(block), 1);
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,6 +19,9 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -67,43 +71,43 @@ public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, IS
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase entity) {
if (block.getBlockHardness(world, pos) != 0F)
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entity) {
if (state.getBlockHardness(world, pos) != 0F)
ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE);
return true;
}
@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, BlockPos pos, EnumFacing side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
public EnumActionResult onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, BlockPos pos, EnumHand hand, EnumFacing side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
if(!p_77648_2_.canPlayerEdit(pos, side, p_77648_1_))
return false;
return EnumActionResult.PASS;
else {
UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, pos);
if(MinecraftForge.EVENT_BUS.post(event))
return false;
return EnumActionResult.FAIL;
if(event.getResult() == Result.ALLOW) {
ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE);
return true;
return EnumActionResult.SUCCESS;
}
Block block = p_77648_3_.getBlockState(pos).getBlock();
if(side != EnumFacing.DOWN && p_77648_3_.getBlockState(pos.up()).getBlock().isAir(p_77648_3_, pos.up()) && (block == Blocks.grass || block == Blocks.dirt)) {
if(side != EnumFacing.DOWN && p_77648_3_.getBlockState(pos.up()).getBlock().isAir(p_77648_3_.getBlockState(pos.up()), p_77648_3_, pos.up()) && (block == Blocks.grass || block == Blocks.dirt)) {
Block block1 = Blocks.farmland;
p_77648_3_.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, block1.stepSound.getStepSound(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getFrequency() * 0.8F);
p_77648_3_.playSound(null, pos, block1.getSoundType().getStepSound(), SoundCategory.BLOCKS, (block1.getSoundType().getVolume() + 1.0F) / 2.0F, block1.getSoundType().getPitch() * 0.8F);
if (p_77648_3_.isRemote)
return true;
return EnumActionResult.SUCCESS;
else {
p_77648_3_.setBlockState(pos, block1.getDefaultState());
ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE);
return true;
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
}
@@ -23,6 +23,7 @@ import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
@@ -289,8 +290,8 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
cand.coordinates,
origin,
null, ToolCommons.materialsAxe,
EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, truncator) > 0,
EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, truncator),
EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, truncator) > 0,
EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, truncator),
0F, false, treatLeavesSpecial);
remainingSwaps--;
@@ -303,7 +304,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
Block block = world.getBlockState(adj).getBlock();
boolean isWood = block.isWood(world, adj);
boolean isLeaf = block.isLeaves(world, adj);
boolean isLeaf = block.isLeaves(world.getBlockState(adj), world, adj);
// If it's not wood or a leaf, we aren't interested.
if(!isWood && !isLeaf)
@@ -34,6 +34,7 @@ import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISequentialBreaker;
import vazkii.botania.api.mana.IManaGivingItem;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe;
@@ -93,22 +94,23 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
getMana(par1ItemStack);
int level = getLevel(par1ItemStack);
if(level != 0) {
setEnabled(par1ItemStack, !isEnabled(par1ItemStack));
if(!par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F);
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, BotaniaSoundEvents.terraPickMode, SoundCategory.PLAYERS, 0.5F, 0.4F);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float sx, float sy, float sz) {
return player.isSneaking() && super.onItemUse(stack, player, world, pos, side, sx, sy, sz);
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
return player.isSneaking() ? super.onItemUse(stack, player, world, pos, hand, side, sx, sy, sz)
: EnumActionResult.PASS;
}
@Override
@@ -147,7 +149,7 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
return;
World world = player.worldObj;
Material mat = world.getBlockState(pos).getBlock().getMaterial();
Material mat = world.getBlockState(pos).getMaterial();
if(!ToolCommons.isRightMaterial(mat, MATERIALS))
return;
@@ -16,20 +16,24 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.stats.Achievement;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
import vazkii.botania.api.mana.ILensEffect;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.achievement.ICraftAchievement;
import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -54,14 +58,14 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
if(par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
PotionEffect haste = player.getActivePotionEffect(MobEffects.digSpeed);
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
if(player.getHeldItemMainhand() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
EntityManaBurst burst = getBurst(player, par1ItemStack);
par2World.spawnEntityInWorld(burst);
ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
par2World.playSoundAtEntity(player, "botania:terraBlade", 0.4F, 1.4F);
par2World.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.terraBlade, SoundCategory.PLAYERS, 0.4F, 1.4F);
}
}
}
@@ -108,7 +112,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, "");
for(EntityLivingBase living : entities) {
if(living instanceof EntityPlayer && (living.getName().equals(attacker) || MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))
if(living instanceof EntityPlayer && (living.getName().equals(attacker) || FMLCommonHandler.instance().getMinecraftServerInstance() != null && !FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()))
continue;
if(living.hurtTime == 0) {
@@ -20,6 +20,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -34,14 +36,14 @@ public class ItemDye extends Item16Colors {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
Block block = par3World.getBlockState(pos).getBlock();
EnumDyeColor color = EnumDyeColor.byMetadata(par1ItemStack.getItemDamage());
if(block == Blocks.wool && color != par3World.getBlockState(pos).getValue(BlockColored.COLOR)
|| block == Blocks.carpet && color != par3World.getBlockState(pos).getValue(BlockCarpet.COLOR)) {
par3World.setBlockState(pos, par3World.getBlockState(pos).withProperty(block == Blocks.wool ? BlockColored.COLOR : BlockCarpet.COLOR, color), 1 | 2);
par1ItemStack.stackSize--;
return true;
return EnumActionResult.SUCCESS;
}
TileEntity tile = par3World.getTileEntity(pos);
@@ -50,15 +52,15 @@ public class ItemDye extends Item16Colors {
if(color != dyable.getColor()) {
dyable.setColor(color);
par1ItemStack.stackSize--;
return true;
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
@Override
public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) {
public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_, EnumHand hand) {
if(p_111207_3_ instanceof EntitySheep) {
EntitySheep entitysheep = (EntitySheep)p_111207_3_;
EnumDyeColor i = EnumDyeColor.byMetadata(p_111207_1_.getItemDamage());
@@ -17,10 +17,15 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.RayTraceResult;
@@ -81,40 +86,41 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
if(stack.stackSize == 0)
event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, null);
event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F);
event.world.playSound(null, event.pos, SoundEvents.entity_item_pickup, SoundCategory.PLAYERS, 0.5F, 1F);
}
}
}
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14)
return EntityDoppleganger.spawn(par2EntityPlayer, par1ItemStack, par3World, pos, par1ItemStack.getItemDamage() == 14);
return EntityDoppleganger.spawn(par2EntityPlayer, par1ItemStack, par3World, pos, par1ItemStack.getItemDamage() == 14) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
else if(par1ItemStack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(par1ItemStack, par3World, pos, par2EntityPlayer)) {
if(!par3World.isRemote)
par3World.playAuxSFX(2005, pos, 0);
return true;
return EnumActionResult.SUCCESS;
}
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, pos, side, par8, par9, par10);
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10);
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer, EnumHand hand) {
if(par1ItemStack.getItemDamage() == 15) {
if(!par2EntityPlayer.capabilities.isCreativeMode)
--par1ItemStack.stackSize;
par3World.playSoundAtEntity(par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
par3World.playSound(null, par2EntityPlayer.posX, par2EntityPlayer.posY, par2EntityPlayer.posZ, SoundEvents.entity_arrow_shoot, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if(!par3World.isRemote)
par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer));
else par2EntityPlayer.swingItem();
else par2EntityPlayer.swingArm(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
@Override
@@ -122,7 +122,7 @@ public class ItemAesirRing extends ItemRelicBauble implements IExtendedWireframe
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0));
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0));
}
@Override
@@ -15,9 +15,14 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
@@ -48,7 +53,7 @@ public class ItemDice extends ItemRelic {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(isRightPlayer(player, stack) && !player.worldObj.isRemote) {
int moonPhase = world.provider.getMoonPhase(world.getWorldTime());
int side = SIDES_FOR_MOON_PHASES[moonPhase];
@@ -66,19 +71,19 @@ public class ItemDice extends ItemRelic {
relic = possible.get(world.rand.nextInt(possible.size()));
}
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.entity_arrow_shoot, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
if(hasRelicAlready(player, relic)) {
player.addChatMessage(new TextComponentTranslation("botaniamisc.dudDiceRoll", relic + 1).setChatStyle(new Style().setColor(TextFormatting.DARK_GREEN)));
stack.stackSize--;
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
player.addChatMessage(new TextComponentTranslation("botaniamisc.diceRoll", relic + 1).setChatStyle(new Style().setColor(TextFormatting.DARK_GREEN)));
return relicStacks[relic].copy();
return ActionResult.newResult(EnumActionResult.SUCCESS, relicStacks[relic].copy());
}
return stack;
return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
@Override
@@ -11,10 +11,16 @@
package vazkii.botania.common.item.relic;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -38,10 +44,10 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
private static final String TAG_DIMENSION = "dim";
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if(player.isSneaking()) {
if(world.isRemote) {
player.swingItem();
player.swingArm(hand);
for(int i = 0; i < 10; i++) {
float x1 = (float) (pos.getX() + Math.random());
float y1 = pos.getY() + 1;
@@ -53,29 +59,33 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
ItemNBTHelper.setInt(stack, TAG_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_Z, pos.getZ());
ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.getDimension());
world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.entity_endermen_teleport, SoundCategory.PLAYERS, 1F, 5F);
}
}
return true;
return EnumActionResult.SUCCESS;
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
float x = (float) (player.posX - Math.random() * player.width);
float y = (float) (player.posY - 1.6 + Math.random());
float z = (float) (player.posZ - Math.random() * player.width);
Botania.proxy.wispFX(player.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F);
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
float x = (float) (living.posX - Math.random() * living.width);
float y = (float) (living.posY - 1.6 + Math.random());
float z = (float) (living.posZ - Math.random() * living.width);
Botania.proxy.wispFX(living.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F);
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player) {
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase living) {
if(!(living instanceof EntityPlayer))
return stack;
EntityPlayer player = ((EntityPlayer) living);
int x = ItemNBTHelper.getInt(stack, TAG_X, 0);
int y = ItemNBTHelper.getInt(stack, TAG_Y, -1);
int z = ItemNBTHelper.getInt(stack, TAG_Z, 0);
@@ -101,7 +111,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
Botania.proxy.wispFX(entity.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), -0.3F + (float) Math.random() * 0.2F);
}
if(!entity.worldObj.isRemote)
entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F);
entity.worldObj.playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.entity_endermen_teleport, SoundCategory.PLAYERS, 1F, 1F);
}
@Override
@@ -10,9 +10,13 @@
*/
package vazkii.botania.common.item.relic;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -37,16 +41,20 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
}
@Override
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
if(p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_))
p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_));
return p_77659_1_;
public ActionResult<ItemStack> onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_, EnumHand hand) {
if(p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_)) {
p_77659_3_.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, p_77659_1_);
}
return ActionResult.newResult(EnumActionResult.PASS, p_77659_1_);
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
super.onUsingTick(stack, player, count);
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
super.onUsingTick(stack, living, count);
if(!(living instanceof EntityPlayer))
return;
EntityPlayer player = ((EntityPlayer) living);
if(ManaItemHandler.requestManaExact(stack, player, 500, true)) {
if(count % 5 == 0)
player.getFoodStats().addStats(1, 1F);