Added Sacrificial Knife event

This commit is contained in:
WayofTime 2015-02-23 18:45:32 -05:00
parent df776f0323
commit 086027faf5
8 changed files with 169 additions and 329 deletions

View file

@ -1,5 +1,5 @@
# #
#Fri Feb 20 07:40:39 EST 2015 #Mon Feb 23 18:21:38 EST 2015
mod_name=BloodMagic mod_name=BloodMagic
forge_version=10.13.2.1232 forge_version=10.13.2.1232
ccc_version=1.0.4.29 ccc_version=1.0.4.29
@ -9,4 +9,4 @@ package_group=com.wayoftime.bloodmagic
mod_version=1.3.1Beta1 mod_version=1.3.1Beta1
minetweaker_version=Dev-1.7.10-3.0.9B minetweaker_version=Dev-1.7.10-3.0.9B
mc_version=1.7.10 mc_version=1.7.10
build_number=7 build_number=9

View file

@ -0,0 +1,22 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
@Cancelable
public class SacrificeKnifeUsedEvent extends Event
{
public final EntityPlayer player;
public boolean shouldDrainHealth;
public boolean shouldFillAltar;
public final int healthDrained;
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp)
{
this.player = player;
this.shouldDrainHealth = shouldDrainHealth;
this.shouldFillAltar = shouldFillAltar;
this.healthDrained = hp;
}
}

View file

@ -171,7 +171,7 @@ public class UpgradedAltars
public static AltarUpgradeComponent getUpgrades(World world, int x, int y, int z, int altarTier) public static AltarUpgradeComponent getUpgrades(World world, int x, int y, int z, int altarTier)
{ {
if(!world.isRemote) if(world.isRemote)
{ {
return null; return null;
} }

View file

@ -1,10 +1,7 @@
package WayofTime.alchemicalWizardry.common.items; package WayofTime.alchemicalWizardry.common.items;
import WayofTime.alchemicalWizardry.AlchemicalWizardry; import java.util.List;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -13,9 +10,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import java.util.List; import WayofTime.alchemicalWizardry.api.event.SacrificeKnifeUsedEvent;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SacrificialDagger extends Item public class SacrificialDagger extends Item
{ {
@ -56,7 +58,21 @@ public class SacrificialDagger extends Item
{ {
if (!par3EntityPlayer.capabilities.isCreativeMode) if (!par3EntityPlayer.capabilities.isCreativeMode)
{ {
par3EntityPlayer.setHealth(par3EntityPlayer.getHealth() - 2); SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(par3EntityPlayer, true, true, 2);
if(MinecraftForge.EVENT_BUS.post(evt))
{
return par1ItemStack;
}
if(evt.shouldDrainHealth)
{
par3EntityPlayer.setHealth(par3EntityPlayer.getHealth() - 2);
}
if(!evt.shouldFillAltar)
{
return par1ItemStack;
}
} }
if (par3EntityPlayer instanceof FakePlayer) if (par3EntityPlayer instanceof FakePlayer)

View file

@ -92,7 +92,7 @@ public class RoutingFocus extends Item
public String getFocusDescription() public String getFocusDescription()
{ {
return "An Enderpearl imbued with blood"; return "tooltip.routingFocus.desc";
} }
@Override @Override

View file

@ -74,157 +74,110 @@ public class RitualEffectItemRouting extends RitualEffect
return; return;
} }
for(int i=0; i<4; i++) for(IInventory outputFocusInventory : outputList)
{ {
Int3 inputFocusChest = this.getInputBufferChestLocation(i); {
TileEntity inputFocusInv = world.getTileEntity(x + inputFocusChest.xCoord, y + inputFocusChest.yCoord, z + inputFocusChest.zCoord); OutputRoutingFocus outputFocus;;
if(inputFocusInv instanceof IInventory)
{ RoutingFocusParadigm parad = new RoutingFocusParadigm();
for(int ji=0; ji<((IInventory) inputFocusInv).getSizeInventory(); ji++) //Iterate through foci inventory
{ TileEntity outputChest = null; //Destination
ItemStack inputFocusStack = ((IInventory) inputFocusInv).getStackInSlot(ji); ForgeDirection inputDirection;;
if(inputFocusStack != null && inputFocusStack.getItem() instanceof InputRoutingFocus)
{ {
InputRoutingFocus inputFocus = (InputRoutingFocus)inputFocusStack.getItem(); IInventory outputChestInventory = null;
TileEntity inputChest = world.getTileEntity(inputFocus.xCoord(inputFocusStack), inputFocus.yCoord(inputFocusStack), inputFocus.zCoord(inputFocusStack));
if(inputChest instanceof IInventory) boolean lastItemWasFocus = true;
{
IInventory inputChestInventory = (IInventory)inputChest; for(int j=0; j<outputFocusInventory.getSizeInventory(); j++)
ForgeDirection syphonDirection = inputFocus.getSetDirection(inputFocusStack); {
boolean[] canSyphonList = new boolean[inputChestInventory.getSizeInventory()]; ItemStack keyStack = outputFocusInventory.getStackInSlot(j);
if(inputChest instanceof ISidedInventory) if(keyStack == null)
{ {
int[] validSlots = ((ISidedInventory) inputChest).getAccessibleSlotsFromSide(syphonDirection.ordinal()); continue;
for(int in : validSlots) }
{
canSyphonList[in] = true; if(keyStack.getItem() instanceof OutputRoutingFocus)
} {
}else if(!lastItemWasFocus)
{ {
for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++) parad.clear();
{ }
canSyphonList[ni] = true;
} outputFocus = (OutputRoutingFocus)keyStack.getItem();
}
parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(keyStack));
for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++) parad.addLogic(outputFocus.getLogic(keyStack));
{ lastItemWasFocus = true;
if(canSyphonList[ni]) continue;
{ }else
ItemStack syphonedStack = inputChestInventory.getStackInSlot(ni); //Has a syphoned item linked, next need to find a destination {
if(syphonedStack == null || (inputChestInventory instanceof ISidedInventory && !((ISidedInventory)inputChestInventory).canExtractItem(ni, syphonedStack, syphonDirection.ordinal()))) lastItemWasFocus = false;
{ }
continue;
} for(RoutingFocusPosAndFacing posAndFacing : parad.locationList)
{
int size = syphonedStack.stackSize; if(posAndFacing == null)
{
for(IInventory outputFocusInventory : outputList) continue;
{ }
//ItemStack stack = outputFocusInventory.getStackInSlot(0); inputDirection = posAndFacing.facing;
//if(stack != null && stack.getItem() instanceof OutputRoutingFocus) //TODO change to output routing focus if(outputChest == null || !posAndFacing.location.equals(new Int3(outputChest.xCoord, outputChest.yCoord, outputChest.zCoord)))
{ {
// boolean transferEverything = true; outputChest = world.getTileEntity(posAndFacing.location.xCoord, posAndFacing.location.yCoord, posAndFacing.location.zCoord);
// for(int j=1; j<outputFocusInventory.getSizeInventory(); j++) if(outputChest instanceof IInventory)
// { {
// if(outputFocusInventory.getStackInSlot(j) != null) outputChestInventory = (IInventory)outputChest;
// { }else
// transferEverything = false; {
// break; continue;
// } }
// } }
OutputRoutingFocus outputFocus;; for(int i=0; i<4; i++)
{
RoutingFocusParadigm parad = new RoutingFocusParadigm(); Int3 inputFocusChest = this.getInputBufferChestLocation(i);
// parad.addRoutingFocusPosAndFacing(outputFocus.getPosAndFacing(stack)); TileEntity inputFocusInv = world.getTileEntity(x + inputFocusChest.xCoord, y + inputFocusChest.yCoord, z + inputFocusChest.zCoord);
// parad.addLogic(outputFocus.getLogic(stack.getItemDamage())); if(inputFocusInv instanceof IInventory)
{
TileEntity outputChest = null; //Destination for(int ji=0; ji<((IInventory) inputFocusInv).getSizeInventory(); ji++) //Iterate through foci inventory
ForgeDirection inputDirection;; {
ItemStack inputFocusStack = ((IInventory) inputFocusInv).getStackInSlot(ji);
// if(transferEverything) if(inputFocusStack != null && inputFocusStack.getItem() instanceof InputRoutingFocus)
// { {
// if(outputChest instanceof IInventory) InputRoutingFocus inputFocus = (InputRoutingFocus)inputFocusStack.getItem();
// { TileEntity inputChest = world.getTileEntity(inputFocus.xCoord(inputFocusStack), inputFocus.yCoord(inputFocusStack), inputFocus.zCoord(inputFocusStack));
// IInventory outputChestInventory = (IInventory)outputChest; if(inputChest instanceof IInventory)
// {
// for(int n=0; n<bufferInventory.getSizeInventory(); n++) IInventory inputChestInventory = (IInventory)inputChest;
// { ForgeDirection syphonDirection = inputFocus.getSetDirection(inputFocusStack);
// ItemStack syphonedStack = bufferInventory.getStackInSlot(n); boolean[] canSyphonList = new boolean[inputChestInventory.getSizeInventory()];
// if(syphonedStack == null) if(inputChest instanceof ISidedInventory)
// { {
// continue; int[] validSlots = ((ISidedInventory) inputChest).getAccessibleSlotsFromSide(syphonDirection.ordinal());
// } for(int in : validSlots)
// int size = syphonedStack.stackSize; {
// ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, outputChestInventory, inputDirection); canSyphonList[in] = true;
// if(size == newStack.stackSize) }
// { }else
// continue; {
// } for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++)
// if(newStack != null && newStack.stackSize <= 0) {
// { canSyphonList[ni] = true;
// newStack = null; }
// } }
// bufferInventory.setInventorySlotContents(n, newStack);
//// break; for(int ni=0; ni<inputChestInventory.getSizeInventory(); ni++)
// } {
// } if(canSyphonList[ni])
// }else {
{ ItemStack syphonedStack = inputChestInventory.getStackInSlot(ni); //Has a syphoned item linked, next need to find a destination
// if(!(outputChest instanceof IInventory)) if(syphonedStack == null || (inputChestInventory instanceof ISidedInventory && !((ISidedInventory)inputChestInventory).canExtractItem(ni, syphonedStack, syphonDirection.ordinal())))
// { {
// continue; continue;
// } }
IInventory outputChestInventory = null; int size = syphonedStack.stackSize;
boolean lastItemWasFocus = true;
for(int j=0; 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));
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;
}
}
if(parad.doesItemMatch(keyStack, syphonedStack)) if(parad.doesItemMatch(keyStack, syphonedStack))
{ {
@ -241,6 +194,8 @@ public class RitualEffectItemRouting extends RitualEffect
continue; continue;
} }
int numberSyphoned = size - newStack.stackSize;
if(newStack != null && newStack.stackSize <= 0) if(newStack != null && newStack.stackSize <= 0)
{ {
size = newStack.stackSize; size = newStack.stackSize;
@ -253,20 +208,7 @@ public class RitualEffectItemRouting extends RitualEffect
} }
} }
} }
} }
// 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;
} }
} }
} }
@ -274,149 +216,6 @@ 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 = 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) public Int3 getInputBufferChestLocation(int number)
@ -440,13 +239,13 @@ public class RitualEffectItemRouting extends RitualEffect
switch(number) switch(number)
{ {
case 0: case 0:
return new Int3(2, 0, 0); return new Int3(2, 0, 2);
case 1: case 1:
return new Int3(-2, 0, 0); return new Int3(-2, 0, 2);
case 2: case 2:
return new Int3(0, 0, 2); return new Int3(2, 0, -2);
case 3: case 3:
return new Int3(0, 0, -2); return new Int3(-2, 0, -2);
} }
return new Int3(0, 0, 0); return new Int3(0, 0, 0);
} }

View file

@ -36,6 +36,8 @@ import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.AltarUpgradeCompone
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars; import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import com.ibm.icu.text.MessageFormat;
public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFluidHandler, IBloodAltar public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFluidHandler, IBloodAltar
{ {
public static final int sizeInv = 1; public static final int sizeInv = 1;
@ -1057,9 +1059,9 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
public void sendChatInfoToPlayer(EntityPlayer player) public void sendChatInfoToPlayer(EntityPlayer player)
{ {
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.currentessence") + " " + this.fluid.amount + "LP")); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.currentessence"), this.fluid.amount)));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.currenttier") + " " + UpgradedAltars.isAltarValid(worldObj, xCoord, yCoord, zCoord))); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.currenttier"), UpgradedAltars.isAltarValid(worldObj, xCoord, yCoord, zCoord))));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.capacity") + " " + this.getCapacity() + "LP")); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.capacity"), this.getCapacity())));
} }
public void sendMoreChatInfoToPlayer(EntityPlayer player) public void sendMoreChatInfoToPlayer(EntityPlayer player)
@ -1070,8 +1072,8 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.progress") + " " + progress + "LP/" + liquidRequired * stackSize + "LP")); player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.progress") + " " + progress + "LP/" + liquidRequired * stackSize + "LP"));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.consumptionrate") + " " + (int) (consumptionRate * (1 + consumptionMultiplier)) + "LP/t")); player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.consumptionrate") + " " + (int) (consumptionRate * (1 + consumptionMultiplier)) + "LP/t"));
} }
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.currentessence") + " " + this.fluid.amount + "LP")); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.currentessence"), this.fluid.amount)));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.inputtank") + " " + this.fluidInput.amount + "LP")); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.inputtank"), this.fluidInput.amount)));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.altar.outputtank") + " " + this.fluidOutput.amount + "LP")); player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.altar.outputtank"), this.fluidOutput.amount)));
} }
} }

View file

@ -379,6 +379,7 @@ tooltip.telepositionfocus.desc=An Enderpearl imbued with blood
tooltip.voidsigil.desc=Better than a Swiffer! tooltip.voidsigil.desc=Better than a Swiffer!
tooltip.watersigil.desc=Infinite water, anyone? tooltip.watersigil.desc=Infinite water, anyone?
tooltip.routingFocus.limit=Limit: tooltip.routingFocus.limit=Limit:
tooltip.routingFocus.desc=A focus used to route items
#Messages #Messages
message.altar.capacity=Capacity: %s LP message.altar.capacity=Capacity: %s LP