1.0.1d push

This commit is contained in:
WayofTime 2014-05-04 18:11:09 -04:00
parent e13818e2da
commit 1c0deadfc6
129 changed files with 4403 additions and 2247 deletions

View file

@ -1,11 +1,12 @@
package WayofTime.alchemicalWizardry.common.rituals;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import java.util.ArrayList;
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.ItemStack;
import net.minecraft.potion.Potion;
@ -13,13 +14,16 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.ArrayList;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
public class RitualEffectCrushing extends RitualEffect
{
@Override
public void performEffect(TEMasterStone ritualStone)
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
World worldSave = MinecraftServer.getServer().worldServers[0];
@ -32,16 +36,17 @@ public class RitualEffectCrushing extends RitualEffect
}
int currentEssence = data.currentEssence;
World world = ritualStone.getWorldObj();
World world = ritualStone.getWorld();
if (world.getWorldTime() % 40 != 0)
if (world.getWorldTime() % 40 != 20)
{
return;
}
int x = ritualStone.xCoord;
int y = ritualStone.yCoord;
int z = ritualStone.zCoord;
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
TileEntity tile = world.getTileEntity(x, y + 1, z);
IInventory tileEntity;
@ -58,6 +63,9 @@ public class RitualEffectCrushing extends RitualEffect
return;
}
boolean isSilkTouch = this.isSilkTouch(world, x, y, z);
int fortuneLevel = this.getFortuneLevel(world, x, y, z);
if (currentEssence < this.getCostPerRefresh())
{
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
@ -87,55 +95,106 @@ public class RitualEffectCrushing extends RitualEffect
continue;
}
ArrayList<ItemStack> itemDropList = block.getDrops(world, x + i, y + j, z + k, meta, 0);
if (itemDropList != null)
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 (ItemStack item : itemDropList)
for (int n = 0; n < invSize; n++)
{
ItemStack copyStack = item.copyItemStack(item);
for (int n = 0; n < invSize; n++)
if (tileEntity.isItemValidForSlot(n, copyStack) && copyStack.stackSize != 0)
{
if (tileEntity.isItemValidForSlot(n, copyStack) && copyStack.stackSize != 0)
ItemStack itemStack = tileEntity.getStackInSlot(n);
if (itemStack == null)
{
ItemStack itemStack = tileEntity.getStackInSlot(n);
tileEntity.setInventorySlotContents(n, item);
copyStack.stackSize = 0;
} else
{
if (itemStack.getItem().equals(copyStack.getItem()))
{
int itemSize = itemStack.stackSize;
int copySize = copyStack.stackSize;
int maxSize = itemStack.getMaxStackSize();
if (itemStack == null)
{
tileEntity.setInventorySlotContents(n, copyStack);
copyStack.stackSize = 0;
} else
{
if (itemStack.getItem().equals(copyStack.getItem()))
if (copySize + itemSize < maxSize)
{
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.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 (copyStack.stackSize > 0)
{
world.spawnEntityInWorld(new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack));
//flag=true;
}
}
else
{
ArrayList<ItemStack> itemDropList = block.getDrops(world, x + i, y + j, z + k, meta, fortuneLevel);
if (itemDropList != null)
{
int invSize = tileEntity.getSizeInventory();
for (ItemStack item : itemDropList)
{
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()))
{
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(flag)
@ -150,10 +209,92 @@ public class RitualEffectCrushing extends RitualEffect
}
}
}
public boolean isSilkTouch(World world, int x, int y, int z)
{
int index = 0;
for(int i=-2; i<=2; i++)
{
for(int j=-2; j<=2; j++)
{
int index1 = Math.abs(i);
int index2 = Math.abs(j);
if((index1 == 2 && (index2 == 2 || index2 == 1)) || (index1 == 1 && index2 == 2))
{
Block block = world.getBlock(x + i, y + 1, z + j);
if(block == Blocks.gold_block)
{
index++;
}
}
}
}
return index>=12;
}
public int getFortuneLevel(World world, int x, int y, int z)
{
int index = 0;
for(int i=-2; i<=2; i++)
{
for(int j=-2; j<=2; j++)
{
int index1 = Math.abs(i);
int index2 = Math.abs(j);
if((index1 == 2 && (index2 == 2 || index2 == 1)) || (index1 == 1 && index2 == 2))
{
Block block = world.getBlock(x + i, y + 1, z + j);
if(block == Blocks.emerald_block)
{
index++;
}
}
}
}
if(index>=12)
{
return 3;
}else if(index>=8)
{
return 2;
}else if(index>=4)
{
return 1;
}
return 0;
}
@Override
public int getCostPerRefresh()
{
return 7;
}
@Override
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> crushingRitual = new ArrayList();
crushingRitual.add(new RitualComponent(0, 0, 1, RitualComponent.EARTH));
crushingRitual.add(new RitualComponent(1, 0, 0, RitualComponent.EARTH));
crushingRitual.add(new RitualComponent(0, 0, -1, RitualComponent.EARTH));
crushingRitual.add(new RitualComponent(-1, 0, 0, RitualComponent.EARTH));
crushingRitual.add(new RitualComponent(2, 0, 0, RitualComponent.FIRE));
crushingRitual.add(new RitualComponent(0, 0, 2, RitualComponent.FIRE));
crushingRitual.add(new RitualComponent(-2, 0, 0, RitualComponent.FIRE));
crushingRitual.add(new RitualComponent(0, 0, -2, RitualComponent.FIRE));
crushingRitual.add(new RitualComponent(2, 0, 2, RitualComponent.DUSK));
crushingRitual.add(new RitualComponent(2, 0, -2, RitualComponent.DUSK));
crushingRitual.add(new RitualComponent(-2, 0, 2, RitualComponent.DUSK));
crushingRitual.add(new RitualComponent(-2, 0, -2, RitualComponent.DUSK));
crushingRitual.add(new RitualComponent(2, 1, 0, RitualComponent.AIR));
crushingRitual.add(new RitualComponent(-2, 1, 0, RitualComponent.AIR));
crushingRitual.add(new RitualComponent(0, 1, 2, RitualComponent.AIR));
crushingRitual.add(new RitualComponent(0, 1, -2, RitualComponent.AIR));
return crushingRitual;
}
}