LOTS of alchemy changes...
This commit is contained in:
parent
64ccc50698
commit
2b749000b6
99 changed files with 7488 additions and 659 deletions
|
@ -5,24 +5,31 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
||||
public class RitualEffectCrushing extends RitualEffect
|
||||
{
|
||||
public static final int crystallosDrain = 10;
|
||||
public static final int orbisTerraeDrain = 10;
|
||||
public static final int potentiaDrain = 10;
|
||||
public static final int virtusDrain = 10;
|
||||
public static final int incendiumDrain = 10;
|
||||
|
||||
@Override
|
||||
public void performEffect(IMasterRitualStone ritualStone)
|
||||
{
|
||||
|
@ -39,12 +46,11 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
int currentEssence = data.currentEssence;
|
||||
World world = ritualStone.getWorld();
|
||||
|
||||
if (world.getWorldTime() % 40 != 20)
|
||||
if (world.getWorldTime() % 10 != 5)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int x = ritualStone.getXCoord();
|
||||
int y = ritualStone.getYCoord();
|
||||
int z = ritualStone.getZCoord();
|
||||
|
@ -64,19 +70,36 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
return;
|
||||
}
|
||||
|
||||
boolean isSilkTouch = this.isSilkTouch(world, x, y, z);
|
||||
int fortuneLevel = this.getFortuneLevel(world, x, y, z);
|
||||
boolean hasRoom = false;
|
||||
for(int i=0; i<tileEntity.getSizeInventory(); i++)
|
||||
{
|
||||
if(tileEntity.getStackInSlot(i) == null)
|
||||
{
|
||||
hasRoom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasRoom)
|
||||
{
|
||||
return; //Prevents overflow
|
||||
}
|
||||
|
||||
boolean hasCrystallos = this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, false);
|
||||
boolean hasOrbisTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, false);
|
||||
boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false);
|
||||
boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false);
|
||||
boolean hasIncendium = this.canDrainReagent(ritualStone, ReagentRegistry.incendiumReagent, incendiumDrain, false);
|
||||
|
||||
boolean isSilkTouch = hasCrystallos;
|
||||
int fortuneLevel = 0;
|
||||
if(hasOrbisTerrae){fortuneLevel++;}
|
||||
if(hasPotentia){fortuneLevel++;}
|
||||
if(hasVirtus){fortuneLevel++;}
|
||||
|
||||
if (currentEssence < this.getCostPerRefresh())
|
||||
{
|
||||
EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
SoulNetworkHandler.causeNauseaToPlayer(owner);
|
||||
} else
|
||||
{
|
||||
//boolean flag = false;
|
||||
|
@ -91,50 +114,19 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
|
||||
if (block != null && !world.isAirBlock(x + i, y + j, z + k))
|
||||
{
|
||||
if ((block.equals(ModBlocks.ritualStone) || block.equals(ModBlocks.blockMasterStone)))
|
||||
if ((block.equals(ModBlocks.ritualStone) || block.equals(ModBlocks.blockMasterStone)) || SpellHelper.isBlockFluid(block))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isSilkTouch && block.canSilkHarvest(world, null, x + i, y + j, z + k, meta))
|
||||
{
|
||||
int invSize = tileEntity.getSizeInventory();
|
||||
//int invSize = tileEntity.getSizeInventory();
|
||||
|
||||
ItemStack item = new ItemStack(block,1,meta);
|
||||
ItemStack copyStack = item.copyItemStack(item);
|
||||
|
||||
for (int n = 0; n < invSize; n++)
|
||||
{
|
||||
if (tileEntity.isItemValidForSlot(n, copyStack) && copyStack.stackSize != 0)
|
||||
{
|
||||
ItemStack itemStack = tileEntity.getStackInSlot(n);
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
tileEntity.setInventorySlotContents(n, item);
|
||||
copyStack.stackSize = 0;
|
||||
} else
|
||||
{
|
||||
if (itemStack.getItem().equals(copyStack.getItem()) && itemStack.getItemDamage() == copyStack.getItemDamage())
|
||||
{
|
||||
int itemSize = itemStack.stackSize;
|
||||
int copySize = copyStack.stackSize;
|
||||
int maxSize = itemStack.getMaxStackSize();
|
||||
|
||||
if (copySize + itemSize < maxSize)
|
||||
{
|
||||
copyStack.stackSize = 0;
|
||||
itemStack.stackSize = itemSize + copySize;
|
||||
tileEntity.setInventorySlotContents(n, itemStack);
|
||||
} else
|
||||
{
|
||||
copyStack.stackSize = itemSize + copySize - maxSize;
|
||||
itemStack.stackSize = maxSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpellHelper.insertStackIntoInventory(copyStack, tileEntity);
|
||||
|
||||
if (copyStack.stackSize > 0)
|
||||
{
|
||||
|
@ -142,6 +134,10 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
//flag=true;
|
||||
}
|
||||
|
||||
if(hasCrystallos)
|
||||
{
|
||||
this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -153,46 +149,59 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
|
||||
for (ItemStack item : itemDropList)
|
||||
{
|
||||
hasIncendium = hasIncendium && this.canDrainReagent(ritualStone, ReagentRegistry.incendiumReagent, incendiumDrain, false);
|
||||
ItemStack copyStack = item.copyItemStack(item);
|
||||
|
||||
for (int n = 0; n < invSize; n++)
|
||||
|
||||
if(this.usesIncendium(copyStack))
|
||||
{
|
||||
if (tileEntity.isItemValidForSlot(n, copyStack) && copyStack.stackSize != 0)
|
||||
{
|
||||
ItemStack itemStack = tileEntity.getStackInSlot(n);
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
tileEntity.setInventorySlotContents(n, item);
|
||||
copyStack.stackSize = 0;
|
||||
} else
|
||||
{
|
||||
if (itemStack.getItem().equals(copyStack.getItem()) && itemStack.getItemDamage() == copyStack.getItemDamage())
|
||||
{
|
||||
int itemSize = itemStack.stackSize;
|
||||
int copySize = copyStack.stackSize;
|
||||
int maxSize = itemStack.getMaxStackSize();
|
||||
|
||||
if (copySize + itemSize < maxSize)
|
||||
{
|
||||
copyStack.stackSize = 0;
|
||||
itemStack.stackSize = itemSize + copySize;
|
||||
tileEntity.setInventorySlotContents(n, itemStack);
|
||||
} else
|
||||
{
|
||||
copyStack.stackSize = itemSize + copySize - maxSize;
|
||||
itemStack.stackSize = maxSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
copyStack = this.transformToNewItem(copyStack, hasIncendium, false);
|
||||
this.canDrainReagent(ritualStone, ReagentRegistry.incendiumReagent, incendiumDrain, true);
|
||||
}
|
||||
|
||||
SpellHelper.insertStackIntoInventory(copyStack, tileEntity);
|
||||
|
||||
// for (int n = 0; n < invSize; n++)
|
||||
// {
|
||||
// if (tileEntity.isItemValidForSlot(n, copyStack) && copyStack.stackSize != 0)
|
||||
// {
|
||||
// ItemStack itemStack = tileEntity.getStackInSlot(n);
|
||||
//
|
||||
// if (itemStack == null)
|
||||
// {
|
||||
// tileEntity.setInventorySlotContents(n, item);
|
||||
// copyStack.stackSize = 0;
|
||||
// } else
|
||||
// {
|
||||
// if (itemStack.getItem().equals(copyStack.getItem()) && itemStack.getItemDamage() == copyStack.getItemDamage())
|
||||
// {
|
||||
// int itemSize = itemStack.stackSize;
|
||||
// int copySize = copyStack.stackSize;
|
||||
// int maxSize = itemStack.getMaxStackSize();
|
||||
//
|
||||
// if (copySize + itemSize < maxSize)
|
||||
// {
|
||||
// copyStack.stackSize = 0;
|
||||
// itemStack.stackSize = itemSize + copySize;
|
||||
// tileEntity.setInventorySlotContents(n, itemStack);
|
||||
// } else
|
||||
// {
|
||||
// copyStack.stackSize = itemSize + copySize - maxSize;
|
||||
// itemStack.stackSize = maxSize;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (copyStack.stackSize > 0)
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack));
|
||||
//flag=true;
|
||||
}
|
||||
|
||||
if(hasOrbisTerrae){this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true);}
|
||||
if(hasPotentia){this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true);}
|
||||
if(hasVirtus){this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true);}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,6 +212,9 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
world.playSoundEffect(x + i, y + j, z + k, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
data.currentEssence = currentEssence - this.getCostPerRefresh();
|
||||
data.markDirty();
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +223,56 @@ public class RitualEffectCrushing extends RitualEffect
|
|||
}
|
||||
}
|
||||
|
||||
private boolean usesIncendium(ItemStack stack)
|
||||
{
|
||||
if(stack != null)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if(item instanceof ItemBlock)
|
||||
{
|
||||
Block block = ((ItemBlock)item).field_150939_a;
|
||||
|
||||
if(block == Blocks.cobblestone || block == Blocks.stone)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ItemStack transformToNewItem(ItemStack stack, boolean hasIncendium, boolean hasCrepitous)
|
||||
{
|
||||
if(stack != null)
|
||||
{
|
||||
ItemStack copyStack = ItemStack.copyItemStack(stack);
|
||||
int stackSize = copyStack.stackSize;
|
||||
|
||||
Item item = stack.getItem();
|
||||
if(item instanceof ItemBlock)
|
||||
{
|
||||
Block block = ((ItemBlock)item).field_150939_a;
|
||||
|
||||
if(hasIncendium)
|
||||
{
|
||||
if(block == Blocks.cobblestone || block == Blocks.stone)
|
||||
{
|
||||
copyStack = new ItemStack(Blocks.netherrack, stackSize, 0);
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean isSilkTouch(World world, int x, int y, int z)
|
||||
{
|
||||
int index = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue