Testing
This commit is contained in:
commit
8601e9faff
498 changed files with 45817 additions and 0 deletions
1422
BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java
Normal file
1422
BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,37 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class TEConduit extends TEOrientable
|
||||
{
|
||||
@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()
|
||||
{
|
||||
//this.capacity=(int) (10000*this.capacityMultiplier);
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.getBlockOrientationPacket(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpell;
|
||||
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpellRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
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.getBlockTileEntity(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.getBlockTileEntity(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.getBlockTileEntity(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.getBlockTileEntity(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
|
||||
int blockID = worldObj.getBlockId(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (blockID == Block.glowStone.blockID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (blockID == Block.blockRedstone.blockID)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (blockID == Block.anvil.blockID)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (blockID == Block.glass.blockID)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (tileEntity instanceof TileEntitySkull)
|
||||
{
|
||||
int skullType = ((TileEntitySkull)tileEntity).getSkullType();
|
||||
|
||||
switch (skullType)
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
|
||||
case 1:
|
||||
return 1;
|
||||
|
||||
case 2:
|
||||
return 2;
|
||||
|
||||
case 4:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEHomHeartRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,765 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.LifeEssenceNetwork;
|
||||
import WayofTime.alchemicalWizardry.common.rituals.Rituals;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
public class TEMasterStone extends TileEntity
|
||||
{
|
||||
private int currentRitual;
|
||||
private boolean isActive;
|
||||
private String owner;
|
||||
private int cooldown;
|
||||
private int var1;
|
||||
private int direction;
|
||||
|
||||
public TEMasterStone()
|
||||
{
|
||||
currentRitual = 0;
|
||||
isActive = false;
|
||||
owner = "";
|
||||
cooldown = 0;
|
||||
var1 = 0;
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
public void activateRitual(World world, int crystalLevel)
|
||||
{
|
||||
int testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord);
|
||||
|
||||
if (testRitual == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean testLevel = Rituals.canCrystalActivate(testRitual, crystalLevel);
|
||||
|
||||
if (!testLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
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))
|
||||
{
|
||||
//TODO Bad stuff
|
||||
return;
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
|
||||
data.markDirty();
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
}
|
||||
|
||||
cooldown = Rituals.getInitialCooldown(testRitual);
|
||||
var1 = 0;
|
||||
currentRitual = 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, currentRitual, direction);
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
|
||||
if (!testRunes)
|
||||
{
|
||||
isActive = false;
|
||||
currentRitual = 0;
|
||||
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, currentRitual);
|
||||
}
|
||||
|
||||
public void performRitual(World world, int x, int y, int z, int ritualID)
|
||||
{
|
||||
Rituals.performEffect(this, ritualID);
|
||||
/*
|
||||
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;
|
||||
|
||||
switch (ritualID)
|
||||
{
|
||||
case 1:
|
||||
if (world.isAirBlock(x, y + 1, z))
|
||||
{
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)3));
|
||||
}
|
||||
|
||||
world.setBlock(x, y + 1, z, Block.waterMoving.blockID, 0, 3);
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (world.isAirBlock(x, y + 1, z))
|
||||
{
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)3));
|
||||
}
|
||||
|
||||
world.setBlock(x, y + 1, z, Block.lavaMoving.blockID, 0, 3);
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}else
|
||||
{
|
||||
if (world.getWorldTime() % 20 != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean flag = false;
|
||||
for(int i=-1; i<=1; i++)
|
||||
{
|
||||
for(int j=-1;j<=1;j++)
|
||||
{
|
||||
int id = world.getBlockId(x+i, y + 2, z+j);
|
||||
Block block = Block.blocksList[id];
|
||||
|
||||
if (block instanceof IPlantable)
|
||||
{
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(xCoord+i, yCoord + 2, zCoord+j, (short)3));
|
||||
block.updateTick(world, x+i, y + 2, z+j, world.rand);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag)
|
||||
{
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
int d0 = 0;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)).expand(d0, d0, d0);
|
||||
axisalignedbb.maxY = Math.min((double)this.worldObj.getHeight(), (double)(this.yCoord + 1+d0));
|
||||
List list = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
|
||||
Iterator iterator = list.iterator();
|
||||
EntityLivingBase entityplayer;
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
entityplayer = (EntityLivingBase)iterator.next();
|
||||
|
||||
if (!(entityplayer.getEntityName().equals(owner)))
|
||||
{
|
||||
double xDif = entityplayer.posX - xCoord;
|
||||
double yDif = entityplayer.posY - (yCoord + 1);
|
||||
double zDif = entityplayer.posZ - zCoord;
|
||||
entityplayer.motionX=0.1*xDif;
|
||||
entityplayer.motionY=0.1*yDif;
|
||||
entityplayer.motionZ=0.1*zDif;
|
||||
entityplayer.fallDistance = 0;
|
||||
if(!(entityplayer instanceof EntityPlayer))
|
||||
{
|
||||
flag=true;
|
||||
}
|
||||
|
||||
//entityplayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.getWorldTime() % 2 == 0 && flag)
|
||||
{
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
int d0 = 5;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)).expand(d0, d0, d0);
|
||||
List list = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
|
||||
Iterator iterator = list.iterator();
|
||||
EntityLivingBase livingEntity;
|
||||
boolean flag = false;
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
livingEntity = (EntityLivingBase)iterator.next();
|
||||
|
||||
if (livingEntity instanceof EntityPlayer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(livingEntity.getEntityName().equals(owner)))
|
||||
{
|
||||
double xDif = livingEntity.posX - (xCoord + 0.5);
|
||||
double yDif = livingEntity.posY - (yCoord + 3);
|
||||
double zDif = livingEntity.posZ - (zCoord + 0.5);
|
||||
livingEntity.motionX=-0.05*xDif;
|
||||
livingEntity.motionY=-0.05*yDif;
|
||||
livingEntity.motionZ=-0.05*zDif;
|
||||
flag=true;
|
||||
//livingEntity.setVelocity(-0.05 * xDif, -0.05 * yDif, -0.05 * zDif);
|
||||
|
||||
if (world.rand.nextInt(10) == 0)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(livingEntity.posX, livingEntity.posY, livingEntity.posZ, (short)1));
|
||||
}
|
||||
|
||||
livingEntity.fallDistance = 0;
|
||||
//entityplayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.getWorldTime() % 2 == 0 && flag)
|
||||
{
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var1 == 0)
|
||||
{
|
||||
int d0 = 0;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord + 1, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 2), (double)(this.zCoord + 1)).expand(d0, d0, d0);
|
||||
List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, axisalignedbb);
|
||||
Iterator iterator = list.iterator();
|
||||
EntityItem item;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
item = (EntityItem)iterator.next();
|
||||
// double xDif = item.posX - (xCoord+0.5);
|
||||
// double yDif = item.posY - (yCoord+1);
|
||||
// double zDif = item.posZ - (zCoord+0.5);
|
||||
ItemStack itemStack = item.getEntityItem();
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack.itemID == AlchemicalWizardry.apprenticeBloodOrb.itemID)
|
||||
{
|
||||
var1 = AlchemicalWizardry.energyBlaster.itemID;
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z));
|
||||
cooldown--;
|
||||
item.setDead();
|
||||
return;
|
||||
}
|
||||
else if (itemStack.itemID == Item.swordDiamond.itemID)
|
||||
{
|
||||
var1 = AlchemicalWizardry.energySword.itemID;
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z));
|
||||
cooldown--;
|
||||
item.setDead();
|
||||
return;
|
||||
}
|
||||
else if (itemStack.itemID == Item.pickaxeDiamond.itemID)
|
||||
{
|
||||
var1 = AlchemicalWizardry.boundPickaxe.itemID;
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z));
|
||||
cooldown--;
|
||||
item.setDead();
|
||||
return;
|
||||
}
|
||||
else if (itemStack.itemID == Item.axeDiamond.itemID)
|
||||
{
|
||||
var1 = AlchemicalWizardry.boundAxe.itemID;
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z));
|
||||
cooldown--;
|
||||
item.setDead();
|
||||
return;
|
||||
}
|
||||
else if (itemStack.itemID == Item.shovelDiamond.itemID)
|
||||
{
|
||||
var1 = AlchemicalWizardry.boundShovel.itemID;
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z));
|
||||
cooldown--;
|
||||
item.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(10) == 0)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(item.posX, item.posY, item.posZ, (short)1));
|
||||
}
|
||||
}
|
||||
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
cooldown--;
|
||||
|
||||
if (world.rand.nextInt(20) == 0)
|
||||
{
|
||||
int lightningPoint = world.rand.nextInt(8);
|
||||
|
||||
switch (lightningPoint)
|
||||
{
|
||||
case 0:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 4, y + 3, z + 0));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 4, y + 3, z + 0));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 0, y + 3, z + 4));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 0, y + 3, z - 4));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z + 3));
|
||||
break;
|
||||
|
||||
case 5:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z + 3));
|
||||
break;
|
||||
|
||||
case 6:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z - 3));
|
||||
break;
|
||||
|
||||
case 7:
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z - 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown <= 0)
|
||||
{
|
||||
EntityItem newItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(var1, 1, 0));
|
||||
worldObj.spawnEntityInWorld(newItem);
|
||||
isActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
int d0 = 0;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord + 1, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 2), (double)(this.zCoord + 1)).expand(d0, d0, d0);
|
||||
List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, axisalignedbb);
|
||||
Iterator iterator = list.iterator();
|
||||
EntityItem item;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
item = (EntityItem)iterator.next();
|
||||
// double xDif = item.posX - (xCoord+0.5);
|
||||
// double yDif = item.posY - (yCoord+1);
|
||||
// double zDif = item.posZ - (zCoord+0.5);
|
||||
ItemStack itemStack = item.getEntityItem();
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack.itemID == AlchemicalWizardry.boundHelmet.itemID)
|
||||
{
|
||||
var1 = 5;
|
||||
}
|
||||
else if (itemStack.itemID == AlchemicalWizardry.boundPlate.itemID)
|
||||
{
|
||||
var1 = 8;
|
||||
}else if (itemStack.itemID == AlchemicalWizardry.boundLeggings.itemID)
|
||||
{
|
||||
var1 = 7;
|
||||
}else if (itemStack.itemID == AlchemicalWizardry.boundBoots.itemID)
|
||||
{
|
||||
var1 = 4;
|
||||
}else if(itemStack.itemID == AlchemicalWizardry.sigilOfHolding.itemID)
|
||||
{
|
||||
var1 = -1;
|
||||
}
|
||||
|
||||
if(var1>0)
|
||||
{
|
||||
item.setDead();
|
||||
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z));
|
||||
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
ItemStack[] inv = ((BoundArmour)itemStack.getItem()).getInternalInventory(itemStack);
|
||||
if(inv!=null)
|
||||
{
|
||||
for(ItemStack internalItem : inv)
|
||||
{
|
||||
if(internalItem!=null)
|
||||
{
|
||||
EntityItem newItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, internalItem.copy());
|
||||
worldObj.spawnEntityInWorld(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
EntityItem newItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(Block.blocksList[AlchemicalWizardry.bloodSocket.blockID],var1));
|
||||
worldObj.spawnEntityInWorld(newItem);
|
||||
|
||||
isActive=false;
|
||||
|
||||
break;
|
||||
}else if(var1 ==-1)
|
||||
{
|
||||
item.setDead();
|
||||
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z));
|
||||
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
ItemStack[] inv = ((SigilOfHolding)itemStack.getItem()).getInternalInventory(itemStack);
|
||||
if(inv!=null)
|
||||
{
|
||||
for(ItemStack internalItem : inv)
|
||||
{
|
||||
if(internalItem!=null)
|
||||
{
|
||||
EntityItem newItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, internalItem.copy());
|
||||
worldObj.spawnEntityInWorld(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
EntityItem newItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(AlchemicalWizardry.sigilOfHolding.itemID,1,0));
|
||||
worldObj.spawnEntityInWorld(newItem);
|
||||
|
||||
isActive=false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(10) == 0)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(TEAltar.getParticlePacket(item.posX, item.posY, item.posZ, (short)1));
|
||||
}
|
||||
}
|
||||
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (currentEssence < Rituals.getCostPerRefresh(ritualID))
|
||||
{
|
||||
EntityPlayer entityOwner = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(owner);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
else
|
||||
{
|
||||
int d0 = 0;
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord+1, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 2), (double)(this.zCoord + 1)).expand(d0, d0, d0);
|
||||
axisalignedbb.maxY = Math.min((double)this.worldObj.getHeight(), (double)(this.yCoord + 2+d0));
|
||||
List list = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
|
||||
Iterator iterator = list.iterator();
|
||||
EntityLivingBase entityplayer;
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
entityplayer = (EntityLivingBase)iterator.next();
|
||||
|
||||
if(entityplayer instanceof EntityPlayer)
|
||||
{
|
||||
PacketDispatcher.sendPacketToPlayer(PacketHandler.getPlayerVelocitySettingPacket(entityplayer.motionX, 1, entityplayer.motionZ), (Player)entityplayer);
|
||||
entityplayer.motionY=1;
|
||||
entityplayer.fallDistance = 0;
|
||||
flag=true;
|
||||
}else
|
||||
//if (!(entityplayer.getEntityName().equals(owner)))
|
||||
{
|
||||
// double xDif = entityplayer.posX - xCoord;
|
||||
// double yDif = entityplayer.posY - (yCoord + 1);
|
||||
// double zDif = entityplayer.posZ - zCoord;
|
||||
//entityplayer.motionX=0.1*xDif;
|
||||
entityplayer.motionY=1;
|
||||
//entityplayer.motionZ=0.1*zDif;
|
||||
entityplayer.fallDistance = 0;
|
||||
flag=true;
|
||||
//entityplayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.getWorldTime() % 2 == 0 && flag)
|
||||
{
|
||||
data.currentEssence = currentEssence - Rituals.getCostPerRefresh(ritualID);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.block.IOrientable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,266 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEPedestal extends TileEntity implements IInventory
|
||||
{
|
||||
private ItemStack[] inv;
|
||||
private int resultID;
|
||||
private int resultDamage;
|
||||
|
||||
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");
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(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 getInvName()
|
||||
{
|
||||
return "TEPedestal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
// 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 PacketHandler.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(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++] = is.itemID;
|
||||
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++)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)2));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,697 @@
|
|||
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.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.alchemicalWizardry.common.IDemon;
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
import WayofTime.alchemicalWizardry.common.PlinthComponent;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
|
||||
import WayofTime.alchemicalWizardry.common.summoning.SummoningRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.summoning.SummoningRegistryComponent;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
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;
|
||||
|
||||
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");
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
|
||||
int slot = tag.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < inv.length)
|
||||
{
|
||||
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList ring1TagList = par1NBTTagCompound.getTagList("ring1Inv");
|
||||
|
||||
for (int i = 0; i < ring1TagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) ring1TagList.tagAt(i);
|
||||
int slot = tag.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < inv.length)
|
||||
{
|
||||
ring1Inv[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList ring2TagList = par1NBTTagCompound.getTagList("ring2Inv");
|
||||
|
||||
for (int i = 0; i < ring2TagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) ring2TagList.tagAt(i);
|
||||
int slot = tag.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < inv.length)
|
||||
{
|
||||
ring2Inv[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList ring3TagList = par1NBTTagCompound.getTagList("ring3Inv");
|
||||
|
||||
for (int i = 0; i < ring3TagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) ring3TagList.tagAt(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 getInvName()
|
||||
{
|
||||
return "TEPlinth";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
// 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.getBlockTileEntity(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset);
|
||||
|
||||
if (tileEntity instanceof TEPedestal)
|
||||
{
|
||||
((TEPedestal)tileEntity).setInventorySlotContents(0, null);
|
||||
PacketDispatcher.sendPacketToAllInDimension(((TEPedestal)tileEntity).getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (PlinthComponent pc : pedestalPositions)
|
||||
{
|
||||
if (i < 6 && pc.getRing() == ring)
|
||||
{
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset);
|
||||
|
||||
if (tileEntity instanceof TEPedestal)
|
||||
{
|
||||
((TEPedestal)tileEntity).setInventorySlotContents(0, null);
|
||||
PacketDispatcher.sendPacketToAllInDimension(((TEPedestal)tileEntity).getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
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.getBlockTileEntity(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.itemID == possibleItem.itemID && (itemStack.getItemDamage() == possibleItem.getItemDamage() || itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE))
|
||||
{
|
||||
((TEPedestal)tileEntity).decrStackSize(0, 1);
|
||||
((TEPedestal)tileEntity).onItemDeletion();
|
||||
PacketDispatcher.sendPacketToAllInDimension(((TEPedestal)tileEntity).getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (PlinthComponent pc : pedestalPositions)
|
||||
{
|
||||
if (i < 6 && pc.getRing() == ring)
|
||||
{
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(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.itemID == possibleItem.itemID && (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);
|
||||
PacketDispatcher.sendPacketToAllInDimension(((TEPedestal)tileEntity).getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
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.getBlockTileEntity(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.getBlockTileEntity(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 PacketHandler.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(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++] = is.itemID;
|
||||
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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import net.minecraft.block.Block;
|
||||
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.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class TESocket extends TileEntity implements IInventory
|
||||
{
|
||||
private ItemStack[] inv;
|
||||
private int resultID;
|
||||
private int resultDamage;
|
||||
|
||||
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");
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(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 getInvName()
|
||||
{
|
||||
return "TESocket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
// 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 PacketHandler.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(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++] = is.itemID;
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,371 @@
|
|||
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.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
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;
|
||||
|
||||
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");
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(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 getInvName()
|
||||
{
|
||||
return "TETeleposer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
// 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.getBlockTileEntity(xf, yf, zf) instanceof TETeleposer && !worldF.getBlockTileEntity(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 PacketHandler.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(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++] = is.itemID;
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,775 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
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.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.IBindingAgent;
|
||||
import WayofTime.alchemicalWizardry.common.ICatalyst;
|
||||
import WayofTime.alchemicalWizardry.common.IFillingAgent;
|
||||
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
||||
import WayofTime.alchemicalWizardry.common.alchemy.AlchemicalPotionCreationHandler;
|
||||
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class TEWritingTable extends TileEntity implements IInventory
|
||||
{
|
||||
private ItemStack[] inv;
|
||||
private int progress;
|
||||
private int progressNeeded = 100;
|
||||
private int amountUsed;
|
||||
|
||||
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.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {}
|
||||
|
||||
@Override
|
||||
public void closeChest() {}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
NBTTagList tagList = tagCompound.getTagList("Inventory");
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(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 getInvName()
|
||||
{
|
||||
return "aw.TEWritingTable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.getPacket(this);
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload getParticlePacket(double x, double y, double z, short particleType)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
dos.writeDouble(x);
|
||||
dos.writeDouble(y);
|
||||
dos.writeDouble(z);
|
||||
dos.writeShort(particleType);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new Packet250CustomPayload("particle", bos.toByteArray());
|
||||
}
|
||||
|
||||
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(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++] = is.itemID;
|
||||
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].itemID == AlchemicalWizardry.alchemyFlask.itemID)
|
||||
{
|
||||
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].itemID == AlchemicalWizardry.blankSlate.itemID)
|
||||
{
|
||||
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)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
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 (worldTime % 4 == 0)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
if (!EnergyItems.syphonWhileInContainer(getStackInSlot(0), amountUsed))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
progress++;
|
||||
|
||||
if (progress >= progressNeeded)
|
||||
{
|
||||
progress = 0;
|
||||
this.setInventorySlotContents(6, getResultingItemStack());
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
this.decrStackSize(i + 1, 1);
|
||||
}
|
||||
|
||||
if (worldObj != null)
|
||||
{
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getStackInSlot(6).getItem().itemID == getResultingItemStack().itemID && getResultingItemStack().stackSize <= (getStackInSlot(6).getMaxStackSize() - getStackInSlot(6).stackSize))
|
||||
{
|
||||
if (worldTime % 4 == 0)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, getParticlePacket(xCoord, yCoord, zCoord, (short)1));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
this.decrStackSize(i + 1, 1);
|
||||
}
|
||||
|
||||
if (worldObj != null)
|
||||
{
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package WayofTime.alchemicalWizardry.common.tileEntity.container;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
|
||||
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 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();
|
||||
|
||||
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 < 6)
|
||||
{
|
||||
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, 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;
|
||||
}
|
||||
}
|
|
@ -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 net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
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.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof TEWritingTable)
|
||||
{
|
||||
return new ContainerWritingTable(player.inventory, (TEWritingTable) tileEntity);
|
||||
}
|
||||
|
||||
case 1:
|
||||
tileEntity = world.getBlockTileEntity(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.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof TEWritingTable)
|
||||
{
|
||||
return new GuiWritingTable(player.inventory, (TEWritingTable) tileEntity);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof TETeleposer)
|
||||
{
|
||||
return new GuiTeleposer(player.inventory, (TETeleposer)tileEntity);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
fontRenderer.drawString("Teleposer", 8, 6, 4210752);
|
||||
//draws "Inventory" or your regional equivalent
|
||||
fontRenderer.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;
|
||||
}
|
||||
}
|
|
@ -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.TEWritingTable;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerWritingTable;
|
||||
|
||||
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
|
||||
fontRenderer.drawString("Alchemic Chemistry Set", 8, 6, 4210752);
|
||||
//draws "Inventory" or your regional equivalent
|
||||
fontRenderer.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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue