Silk Touch Upgrade for the Destructor (#471)

* Silk Touch Upgrade for the Destructor

* Removed unused imports

* Naming Convention

* Get enchant by string id

* Moved if

* Forgot to add the renamed files and fix some coding style

* Unused statement

* Remove unused var
This commit is contained in:
InusualZ
2016-10-15 17:51:27 -04:00
committed by Raoul
parent 086adaa57a
commit 28993a4a59
8 changed files with 36 additions and 9 deletions

View File

@@ -70,6 +70,7 @@ public final class RSConfig {
public int craftingUpgradeUsage; public int craftingUpgradeUsage;
public int stackUpgradeUsage; public int stackUpgradeUsage;
public int interdimensionalUpgradeUsage; public int interdimensionalUpgradeUsage;
public int silkTouchUpgradeUsage;
//endregion //endregion
//region Categories //region Categories
@@ -157,6 +158,7 @@ public final class RSConfig {
craftingUpgradeUsage = config.getInt("crafting", UPGRADES, 5, 0, Integer.MAX_VALUE, "The additional energy used per Crafting Upgrade"); craftingUpgradeUsage = config.getInt("crafting", UPGRADES, 5, 0, Integer.MAX_VALUE, "The additional energy used per Crafting Upgrade");
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");
//endregion //endregion
if (config.hasChanged()) { if (config.hasChanged()) {

View File

@@ -1,6 +1,8 @@
package refinedstorage.item; package refinedstorage.item;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
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;
@@ -15,6 +17,7 @@ public class ItemUpgrade extends ItemBase {
public static final int TYPE_CRAFTING = 3; public static final int TYPE_CRAFTING = 3;
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 ItemUpgrade() { public ItemUpgrade() {
super("upgrade"); super("upgrade");
@@ -26,7 +29,7 @@ public class ItemUpgrade extends ItemBase {
@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 <= 5; ++i) { for (int i = 0; i <= 6; ++i) {
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
} }
@@ -43,6 +46,8 @@ public class ItemUpgrade extends ItemBase {
return RS.INSTANCE.config.stackUpgradeUsage; return RS.INSTANCE.config.stackUpgradeUsage;
case TYPE_INTERDIMENSIONAL: case TYPE_INTERDIMENSIONAL:
return RS.INSTANCE.config.interdimensionalUpgradeUsage; return RS.INSTANCE.config.interdimensionalUpgradeUsage;
case TYPE_SILK_TOUCH:
return RS.INSTANCE.config.silkTouchUpgradeUsage;
default: default:
return 0; return 0;
} }
@@ -58,6 +63,8 @@ public class ItemUpgrade extends ItemBase {
return new ItemStack(Blocks.CRAFTING_TABLE); return new ItemStack(Blocks.CRAFTING_TABLE);
case ItemUpgrade.TYPE_INTERDIMENSIONAL: case ItemUpgrade.TYPE_INTERDIMENSIONAL:
return new ItemStack(Items.NETHER_STAR); return new ItemStack(Items.NETHER_STAR);
case ItemUpgrade.TYPE_SILK_TOUCH:
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("silk_touch"), 1));
default: default:
return null; return null;
} }

View File

@@ -197,7 +197,8 @@ public class ClientProxy extends CommonProxy {
new ResourceLocation("refinedstorage:range_upgrade"), new ResourceLocation("refinedstorage:range_upgrade"),
new ResourceLocation("refinedstorage:speed_upgrade"), new ResourceLocation("refinedstorage:speed_upgrade"),
new ResourceLocation("refinedstorage:stack_upgrade"), new ResourceLocation("refinedstorage:stack_upgrade"),
new ResourceLocation("refinedstorage:interdimensional_upgrade") new ResourceLocation("refinedstorage:interdimensional_upgrade"),
new ResourceLocation("refinedstorage:silk_touch_upgrade")
); );
// Items // Items
@@ -249,6 +250,7 @@ public class ClientProxy extends CommonProxy {
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_CRAFTING, new ModelResourceLocation("refinedstorage:crafting_upgrade", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_CRAFTING, new ModelResourceLocation("refinedstorage:crafting_upgrade", "inventory"));
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_STACK, new ModelResourceLocation("refinedstorage:stack_upgrade", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_STACK, new ModelResourceLocation("refinedstorage:stack_upgrade", "inventory"));
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_INTERDIMENSIONAL, new ModelResourceLocation("refinedstorage:interdimensional_upgrade", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_INTERDIMENSIONAL, new ModelResourceLocation("refinedstorage:interdimensional_upgrade", "inventory"));
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_SILK_TOUCH, new ModelResourceLocation("refinedstorage:silk_touch_upgrade", "inventory"));
// Blocks // Blocks
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory"));

View File

@@ -540,6 +540,7 @@ public class CommonProxy {
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE));
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SPEED)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SPEED));
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_CRAFTING)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
GameRegistry.addShapedRecipe(new ItemStack(RSItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK), GameRegistry.addShapedRecipe(new ItemStack(RSItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK),

View File

@@ -38,6 +38,7 @@ import refinedstorage.tile.data.ITileDataProducer;
import refinedstorage.tile.data.TileDataParameter; import refinedstorage.tile.data.TileDataParameter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public class TileDestructor extends TileMultipartNode implements IComparable, IFilterable, IType { public class TileDestructor extends TileMultipartNode implements IComparable, IFilterable, IType {
@@ -68,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); private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH);
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;
@@ -125,7 +126,18 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF
if (frontStack != null) { if (frontStack != null) {
if (IFilterable.canTake(itemFilters, mode, compare, frontStack)) { if (IFilterable.canTake(itemFilters, mode, compare, frontStack)) {
List<ItemStack> drops = frontBlockState.getBlock().getDrops(worldObj, front, frontBlockState, 0); List<ItemStack> drops;
if (!upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH)) {
drops = frontBlockState.getBlock().getDrops(worldObj, front, frontBlockState, 0);
} else {
drops = Collections.singletonList(frontStack);
}
for (ItemStack drop : drops) {
if (network.insertItem(drop, drop.stackSize, true) != null) {
return;
}
}
worldObj.playEvent(null, 2001, front, Block.getStateId(frontBlockState)); worldObj.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
worldObj.setBlockToAir(front); worldObj.setBlockToAir(front);
@@ -136,11 +148,7 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF
if (network == null) { if (network == null) {
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop); InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), drop);
} else { } else {
ItemStack remainder = network.insertItem(drop, drop.stackSize, false); network.insertItem(drop, drop.stackSize, false);
if (remainder != null) {
InventoryHelper.spawnItemStack(worldObj, front.getX(), front.getY(), front.getZ(), remainder);
}
} }
} }
} }

View File

@@ -212,6 +212,7 @@ item.refinedstorage:upgrade.2.name=Speed Upgrade
item.refinedstorage:upgrade.3.name=Crafting Upgrade 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: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

View File

@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "refinedstorage:items/silk_touch_upgrade" // Place Holder
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB