Removed needing a buffer chest for the new item routing ritual - working on a few odd quirks, however.

This commit is contained in:
WayofTime 2015-01-30 18:53:52 -05:00
parent 2888fcfe07
commit 539bb564fa
12 changed files with 437 additions and 188 deletions

View file

@ -1508,8 +1508,8 @@ public class AlchemicalWizardry
String strLine;
//Read File Line By Line
int maxWidth = 25;
int maxLines = 16;
int defMaxLines = 16;
int maxLines = defMaxLines;
int currentPage = 0;
@ -1545,6 +1545,31 @@ public class AlchemicalWizardry
String title = strLine.replaceFirst("//TITLE ", " ").trim();
currentTitle = "aw.entry." + title;
continue;
}else if(strLine.startsWith("//SPECIAL "))
{
if(strings[currentPage].isEmpty())
{
String lines = strLine.replaceFirst("//SPECIAL ", "");
Integer ln = Integer.decode(lines);
if(ln != null)
{
maxLines = ln;
}
}else
{
String[] newStrings = new String[currentPage + 1 + 1]; //Just to show that it is increasing
for(int i=0; i<strings.length; i++)
{
newStrings[i] = strings[i];
}
currentPage++;
newStrings[currentPage - 1] = currentTitle + "." + pageIndex + "=" + newStrings[currentPage - 1];
newStrings[currentPage] = "";
strings = newStrings;
}
continue;
}
@ -1568,12 +1593,6 @@ public class AlchemicalWizardry
word = word.replace('\t', ' ');
List list = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strings[currentPage] + " " + word, 110);
// if(currentWidth != 0 && currentWidth + length + 1 > maxWidth)
// {
// currentLine++;
// currentWidth = 0;
// }
//if(currentLine > maxLines)
if(list.size() > maxLines)
{
changePage = true;
@ -1593,7 +1612,9 @@ public class AlchemicalWizardry
strings = newStrings;
pageIndex++;
maxLines = defMaxLines;
changePage = false;
}else
{

View file

@ -35,4 +35,10 @@ public class Int3
{
return o instanceof Int3 ? ((Int3) o).xCoord == this.xCoord && ((Int3) o).yCoord == this.yCoord && ((Int3) o).zCoord == this.zCoord : false;
}
@Override
public int hashCode()
{
return this.xCoord + this.yCoord << 8 + this.zCoord << 16;
}
}

View file

@ -11,6 +11,8 @@ public class RoutingFocusParadigm
public List<RoutingFocusPosAndFacing> locationList = new LinkedList();
public int maximumAmount = 0;
public void addRoutingFocusPosAndFacing(RoutingFocusPosAndFacing facing)
{
locationList.add(facing);
@ -38,4 +40,14 @@ public class RoutingFocusParadigm
logicList.clear();
locationList.clear();
}
public void setMaximumAmount(int amt)
{
this.maximumAmount = amt;
}
public int getMaximumAmount()
{
return this.maximumAmount;
}
}

View file

@ -1,6 +1,7 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;

View file

@ -49,7 +49,7 @@ public class EntryImage implements IEntry{
if(this.entryName == null)
this.entryName = key;
String s = StatCollector.translateToLocal("bu.entry." + this.entryName + "." + page);
String s = StatCollector.translateToLocal("aw.entry." + this.entryName + "." + page);
x = left + width / 2 - 58;
y = (top + 15) + 65;

View file

@ -685,8 +685,18 @@ public class AlchemicalWizardryEventHooks
}
@Optional.Method(modid = "Botania")
private boolean isManaBurst(Entity projectile)
private boolean isManaBurst(Entity entity)
{
return projectile instanceof IManaBurst;
if(entity instanceof IManaBurst) {
ItemStack lens = ((IManaBurst)entity).getSourceLens();
if(lens.getItemDamage()!=8 && lens.getItemDamage()!=11)
return false;
else
return true;
}
else
return false;
}
}

View file

@ -1,5 +1,8 @@
package WayofTime.alchemicalWizardry.common.book;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import WayofTime.alchemicalWizardry.ModBlocks;
@ -41,9 +44,10 @@ public class BUEntries
public void initEntries()
{
HashMap<Integer, IEntry> aIntroMap = new HashMap();
aIntroMap.put(0, new EntryImage("bloodutils:textures/misc/screenshots/t1.png", 854, 480));
/* The Architect */
aIntro = this.getPureTextEntry(5, "Your classic tragic backstory", 1);
aIntro = this.getMixedTextEntry(6, "Your classic tragic backstory", 1, aIntroMap);
aBloodAltar = this.getPureTextEntry(3, "The Blood Altar", 1);
aSoulNetwork = this.getPureTextEntry(3, "The Soul Network", 1);
aBasicsOfSigils = this.getPureTextEntry(4, "Basics of sigils and a glimpse into the soul", 1);
@ -142,6 +146,25 @@ public class BUEntries
return new Entry(entries, name, pageNumber);
}
public Entry getMixedTextEntry(int numberOfPages, String name, int pageNumber, Map<Integer, IEntry> map)
{
IEntry[] entries = new IEntry[numberOfPages];
for(int i=0; i<numberOfPages; i++)
{
entries[i] = new EntryText();
}
for(Map.Entry<Integer, IEntry> ent : map.entrySet())
{
if(ent.getKey() < entries.length)
{
entries[ent.getKey()] = ent.getValue();
}
}
return new Entry(entries, name, pageNumber);
}
/* Architect */
public static Entry aIntro;
public static Entry aBloodAltar;
@ -310,4 +333,4 @@ public class BUEntries
/** Debug */
EntryRegistry.registerEntry(BUEntries.categoryBasics, EntryRegistry.basics, BUEntries.debug);
}
}
}

View file

@ -1,7 +1,9 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.inventory.IInventory;
@ -51,26 +53,44 @@ public class RitualEffectItemRouting extends RitualEffect
{
return;
}
Map<Int3, IInventory> tileMap = new HashMap();
IInventory bufferInventory = (IInventory)bufferTile;
List<IInventory> outputList = new ArrayList();
for(int i=0; i<4; i++) //Check output foci chests, return if none available
{
Int3 outputFocusChest = this.getOutputBufferChestLocation(i);
TileEntity outputFocusInv = world.getTileEntity(x + outputFocusChest.xCoord, y + outputFocusChest.yCoord, z + outputFocusChest.zCoord);
if(outputFocusInv instanceof IInventory)
{
outputList.add((IInventory)outputFocusInv);
}
}
if(outputList.isEmpty())
{
return;
}
for(int i=0; i<4; i++)
{
Int3 inputFocusChest = this.getInputBufferChestLocation(i);
TileEntity inputFocusInv = world.getTileEntity(x + inputFocusChest.xCoord, y + inputFocusChest.yCoord, z + inputFocusChest.zCoord);
if(inputFocusInv instanceof IInventory)
{
for(int j=0; j<((IInventory) inputFocusInv).getSizeInventory(); j++)
for(int ji=0; ji<((IInventory) inputFocusInv).getSizeInventory(); ji++) //Iterate through foci inventory
{
ItemStack stack = ((IInventory) inputFocusInv).getStackInSlot(j);
if(stack != null && stack.getItem() instanceof InputRoutingFocus)
ItemStack inputFocusStack = ((IInventory) inputFocusInv).getStackInSlot(ji);
if(inputFocusStack != null && inputFocusStack.getItem() instanceof InputRoutingFocus)
{
InputRoutingFocus inputFocus = (InputRoutingFocus)stack.getItem();
TileEntity inputChest = world.getTileEntity(inputFocus.xCoord(stack), inputFocus.yCoord(stack), inputFocus.zCoord(stack));
InputRoutingFocus inputFocus = (InputRoutingFocus)inputFocusStack.getItem();
TileEntity inputChest = world.getTileEntity(inputFocus.xCoord(inputFocusStack), inputFocus.yCoord(inputFocusStack), inputFocus.zCoord(inputFocusStack));
if(inputChest instanceof IInventory)
{
IInventory inputChestInventory = (IInventory)inputChest;
ForgeDirection syphonDirection = inputFocus.getSetDirection(stack);
ForgeDirection syphonDirection = inputFocus.getSetDirection(inputFocusStack);
boolean[] canSyphonList = new boolean[inputChestInventory.getSizeInventory()];
if(inputChest instanceof ISidedInventory)
{
@ -81,33 +101,187 @@ public class RitualEffectItemRouting extends RitualEffect
}
}else
{
for(int n=0; n<inputChestInventory.getSizeInventory(); n++)
for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++)
{
canSyphonList[n] = true;
canSyphonList[ni] = true;
}
}
for(int n=0; n<inputChestInventory.getSizeInventory(); n++)
for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++)
{
if(canSyphonList[n])
if(canSyphonList[ni])
{
ItemStack syphonedStack = inputChestInventory.getStackInSlot(n);
ItemStack syphonedStack = inputChestInventory.getStackInSlot(ni); //Has a syphoned item linked, next need to find a destination
if(syphonedStack == null)
{
continue;
}
int size = syphonedStack.stackSize;
ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, bufferInventory, ForgeDirection.DOWN);
if(size == newStack.stackSize)
{
continue;
}
if(newStack != null && newStack.stackSize <= 0)
for(IInventory outputFocusInventory : outputList)
{
newStack = null;
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;
}
}
OutputRoutingFocus outputFocus = (OutputRoutingFocus)stack.getItem();
RoutingFocusParadigm parad = new RoutingFocusParadigm();
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);
// if(transferEverything)
// {
// if(outputChest instanceof IInventory)
// {
// IInventory outputChestInventory = (IInventory)outputChest;
//
// for(int n=0; n<bufferInventory.getSizeInventory(); n++)
// {
// ItemStack syphonedStack = bufferInventory.getStackInSlot(n);
// if(syphonedStack == null)
// {
// continue;
// }
// int size = syphonedStack.stackSize;
// ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
// if(size == newStack.stackSize)
// {
// continue;
// }
// if(newStack != null && newStack.stackSize <= 0)
// {
// newStack = null;
// }
// bufferInventory.setInventorySlotContents(n, newStack);
//// break;
// }
// }
// }else
{
if(!(outputChest instanceof IInventory))
{
continue;
}
IInventory outputChestInventory = (IInventory)outputChest;
boolean lastItemWasFocus = true;
for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
{
ItemStack keyStack = outputFocusInventory.getStackInSlot(j);
if(keyStack == null)
{
continue;
}
if(keyStack.getItem() instanceof OutputRoutingFocus)
{
if(!lastItemWasFocus)
{
parad.clear();
}
outputFocus = (OutputRoutingFocus)keyStack.getItem();
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(keyStack));
parad.addLogic(outputFocus.getLogic(keyStack.getItemDamage()));
lastItemWasFocus = true;
continue;
}else
{
lastItemWasFocus = false;
}
for(RoutingFocusPosAndFacing posAndFacing : parad.locationList)
{
if(posAndFacing == null)
{
continue;
}
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
{
continue;
}
}
if(parad.doesItemMatch(keyStack, syphonedStack))
{
ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
if(size == newStack.stackSize)
{
continue;
}
if(newStack != null && newStack.stackSize <= 0)
{
size = newStack.stackSize;
newStack = null;
}
inputChestInventory.setInventorySlotContents(ni, newStack);
// break;
}
}
}
}
}
}
inputChestInventory.setInventorySlotContents(n, newStack);
// ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, bufferInventory, ForgeDirection.DOWN);
// if(size == newStack.stackSize)
// {
// continue;
// }
// if(newStack != null && newStack.stackSize <= 0)
// {
// newStack = null;
// }
// inputChestInventory.setInventorySlotContents(n, newStack);
// break;
}
}
@ -117,148 +291,148 @@ public class RitualEffectItemRouting extends RitualEffect
}
}
for(int i=0; i<4; i++)
{
Int3 outputFocusChest = this.getOutputBufferChestLocation(i);
TileEntity outputFocusInv = world.getTileEntity(x + outputFocusChest.xCoord, y + outputFocusChest.yCoord, z + outputFocusChest.zCoord);
if(outputFocusInv instanceof IInventory)
{
IInventory outputFocusInventory = (IInventory)outputFocusInv;
ItemStack stack = ((IInventory) outputFocusInv).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;
}
}
OutputRoutingFocus outputFocus = (OutputRoutingFocus)stack.getItem();
RoutingFocusParadigm parad = new RoutingFocusParadigm();
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(stack));
parad.addLogic(outputFocus.getLogic(stack.getItemDamage()));
TileEntity outputChest = world.getTileEntity(outputFocus.xCoord(stack), outputFocus.yCoord(stack), outputFocus.zCoord(stack)); //Destination
ForgeDirection inputDirection = outputFocus.getSetDirection(stack);
if(transferEverything)
{
if(outputChest instanceof IInventory)
{
IInventory outputChestInventory = (IInventory)outputChest;
for(int n=0; n<bufferInventory.getSizeInventory(); n++)
{
ItemStack syphonedStack = bufferInventory.getStackInSlot(n);
if(syphonedStack == null)
{
continue;
}
int size = syphonedStack.stackSize;
ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
if(size == newStack.stackSize)
{
continue;
}
if(newStack != null && newStack.stackSize <= 0)
{
newStack = null;
}
bufferInventory.setInventorySlotContents(n, newStack);
// break;
}
}
}else
{
if(!(outputChest instanceof IInventory))
{
continue;
}
IInventory outputChestInventory = (IInventory)outputChest;
boolean lastItemWasFocus = true;
for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
{
ItemStack keyStack = outputFocusInventory.getStackInSlot(j);
if(keyStack == null)
{
continue;
}
if(keyStack.getItem() instanceof OutputRoutingFocus)
{
if(!lastItemWasFocus)
{
parad.clear();
}
outputFocus = (OutputRoutingFocus)keyStack.getItem();
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(keyStack));
parad.addLogic(outputFocus.getLogic(keyStack.getItemDamage()));
lastItemWasFocus = true;
continue;
}else
{
lastItemWasFocus = false;
}
for(RoutingFocusPosAndFacing posAndFacing : parad.locationList)
{
if(posAndFacing == null)
{
continue;
}
inputDirection = posAndFacing.facing;
if(outputChest == null || !posAndFacing.location.equals(new Int3(outputChest.xCoord, outputChest.yCoord, outputChest.zCoord)))
{
outputChest = world.getTileEntity(posAndFacing.location.xCoord, posAndFacing.location.yCoord, posAndFacing.location.zCoord);
if(outputChest instanceof IInventory)
{
outputChestInventory = (IInventory)outputChest;
}else
{
continue;
}
}
for(int n=0; n<bufferInventory.getSizeInventory(); n++)
{
ItemStack checkStack = bufferInventory.getStackInSlot(n);
if(checkStack == null)
{
continue;
}
if(parad.doesItemMatch(keyStack, checkStack))
{
int size = checkStack.stackSize;
ItemStack newStack = SpellHelper.insertStackIntoInventory(checkStack, outputChestInventory, inputDirection);
if(size == newStack.stackSize)
{
continue;
}
if(newStack != null && newStack.stackSize <= 0)
{
newStack = null;
}
bufferInventory.setInventorySlotContents(n, newStack);
// break;
}
}
}
}
}
}
}
}
// for(int i=0; i<4; i++)
// {
// Int3 outputFocusChest = this.getOutputBufferChestLocation(i);
// TileEntity outputFocusInv = world.getTileEntity(x + outputFocusChest.xCoord, y + outputFocusChest.yCoord, z + outputFocusChest.zCoord);
// if(outputFocusInv instanceof IInventory)
// {
// IInventory outputFocusInventory = (IInventory)outputFocusInv;
// 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;
// }
// }
//
// OutputRoutingFocus outputFocus = (OutputRoutingFocus)stack.getItem();
//
// RoutingFocusParadigm parad = new RoutingFocusParadigm();
// parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(stack));
// parad.addLogic(outputFocus.getLogic(stack.getItemDamage()));
//
// TileEntity outputChest = world.getTileEntity(outputFocus.xCoord(stack), outputFocus.yCoord(stack), outputFocus.zCoord(stack)); //Destination
// ForgeDirection inputDirection = outputFocus.getSetDirection(stack);
//
// if(transferEverything)
// {
// if(outputChest instanceof IInventory)
// {
// IInventory outputChestInventory = (IInventory)outputChest;
//
// for(int n=0; n<bufferInventory.getSizeInventory(); n++)
// {
// ItemStack syphonedStack = bufferInventory.getStackInSlot(n);
// if(syphonedStack == null)
// {
// continue;
// }
// int size = syphonedStack.stackSize;
// ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
// if(size == newStack.stackSize)
// {
// continue;
// }
// if(newStack != null && newStack.stackSize <= 0)
// {
// newStack = null;
// }
// bufferInventory.setInventorySlotContents(n, newStack);
//// break;
// }
// }
// }else
// {
// if(!(outputChest instanceof IInventory))
// {
// continue;
// }
//
// IInventory outputChestInventory = (IInventory)outputChest;
//
// boolean lastItemWasFocus = true;
//
// for(int j=1; j<outputFocusInventory.getSizeInventory(); j++)
// {
// ItemStack keyStack = outputFocusInventory.getStackInSlot(j);
// if(keyStack == null)
// {
// continue;
// }
//
// if(keyStack.getItem() instanceof OutputRoutingFocus)
// {
// if(!lastItemWasFocus)
// {
// parad.clear();
// }
//
// outputFocus = (OutputRoutingFocus)keyStack.getItem();
//
// parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(keyStack));
// parad.addLogic(outputFocus.getLogic(keyStack.getItemDamage()));
// lastItemWasFocus = true;
// continue;
// }else
// {
// lastItemWasFocus = false;
// }
//
// for(RoutingFocusPosAndFacing posAndFacing : parad.locationList)
// {
// if(posAndFacing == null)
// {
// continue;
// }
// inputDirection = posAndFacing.facing;
// if(outputChest == null || !posAndFacing.location.equals(new Int3(outputChest.xCoord, outputChest.yCoord, outputChest.zCoord)))
// {
// outputChest = world.getTileEntity(posAndFacing.location.xCoord, posAndFacing.location.yCoord, posAndFacing.location.zCoord);
// if(outputChest instanceof IInventory)
// {
// outputChestInventory = (IInventory)outputChest;
// }else
// {
// continue;
// }
// }
//
// for(int n=0; n<bufferInventory.getSizeInventory(); n++)
// {
// ItemStack checkStack = bufferInventory.getStackInSlot(n);
// if(checkStack == null)
// {
// continue;
// }
//
// if(parad.doesItemMatch(keyStack, checkStack))
// {
// int size = checkStack.stackSize;
// ItemStack newStack = SpellHelper.insertStackIntoInventory(checkStack, outputChestInventory, inputDirection);
// if(size == newStack.stackSize)
// {
// continue;
// }
// if(newStack != null && newStack.stackSize <= 0)
// {
// newStack = null;
// }
// bufferInventory.setInventorySlotContents(n, newStack);
//// break;
// }
// }
// }
// }
// }
// }
// }
// }
}
public Int3 getInputBufferChestLocation(int number)