Joshie comment!

This commit is contained in:
WayofTime 2014-06-02 15:16:36 -04:00
parent 1c0deadfc6
commit ac943e9d38
753 changed files with 8715 additions and 1184 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
public class TEConduit extends TESpellBlock
{
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
}
//Logic for the actual block is under here
@Override
public void updateEntity()
{
}
@Override
protected void applySpellChange(SpellParadigm parad)
{
return;
}
}

View file

@ -0,0 +1,167 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpell;
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpellRegistry;
public class TEHomHeart extends TileEntity
{
public boolean canCastSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return true;
}
public int castSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
HomSpell spell = getSpell();
if (spell != null)
{
switch (getModifiedParadigm())
{
case 0:
spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 1:
spell.onOffensiveMeleeRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 2:
spell.onDefensiveRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 3:
spell.onEnvironmentalRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
}
//spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer);
}
return 0;
}
public HomSpell getSpell()
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
return null;
}
public int getModifiedParadigm()
{
//TODO change so that it works with a Tile Entity for a custom head or whatnot
Block block = worldObj.getBlock(xCoord, yCoord + 1, zCoord);
if (block == Blocks.glowstone)
{
return 0;
} else if (block == Blocks.redstone_block)
{
return 1;
} else if (block == Blocks.anvil)
{
return 2;
} else if (block == Blocks.glass)
{
return 3;
}
TileEntity tileEntity = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
if (tileEntity instanceof TileEntitySkull)
{
int skullType = ((TileEntitySkull) tileEntity).func_145904_a();
switch (skullType)
{
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 4:
return 3;
}
}
return -1;
}
}

View file

@ -0,0 +1,11 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.tileentity.TileEntity;
public class TEImperfectRitualStone extends TileEntity
{
public TEImperfectRitualStone()
{
// TODO Auto-generated constructor stub
}
}

View file

@ -0,0 +1,235 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class TEMasterStone extends TileEntity implements IMasterRitualStone
{
//private int currentRitual;
private String currentRitualString;
private boolean isActive;
private String owner;
private String varString1;
private int cooldown;
private int var1;
private int direction;
public TEMasterStone()
{
//currentRitual = 0;
isActive = false;
owner = "";
cooldown = 0;
var1 = 0;
direction = 0;
varString1 = "";
currentRitualString = "";
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
//currentRitual = par1NBTTagCompound.getInteger("currentRitual");
isActive = par1NBTTagCompound.getBoolean("isActive");
owner = par1NBTTagCompound.getString("owner");
cooldown = par1NBTTagCompound.getInteger("cooldown");
var1 = par1NBTTagCompound.getInteger("var1");
direction = par1NBTTagCompound.getInteger("direction");
currentRitualString = par1NBTTagCompound.getString("currentRitualString");
// varString1 = par1NBTTagCompound.getString("varString1");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
//par1NBTTagCompound.setInteger("currentRitual", currentRitual);
par1NBTTagCompound.setBoolean("isActive", isActive);
par1NBTTagCompound.setString("owner", owner);
par1NBTTagCompound.setInteger("cooldown", cooldown);
par1NBTTagCompound.setInteger("var1", var1);
par1NBTTagCompound.setInteger("direction", direction);
par1NBTTagCompound.setString("currentRitualString", currentRitualString);
// par1NBTTagCompound.setString("varString1", varString1);
}
public void activateRitual(World world, int crystalLevel, EntityPlayer player)
{
if (world.isRemote)
{
return;
}
String testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord);
if (testRitual.equals(""))
{
player.addChatMessage(new ChatComponentText("Nothing appears to have happened..."));
return;
}
boolean testLevel = Rituals.canCrystalActivate(testRitual, crystalLevel);
if (!testLevel)
{
player.addChatMessage(new ChatComponentText("Your crystal vibrates pathetically."));
return;
}
World worldSave = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) worldSave.loadItemData(LifeEssenceNetwork.class, owner);
if (data == null)
{
data = new LifeEssenceNetwork(owner);
worldSave.setItemData(owner, data);
}
int currentEssence = data.currentEssence;
if (currentEssence < Rituals.getCostForActivation(testRitual))
{
player.addChatMessage(new ChatComponentText("You feel a pull, but you are too weak to push any further."));
//TODO Bad stuff
return;
}
if (!world.isRemote)
{
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
data.markDirty();
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
for (int i = 0; i < 12; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
}
cooldown = Rituals.getInitialCooldown(testRitual);
var1 = 0;
currentRitualString = testRitual;
isActive = true;
direction = Rituals.getDirectionOfRitual(world, xCoord, yCoord, zCoord, testRitual);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public void setOwner(String owner)
{
this.owner = owner;
}
@Override
public void updateEntity()
{
if (!isActive)
{
return;
}
int worldTime = (int) (worldObj.getWorldTime() % 24000);
if (worldObj.isRemote)
{
return;
}
if (worldTime % 100 == 0)
{
boolean testRunes = Rituals.checkDirectionOfRitualValid(worldObj, xCoord, yCoord, zCoord, currentRitualString, direction);
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
if (!testRunes)
{
isActive = false;
currentRitualString = "";
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
//PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)3));
return;
}
}
if (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0)
{
return;
}
performRitual(worldObj, xCoord, yCoord, zCoord, currentRitualString);
}
public void performRitual(World world, int x, int y, int z, String currentRitualString2)
{
Rituals.performEffect(this, currentRitualString2);
}
public String getOwner()
{
return owner;
}
public void setCooldown(int newCooldown)
{
this.cooldown = newCooldown;
}
public int getCooldown()
{
return this.cooldown;
}
public void setVar1(int newVar1)
{
this.var1 = newVar1;
}
public int getVar1()
{
return this.var1;
}
public void setActive(boolean active)
{
this.isActive = active;
}
public int getDirection()
{
return this.direction;
}
@Override
public World getWorld()
{
return this.getWorldObj();
}
@Override
public int getXCoord()
{
return xCoord;
}
@Override
public int getYCoord()
{
return yCoord;
}
@Override
public int getZCoord()
{
return zCoord;
}
}

View file

@ -0,0 +1,109 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.block.IOrientable;
public class TEOrientable extends TileEntity implements IOrientable
{
protected ForgeDirection inputFace;
protected ForgeDirection outputFace;
public TEOrientable()
{
this.inputFace = ForgeDirection.DOWN;
this.outputFace = ForgeDirection.UP;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.setInputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("inputFace")));
this.setOutputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("outputFace")));
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("inputFace", TEOrientable.getIntForForgeDirection(this.getInputDirection()));
par1NBTTagCompound.setInteger("outputFace", TEOrientable.getIntForForgeDirection(this.getOutputDirection()));
}
@Override
public ForgeDirection getInputDirection()
{
return this.inputFace;
}
@Override
public ForgeDirection getOutputDirection()
{
return this.outputFace;
}
@Override
public void setInputDirection(ForgeDirection direction)
{
this.inputFace = direction;
}
@Override
public void setOutputDirection(ForgeDirection direction)
{
this.outputFace = direction;
}
public static int getIntForForgeDirection(ForgeDirection direction)
{
switch (direction)
{
case DOWN:
return 0;
case UP:
return 1;
case NORTH:
return 2;
case SOUTH:
return 3;
case WEST:
return 4;
case EAST:
return 5;
default:
return 0;
}
}
@Override
public Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public boolean isSideRendered(ForgeDirection side)
{
if(side.equals(this.getInputDirection()) || side.equals(this.getOutputDirection()))
{
return true;
}
return false;
}
public String getResourceLocationForMeta(int meta)
{
return "";
}
}

View file

@ -0,0 +1,268 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class TEPedestal extends TileEntity implements IInventory
{
private ItemStack[] inv;
private int resultID;
private int resultDamage;
public static final int sizeInv = 1;
private boolean isActive;
public TEPedestal()
{
this.inv = new ItemStack[1];
resultID = 0;
resultDamage = 0;
isActive = false;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
resultID = par1NBTTagCompound.getInteger("resultID");
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
isActive = par1NBTTagCompound.getBoolean("isActive");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
inv[i].writeToNBT(tag);
itemList.appendTag(tag);
}
}
par1NBTTagCompound.setInteger("resultID", resultID);
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
par1NBTTagCompound.setTag("Inventory", itemList);
par1NBTTagCompound.setBoolean("isActive", isActive);
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return inv[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amt)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
if (stack.stackSize <= amt)
{
setInventorySlotContents(slot, null);
} else
{
stack = stack.splitStack(amt);
if (stack.stackSize == 0)
{
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack)
{
inv[slot] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "TEPedestal";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
{
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openInventory()
{
// TODO Auto-generated method stub
}
@Override
public void closeInventory()
{
// TODO Auto-generated method stub
}
//Logic for the actual block is under here
@Override
public void updateEntity()
{
super.updateEntity();
}
public void setActive()
{
isActive = false;
}
public boolean isActive()
{
return isActive;
}
@Override
public Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public void handlePacketData(int[] intData)
{
if (intData == null)
{
return;
}
if (intData.length == 3)
{
for (int i = 0; i < 1; i++)
{
if (intData[i * 3 + 2] != 0)
{
ItemStack is = new ItemStack(Item.getItemById(intData[i * 3]), intData[i * 3 + 2], intData[i * 3 + 1]);
inv[i] = is;
} else
{
inv[i] = null;
}
}
}
}
public int[] buildIntDataList()
{
int[] sortList = new int[1 * 3];
int pos = 0;
for (ItemStack is : inv)
{
if (is != null)
{
sortList[pos++] = Item.getIdFromItem(is.getItem());
sortList[pos++] = is.getItemDamage();
sortList[pos++] = is.stackSize;
} else
{
sortList[pos++] = 0;
sortList[pos++] = 0;
sortList[pos++] = 0;
}
}
return sortList;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
if (slot == 0)
{
return true;
}
return false;
}
public void onItemDeletion()
{
//worldObj.createExplosion(null, xCoord+0.5, yCoord+0.5, zCoord+0.5, 1, false);
worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, xCoord, yCoord, zCoord));
for (int i = 0; i < 16; i++)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 2, xCoord, yCoord, zCoord);
}
}
}

View file

@ -0,0 +1,694 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistry;
import WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistryComponent;
import WayofTime.alchemicalWizardry.common.IDemon;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.PlinthComponent;
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
public class TEPlinth extends TileEntity implements IInventory
{
private ItemStack[] inv;
private boolean isActive;
private boolean paradigm;
private ItemStack[] ring1Inv;
private ItemStack[] ring2Inv;
private ItemStack[] ring3Inv;
public static final int sizeInv = 1;
private int progressInterval;
private int progress;
public static List<PlinthComponent> pedestalPositions = new ArrayList();
public TEPlinth()
{
this.inv = new ItemStack[1];
this.ring1Inv = new ItemStack[6];
this.ring2Inv = new ItemStack[6];
this.ring3Inv = new ItemStack[6];
isActive = false;
progress = 0;
progressInterval = 50;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
NBTTagList ring1TagList = par1NBTTagCompound.getTagList("ring1Inv",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < ring1TagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) ring1TagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
ring1Inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
NBTTagList ring2TagList = par1NBTTagCompound.getTagList("ring2Inv",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < ring2TagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) ring2TagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
ring2Inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
NBTTagList ring3TagList = par1NBTTagCompound.getTagList("ring3Inv",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < ring3TagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) ring3TagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
ring3Inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
progress = par1NBTTagCompound.getInteger("progress");
progressInterval = par1NBTTagCompound.getInteger("progressInterval");
isActive = par1NBTTagCompound.getBoolean("isActive");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
inv[i].writeToNBT(tag);
itemList.appendTag(tag);
}
}
par1NBTTagCompound.setTag("Inventory", itemList);
NBTTagList ring1ItemList = new NBTTagList();
for (int i = 0; i < ring1Inv.length; i++)
{
ItemStack stack = ring1Inv[i];
if (ring1Inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
ring1Inv[i].writeToNBT(tag);
ring1ItemList.appendTag(tag);
}
}
par1NBTTagCompound.setTag("ring1Inv", ring1ItemList);
NBTTagList ring2ItemList = new NBTTagList();
for (int i = 0; i < ring2Inv.length; i++)
{
ItemStack stack = ring2Inv[i];
if (ring2Inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
ring2Inv[i].writeToNBT(tag);
ring2ItemList.appendTag(tag);
}
}
par1NBTTagCompound.setTag("ring2Inv", ring1ItemList);
NBTTagList ring3ItemList = new NBTTagList();
for (int i = 0; i < ring3Inv.length; i++)
{
ItemStack stack = ring3Inv[i];
if (ring3Inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
ring3Inv[i].writeToNBT(tag);
ring3ItemList.appendTag(tag);
}
}
par1NBTTagCompound.setTag("ring3Inv", ring1ItemList);
par1NBTTagCompound.setInteger("progress", progress);
par1NBTTagCompound.setInteger("progressInterval", progressInterval);
par1NBTTagCompound.setBoolean("isActive", isActive);
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return inv[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amt)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
if (stack.stackSize <= amt)
{
setInventorySlotContents(slot, null);
} else
{
stack = stack.splitStack(amt);
if (stack.stackSize == 0)
{
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack)
{
inv[slot] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "TEPlinth";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
{
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openInventory()
{
// TODO Auto-generated method stub
}
@Override
public void closeInventory()
{
// TODO Auto-generated method stub
}
//Logic for the actual block is under here
@Override
public void updateEntity()
{
super.updateEntity();
if (worldObj.isRemote)
{
return;
}
if (!isActive())
{
if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery)
{
int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true)))
{
SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true));
isActive = true;
paradigm = true;
progress = 0;
ring1Inv = src.getRingRecipeForRing(1);
ring2Inv = src.getRingRecipeForRing(2);
ring3Inv = src.getRingRecipeForRing(3);
} else if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false)))
{
SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false));
isActive = true;
paradigm = false;
progress = 0;
ring1Inv = src.getRingRecipeForRing(1);
ring2Inv = src.getRingRecipeForRing(2);
ring3Inv = src.getRingRecipeForRing(3);
} else
{
isActive = false;
progress = 0;
}
}
} else
{
if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery)
{
if (progress % progressInterval == 0)
{
int ring = (progress / progressInterval) / 6 + 1;
int slot = (progress / progressInterval) % 6;
ItemStack itemStack;
switch (ring)
{
case 1:
itemStack = this.ring1Inv[slot];
break;
case 2:
itemStack = this.ring2Inv[slot];
break;
case 3:
itemStack = this.ring3Inv[slot];
break;
default:
itemStack = null;
}
if (itemStack == null)
{
progress += progressInterval;
} else
{
if (this.deleteItemStackInRing(ring, itemStack))
{
progress++;
}
}
} else
{
progress++;
}
if (progress >= progressInterval * 18)
{
int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
EntityLivingBase entity = SummoningRegistry.getEntity(worldObj, bloodOrbLevel, ring1Inv, ring2Inv, ring3Inv);
//EntityLivingBase entity = new EntityFallenAngel(worldObj);
if (entity != null)
{
//entity.worldObj = worldObj;
entity.setPosition(xCoord + 0.5, yCoord + 1, zCoord + 0.5);
worldObj.spawnEntityInWorld(entity);
if (entity instanceof IDemon)
{
((IDemon) entity).setSummonedConditions();
}
worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 3, false);
deleteItemsInRing(1);
isActive = false;
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
}
}
public void deleteItemsInRing(int ring)
{
if (paradigm)
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
if (tileEntity instanceof TEPedestal)
{
((TEPedestal) tileEntity).setInventorySlotContents(0, null);
worldObj.markBlockForUpdate(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
i++;
}
}
}
} else
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset);
if (tileEntity instanceof TEPedestal)
{
((TEPedestal) tileEntity).setInventorySlotContents(0, null);
worldObj.markBlockForUpdate(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset);
i++;
}
}
}
}
}
public boolean deleteItemStackInRing(int ring, ItemStack itemStack)
{
if (itemStack == null)
{
return true;
}
if (paradigm)
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
if (tileEntity instanceof TEPedestal)
{
ItemStack possibleItem = ((TEPedestal) tileEntity).getStackInSlot(0);
if (possibleItem == null)
{
i++;
continue;
}
boolean test = false;
if (possibleItem.getItem() instanceof ItemBlock)
{
if (itemStack.getItem() instanceof ItemBlock)
{
test = true;
}
} else if (!(itemStack.getItem() instanceof ItemBlock))
{
test = true;
}
if (test)
{
if (itemStack.getItem()== possibleItem.getItem() && (itemStack.getItemDamage() == possibleItem.getItemDamage() || itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE))
{
((TEPedestal) tileEntity).decrStackSize(0, 1);
if(((TEPedestal) tileEntity).getStackInSlot(0) !=null && ((TEPedestal) tileEntity).getStackInSlot(0).stackSize==0)
{
((TEPedestal) tileEntity).setInventorySlotContents(0, null);
}
((TEPedestal) tileEntity).onItemDeletion();
worldObj.markBlockForUpdate(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
return true;
}
}
i++;
}
}
}
} else
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset);
if (tileEntity instanceof TEPedestal)
{
ItemStack possibleItem = ((TEPedestal) tileEntity).getStackInSlot(0);
if (possibleItem == null)
{
i++;
continue;
}
boolean test = false;
if (possibleItem.getItem() instanceof ItemBlock)
{
if (itemStack.getItem() instanceof ItemBlock)
{
test = true;
}
} else if (!(itemStack.getItem() instanceof ItemBlock))
{
test = true;
}
if (test)
{
if (itemStack.getItem() == possibleItem.getItem() && (itemStack.getItemDamage() == possibleItem.getItemDamage() || itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE))
{
((TEPedestal) tileEntity).decrStackSize(0, 1);
((TEPedestal) tileEntity).onItemDeletion();
//worldObj.markBlockForUpdate(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
worldObj.markBlockForUpdate(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
return true;
}
}
i++;
}
}
}
}
return false;
}
public ItemStack[] composeItemsForRingAndParadigm(int ring, boolean paradigm)
{
ItemStack[] composed = new ItemStack[6];
if (paradigm)
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
if (tileEntity instanceof TEPedestal)
{
composed[i] = ((TEPedestal) tileEntity).getStackInSlot(0);
i++;
}
}
}
} else
{
int i = 0;
for (PlinthComponent pc : pedestalPositions)
{
if (i < 6 && pc.getRing() == ring)
{
TileEntity tileEntity = worldObj.getTileEntity(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset);
if (tileEntity instanceof TEPedestal)
{
composed[i] = ((TEPedestal) tileEntity).getStackInSlot(0);
i++;
}
}
}
}
return composed;
}
public void setActive()
{
isActive = false;
}
public boolean isActive()
{
return isActive;
}
@Override
public Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public void handlePacketData(int[] intData)
{
if (intData == null)
{
return;
}
if (intData.length == 3)
{
for (int i = 0; i < 1; i++)
{
if (intData[i * 3 + 2] != 0)
{
ItemStack is = new ItemStack(Item.getItemById(intData[i * 3]), intData[i * 3 + 2], intData[i * 3 + 1]);
inv[i] = is;
} else
{
inv[i] = null;
}
}
}
}
public int[] buildIntDataList()
{
int[] sortList = new int[1 * 3];
int pos = 0;
for (ItemStack is : inv)
{
if (is != null)
{
sortList[pos++] = Item.getIdFromItem(is.getItem());
sortList[pos++] = is.getItemDamage();
sortList[pos++] = is.stackSize;
} else
{
sortList[pos++] = 0;
sortList[pos++] = 0;
sortList[pos++] = 0;
}
}
return sortList;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
if (slot == 0)
{
return true;
}
return false;
}
public static void initialize()
{
pedestalPositions.add(new PlinthComponent(1, 0, -2, 1));
pedestalPositions.add(new PlinthComponent(2, 0, 0, 1));
pedestalPositions.add(new PlinthComponent(1, 0, +2, 1));
pedestalPositions.add(new PlinthComponent(-1, 0, -2, 1));
pedestalPositions.add(new PlinthComponent(-2, 0, 0, 1));
pedestalPositions.add(new PlinthComponent(-1, 0, +2, 1));
pedestalPositions.add(new PlinthComponent(3, 1, -5, 2));
pedestalPositions.add(new PlinthComponent(6, 1, 0, 2));
pedestalPositions.add(new PlinthComponent(3, 1, +5, 2));
pedestalPositions.add(new PlinthComponent(-3, 1, -5, 2));
pedestalPositions.add(new PlinthComponent(-6, 1, 0, 2));
pedestalPositions.add(new PlinthComponent(-3, 1, +5, 2));
pedestalPositions.add(new PlinthComponent(0, 2, -9, 3));
pedestalPositions.add(new PlinthComponent(7, 2, -4, 3));
pedestalPositions.add(new PlinthComponent(7, 2, +4, 3));
pedestalPositions.add(new PlinthComponent(0, 2, +9, 3));
pedestalPositions.add(new PlinthComponent(-7, 2, -4, 3));
pedestalPositions.add(new PlinthComponent(-7, 2, 4, 3));
}
}

View file

@ -0,0 +1,255 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
public class TESocket extends TileEntity implements IInventory
{
private ItemStack[] inv;
private int resultID;
private int resultDamage;
public static final int sizeInv = 1;
private boolean isActive;
public TESocket()
{
this.inv = new ItemStack[1];
resultID = 0;
resultDamage = 0;
isActive = false;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
resultID = par1NBTTagCompound.getInteger("resultID");
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
isActive = par1NBTTagCompound.getBoolean("isActive");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
inv[i].writeToNBT(tag);
itemList.appendTag(tag);
}
}
par1NBTTagCompound.setInteger("resultID", resultID);
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
par1NBTTagCompound.setTag("Inventory", itemList);
par1NBTTagCompound.setBoolean("isActive", isActive);
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return inv[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amt)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
if (stack.stackSize <= amt)
{
setInventorySlotContents(slot, null);
} else
{
stack = stack.splitStack(amt);
if (stack.stackSize == 0)
{
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack)
{
inv[slot] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "TESocket";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
{
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openInventory()
{
// TODO Auto-generated method stub
}
@Override
public void closeInventory()
{
// TODO Auto-generated method stub
}
//Logic for the actual block is under here
@Override
public void updateEntity()
{
super.updateEntity();
}
public void setActive()
{
isActive = false;
}
public boolean isActive()
{
return isActive;
}
@Override
public Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public void handlePacketData(int[] intData)
{
if (intData == null)
{
return;
}
if (intData.length == 3)
{
for (int i = 0; i < 1; i++)
{
if (intData[i * 3 + 2] != 0)
{
ItemStack is = new ItemStack(Item.getItemById(intData[i * 3]), intData[i * 3 + 2], intData[i * 3 + 1]);
inv[i] = is;
} else
{
inv[i] = null;
}
}
}
}
public int[] buildIntDataList()
{
int[] sortList = new int[1 * 3];
int pos = 0;
for (ItemStack is : inv)
{
if (is != null)
{
sortList[pos++] = Item.getIdFromItem(is.getItem());
sortList[pos++] = is.getItemDamage();
sortList[pos++] = is.stackSize;
} else
{
sortList[pos++] = 0;
sortList[pos++] = 0;
sortList[pos++] = 0;
}
}
return sortList;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
if (slot == 0)
{
return true;
}
return false;
}
}

View file

@ -0,0 +1,149 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.IFluidBlock;
import WayofTime.alchemicalWizardry.ModBlocks;
public class TESpectralContainer extends TileEntity
{
private ItemStack[] inv;
private int ticksRemaining;
public TESpectralContainer()
{
this.inv = new ItemStack[1];
ticksRemaining = 0;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
ticksRemaining = par1NBTTagCompound.getInteger("ticksRemaining");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
inv[i].writeToNBT(tag);
itemList.appendTag(tag);
}
}
par1NBTTagCompound.setTag("Inventory", itemList);
par1NBTTagCompound.setInteger("ticksRemaining", ticksRemaining);
}
@Override
public void updateEntity()
{
super.updateEntity();
this.ticksRemaining--;
if(this.ticksRemaining<=0)
{
this.returnContainedBlock();
}
}
public static boolean createSpectralBlockAtLocation(World world, int x, int y, int z, int duration)
{
Block block = world.getBlock(x, y, z);
if(block==null)
{
return false;
}
if(world.getTileEntity(x, y, z)==null || block instanceof IFluidBlock)
{
int meta = world.getBlockMetadata(x, y, z);
ItemStack item = new ItemStack(block, 1, meta);
world.setBlock(x, y, z, ModBlocks.blockSpectralContainer);
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TESpectralContainer)
{
((TESpectralContainer) tile).setContainedItem(item);
((TESpectralContainer) tile).setDuration(duration);
return true;
}
}
return false;
}
public void setDuration(int dur)
{
this.ticksRemaining = dur;
}
public void resetDuration(int dur)
{
if(this.ticksRemaining<dur)
{
this.ticksRemaining = dur;
}
}
public void setContainedItem(ItemStack item)
{
this.inv[0] = item;
}
public void returnContainedBlock()
{
ItemStack item = this.inv[0];
if(item!=null)
{
if(item.getItem() instanceof ItemBlock)
{
Block block = ((ItemBlock)item.getItem()).field_150939_a;
int meta = item.getItemDamage();
if(block != null)
{
this.worldObj.setBlock(xCoord, yCoord, zCoord, block, meta, 6);
}
}
}else
{
this.worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}
}
}

View file

@ -0,0 +1,48 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
public abstract class TESpellBlock extends TEOrientable
{
public void modifySpellParadigm(SpellParadigm parad)
{
this.applySpellChange(parad);
TileEntity tile = this.getTileAtOutput();
if(tile instanceof TESpellBlock)
{
TESpellBlock outputBlock = (TESpellBlock)tile;
outputBlock.modifySpellParadigm(parad);
}
}
protected abstract void applySpellChange(SpellParadigm parad);
public TESpellBlock getTileAtOutput()
{
ForgeDirection output = this.getOutputDirection();
int xOffset = output.offsetX;
int yOffset = output.offsetY;
int zOffset = output.offsetZ;
TileEntity tile = worldObj.getTileEntity(xCoord + xOffset, yCoord + yOffset, zCoord + zOffset);
if(tile instanceof TESpellBlock && ((TESpellBlock)tile).canInputRecieveOutput(output))
{
return (TESpellBlock)tile;
}
return null;
}
public boolean canInputRecieve()
{
return true;
}
public boolean canInputRecieveOutput(ForgeDirection output)
{
return this.canInputRecieve() && this.getInputDirection().getOpposite()==output;
}
}

View file

@ -0,0 +1,43 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffect;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffectEarth;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffectFire;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffectIce;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffectWind;
public class TESpellEffectBlock extends TESpellBlock
{
@Override
protected void applySpellChange(SpellParadigm parad)
{
parad.addBufferedEffect(this.getSpellEffect());
}
public SpellEffect getSpellEffect()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0: return new SpellEffectFire();
case 1: return new SpellEffectIce();
case 2: return new SpellEffectWind();
case 3: return new SpellEffectEarth();
}
return new SpellEffectFire();
}
@Override
public String getResourceLocationForMeta(int meta)
{
switch(meta)
{
case 0: return "alchemicalwizardry:textures/models/SpellEffectFire.png";
case 1: return "alchemicalwizardry:textures/models/SpellEffectIce.png";
case 2: return "alchemicalwizardry:textures/models/SpellEffectWind.png";
case 3: return "alchemicalwizardry:textures/models/SpellEffectEarth.png";
}
return "";
}
}

View file

@ -0,0 +1,155 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancementCost;
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancementPotency;
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancementPower;
public class TESpellEnhancementBlock extends TESpellBlock
{
@Override
protected void applySpellChange(SpellParadigm parad)
{
int i = -1;
switch(this.enhancementType())
{
case 0:
i = parad.getBufferedEffectPower();
break;
case 1:
i = parad.getBufferedEffectCost();
break;
case 2:
i = parad.getBufferedEffectPotency();
break;
}
if(i!=-1 && i<this.getLimit())
{
parad.applyEnhancement(getSpellEnhancement());
}
else if(i<this.getLimit())
{
this.doBadStuff();
}
}
public SpellEnhancement getSpellEnhancement()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0:
case 1:
case 2:
case 3:
case 4:
return new SpellEnhancementPower();
case 5:
case 6:
case 7:
case 8:
case 9:
return new SpellEnhancementCost();
case 10:
case 11:
case 12:
case 13:
case 14:
return new SpellEnhancementPotency();
}
return new SpellEnhancementCost();
}
public int getLimit()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0:
return 1;
case 1:
return 2;
case 2:
return 3;
case 3:
return 4;
case 4:
return 5;
case 5:
return 1;
case 6:
return 2;
case 7:
return 3;
case 8:
return 4;
case 9:
return 5;
case 10:
return 1;
case 11:
return 2;
case 12:
return 3;
case 13:
return 4;
case 14:
return 5;
}
return 0;
}
public int enhancementType() //0 is power, 1 is cost, 2 is potency
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0:
case 1:
case 2:
case 3:
case 4:
return 0;
case 5:
case 6:
case 7:
case 8:
case 9:
return 1;
case 10:
case 11:
case 12:
case 13:
case 14:
return 2;
}
return 1;
}
public void doBadStuff()
{
}
@Override
public String getResourceLocationForMeta(int meta)
{
switch(meta)
{
case 0: return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png";
case 1: return "alchemicalwizardry:textures/models/SpellEnhancementPower2.png";
case 2: return "alchemicalwizardry:textures/models/SpellEnhancementPower3.png";
case 5: return "alchemicalwizardry:textures/models/SpellEnhancementCost1.png";
case 6: return "alchemicalwizardry:textures/models/SpellEnhancementCost2.png";
case 7: return "alchemicalwizardry:textures/models/SpellEnhancementCost3.png";
case 10: return "alchemicalwizardry:textures/models/SpellEnhancementPotency1.png";
case 11: return "alchemicalwizardry:textures/models/SpellEnhancementPotency2.png";
case 12: return "alchemicalwizardry:textures/models/SpellEnhancementPotency3.png";
}
return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png";
}
}

View file

@ -0,0 +1,43 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifier;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifierDefault;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifierDefensive;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifierEnvironmental;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifierOffensive;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
public class TESpellModifierBlock extends TESpellBlock
{
@Override
protected void applySpellChange(SpellParadigm parad)
{
parad.modifyBufferedEffect(this.getSpellModifier());
}
public SpellModifier getSpellModifier()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0: return new SpellModifierDefault();
case 1: return new SpellModifierOffensive();
case 2: return new SpellModifierDefensive();
case 3: return new SpellModifierEnvironmental();
}
return new SpellModifierDefault();
}
@Override
public String getResourceLocationForMeta(int meta)
{
switch(meta)
{
case 0: return "alchemicalwizardry:textures/models/SpellModifierDefault.png";
case 1: return "alchemicalwizardry:textures/models/SpellModifierOffensive.png";
case 2: return "alchemicalwizardry:textures/models/SpellModifierDefensive.png";
case 3: return "alchemicalwizardry:textures/models/SpellModifierEnvironmental.png";
}
return "alchemicalwizardry:textures/models/SpellModifierDefault.png";
}
}

View file

@ -0,0 +1,97 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmMelee;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmSelf;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmTool;
public class TESpellParadigmBlock extends TESpellBlock
{
public SpellParadigm getSpellParadigm()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
switch(meta)
{
case 0: return new SpellParadigmProjectile();
case 1: return new SpellParadigmSelf();
case 2: return new SpellParadigmMelee();
case 3: return new SpellParadigmTool();
}
return new SpellParadigmSelf();
}
@Override
protected void applySpellChange(SpellParadigm parad)
{
return;
}
public boolean canInputRecieve()
{
return false;
}
public void castSpell(World world, EntityPlayer entity, ItemStack spellCasterStack)
{
SpellParadigm parad = this.getSpellParadigm();
this.modifySpellParadigm(parad);
// if(parad instanceof SpellParadigmSelf)
// {
// List<String> stringList = parad.effectList;
// SpellParadigmSelf spellParadSelf = SpellParadigmSelf.getParadigmForStringArray(stringList);
// for(String str : stringList)
// {
// ChatMessageComponent chat = new ChatMessageComponent();
// chat.addText(str);
// entity.sendChatToPlayer(chat);
// }
// spellParadSelf.castSpell(world, entity, spellCasterStack);
// }
// else if(parad instanceof SpellParadigmProjectile)
// {
// List<String> stringList = parad.effectList;
// SpellParadigmProjectile spellParadSelf = SpellParadigmProjectile.getParadigmForStringArray(stringList);
// for(String str : stringList)
// {
// ChatMessageComponent chat = new ChatMessageComponent();
// chat.addText(str);
// entity.sendChatToPlayer(chat);
// }
// spellParadSelf.castSpell(world, entity, spellCasterStack);
// }else
{
parad.applyAllSpellEffects();
parad.castSpell(world, entity, spellCasterStack);
}
}
@Override
public String getResourceLocationForMeta(int meta)
{
switch(meta)
{
case 0: return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png";
case 1: return "alchemicalwizardry:textures/models/SpellParadigmSelf.png";
case 2: return "alchemicalwizardry:textures/models/SpellParadigmMelee.png";
}
return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png";
}
@Override
public void setInputDirection(ForgeDirection direction)
{
}
@Override
public ForgeDirection getInputDirection()
{
return ForgeDirection.UNKNOWN;
}
}

View file

@ -0,0 +1,374 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.block.BlockTeleposer;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.items.TelepositionFocus;
public class TETeleposer extends TileEntity implements IInventory
{
private ItemStack[] inv;
private int resultID;
private int resultDamage;
private int previousInput;
public static final int sizeInv = 1;
private boolean isActive;
public TETeleposer()
{
this.inv = new ItemStack[1];
resultID = 0;
resultDamage = 0;
isActive = false;
previousInput = 0;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
resultID = par1NBTTagCompound.getInteger("resultID");
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
isActive = par1NBTTagCompound.getBoolean("isActive");
previousInput = par1NBTTagCompound.getInteger("previousInput");
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (inv[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
inv[i].writeToNBT(tag);
itemList.appendTag(tag);
}
}
par1NBTTagCompound.setInteger("resultID", resultID);
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
par1NBTTagCompound.setTag("Inventory", itemList);
par1NBTTagCompound.setBoolean("isActive", isActive);
par1NBTTagCompound.setInteger("previousInput", previousInput);
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return inv[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amt)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
if (stack.stackSize <= amt)
{
setInventorySlotContents(slot, null);
} else
{
stack = stack.splitStack(amt);
if (stack.stackSize == 0)
{
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack)
{
inv[slot] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "TETeleposer";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
{
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openInventory()
{
// TODO Auto-generated method stub
}
@Override
public void closeInventory()
{
// TODO Auto-generated method stub
}
//Logic for the actual block is under here
@Override
public void updateEntity()
{
super.updateEntity();
if (worldObj.isRemote)
{
return;
}
int currentInput = worldObj.getBlockPowerInput(xCoord, yCoord, zCoord);
if (previousInput == 0 && currentInput != 0)
{
ItemStack focus = this.getStackInSlot(0);
if (focus != null && focus.getItem() instanceof TelepositionFocus)
{
TelepositionFocus focusItem = (TelepositionFocus) (focus.getItem());
int xf = focusItem.xCoord(focus);
int yf = focusItem.yCoord(focus);
int zf = focusItem.zCoord(focus);
World worldF = focusItem.getWorld(focus);
int damage = (int) (0.5f * Math.sqrt((xCoord - xf) * (xCoord - xf) + (yCoord - yf + 1) * (yCoord - yf + 1) + (zCoord - zf) * (zCoord - zf)));
int focusLevel = ((TelepositionFocus) focusItem).getFocusLevel();
int transportCount = 0;
int entityCount = 0;
if (worldF != null && worldF.getTileEntity(xf, yf, zf) instanceof TETeleposer && !worldF.getTileEntity(xf, yf, zf).equals(this))
{
//Prime the teleportation
int d0 = focusLevel - 1;
AxisAlignedBB axisalignedbb1 = AxisAlignedBB.getAABBPool().getAABB((double) this.xCoord, (double) this.yCoord + d0 + 1, (double) this.zCoord, (double) (this.xCoord + 1), (double) (this.yCoord + 2 + d0), (double) (this.zCoord + 1)).expand(d0, d0, d0);
axisalignedbb1.maxY = Math.min((double) this.worldObj.getHeight(), this.yCoord + 2 + d0 + d0);
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb1);
Iterator iterator1 = list1.iterator();
EntityLivingBase entityplayer1;
while (iterator1.hasNext())
{
entityplayer1 = (EntityLivingBase) iterator1.next();
entityCount++;
}
//int d0 = focusLevel-1;
AxisAlignedBB axisalignedbb2 = AxisAlignedBB.getAABBPool().getAABB(xf, yf + d0 + 1, zf, xf + 1, yf + 2 + d0, zf).expand(d0, d0, d0);
//axisalignedbb2.maxY = Math.min((double)worldF.getHeight(),yf+1+d0+d0);
List list2 = worldF.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb2);
Iterator iterator2 = list2.iterator();
EntityLivingBase entityplayer2;
while (iterator2.hasNext())
{
entityplayer2 = (EntityLivingBase) iterator2.next();
entityCount++;
}
if (EnergyItems.canSyphonInContainer(focus, damage * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) + damage * entityCount))
{
for (int k = 0; k <= (focusLevel * 2 - 2); k++)
//for(int k=(focusLevel*2-1);k>=0;k--)
{
for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++)
{
for (int j = -(focusLevel - 1); j <= (focusLevel - 1); j++)
{
{
if (BlockTeleposer.swapBlocks(worldObj, worldF, xCoord + i, yCoord + 1 + k, zCoord + j, xf + i, yf + 1 + k, zf + j))
{
transportCount++;
}
}
}
}
}
if (!worldF.equals(worldObj))
{
entityCount = 0;
}
EnergyItems.syphonWhileInContainer(focus, damage * transportCount + damage * entityCount);
//Teleport
if (worldF.equals(worldObj))
{
iterator1 = list1.iterator();
iterator2 = list2.iterator();
while (iterator1.hasNext())
{
entityplayer1 = (EntityLivingBase) iterator1.next();
entityplayer1.worldObj = worldF;
entityplayer1.setPositionAndUpdate(entityplayer1.posX - this.xCoord + xf, entityplayer1.posY - this.yCoord + yf, entityplayer1.posZ - this.zCoord + zf);
}
while (iterator2.hasNext())
{
entityplayer2 = (EntityLivingBase) iterator2.next();
entityplayer2.worldObj = worldF;
entityplayer2.setPositionAndUpdate(entityplayer2.posX + this.xCoord - xf, entityplayer2.posY + this.yCoord - yf, entityplayer2.posZ + this.zCoord - zf);
}
}
}
}
}
}
previousInput = currentInput;
}
public void setActive()
{
isActive = false;
}
public boolean isActive()
{
return isActive;
}
@Override
public Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public void handlePacketData(int[] intData)
{
if (intData == null)
{
return;
}
if (intData.length == 3)
{
for (int i = 0; i < 1; i++)
{
if (intData[i * 3 + 2] != 0)
{
ItemStack is = new ItemStack(Item.getItemById(intData[i * 3]), intData[i * 3 + 2], intData[i * 3 + 1]);
inv[i] = is;
} else
{
inv[i] = null;
}
}
}
}
public int[] buildIntDataList()
{
int[] sortList = new int[1 * 3];
int pos = 0;
for (ItemStack is : inv)
{
if (is != null)
{
sortList[pos++] = Item.getIdFromItem(is.getItem());
sortList[pos++] = is.getItemDamage();
sortList[pos++] = is.stackSize;
} else
{
sortList[pos++] = 0;
sortList[pos++] = 0;
sortList[pos++] = 0;
}
}
return sortList;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
if (slot == 0)
{
return true;
}
return false;
}
}

View file

@ -0,0 +1,815 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemicalPotionCreationHandler;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipe;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import WayofTime.alchemicalWizardry.common.IBindingAgent;
import WayofTime.alchemicalWizardry.common.ICatalyst;
import WayofTime.alchemicalWizardry.common.IFillingAgent;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class TEWritingTable extends TileEntity implements IInventory
{
private ItemStack[] inv;
private int progress;
private int progressNeeded = 100;
private int amountUsed;
public static final int sizeInv = 7;
public TEWritingTable()
{
inv = new ItemStack[7];
}
@Override
public int getSizeInventory()
{
return inv.length;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return inv[slot];
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
inv[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit())
{
stack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize(int slot, int amt)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
if (stack.stackSize <= amt)
{
setInventorySlotContents(slot, null);
} else
{
stack = stack.splitStack(amt);
if (stack.stackSize == 0)
{
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if (stack != null)
{
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
NBTTagList tagList = tagCompound.getTagList("Inventory",Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
byte slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
progress = tagCompound.getInteger("progress");
amountUsed = tagCompound.getInteger("amountUsed");
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++)
{
ItemStack stack = inv[i];
if (stack != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
stack.writeToNBT(tag);
itemList.appendTag(tag);
}
}
tagCompound.setTag("Inventory", itemList);
tagCompound.setInteger("progress", progress);
tagCompound.setInteger("amountUsed", amountUsed);
}
@Override
public String getInventoryName()
{
return "aw.TEWritingTable";
}
@Override
public boolean hasCustomInventoryName()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
// TODO Auto-generated method stub
return false;
}
@Override
public net.minecraft.network.Packet getDescriptionPacket()
{
return NewPacketHandler.getPacket(this);
}
public void handlePacketData(int[] intData)
{
if (intData == null)
{
return;
}
if (intData.length == 3 * 7)
{
for (int i = 0; i < 7; i++)
{
if (intData[i * 3 + 2] != 0)
{
ItemStack is = new ItemStack(Item.getItemById(intData[i * 3]), intData[i * 3 + 2], intData[i * 3 + 1]);
inv[i] = is;
} else
{
inv[i] = null;
}
}
}
}
public int[] buildIntDataList()
{
int[] sortList = new int[7 * 3];
int pos = 0;
for (ItemStack is : inv)
{
if (is != null)
{
sortList[pos++] = Item.getIdFromItem(is.getItem());
sortList[pos++] = is.getItemDamage();
sortList[pos++] = is.stackSize;
} else
{
sortList[pos++] = 0;
sortList[pos++] = 0;
sortList[pos++] = 0;
}
}
return sortList;
}
public ItemStack getResultingItemStack()
{
ItemStack[] composedRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
composedRecipe[i] = inv[i + 1];
}
return AlchemyRecipeRegistry.getResult(composedRecipe, inv[0]);
}
public boolean isRecipeValid()
{
return (getResultingItemStack() != null);
}
public int getAmountNeeded(ItemStack bloodOrb)
{
ItemStack[] composedRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
composedRecipe[i] = inv[i + 1];
}
return AlchemyRecipeRegistry.getAmountNeeded(composedRecipe, bloodOrb);
}
public boolean containsPotionFlask()
{
if (getPotionFlaskPosition() != -1)
{
return true;
} else
{
return false;
}
}
public int getPotionFlaskPosition()
{
for (int i = 1; i <= 5; i++)
{
if (inv[i] != null && !(inv[i].getItem() instanceof ItemBlock) && inv[i].getItem() == ModItems.alchemyFlask)
{
return i;
}
}
return -1;
}
public boolean containsRegisteredPotionIngredient()
{
if (getRegisteredPotionIngredientPosition() != -1)
{
return true;
} else
{
return false;
}
}
public int getRegisteredPotionIngredientPosition()
{
ItemStack[] composedRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
composedRecipe[i] = inv[i + 1];
}
int location = AlchemicalPotionCreationHandler.getRegisteredPotionIngredientPosition(composedRecipe);
if (location != -1)
{
return location + 1;
}
return -1;
}
public boolean containsCatalyst()
{
if (getCatalystPosition() != -1)
{
return true;
}
return false;
}
public int getCatalystPosition()
{
for (int i = 0; i < 5; i++)
{
if (inv[i + 1] != null && inv[i + 1].getItem() instanceof ICatalyst)
{
return i + 1;
}
}
return -1;
}
public boolean containsBindingAgent()
{
if (getBindingAgentPosition() != -1)
{
return true;
}
return false;
}
public int getBindingAgentPosition()
{
for (int i = 0; i < 5; i++)
{
if (inv[i + 1] != null && inv[i + 1].getItem() instanceof IBindingAgent)
{
return i + 1;
}
}
return -1;
}
public boolean containsFillingAgent()
{
if (getFillingAgentPosition() != -1)
{
return true;
}
return false;
}
public int getFillingAgentPosition()
{
for (int i = 0; i < 5; i++)
{
if (inv[i + 1] != null && inv[i + 1].getItem() instanceof IFillingAgent)
{
return i + 1;
}
}
return -1;
}
public boolean containsBlankSlate()
{
if (getBlankSlatePosition() != -1)
{
return true;
}
return false;
}
public int getBlankSlatePosition()
{
for (int i = 0; i < 5; i++)
{
if (inv[i + 1] != null && inv[i + 1].getItem() == ModItems.blankSlate)
{
return i + 1;
}
}
return -1;
}
@Override
public void updateEntity()
{
long worldTime = worldObj.getWorldTime();
if (worldObj.isRemote)
{
return;
}
// if(worldTime%100==0)
// {
// if (worldObj != null)
// {
// worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
// }
// }
if (containsPotionFlask() && containsRegisteredPotionIngredient())
{
if (containsCatalyst())
{
if (getStackInSlot(6) == null)
{
progress++;
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (progress >= progressNeeded)
{
ItemStack flaskStack = inv[this.getPotionFlaskPosition()];
ItemStack ingredientStack = inv[this.getRegisteredPotionIngredientPosition()];
ItemStack catalystStack = inv[this.getCatalystPosition()];
if (flaskStack == null || ingredientStack == null || catalystStack == null)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
int potionID = AlchemicalPotionCreationHandler.getPotionIDForStack(ingredientStack);
int catalystLevel = ((ICatalyst) catalystStack.getItem()).getCatalystLevel();
boolean isConcentration = ((ICatalyst) catalystStack.getItem()).isConcentration();
if (potionID == -1 || catalystLevel < 0)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
if (isConcentration)
{
((AlchemyFlask) flaskStack.getItem()).setConcentrationOfPotion(flaskStack, potionID, catalystLevel);
} else
{
((AlchemyFlask) flaskStack.getItem()).setDurationFactorOfPotion(flaskStack, potionID, catalystLevel);
}
//((AlchemyFlask)flaskStack.getItem()).setConcentrationOfPotion(flaskStack, Potion.regeneration.id, 2);
this.setInventorySlotContents(6, flaskStack);
this.decrStackSize(this.getPotionFlaskPosition(), 1);
this.decrStackSize(this.getCatalystPosition(), 1);
this.decrStackSize(this.getRegisteredPotionIngredientPosition(), 1);
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
} else if (containsBindingAgent())
{
if (getStackInSlot(6) == null)
{
progress++;
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (progress >= progressNeeded)
{
ItemStack flaskStack = inv[this.getPotionFlaskPosition()];
ItemStack ingredientStack = inv[this.getRegisteredPotionIngredientPosition()];
ItemStack agentStack = inv[this.getBindingAgentPosition()];
if (flaskStack == null || ingredientStack == null || agentStack == null)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
int potionEffectNumber = ((AlchemyFlask) flaskStack.getItem()).getNumberOfPotionEffects(flaskStack);
int potionID = AlchemicalPotionCreationHandler.getPotionIDForStack(ingredientStack);
int tickDuration = AlchemicalPotionCreationHandler.getPotionTickDurationForStack(ingredientStack);
float successChance = ((IBindingAgent) agentStack.getItem()).getSuccessRateForPotionNumber(potionEffectNumber);
//boolean isConcentration = ((ICatalyst)catalystStack.getItem()).isConcentration();
if (potionID == -1)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
((AlchemyFlask) flaskStack.getItem()).addPotionEffect(flaskStack, potionID, tickDuration);
//((AlchemyFlask)flaskStack.getItem()).addPotionEffect(flaskStack, Potion.regeneration.id, 1000);
if (successChance > worldObj.rand.nextFloat())
{
this.setInventorySlotContents(6, flaskStack);
} else
{
worldObj.createExplosion(null, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 2, false);
}
this.decrStackSize(this.getPotionFlaskPosition(), 1);
this.decrStackSize(this.getBindingAgentPosition(), 1);
this.decrStackSize(this.getRegisteredPotionIngredientPosition(), 1);
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
} else if (this.containsBlankSlate() && this.containsPotionFlask())
{
if (getStackInSlot(6) == null)
{
progress++;
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (progress >= progressNeeded)
{
ItemStack flaskStack = inv[this.getPotionFlaskPosition()];
//ItemStack ingredientStack = inv[this.getRegisteredPotionIngredientPosition()];
ItemStack blankSlate = inv[this.getBlankSlatePosition()];
if (flaskStack == null || blankSlate == null)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
//boolean isConcentration = ((ICatalyst)catalystStack.getItem()).isConcentration();
((AlchemyFlask) flaskStack.getItem()).setIsPotionThrowable(true, flaskStack);
//((AlchemyFlask)flaskStack.getItem()).addPotionEffect(flaskStack, Potion.regeneration.id, 1000);
//if(successChance>worldObj.rand.nextFloat())
this.setInventorySlotContents(6, flaskStack);
this.decrStackSize(this.getPotionFlaskPosition(), 1);
this.decrStackSize(this.getBlankSlatePosition(), 1);
//this.decrStackSize(this.getRegisteredPotionIngredientPosition(), 1);
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
} else if (this.containsFillingAgent() && this.containsPotionFlask())
{
//TODO
if (getStackInSlot(6) == null)
{
progress++;
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (progress >= progressNeeded)
{
ItemStack flaskStack = inv[this.getPotionFlaskPosition()];
//ItemStack ingredientStack = inv[this.getRegisteredPotionIngredientPosition()];
ItemStack fillingAgent = inv[this.getFillingAgentPosition()];
if (flaskStack == null || fillingAgent == null)
{
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}
//boolean isConcentration = ((ICatalyst)catalystStack.getItem()).isConcentration();
int potionEffects = ((AlchemyFlask) flaskStack.getItem()).getNumberOfPotionEffects(flaskStack);
int potionFillAmount = ((IFillingAgent) fillingAgent.getItem()).getFilledAmountForPotionNumber(potionEffects);
flaskStack.setItemDamage(Math.max(0, flaskStack.getItemDamage() - potionFillAmount));
//((AlchemyFlask)flaskStack.getItem()).addPotionEffect(flaskStack, Potion.regeneration.id, 1000);
//if(successChance>worldObj.rand.nextFloat())
this.setInventorySlotContents(6, flaskStack);
this.decrStackSize(this.getPotionFlaskPosition(), 1);
this.decrStackSize(this.getFillingAgentPosition(), 1);
//this.decrStackSize(this.getRegisteredPotionIngredientPosition(), 1);
progress = 0;
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
} else
{
if (!isRecipeValid())
{
progress = 0;
return;
}
if (progress <= 0)
{
progress = 0;
amountUsed = this.getAmountNeeded(getStackInSlot(0));
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
if (getStackInSlot(6) == null)
{
if (!EnergyItems.syphonWhileInContainer(getStackInSlot(0), amountUsed))
{
return;
}
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
progress++;
if (progress >= progressNeeded)
{
progress = 0;
this.setInventorySlotContents(6, getResultingItemStack());
ItemStack[] composedRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
composedRecipe[i] = inv[i + 1];
}
this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0]));
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
} else if (getStackInSlot(6).getItem() == getResultingItemStack().getItem() && getResultingItemStack().stackSize <= (getStackInSlot(6).getMaxStackSize() - getStackInSlot(6).stackSize))
{
if (worldTime % 4 == 0)
{
SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (!EnergyItems.syphonWhileInContainer(getStackInSlot(0), amountUsed))
{
return;
}
progress++;
if (progress >= progressNeeded)
{
progress = 0;
ItemStack result = getResultingItemStack().copy();
result.stackSize += getStackInSlot(6).stackSize;
this.setInventorySlotContents(6, result);
ItemStack[] composedRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
composedRecipe[i] = inv[i + 1];
}
this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0]));
if (worldObj != null)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
//worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public void decrementSlots(ItemStack[] recipe) //TODO Fix this. This doesn't work.
{
boolean[] decrementedList = new boolean[]{false,false,false,false,false};
for(int i=0; i<(Math.min(recipe.length,5)); i++)
{
ItemStack decStack = recipe[i];
if(decStack == null)
{
continue;
}
for(int j=0; j<5; j++)
{
ItemStack testStack = this.getStackInSlot(j+1);
if(testStack != null && (testStack.isItemEqual(decStack) || (testStack.getItem() == decStack.getItem() && decStack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) && !(decrementedList[j]))
{
if(testStack.getItem().hasContainerItem(testStack))
{
this.inv[j+1] = testStack.getItem().getContainerItem(testStack);
}else
{
this.decrStackSize(j+1, 1);
}
decrementedList[j] = true;
break;
}
}
}
}
public ItemStack[] getRecipeForItems(ItemStack[] recipe, ItemStack bloodOrb)
{
if (bloodOrb == null)
{
return null;
}
if (!(bloodOrb.getItem() instanceof IBloodOrb))
{
return null;
}
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
for (AlchemyRecipe ar : AlchemyRecipeRegistry.recipes)
{
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
{
return ar.getRecipe();
}
}
return null;
}
}

View file

@ -0,0 +1,96 @@
package WayofTime.alchemicalWizardry.common.tileEntity.container;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerAltar extends Container
{
protected TEAltar tileEntity;
public ContainerAltar(InventoryPlayer inventoryPlayer, TEAltar te)
{
tileEntity = te;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
bindPlayerInventory(inventoryPlayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9)
{
if (!this.mergeItemStack(stackInSlot, 0, 35, true))
{
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false))
{
return null;
}
if (stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
} else
{
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View file

@ -0,0 +1,106 @@
package WayofTime.alchemicalWizardry.common.tileEntity.container;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerTeleposer extends Container
{
protected TETeleposer tileEntity;
public ContainerTeleposer(InventoryPlayer inventoryPlayer, TETeleposer te)
{
tileEntity = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
// addSlotToContainer(new Slot(tileEntity, 0, 152, 110));
// addSlotToContainer(new Slot(tileEntity, 1, 80, 18));
// addSlotToContainer(new Slot(tileEntity, 2, 33, 52));
// addSlotToContainer(new Slot(tileEntity, 3, 51, 110));
// addSlotToContainer(new Slot(tileEntity, 4, 109, 110));
// addSlotToContainer(new Slot(tileEntity, 5, 127, 52));
addSlotToContainer(new Slot(tileEntity, 0, 80, 67));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileEntity.isUseableByPlayer(player);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 140 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 198));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot == 7)
{
if (!this.mergeItemStack(stackInSlot, 7, 35, true))
{
return null;
}
slotObject.onSlotChange(stackInSlot, stack);
}
//merges the item into player inventory since its in the tileEntity
if (slot < 1)
{
if (!this.mergeItemStack(stackInSlot, 7, 35, true))
{
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 0, false))
{
return null;
}
if (stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
} else
{
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View file

@ -0,0 +1,104 @@
package WayofTime.alchemicalWizardry.common.tileEntity.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
public class ContainerWritingTable extends Container
{
protected TEWritingTable tileEntity;
public ContainerWritingTable(InventoryPlayer inventoryPlayer, TEWritingTable te)
{
tileEntity = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
addSlotToContainer(new Slot(tileEntity, 0, 152, 110));
addSlotToContainer(new Slot(tileEntity, 1, 80, 18));
addSlotToContainer(new Slot(tileEntity, 2, 33, 52));
addSlotToContainer(new Slot(tileEntity, 3, 51, 110));
addSlotToContainer(new Slot(tileEntity, 4, 109, 110));
addSlotToContainer(new Slot(tileEntity, 5, 127, 52));
addSlotToContainer(new Slot(tileEntity, 6, 80, 67));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileEntity.isUseableByPlayer(player);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 140 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 198));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot <= 6)
{
if (!this.mergeItemStack(stackInSlot, 7, 43, true))
{
return null;
}
}
else if(stack.getItem() instanceof IBloodOrb)
{
if (!this.mergeItemStack(stackInSlot, 0, 1, false))
{
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 1, 6, false))
{
return null;
}
if (stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
} else
{
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View file

@ -0,0 +1,73 @@
package WayofTime.alchemicalWizardry.common.tileEntity.gui;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerTeleposer;
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerWritingTable;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler
{
//returns an instance of the Container you made earlier
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity;
switch (id)
{
case 0:
tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TEWritingTable)
{
return new ContainerWritingTable(player.inventory, (TEWritingTable) tileEntity);
}
case 1:
tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TETeleposer)
{
return new ContainerTeleposer(player.inventory, (TETeleposer) tileEntity);
}
}
return null;
}
//returns an instance of the Gui you made earlier
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity;
switch (id)
{
case 0:
tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TEWritingTable)
{
return new GuiWritingTable(player.inventory, (TEWritingTable) tileEntity);
}
break;
case 1:
tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TETeleposer)
{
return new GuiTeleposer(player.inventory, (TETeleposer) tileEntity);
}
break;
}
return null;
}
}

View file

@ -0,0 +1,47 @@
package WayofTime.alchemicalWizardry.common.tileEntity.gui;
import net.minecraft.client.gui.inventory.GuiBrewingStand;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerTeleposer;
public class GuiTeleposer extends GuiContainer
{
public GuiTeleposer(InventoryPlayer inventoryPlayer, TETeleposer tileEntity)
{
//the container is instanciated and passed to the superclass for handling
super(new ContainerTeleposer(inventoryPlayer, tileEntity));
xSize = 176;
ySize = 222;
}
@Override
protected void drawGuiContainerForegroundLayer(int param1, int param2)
{
//draw text and stuff here
//the parameters for drawString are: string, x, y, color
fontRendererObj.drawString("Teleposer", 8, 6, 4210752);
//draws "Inventory" or your regional equivalent
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, 130, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
//draw your Gui here, only thing you need to change is the path
//ResourceLocation texture = mc.renderEngine.getTexture("/gui/trap.png");
ResourceLocation test = new ResourceLocation("alchemicalwizardry", "gui/Teleposer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(test);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
GuiBrewingStand d;
}
}

View file

@ -0,0 +1,45 @@
package WayofTime.alchemicalWizardry.common.tileEntity.gui;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerWritingTable;
import net.minecraft.client.gui.inventory.GuiBrewingStand;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
public class GuiWritingTable extends GuiContainer
{
public GuiWritingTable(InventoryPlayer inventoryPlayer, TEWritingTable tileEntity)
{
//the container is instanciated and passed to the superclass for handling
super(new ContainerWritingTable(inventoryPlayer, tileEntity));
xSize = 176;
ySize = 222;
}
@Override
protected void drawGuiContainerForegroundLayer(int param1, int param2)
{
//draw text and stuff here
//the parameters for drawString are: string, x, y, color
fontRendererObj.drawString("Alchemic Chemistry Set", 8, 6, 4210752);
//draws "Inventory" or your regional equivalent
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, 130, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
//draw your Gui here, only thing you need to change is the path
//ResourceLocation texture = mc.renderEngine.getTexture("/gui/trap.png");
ResourceLocation test = new ResourceLocation("alchemicalwizardry", "gui/WritingTable.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(test);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
GuiBrewingStand d;
}
}