Fortune Upgrade (#475)
* Fortune Upgrade mechanic * Implemented upgrade tooltip and a couple of fix * Use the tooltip instead of doing a special name * Add the crafting recipe for the upgrade * Item tooltip localization
This commit is contained in:
@@ -71,6 +71,7 @@ public final class RSConfig {
|
|||||||
public int stackUpgradeUsage;
|
public int stackUpgradeUsage;
|
||||||
public int interdimensionalUpgradeUsage;
|
public int interdimensionalUpgradeUsage;
|
||||||
public int silkTouchUpgradeUsage;
|
public int silkTouchUpgradeUsage;
|
||||||
|
public int fortuneUpgradeUsagePerFortune;
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Categories
|
//region Categories
|
||||||
@@ -159,6 +160,7 @@ public final class RSConfig {
|
|||||||
stackUpgradeUsage = config.getInt("stack", UPGRADES, 12, 0, Integer.MAX_VALUE, "The additional energy used per Stack Upgrade");
|
stackUpgradeUsage = config.getInt("stack", UPGRADES, 12, 0, Integer.MAX_VALUE, "The additional energy used per Stack Upgrade");
|
||||||
interdimensionalUpgradeUsage = config.getInt("interdimensional", UPGRADES, 1000, 0, Integer.MAX_VALUE, "The additional energy used by the Interdimensional Upgrade");
|
interdimensionalUpgradeUsage = config.getInt("interdimensional", UPGRADES, 1000, 0, Integer.MAX_VALUE, "The additional energy used by the Interdimensional Upgrade");
|
||||||
silkTouchUpgradeUsage = config.getInt("silkTouch", UPGRADES, 15, 0, Integer.MAX_VALUE, "The additional energy used by the Silk Touch Upgrade");
|
silkTouchUpgradeUsage = config.getInt("silkTouch", UPGRADES, 15, 0, Integer.MAX_VALUE, "The additional energy used by the Silk Touch Upgrade");
|
||||||
|
fortuneUpgradeUsagePerFortune = config.getInt("fortune", UPGRADES, 10, 0, Integer.MAX_VALUE, "The additional energy used by the Fortune Upgrade, multiplied by the level of the enchantment");
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
if (config.hasChanged()) {
|
if (config.hasChanged()) {
|
||||||
|
|||||||
@@ -16,7 +16,16 @@ public class SoldererRecipeUpgrade implements ISoldererRecipe {
|
|||||||
public SoldererRecipeUpgrade(int type) {
|
public SoldererRecipeUpgrade(int type) {
|
||||||
this.result = new ItemStack(RSItems.UPGRADE, 1, type);
|
this.result = new ItemStack(RSItems.UPGRADE, 1, type);
|
||||||
this.rows = new ItemStack[]{
|
this.rows = new ItemStack[]{
|
||||||
ItemUpgrade.getRequirement(type),
|
ItemUpgrade.getRequirement(result),
|
||||||
|
new ItemStack(RSItems.UPGRADE, 1, 0),
|
||||||
|
new ItemStack(Items.REDSTONE)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public SoldererRecipeUpgrade(ItemStack result) {
|
||||||
|
this.result = result;
|
||||||
|
this.rows = new ItemStack[]{
|
||||||
|
ItemUpgrade.getRequirement(result),
|
||||||
new ItemStack(RSItems.UPGRADE, 1, 0),
|
new ItemStack(RSItems.UPGRADE, 1, 0),
|
||||||
new ItemStack(Items.REDSTONE)
|
new ItemStack(Items.REDSTONE)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,13 +48,23 @@ public class ItemHandlerUpgrade extends ItemHandlerBasic {
|
|||||||
|
|
||||||
for (int i = 0; i < getSlots(); ++i) {
|
for (int i = 0; i < getSlots(); ++i) {
|
||||||
if (getStackInSlot(i) != null) {
|
if (getStackInSlot(i) != null) {
|
||||||
usage += ItemUpgrade.getEnergyUsage(getStackInSlot(i).getItemDamage());
|
usage += ItemUpgrade.getEnergyUsage(getStackInSlot(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFortuneLevel() {
|
||||||
|
for (int i = 0; i < getSlots(); ++i) {
|
||||||
|
if (getStackInSlot(i) != null && getStackInSlot(i).getItemDamage() == ItemUpgrade.TYPE_FORTUNE) {
|
||||||
|
return ItemUpgrade.getFortuneLevel(getStackInSlot(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public int getInteractStackSize() {
|
public int getInteractStackSize() {
|
||||||
return hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1;
|
return hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
package refinedstorage.item;
|
package refinedstorage.item;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.EnchantmentData;
|
import net.minecraft.enchantment.EnchantmentData;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import refinedstorage.RS;
|
import refinedstorage.RS;
|
||||||
|
import refinedstorage.RSItems;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -18,6 +24,9 @@ public class ItemUpgrade extends ItemBase {
|
|||||||
public static final int TYPE_STACK = 4;
|
public static final int TYPE_STACK = 4;
|
||||||
public static final int TYPE_INTERDIMENSIONAL = 5;
|
public static final int TYPE_INTERDIMENSIONAL = 5;
|
||||||
public static final int TYPE_SILK_TOUCH = 6;
|
public static final int TYPE_SILK_TOUCH = 6;
|
||||||
|
public static final int TYPE_FORTUNE = 7;
|
||||||
|
|
||||||
|
private static final String NBT_FORTUNE = "Fortune";
|
||||||
|
|
||||||
public ItemUpgrade() {
|
public ItemUpgrade() {
|
||||||
super("upgrade");
|
super("upgrade");
|
||||||
@@ -27,15 +36,45 @@ public class ItemUpgrade extends ItemBase {
|
|||||||
setMaxStackSize(1);
|
setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||||
|
if (stack.getItemDamage() == TYPE_FORTUNE) {
|
||||||
|
tooltip.add(I18n.format("enchantment.lootBonusDigger") + " " + I18n.format("enchantment.level." + ItemUpgrade.getFortuneLevel(stack)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
|
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||||
for (int i = 0; i <= 6; ++i) {
|
for (int i = 0; i <= 6; ++i) {
|
||||||
list.add(new ItemStack(item, 1, i));
|
list.add(new ItemStack(item, 1, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int j = 1; j <= 3; ++j) {
|
||||||
|
list.add(initializeForFortune(j));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getEnergyUsage(int type) {
|
public static ItemStack initializeForFortune(int level) {
|
||||||
switch (type) {
|
ItemStack stack = new ItemStack(RSItems.UPGRADE, 1, TYPE_FORTUNE);
|
||||||
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
stack.getTagCompound().setInteger(NBT_FORTUNE, level);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getFortuneLevel(ItemStack stack) {
|
||||||
|
if (stack != null && stack.getItemDamage() == ItemUpgrade.TYPE_FORTUNE) {
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
if (tag.hasKey(ItemUpgrade.NBT_FORTUNE)) {
|
||||||
|
return tag.getInteger(ItemUpgrade.NBT_FORTUNE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEnergyUsage(ItemStack stack) {
|
||||||
|
switch (stack.getItemDamage()) {
|
||||||
case TYPE_RANGE:
|
case TYPE_RANGE:
|
||||||
return RS.INSTANCE.config.rangeUpgradeUsage;
|
return RS.INSTANCE.config.rangeUpgradeUsage;
|
||||||
case TYPE_SPEED:
|
case TYPE_SPEED:
|
||||||
@@ -48,13 +87,15 @@ public class ItemUpgrade extends ItemBase {
|
|||||||
return RS.INSTANCE.config.interdimensionalUpgradeUsage;
|
return RS.INSTANCE.config.interdimensionalUpgradeUsage;
|
||||||
case TYPE_SILK_TOUCH:
|
case TYPE_SILK_TOUCH:
|
||||||
return RS.INSTANCE.config.silkTouchUpgradeUsage;
|
return RS.INSTANCE.config.silkTouchUpgradeUsage;
|
||||||
|
case TYPE_FORTUNE:
|
||||||
|
return RS.INSTANCE.config.fortuneUpgradeUsagePerFortune * ItemUpgrade.getFortuneLevel(stack);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getRequirement(int type) {
|
public static ItemStack getRequirement(ItemStack stack) {
|
||||||
switch (type) {
|
switch (stack.getItemDamage()) {
|
||||||
case ItemUpgrade.TYPE_RANGE:
|
case ItemUpgrade.TYPE_RANGE:
|
||||||
return new ItemStack(Items.ENDER_PEARL);
|
return new ItemStack(Items.ENDER_PEARL);
|
||||||
case ItemUpgrade.TYPE_SPEED:
|
case ItemUpgrade.TYPE_SPEED:
|
||||||
@@ -65,6 +106,8 @@ public class ItemUpgrade extends ItemBase {
|
|||||||
return new ItemStack(Items.NETHER_STAR);
|
return new ItemStack(Items.NETHER_STAR);
|
||||||
case ItemUpgrade.TYPE_SILK_TOUCH:
|
case ItemUpgrade.TYPE_SILK_TOUCH:
|
||||||
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("silk_touch"), 1));
|
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("silk_touch"), 1));
|
||||||
|
case ItemUpgrade.TYPE_FORTUNE:
|
||||||
|
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("fortune"), getFortuneLevel(stack)));
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -542,6 +542,9 @@ public class CommonProxy {
|
|||||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_INTERDIMENSIONAL));
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_INTERDIMENSIONAL));
|
||||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SILK_TOUCH));
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SILK_TOUCH));
|
||||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
|
||||||
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.initializeForFortune(1)));
|
||||||
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.initializeForFortune(2)));
|
||||||
|
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.initializeForFortune(3)));
|
||||||
|
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RSItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK),
|
GameRegistry.addShapedRecipe(new ItemStack(RSItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK),
|
||||||
"USU",
|
"USU",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF
|
|||||||
private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, this);
|
private ItemHandlerBasic itemFilters = new ItemHandlerBasic(9, this);
|
||||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, this);
|
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, this);
|
||||||
|
|
||||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH);
|
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH, ItemUpgrade.TYPE_FORTUNE);
|
||||||
|
|
||||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||||
private int mode = IFilterable.WHITELIST;
|
private int mode = IFilterable.WHITELIST;
|
||||||
@@ -120,17 +120,18 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF
|
|||||||
}
|
}
|
||||||
} else if (type == IType.ITEMS) {
|
} else if (type == IType.ITEMS) {
|
||||||
IBlockState frontBlockState = worldObj.getBlockState(front);
|
IBlockState frontBlockState = worldObj.getBlockState(front);
|
||||||
|
Block frontBlock = frontBlockState.getBlock();
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
ItemStack frontStack = frontBlockState.getBlock().getItem(worldObj, front, frontBlockState);
|
ItemStack frontStack = frontBlock.getItem(worldObj, front, frontBlockState);
|
||||||
|
|
||||||
if (frontStack != null) {
|
if (frontStack != null) {
|
||||||
if (IFilterable.canTake(itemFilters, mode, compare, frontStack)) {
|
if (IFilterable.canTake(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(worldObj, front) != -1.0) {
|
||||||
List<ItemStack> drops;
|
List<ItemStack> drops;
|
||||||
if (!upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH)) {
|
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH) && frontBlock.canSilkHarvest(worldObj, front, frontBlockState, null)) {
|
||||||
drops = frontBlockState.getBlock().getDrops(worldObj, front, frontBlockState, 0);
|
|
||||||
} else {
|
|
||||||
drops = Collections.singletonList(frontStack);
|
drops = Collections.singletonList(frontStack);
|
||||||
|
} else {
|
||||||
|
drops = frontBlock.getDrops(worldObj, front, frontBlockState, upgrades.getFortuneLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ item.refinedstorage:upgrade.3.name=Crafting Upgrade
|
|||||||
item.refinedstorage:upgrade.4.name=Stack Upgrade
|
item.refinedstorage:upgrade.4.name=Stack Upgrade
|
||||||
item.refinedstorage:upgrade.5.name=Interdimensional Upgrade
|
item.refinedstorage:upgrade.5.name=Interdimensional Upgrade
|
||||||
item.refinedstorage:upgrade.6.name=Silk Touch Upgrade
|
item.refinedstorage:upgrade.6.name=Silk Touch Upgrade
|
||||||
|
item.refinedstorage:upgrade.7.name=Fortune Upgrade
|
||||||
item.refinedstorage:storage_housing.name=Storage Housing
|
item.refinedstorage:storage_housing.name=Storage Housing
|
||||||
item.refinedstorage:grid_filter.name=Grid Filter
|
item.refinedstorage:grid_filter.name=Grid Filter
|
||||||
item.refinedstorage:network_card.name=Network Card
|
item.refinedstorage:network_card.name=Network Card
|
||||||
Reference in New Issue
Block a user