Almost finished Ritual for item routing
This commit is contained in:
parent
539bb564fa
commit
3b590fab6c
|
@ -287,7 +287,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod(modid = "AWWayofTime", name = "AlchemicalWizardry", version = "v1.3.0b", guiFactory = "WayofTime.alchemicalWizardry.client.gui.ConfigGuiFactory")
|
||||
@Mod(modid = "AWWayofTime", name = "AlchemicalWizardry", version = "v1.3.1", guiFactory = "WayofTime.alchemicalWizardry.client.gui.ConfigGuiFactory")
|
||||
|
||||
public class AlchemicalWizardry
|
||||
{
|
||||
|
@ -712,6 +712,7 @@ public class AlchemicalWizardry
|
|||
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(ModItems.itemBloodLightSigil), "btb", "sss", "bob", 'o', magicianBloodOrbStack, 'b', glowstoneBlockStack, 't', new ItemStack(Blocks.torch), 's', imbuedSlateStack));
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.itemKeyOfDiablo), " gw", "gdg", "wg ", 'w', weakBloodShardStack, 'g', goldIngotStack, 'd', diamondStack);
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.itemBloodPack), "gbg","flf","gsg",'s', blankSlateStack,'g', glassStack,'f',new ItemStack(Items.flint,1,craftingConstant),'b', emptyBucketStack, 'l', new ItemStack(Items.leather_chestplate));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.itemMailCatalogue), new ItemStack(Items.book), new ItemStack(Items.dye, 1, 0), new ItemStack(Items.feather), glassStack, glassStack);
|
||||
customPotionDrowning = (new PotionDrowning(customPotionDrowningID, true, 0)).setIconIndex(0, 0).setPotionName("Drowning");
|
||||
customPotionBoost = (new PotionBoost(customPotionBoostID, false, 0)).setIconIndex(0, 0).setPotionName("Boost");
|
||||
customPotionProjProt = (new PotionProjectileProtect(customPotionProjProtID, false, 0)).setIconIndex(0, 0).setPotionName("Whirlwind");
|
||||
|
|
|
@ -4,8 +4,13 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
public class RoutingFocusLogic
|
||||
{
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) : false);
|
||||
}
|
||||
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return previous || (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) : false);
|
||||
return previous || this.getDefaultMatch(keyStack, checkedStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack;
|
|||
public class RoutingFocusLogicIgnMeta extends RoutingFocusLogic
|
||||
{
|
||||
@Override
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return previous || (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() : false);
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() : false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,14 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
public class RoutingFocusLogicMatchNBT extends RoutingFocusLogic
|
||||
{
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) && keyStack.areItemStackTagsEqual(keyStack, checkedStack) : false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return previous && (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) && keyStack.areItemStackTagsEqual(keyStack, checkedStack) : false);
|
||||
return previous && this.getDefaultMatch(keyStack, checkedStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,15 @@ import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
|||
public class RoutingFocusLogicModItems extends RoutingFocusLogic
|
||||
{
|
||||
@Override
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
if(keyStack != null && checkedStack != null)
|
||||
{
|
||||
UniqueIdentifier keyId = GameRegistry.findUniqueIdentifierFor(keyStack.getItem());
|
||||
UniqueIdentifier checkedId = GameRegistry.findUniqueIdentifierFor(checkedStack.getItem());
|
||||
return previous && keyId.modId.equals(checkedId.modId);
|
||||
return keyId.modId.equals(checkedId.modId);
|
||||
}
|
||||
|
||||
return previous;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,16 @@ public class RoutingFocusParadigm
|
|||
public boolean doesItemMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
boolean isGood = false;
|
||||
boolean isFirst = true;
|
||||
for(RoutingFocusLogic logic : logicList)
|
||||
{
|
||||
if(isFirst)
|
||||
{
|
||||
isGood = logic.getDefaultMatch(keyStack, checkedStack);
|
||||
isFirst = false;
|
||||
continue;
|
||||
}
|
||||
isGood = logic.doesItemMatch(isGood, keyStack, checkedStack);
|
||||
if(isGood){return true;}
|
||||
}
|
||||
|
||||
return isGood;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.routing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
|
||||
|
@ -52,11 +56,28 @@ public class OutputRoutingFocus extends RoutingFocus
|
|||
case 1:
|
||||
addedString = "modItem";
|
||||
break;
|
||||
case 2:
|
||||
addedString = "ignMeta";
|
||||
break;
|
||||
case 3:
|
||||
addedString = "matchNBT";
|
||||
break;
|
||||
}
|
||||
|
||||
return super.getUnlocalizedName() + "." + addedString;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < 4; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoutingFocusLogic getLogic(int damage)
|
||||
{
|
||||
switch(damage)
|
||||
|
|
|
@ -6,13 +6,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.Int3;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusPosAndFacing;
|
||||
|
||||
public class RoutingFocus extends Item
|
||||
|
@ -152,4 +153,35 @@ public class RoutingFocus extends Item
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public RoutingFocusLogic getLogic(int damage)
|
||||
{
|
||||
return new RoutingFocusLogic();
|
||||
}
|
||||
|
||||
public int getDefaultStackLimit(int damage)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getStackLimitAmount(ItemStack itemStack)
|
||||
{
|
||||
if (!(itemStack.getTagCompound() == null))
|
||||
{
|
||||
return itemStack.getTagCompound().getInteger("stackLimit");
|
||||
} else
|
||||
{
|
||||
return getDefaultStackLimit(itemStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setStackLimitAmount(ItemStack itemStack, int amt)
|
||||
{
|
||||
if ((itemStack.getTagCompound() == null))
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setInteger("stackLimit", amt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,16 +47,16 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
int yBufOffset = 1;
|
||||
int zBufOffset = 0;
|
||||
|
||||
TileEntity bufferTile = world.getTileEntity(x + xBufOffset, y + yBufOffset, z + zBufOffset);
|
||||
|
||||
if(!(bufferTile instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TileEntity bufferTile = world.getTileEntity(x + xBufOffset, y + yBufOffset, z + zBufOffset);
|
||||
//
|
||||
// if(!(bufferTile instanceof IInventory))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
Map<Int3, IInventory> tileMap = new HashMap();
|
||||
|
||||
IInventory bufferInventory = (IInventory)bufferTile;
|
||||
// IInventory bufferInventory = (IInventory)bufferTile;
|
||||
|
||||
List<IInventory> outputList = new ArrayList();
|
||||
for(int i=0; i<4; i++) //Check output foci chests, return if none available
|
||||
|
@ -112,7 +112,7 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
if(canSyphonList[ni])
|
||||
{
|
||||
ItemStack syphonedStack = inputChestInventory.getStackInSlot(ni); //Has a syphoned item linked, next need to find a destination
|
||||
if(syphonedStack == null)
|
||||
if(syphonedStack == null || (inputChestInventory instanceof ISidedInventory && !((ISidedInventory)inputChestInventory).canExtractItem(ni, syphonedStack, syphonDirection.ordinal())))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -121,39 +121,27 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
|
||||
for(IInventory outputFocusInventory : outputList)
|
||||
{
|
||||
ItemStack stack = outputFocusInventory.getStackInSlot(0);
|
||||
if(stack != null && stack.getItem() instanceof OutputRoutingFocus) //TODO change to output routing focus
|
||||
//ItemStack stack = outputFocusInventory.getStackInSlot(0);
|
||||
//if(stack != null && stack.getItem() instanceof OutputRoutingFocus) //TODO change to output routing focus
|
||||
{
|
||||
boolean transferEverything = true;
|
||||
for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
|
||||
{
|
||||
if(outputFocusInventory.getStackInSlot(j) != null)
|
||||
{
|
||||
transferEverything = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// boolean transferEverything = true;
|
||||
// for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
|
||||
// {
|
||||
// if(outputFocusInventory.getStackInSlot(j) != null)
|
||||
// {
|
||||
// transferEverything = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
OutputRoutingFocus outputFocus = (OutputRoutingFocus)stack.getItem();
|
||||
OutputRoutingFocus outputFocus;;
|
||||
|
||||
RoutingFocusParadigm parad = new RoutingFocusParadigm();
|
||||
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(stack));
|
||||
parad.addLogic(outputFocus.getLogic(stack.getItemDamage()));
|
||||
// parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(stack));
|
||||
// parad.addLogic(outputFocus.getLogic(stack.getItemDamage()));
|
||||
|
||||
Int3 outputChestPos = new Int3(outputFocus.xCoord(stack), outputFocus.yCoord(stack), outputFocus.zCoord(stack));
|
||||
TileEntity outputChest; //Destination
|
||||
if(tileMap.containsKey(outputChestPos))
|
||||
{
|
||||
outputChest = (TileEntity) tileMap.get(outputChestPos);
|
||||
}else
|
||||
{
|
||||
outputChest = world.getTileEntity(outputFocus.xCoord(stack), outputFocus.yCoord(stack), outputFocus.zCoord(stack));
|
||||
if(outputChest instanceof IInventory)
|
||||
{
|
||||
tileMap.put(outputChestPos, (IInventory)outputChest);
|
||||
}
|
||||
}
|
||||
ForgeDirection inputDirection = outputFocus.getSetDirection(stack);
|
||||
TileEntity outputChest = null; //Destination
|
||||
ForgeDirection inputDirection;;
|
||||
|
||||
// if(transferEverything)
|
||||
// {
|
||||
|
@ -184,16 +172,16 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
// }
|
||||
// }else
|
||||
{
|
||||
if(!(outputChest instanceof IInventory))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// if(!(outputChest instanceof IInventory))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
IInventory outputChestInventory = (IInventory)outputChest;
|
||||
IInventory outputChestInventory = null;
|
||||
|
||||
boolean lastItemWasFocus = true;
|
||||
|
||||
for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
|
||||
for(int j=0; j<outputFocusInventory.getSizeInventory(); j++)
|
||||
{
|
||||
ItemStack keyStack = outputFocusInventory.getStackInSlot(j);
|
||||
if(keyStack == null)
|
||||
|
@ -227,20 +215,9 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
}
|
||||
inputDirection = posAndFacing.facing;
|
||||
if(outputChest == null || !posAndFacing.location.equals(new Int3(outputChest.xCoord, outputChest.yCoord, outputChest.zCoord)))
|
||||
{
|
||||
outputChestPos = new Int3(outputChest.xCoord, outputChest.yCoord, outputChest.zCoord);
|
||||
if(tileMap.containsKey(outputChestPos))
|
||||
{
|
||||
outputChest = (TileEntity) tileMap.get(outputChestPos);
|
||||
}else
|
||||
{
|
||||
outputChest = world.getTileEntity(posAndFacing.location.xCoord, posAndFacing.location.yCoord, posAndFacing.location.zCoord);
|
||||
if(outputChest instanceof IInventory)
|
||||
{
|
||||
tileMap.put(outputChestPos, (IInventory)outputChest);
|
||||
}
|
||||
}
|
||||
if(outputChest instanceof IInventory)
|
||||
{
|
||||
outputChestInventory = (IInventory)outputChest;
|
||||
}else
|
||||
|
@ -486,4 +463,6 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
|
||||
return omegaRitual;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -519,7 +519,7 @@ public class SpellHelper
|
|||
int[] array = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(dir.ordinal());
|
||||
for(int in : array)
|
||||
{
|
||||
canBeInserted[in] = true;
|
||||
canBeInserted[in] = ((ISidedInventory)inventory).canInsertItem(in, stack, dir.ordinal());
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
|
|
@ -202,6 +202,11 @@ item.itemCompressionSigil.name=Sigil of Compression
|
|||
item.itemAssassinSigil.name=Sigil of the Assassin
|
||||
item.transcendentBloodOrb.name=Transcendent Blood Orb
|
||||
item.itemMailCatalogue.name=Mail Order Catalogue
|
||||
item.inputRoutingFocus.name=Input Routing Focus
|
||||
item.outputRoutingFocus.default.name=Default Output Routing Focus
|
||||
item.outputRoutingFocus.modItem.name=Output Routing Focus (ModItem)
|
||||
item.outputRoutingFocus.ignMeta.name=Output Routing Focus (Ignore Meta)
|
||||
item.outputRoutingFocus.matchNBT.name=Output Routing Focus (MatchNBT)
|
||||
|
||||
#Creative Tab
|
||||
itemGroup.tabBloodMagic=Blood Magic
|
||||
|
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
Loading…
Reference in a new issue