mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Merge branch 'master' of https://github.com/Vazkii/Botania
This commit is contained in:
commit
3a816ece7a
22 files changed
+1000
-200
No files matched your search
@@ -10,10 +10,14 @@
|
||||
*/
|
||||
package vazkii.botania.api.item;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import vazkii.botania.api.mana.ManaProficiencyEvent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* An armor item that implements this gives the player wearing it mana proficiency, by
|
||||
@@ -24,22 +28,42 @@ import net.minecraft.item.ItemStack;
|
||||
*/
|
||||
public interface IManaProficiencyArmor {
|
||||
|
||||
public boolean shouldGiveProficiency(ItemStack stack, EntityEquipmentSlot slot, EntityPlayer player);
|
||||
@Deprecated
|
||||
default boolean shouldGiveProficiency(ItemStack armorStack, EntityEquipmentSlot slot, EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean shouldGiveProficiency(ItemStack armorStack, EntityEquipmentSlot slot, EntityPlayer player, @Nullable ItemStack rod) {
|
||||
return shouldGiveProficiency(armorStack, slot, player);
|
||||
}
|
||||
|
||||
public final static class Helper {
|
||||
|
||||
@Deprecated
|
||||
public static boolean hasProficiency(EntityPlayer player) {
|
||||
return hasProficiency(player, null);
|
||||
}
|
||||
|
||||
public static boolean hasProficiency(EntityPlayer player, @Nullable ItemStack rod) {
|
||||
boolean proficient = false;
|
||||
|
||||
for(EntityEquipmentSlot e: EntityEquipmentSlot.values()) {
|
||||
if(e.getSlotType() != EntityEquipmentSlot.Type.ARMOR)
|
||||
continue;
|
||||
ItemStack armor = player.getItemStackFromSlot(e);
|
||||
if(armor != null) {
|
||||
Item item = armor.getItem();
|
||||
if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player))
|
||||
return true;
|
||||
if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) {
|
||||
proficient = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
ManaProficiencyEvent event = new ManaProficiencyEvent(player, rod, proficient);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
return event.isProficient();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -20,12 +22,18 @@ import net.minecraft.item.ItemStack;
|
||||
*/
|
||||
public interface IManaDiscountArmor {
|
||||
|
||||
@Deprecated
|
||||
default float getDiscount(ItemStack stack, int slot, EntityPlayer player) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mana discount that this piece of armor provides. This is added
|
||||
* together to create the full discount.
|
||||
* Gets the mana discount that this piece of armor provides for the specified
|
||||
* tool. This is added together to create the full discount.
|
||||
* Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example.
|
||||
* You can also return negative values to make tools cost more.
|
||||
*/
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player);
|
||||
|
||||
default float getDiscount(ItemStack stack, int slot, EntityPlayer player, @Nullable ItemStack tool) {
|
||||
return getDiscount(stack, slot, player);
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,32 @@
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class ManaDiscountEvent extends Event {
|
||||
|
||||
private final EntityPlayer entityPlayer;
|
||||
private float discount;
|
||||
|
||||
public ManaDiscountEvent(EntityPlayer entityPlayer, float discount) {
|
||||
private ItemStack tool;
|
||||
|
||||
public ManaDiscountEvent(EntityPlayer entityPlayer, float discount, @Nullable ItemStack tool) {
|
||||
this.entityPlayer = entityPlayer;
|
||||
this.discount = discount;
|
||||
this.tool = tool;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ManaDiscountEvent(EntityPlayer entityPlayer, float discount) {
|
||||
this(entityPlayer, discount, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
public EntityPlayer getEntityPlayer() {
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -317,19 +319,24 @@ public final class ManaItemHandler {
|
||||
return requestManaExact(stack, player, cost, remove);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static float getFullDiscountForTools(EntityPlayer player) {
|
||||
return getFullDiscountForTools(player, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sum of all the discounts on IManaDiscountArmor items equipped
|
||||
* on the player passed in.
|
||||
* on the player passed in. This discount can vary based on what the passed tool is.
|
||||
*/
|
||||
public static float getFullDiscountForTools(EntityPlayer player) {
|
||||
public static float getFullDiscountForTools(EntityPlayer player, @Nullable ItemStack tool) {
|
||||
float discount = 0F;
|
||||
for(int i = 0; i < player.inventory.armorInventory.length; i++) {
|
||||
ItemStack armor = player.inventory.armorInventory[i];
|
||||
if(armor != null && armor.getItem() instanceof IManaDiscountArmor)
|
||||
discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player);
|
||||
discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player, tool);
|
||||
}
|
||||
|
||||
ManaDiscountEvent event = new ManaDiscountEvent(player, discount);
|
||||
ManaDiscountEvent event = new ManaDiscountEvent(player, discount, tool);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
discount = event.getDiscount();
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* This class was created by <Flaxbeard>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 4, 2016, 10:46:12 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class ManaProficiencyEvent extends Event {
|
||||
|
||||
private final EntityPlayer entityPlayer;
|
||||
private ItemStack rod;
|
||||
private boolean proficient;
|
||||
|
||||
public ManaProficiencyEvent(EntityPlayer entityPlayer, @Nullable ItemStack rod, boolean proficient) {
|
||||
this.entityPlayer = entityPlayer;
|
||||
this.rod = rod;
|
||||
this.proficient = proficient;
|
||||
}
|
||||
|
||||
public EntityPlayer getEntityPlayer() {
|
||||
return entityPlayer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getRod() {
|
||||
return rod;
|
||||
}
|
||||
|
||||
public boolean isProficient() {
|
||||
return proficient;
|
||||
}
|
||||
|
||||
public void setProficient(boolean proficient) {
|
||||
this.proficient = proficient;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "82", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "83", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
package vazkii.botania.common.item.equipment.armor.elementium;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,7 +24,7 @@ public class ItemElementiumHelm extends ItemElementiumArmor implements IManaDisc
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player) {
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player, @Nullable ItemStack tool) {
|
||||
return hasArmorSet(player) ? 0.1F : 0F;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.armor.manasteel;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -27,7 +29,7 @@ public class ItemManasteelHelm extends ItemManasteelArmor implements IManaDiscou
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player) {
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player, @Nullable ItemStack tool) {
|
||||
return hasArmorSet(player) ? 0.1F : 0F;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.armor.manaweave;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
@@ -31,7 +33,7 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player) {
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player, @Nullable ItemStack tool) {
|
||||
return hasArmorSet(player) ? 0.35F : 0F;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -12,6 +12,8 @@ package vazkii.botania.common.item.equipment.armor.terrasteel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -64,7 +66,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player) {
|
||||
public float getDiscount(ItemStack stack, int slot, EntityPlayer player, @Nullable ItemStack tool) {
|
||||
return hasArmorSet(player) ? 0.2F : 0F;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
|
||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer p, EnumHand hand) {
|
||||
if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) {
|
||||
if(world.isRemote) {
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15;
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(p, stack) ? 20 : 15;
|
||||
long seedxor = world.rand.nextLong();
|
||||
doHighlight(world, new BlockPos(p), range, seedxor);
|
||||
p.swingArm(hand);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1);
|
||||
int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player) ? 3 : 1;
|
||||
int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 3 : 1;
|
||||
if(extraRange != extraRangeNew)
|
||||
ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
|
||||
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
|
||||
player.worldObj.spawnEntityInWorld(entity);
|
||||
|
||||
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.Helper.hasProficiency(player) ? COOLDOWN / 2 : COOLDOWN);
|
||||
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack) ? COOLDOWN / 2 : COOLDOWN);
|
||||
|
||||
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BLAZE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
@@ -211,7 +211,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
|
||||
Vector3 moveVector = new Vector3(player.getLookVec().normalize());
|
||||
if(item instanceof EntityItem) {
|
||||
((EntityItem) item).setPickupDelay(20);
|
||||
float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F;
|
||||
float mot = IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 2.25F : 1.5F;
|
||||
item.motionX = moveVector.x * mot;
|
||||
item.motionY = moveVector.y;
|
||||
item.motionZ = moveVector.z * mot;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
if(!(living instanceof EntityPlayer)) return;
|
||||
EntityPlayer player = (EntityPlayer) living;
|
||||
|
||||
if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if(spawnMissile(player.worldObj, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1)))
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
BlockPos.MutableBlockPos lastChecker = new BlockPos.MutableBlockPos();
|
||||
|
||||
int count = 0;
|
||||
boolean prof = IManaProficiencyArmor.Helper.hasProficiency(player);
|
||||
boolean prof = IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack);
|
||||
int maxlen = prof ? 160 : 100;
|
||||
int time = prof ? (int) (TIME * 1.6) : TIME;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
}
|
||||
|
||||
if(!decremented)
|
||||
playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME));
|
||||
playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p, stack) ? (int) (TIME * 0.6) : TIME));
|
||||
else {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
double x = pos.getBlockPos().getX() + Math.random();
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
}
|
||||
|
||||
private void terraform(ItemStack par1ItemStack, World world, EntityPlayer player) {
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(player) ? 22 : 16;
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack) ? 22 : 16;
|
||||
|
||||
BlockPos startCenter = new BlockPos(player).down();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
} else if(isFlying(par1ItemStack)) {
|
||||
if(holding) {
|
||||
player.fallDistance = 0F;
|
||||
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25;
|
||||
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack) ? 1.6 : 1.25;
|
||||
|
||||
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.airRod, SoundCategory.PLAYERS, 0.1F, 0.25F);
|
||||
for(int i = 0; i < 5; i++)
|
||||
|
||||
Reference in new issue
Block a user