Finishing the darn Phantom Hands ritual
This commit is contained in:
parent
f87da36775
commit
dc7d9ebc06
45 changed files with 662 additions and 270 deletions
|
@ -35,6 +35,11 @@ public class CommonProxy
|
|||
{
|
||||
// Nothing here as the server doesn't render graphics!
|
||||
}
|
||||
|
||||
public void registerPostSideObjects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerEntities()
|
||||
{
|
||||
|
|
|
@ -17,6 +17,8 @@ import WayofTime.alchemicalWizardry.book.entries.EntryText;
|
|||
import WayofTime.alchemicalWizardry.book.entries.IEntry;
|
||||
import WayofTime.alchemicalWizardry.book.enums.EnumType;
|
||||
import WayofTime.alchemicalWizardry.book.registries.EntryRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BUEntries
|
||||
{
|
||||
|
@ -47,6 +49,7 @@ public class BUEntries
|
|||
EntryRegistry.registerCategories(BUEntries.categoryTest);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void initEntries()
|
||||
{
|
||||
HashMap<Integer, IEntry> aIntroMap = new HashMap();
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
|
||||
public class ItemComponents extends Item
|
||||
{
|
||||
private static final String[] ITEM_NAMES = new String[]{"QuartzRod", "EmptyCore", "MagicalesCable", "WoodBrace", "StoneBrace", "ProjectileCore", "SelfCore", "MeleeCore", "ParadigmBackPlate", "OutputCable", "FlameCore", "IcyCore", "GustCore", "EarthenCore", "InputCable", "CrackedRunicPlate", "RunicPlate", "ScribedRunicPlate", "DefaultCore", "OffensiveCore", "DefensiveCore", "EnvironmentalCore", "PowerCore", "CostCore", "PotencyCore", "ObsidianBrace", "ToolCore", "EtherealSlate", "LifeShard", "SoulShard", "SoulRunicPlate", "LifeBrace"};
|
||||
private static final String[] ITEM_NAMES = new String[]{"QuartzRod", "EmptyCore", "MagicalesCable", "WoodBrace", "StoneBrace", "ProjectileCore", "SelfCore", "MeleeCore", "ParadigmBackPlate", "OutputCable", "FlameCore", "IcyCore", "GustCore", "EarthenCore", "InputCable", "CrackedRunicPlate", "RunicPlate", "ScribedRunicPlate", "DefaultCore", "OffensiveCore", "DefensiveCore", "EnvironmentalCore", "PowerCore", "CostCore", "PotencyCore", "ObsidianBrace", "ToolCore", "EtherealSlate", "LifeShard", "SoulShard", "SoulRunicPlate", "LifeBrace", "EnderShard"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.routing;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ILimitedRoutingFocus
|
||||
{
|
||||
public int getRoutingFocusLimit(ItemStack stack);
|
||||
|
||||
public void setRoutingFocusLimit(ItemStack stack, int limit);
|
||||
}
|
|
@ -4,30 +4,54 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicIgnMeta;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicMatchNBT;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicModItems;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitDefault;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitIgnMeta;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitMatchNBT;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogicLimitModItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class OutputRoutingFocus extends RoutingFocus
|
||||
public class OutputRoutingFocus extends RoutingFocus implements ILimitedRoutingFocus
|
||||
{
|
||||
IIcon modItemIcon;
|
||||
IIcon ignMetaIcon;
|
||||
IIcon matchNBTIcon;
|
||||
|
||||
public OutputRoutingFocus()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
|
||||
|
||||
if (!(par1ItemStack.getTagCompound() == null))
|
||||
{
|
||||
int limit = this.getRoutingFocusLimit(par1ItemStack);
|
||||
if(limit > 0)
|
||||
{
|
||||
par3List.add(StatCollector.translateToLocal("tooltip.routingFocus.limit") + " " + limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocus");
|
||||
this.modItemIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusModItems");
|
||||
this.ignMetaIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusIgnMeta");
|
||||
this.matchNBTIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusMatchNBT");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -39,6 +63,10 @@ public class OutputRoutingFocus extends RoutingFocus
|
|||
return this.itemIcon;
|
||||
case 1:
|
||||
return this.modItemIcon;
|
||||
case 2:
|
||||
return this.ignMetaIcon;
|
||||
case 3:
|
||||
return this.matchNBTIcon;
|
||||
}
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
@ -78,19 +106,49 @@ public class OutputRoutingFocus extends RoutingFocus
|
|||
}
|
||||
|
||||
@Override
|
||||
public RoutingFocusLogic getLogic(int damage)
|
||||
public RoutingFocusLogic getLogic(ItemStack itemStack)
|
||||
{
|
||||
switch(damage)
|
||||
if(itemStack != null)
|
||||
{
|
||||
case 0:
|
||||
return new RoutingFocusLogic();
|
||||
case 1:
|
||||
return new RoutingFocusLogicModItems();
|
||||
case 2:
|
||||
return new RoutingFocusLogicIgnMeta();
|
||||
case 3:
|
||||
return new RoutingFocusLogicMatchNBT();
|
||||
switch(itemStack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
return new RoutingFocusLogicLimitDefault(itemStack);
|
||||
case 1:
|
||||
return new RoutingFocusLogicLimitModItems(itemStack);
|
||||
case 2:
|
||||
return new RoutingFocusLogicLimitIgnMeta(itemStack);
|
||||
case 3:
|
||||
return new RoutingFocusLogicLimitMatchNBT(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return new RoutingFocusLogic();
|
||||
}
|
||||
}
|
||||
|
||||
public int getDefaultStackLimit(int damage)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getRoutingFocusLimit(ItemStack itemStack)
|
||||
{
|
||||
if (!(itemStack.getTagCompound() == null))
|
||||
{
|
||||
return itemStack.getTagCompound().getInteger("stackLimit");
|
||||
} else
|
||||
{
|
||||
return getDefaultStackLimit(itemStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setRoutingFocusLimit(ItemStack itemStack, int amt)
|
||||
{
|
||||
if ((itemStack.getTagCompound() == null))
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setInteger("stackLimit", amt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -15,6 +16,7 @@ import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|||
import WayofTime.alchemicalWizardry.api.Int3;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusLogic;
|
||||
import WayofTime.alchemicalWizardry.api.RoutingFocusPosAndFacing;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
||||
public class RoutingFocus extends Item
|
||||
{
|
||||
|
@ -30,25 +32,25 @@ public class RoutingFocus extends Item
|
|||
return new RoutingFocusPosAndFacing(new Int3(this.xCoord(itemStack), this.yCoord(itemStack), this.zCoord(itemStack)), this.getSetDirection(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
this.cycleDirection(itemStack);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public void cycleDirection(ItemStack itemStack)
|
||||
{
|
||||
ForgeDirection dir = this.getSetDirection(itemStack);
|
||||
int direction = dir.ordinal();
|
||||
direction++;
|
||||
if(direction >= ForgeDirection.VALID_DIRECTIONS.length)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
this.setSetDirection(itemStack, ForgeDirection.getOrientation(direction));
|
||||
}
|
||||
// @Override
|
||||
// public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
|
||||
// {
|
||||
// this.cycleDirection(itemStack);
|
||||
// return itemStack;
|
||||
// }
|
||||
//
|
||||
// public void cycleDirection(ItemStack itemStack)
|
||||
// {
|
||||
// ForgeDirection dir = this.getSetDirection(itemStack);
|
||||
// int direction = dir.ordinal();
|
||||
// direction++;
|
||||
// if(direction >= ForgeDirection.VALID_DIRECTIONS.length)
|
||||
// {
|
||||
// direction = 0;
|
||||
// }
|
||||
//
|
||||
// this.setSetDirection(itemStack, ForgeDirection.getOrientation(direction));
|
||||
// }
|
||||
|
||||
public ForgeDirection getSetDirection(ItemStack itemStack)
|
||||
{
|
||||
|
@ -77,7 +79,7 @@ public class RoutingFocus extends Item
|
|||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add(this.getFocusDescription());
|
||||
par3List.add(StatCollector.translateToLocal(this.getFocusDescription()));
|
||||
|
||||
if (!(par1ItemStack.getTagCompound() == null))
|
||||
{
|
||||
|
@ -96,15 +98,35 @@ public class RoutingFocus extends Item
|
|||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
if(player.isSneaking())
|
||||
{
|
||||
if(this instanceof ILimitedRoutingFocus)
|
||||
{
|
||||
int pastAmount = ((ILimitedRoutingFocus)this).getRoutingFocusLimit(stack);
|
||||
int amount = SpellHelper.getNumberOfItemsInInventory((IInventory)tile, ForgeDirection.getOrientation(side));
|
||||
if(amount != pastAmount)
|
||||
{
|
||||
((ILimitedRoutingFocus)this).setRoutingFocusLimit(stack, amount);
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.routerfocus.limit") + amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setCoordinates(stack, x, y, z);
|
||||
this.setSetDirection(stack, ForgeDirection.getOrientation(side));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCoordinates(ItemStack itemStack, int x, int y, int z)
|
||||
|
@ -154,34 +176,8 @@ public class RoutingFocus extends Item
|
|||
}
|
||||
}
|
||||
|
||||
public RoutingFocusLogic getLogic(int damage)
|
||||
public RoutingFocusLogic getLogic(ItemStack itemStack)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
outputFocus = (OutputRoutingFocus)keyStack.getItem();
|
||||
|
||||
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(keyStack));
|
||||
parad.addLogic(outputFocus.getLogic(keyStack.getItemDamage()));
|
||||
parad.addLogic(outputFocus.getLogic(keyStack));
|
||||
lastItemWasFocus = true;
|
||||
continue;
|
||||
}else
|
||||
|
@ -228,7 +228,14 @@ public class RitualEffectItemRouting extends RitualEffect
|
|||
|
||||
if(parad.doesItemMatch(keyStack, syphonedStack))
|
||||
{
|
||||
ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
|
||||
ItemStack newStack = null;
|
||||
if(parad.maximumAmount <= 0)
|
||||
{
|
||||
newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection);
|
||||
}else
|
||||
{
|
||||
newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection, parad.maximumAmount);
|
||||
}
|
||||
if(size == newStack.stackSize)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -479,6 +479,37 @@ public class SpellHelper
|
|||
return stack1.getItem() == stack2.getItem() && tagsEqual && stack1.getItemDamage() == stack2.getItemDamage() && Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack1 Stack that is placed into a slot
|
||||
* @param stack2 Slot content that stack1 is placed into
|
||||
* @return Stacks after stacking
|
||||
*/
|
||||
public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2, int transferMax)
|
||||
{
|
||||
ItemStack[] returned = new ItemStack[2];
|
||||
|
||||
if (canCombine(stack1, stack2))
|
||||
{
|
||||
int transferedAmount = Math.min(transferMax, stack2 == null ? stack1.stackSize : Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize));
|
||||
if (transferedAmount > 0)
|
||||
{
|
||||
ItemStack copyStack = stack1.splitStack(transferedAmount);
|
||||
if (stack2 == null)
|
||||
{
|
||||
stack2 = copyStack;
|
||||
} else
|
||||
{
|
||||
stack2.stackSize += transferedAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returned[0] = stack1;
|
||||
returned[1] = stack2;
|
||||
|
||||
return returned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack1 Stack that is placed into a slot
|
||||
* @param stack2 Slot content that stack1 is placed into
|
||||
|
@ -553,6 +584,115 @@ public class SpellHelper
|
|||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, ForgeDirection dir, int limit)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
|
||||
|
||||
if(inventory instanceof ISidedInventory)
|
||||
{
|
||||
int[] array = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(dir.ordinal());
|
||||
for(int in : array)
|
||||
{
|
||||
canBeInserted[in] = ((ISidedInventory)inventory).canInsertItem(in, stack, dir.ordinal());
|
||||
}
|
||||
}else
|
||||
{
|
||||
for(int i=0; i<canBeInserted.length; i++)
|
||||
{
|
||||
canBeInserted[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int numberMatching = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
if(!canBeInserted[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack invStack = inventory.getStackInSlot(i);
|
||||
|
||||
if(invStack != null && canCombine(stack, invStack))
|
||||
{
|
||||
numberMatching += invStack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if(numberMatching >= limit)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
int newLimit = limit - numberMatching;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
if(!canBeInserted[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int prevStackSize = stack.stackSize;
|
||||
|
||||
ItemStack[] combinedStacks = combineStacks(stack, inventory.getStackInSlot(i), newLimit);
|
||||
stack = combinedStacks[0];
|
||||
inventory.setInventorySlotContents(i, combinedStacks[1]);
|
||||
|
||||
newLimit -= (prevStackSize - stack.stackSize);
|
||||
|
||||
if (newLimit <= 0 || stack.stackSize <= 0)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static int getNumberOfItemsInInventory(IInventory inventory, ForgeDirection dir)
|
||||
{
|
||||
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
|
||||
|
||||
if(inventory instanceof ISidedInventory)
|
||||
{
|
||||
int[] array = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(dir.ordinal());
|
||||
for(int in : array)
|
||||
{
|
||||
canBeInserted[in] = true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
for(int i=0; i<canBeInserted.length; i++)
|
||||
{
|
||||
canBeInserted[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int amountOfItems = 0;
|
||||
|
||||
for(int i=0; i<canBeInserted.length; i++)
|
||||
{
|
||||
if(canBeInserted[i])
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
amountOfItems += stack.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return amountOfItems;
|
||||
}
|
||||
|
||||
public static boolean hydrateSoil(World world, int x, int y, int z)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue