Added multiple router filters and made sure that they are able to work properly. Textures and localization completed. Added a recipe for a consumable "frame" - more of these gating materials to be added.

This commit is contained in:
WayofTime 2016-01-21 15:53:37 -05:00
parent 6c91865c5e
commit b8079bb509
19 changed files with 202 additions and 7 deletions

View file

@ -28,6 +28,7 @@ public class ItemComponent extends Item
public static final String REAGENT_SIGHT = "reagentSight";
public static final String REAGENT_BINDING = "reagentBinding";
public static final String REAGENT_SUPPRESSION = "reagentSuppression";
public static final String COMPONENT_FRAME_PART = "frameParts";
public ItemComponent()
{
@ -53,6 +54,7 @@ public class ItemComponent extends Item
names.add(7, REAGENT_SIGHT);
names.add(8, REAGENT_BINDING);
names.add(9, REAGENT_SUPPRESSION);
names.add(10, COMPONENT_FRAME_PART);
}
@Override

View file

@ -14,14 +14,18 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.item.inventory.ItemInventory;
import WayofTime.bloodmagic.routing.DefaultItemFilter;
import WayofTime.bloodmagic.routing.IItemFilter;
import WayofTime.bloodmagic.routing.IgnoreNBTItemFilter;
import WayofTime.bloodmagic.routing.ModIdItemFilter;
import WayofTime.bloodmagic.routing.OreDictItemFilter;
import WayofTime.bloodmagic.routing.TestItemFilter;
import WayofTime.bloodmagic.util.GhostItemHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemRouterFilter extends Item implements IItemFilterProvider
{
public static String[] names = { "exact" };
public static String[] names = { "exact", "ignoreNBT", "modItems", "oreDict" };
public ItemRouterFilter()
{
@ -60,6 +64,26 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider
public IItemFilter getInputItemFilter(ItemStack filterStack, IInventory inventory, EnumFacing syphonDirection)
{
IItemFilter testFilter = new TestItemFilter();
switch (filterStack.getMetadata())
{
case 0:
testFilter = new TestItemFilter();
break;
case 1:
testFilter = new IgnoreNBTItemFilter();
break;
case 2:
testFilter = new ModIdItemFilter();
break;
case 3:
testFilter = new OreDictItemFilter();
break;
default:
testFilter = new DefaultItemFilter();
}
List<ItemStack> filteredList = new ArrayList<ItemStack>();
ItemInventory inv = new ItemInventory(filterStack, 9, "");
for (int i = 0; i < inv.getSizeInventory(); i++)
@ -83,6 +107,26 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider
public IItemFilter getOutputItemFilter(ItemStack filterStack, IInventory inventory, EnumFacing syphonDirection)
{
IItemFilter testFilter = new TestItemFilter();
switch (filterStack.getMetadata())
{
case 0:
testFilter = new TestItemFilter();
break;
case 1:
testFilter = new IgnoreNBTItemFilter();
break;
case 2:
testFilter = new ModIdItemFilter();
break;
case 3:
testFilter = new OreDictItemFilter();
break;
default:
testFilter = new DefaultItemFilter();
}
List<ItemStack> filteredList = new ArrayList<ItemStack>();
ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later.
for (int i = 0; i < inv.getSizeInventory(); i++)

View file

@ -70,6 +70,12 @@ public class ModRecipes
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.ritualStone), "aba", "bcb", "aba", 'a', Blocks.obsidian, 'b', new ItemStack(ModItems.slate, 1, 1), 'c', OrbRegistry.getOrbStack(ModItems.orbApprentice)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.ritualController), "aba", "bcb", "aba", 'a', Blocks.obsidian, 'b', ModBlocks.ritualStone, 'c', OrbRegistry.getOrbStack(ModItems.orbMagician)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.ritualController, 1, 1), "aba", "bcb", "aba", 'a', Blocks.obsidian, 'b', "stone", 'c', OrbRegistry.getOrbStack(ModItems.orbWeak)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.baseItemFilter, 1, 0), "sgs", "gfg", "sgs", 'f', ItemComponent.getStack(ItemComponent.COMPONENT_FRAME_PART), 'g', new ItemStack(Blocks.glass), 's', Items.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.baseItemFilter, 1, 1), "sgs", "gfg", "sgs", 'f', ItemComponent.getStack(ItemComponent.COMPONENT_FRAME_PART), 'g', "dyeYellow", 's', Items.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.baseItemFilter, 1, 2), "sgs", "gfg", "sgs", 'f', ItemComponent.getStack(ItemComponent.COMPONENT_FRAME_PART), 'g', "dyeGreen", 's', Items.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.baseItemFilter, 1, 3), "sgs", "gfg", "sgs", 'f', ItemComponent.getStack(ItemComponent.COMPONENT_FRAME_PART), 'g', "dyePurple", 's', Items.stick));
}
public static void addAltarRecipes()
@ -168,7 +174,7 @@ public class ModRecipes
TartaricForgeRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_SUPPRESSION), 500, 50, ModBlocks.teleposer, Items.water_bucket, Items.lava_bucket, Items.blaze_rod);
TartaricForgeRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), 400, 10, "dustGlowstone", "dustRedstone", "nuggetGold", Items.gunpowder);
TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(ModItems.baseItemFilter), 400, 10, new ItemStack(Blocks.glass), new ItemStack(Blocks.cobblestone), new ItemStack(ModItems.slate), Items.stick);
TartaricForgeRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.COMPONENT_FRAME_PART), 400, 10, "blockGlass", "stone", new ItemStack(ModItems.slate));
TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(ModItems.nodeRouter), 400, 5, Items.stick, new ItemStack(ModItems.slate, 1, 1), "gemLapis", "gemLapis");
TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(ModBlocks.itemRoutingNode), 400, 5, "dustGlowstone", "dustRedstone", "blockGlass", "stone");
TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(ModBlocks.outputRoutingNode), 400, 25, "dustGlowstone", "dustRedstone", "ingotIron", new ItemStack(ModBlocks.itemRoutingNode));

View file

@ -37,6 +37,7 @@ public class DefaultItemFilter implements IItemFilter
* initialized as an output filter. If false, it should be
* initialized as an input filter.
*/
@Override
public void initializeFilter(List<ItemStack> filteredList, IInventory inventory, EnumFacing side, boolean isFilterOutput)
{
accessedInventory = inventory;
@ -53,6 +54,7 @@ public class DefaultItemFilter implements IItemFilter
* @return - The remainder of the stack after it has been absorbed into the
* inventory.
*/
@Override
public ItemStack transferStackThroughOutputFilter(ItemStack inputStack)
{
int allowedAmount = inputStack.stackSize; //This is done to make the migration to a maximum amount transfered a lot easier
@ -77,6 +79,7 @@ public class DefaultItemFilter implements IItemFilter
* This method is only called on an input filter to transfer ItemStacks from
* the input inventory to the output inventory.
*/
@Override
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer)
{
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];

View file

@ -0,0 +1,26 @@
package WayofTime.bloodmagic.routing;
import net.minecraft.item.ItemStack;
public class IgnoreNBTItemFilter extends TestItemFilter
{
@Override
public boolean doesStackMatchFilter(ItemStack testStack)
{
for (ItemStack filterStack : requestList)
{
if (doStacksMatch(filterStack, testStack))
{
return true;
}
}
return false;
}
@Override
public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack)
{
return filterStack != null && testStack != null && filterStack.getItem() == testStack.getItem() && filterStack.getMetadata() == testStack.getMetadata();
}
}

View file

@ -0,0 +1,28 @@
package WayofTime.bloodmagic.routing;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameData;
public class ModIdItemFilter extends TestItemFilter
{
@Override
public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack)
{
if (filterStack != null && testStack != null && filterStack.getItem() != null && testStack.getItem() != null)
{
String keyId = getModID(filterStack.getItem());
String checkedId = getModID(testStack.getItem());
return keyId.equals(checkedId);
}
return false;
}
public String getModID(Item itm)
{
ResourceLocation resource = GameData.getItemRegistry().getNameForObject(itm);
return resource.getResourceDomain();
}
}

View file

@ -0,0 +1,46 @@
package WayofTime.bloodmagic.routing;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class OreDictItemFilter extends TestItemFilter
{
@Override
public boolean doesStackMatchFilter(ItemStack testStack)
{
for (ItemStack filterStack : requestList)
{
if (doStacksMatch(filterStack, testStack))
{
return true;
}
}
return false;
}
@Override
public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack)
{
int[] filterIds = OreDictionary.getOreIDs(filterStack);
int[] testIds = OreDictionary.getOreIDs(testStack);
if (filterIds.length <= 0 || testIds.length <= 0)
{
return false;
}
for (int filterId : filterIds)
{
for (int testId : testIds)
{
if (filterId == testId)
{
return true;
}
}
}
return false;
}
}

View file

@ -25,9 +25,9 @@ public class TestItemFilter implements IItemFilter
* inserted in the inventory to finish its request. For the case of an input
* filter, it keeps track of how many can be removed.
*/
private List<ItemStack> requestList;
private IInventory accessedInventory;
private EnumFacing accessedSide;
protected List<ItemStack> requestList;
protected IInventory accessedInventory;
protected EnumFacing accessedSide;
/**
* Initializes the filter so that it knows what it wants to fulfill.
@ -45,6 +45,7 @@ public class TestItemFilter implements IItemFilter
* initialized as an output filter. If false, it should be
* initialized as an input filter.
*/
@Override
public void initializeFilter(List<ItemStack> filteredList, IInventory inventory, EnumFacing side, boolean isFilterOutput)
{
this.accessedInventory = inventory;
@ -166,6 +167,7 @@ public class TestItemFilter implements IItemFilter
* @return - The remainder of the stack after it has been absorbed into the
* inventory.
*/
@Override
public ItemStack transferStackThroughOutputFilter(ItemStack inputStack)
{
int allowedAmount = 0;
@ -212,6 +214,7 @@ public class TestItemFilter implements IItemFilter
* This method is only called on an input filter to transfer ItemStacks from
* the input inventory to the output inventory.
*/
@Override
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer)
{
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];
@ -290,6 +293,7 @@ public class TestItemFilter implements IItemFilter
}
}
@Override
public boolean doesStackMatchFilter(ItemStack testStack)
{
for (ItemStack filterStack : requestList)
@ -303,6 +307,7 @@ public class TestItemFilter implements IItemFilter
return false;
}
@Override
public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack)
{
return Utils.canCombine(filterStack, testStack);

View file

@ -124,7 +124,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti
List<IItemFilter> inputList = inputEntry.getValue();
for (IItemFilter inputFilter : inputList)
{
inputFilter.transferThroughInputFilter(outputFilter, 1);
inputFilter.transferThroughInputFilter(outputFilter, 8);
}
}
}

View file

@ -76,6 +76,7 @@ item.BloodMagic.baseComponent.reagentAffinity.name=Elemental Affinity Reagent
item.BloodMagic.baseComponent.reagentSight.name=Sight Reagent
item.BloodMagic.baseComponent.reagentBinding.name=Binding Reagent
item.BloodMagic.baseComponent.reagentSuppression.name=Suppression Reagent
item.BloodMagic.baseComponent.frameParts.name=Frame Parts
item.BloodMagic.monsterSoul.base.name=Demonic Will
@ -122,6 +123,9 @@ item.BloodMagic.sentientBow.name=Sentient Bow
item.BloodMagic.nodeRouter.name=Node Router
item.BloodMagic.itemFilter.exact.name=Precise Item Filter
item.BloodMagic.itemFilter.ignoreNBT.name=NBT Item Filter
item.BloodMagic.itemFilter.modItems.name=Mod Item Filter
item.BloodMagic.itemFilter.oreDict.name=Ore Dictionary Item Filter
# Blocks
tile.BloodMagic.fluid.lifeEssence.name=Life Essence
@ -262,7 +266,10 @@ tooltip.BloodMagic.soulGem.greater=A gem used to contain a greater amount of wil
tooltip.BloodMagic.soulGem.grand=A gem used to contain a large amount of will
tooltip.BloodMagic.soulSnare.desc=Throw at a monster and then kill them to obtain their demonic will
tooltip.BloodMagic.itemFilter.exact=Will make sure the items match precisely.
tooltip.BloodMagic.itemFilter.exact=Will make sure the items match precisely
tooltip.BloodMagic.itemFilter.ignoreNBT=Ignores the NBT of the filter
tooltip.BloodMagic.itemFilter.modItems=Matches all items from the same mod
tooltip.BloodMagic.itemFilter.oreDict=Used to filter through the Ore Dictionary
# Ritual
ritual.BloodMagic.testRitual=Test Ritual

View file

@ -0,0 +1,7 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/ComponentFrameParts"
}
}

View file

@ -0,0 +1,7 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/ItemRouterFilterIgnoreNBT"
}
}

View file

@ -0,0 +1,7 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/ItemRouterFilterModItems"
}
}

View file

@ -0,0 +1,7 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/ItemRouterFilterOreDict"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B