Anti-comments sweep!

This commit is contained in:
Tombenpotter 2014-10-13 22:33:20 +02:00
parent e6a10f3f06
commit dea1f87078
454 changed files with 23594 additions and 26739 deletions

View file

@ -1,9 +1,10 @@
package WayofTime.alchemicalWizardry.common.tileEntity;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.*;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -17,16 +18,10 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class TEMasterStone extends TileEntity implements IMasterRitualStone
{
@ -39,17 +34,17 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
private int direction;
public boolean isRunning;
public int runningTime;
private NBTTagCompound customRitualTag;
protected ReagentContainer[] tanks;
protected Map<Reagent, Integer> attunedTankMap;
public TEMasterStone()
{
tanks = new ReagentContainer[]{new ReagentContainer(1000),new ReagentContainer(1000),new ReagentContainer(1000)};
this.attunedTankMap = new HashMap();
tanks = new ReagentContainer[]{new ReagentContainer(1000), new ReagentContainer(1000), new ReagentContainer(1000)};
this.attunedTankMap = new HashMap();
isActive = false;
owner = "";
cooldown = 0;
@ -59,49 +54,49 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
currentRitualString = "";
isRunning = false;
runningTime = 0;
this.customRitualTag = new NBTTagCompound();
}
public void readClientNBT(NBTTagCompound tag)
{
currentRitualString = tag.getString("currentRitualString");
currentRitualString = tag.getString("currentRitualString");
isRunning = tag.getBoolean("isRunning");
runningTime = tag.getInteger("runningTime");
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
int size = tagList.tagCount();
this.tanks = new ReagentContainer[size];
for(int i=0; i<size; i++)
for (int i = 0; i < size; i++)
{
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
}
}
public void writeClientNBT(NBTTagCompound tag)
{
tag.setString("currentRitualString", currentRitualString);
tag.setString("currentRitualString", currentRitualString);
tag.setBoolean("isRunning", isRunning);
tag.setInteger("runningTime",runningTime);
tag.setInteger("runningTime", runningTime);
NBTTagList tagList = new NBTTagList();
for(int i=0; i<this.tanks.length; i++)
for (int i = 0; i < this.tanks.length; i++)
{
NBTTagCompound savedTag = new NBTTagCompound();
if(this.tanks[i] != null)
{
this.tanks[i].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
NBTTagCompound savedTag = new NBTTagCompound();
if (this.tanks[i] != null)
{
this.tanks[i].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
}
tag.setTag("reagentTanks", tagList);
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
@ -114,27 +109,27 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
currentRitualString = tag.getString("currentRitualString");
isRunning = tag.getBoolean("isRunning");
runningTime = tag.getInteger("runningTime");
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
int size = tagList.tagCount();
this.tanks = new ReagentContainer[size];
for(int i=0; i<size; i++)
for (int i = 0; i < size; i++)
{
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
}
NBTTagList attunedTagList = tag.getTagList("attunedTankMap", Constants.NBT.TAG_COMPOUND);
for(int i=0; i<attunedTagList.tagCount(); i++)
for (int i = 0; i < attunedTagList.tagCount(); i++)
{
NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
}
customRitualTag = tag.getCompoundTag("customRitualTag");
}
@ -149,49 +144,49 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
tag.setInteger("direction", direction);
tag.setString("currentRitualString", currentRitualString);
tag.setBoolean("isRunning", isRunning);
tag.setInteger("runningTime",runningTime);
tag.setInteger("runningTime", runningTime);
NBTTagList tagList = new NBTTagList();
for(int i=0; i<this.tanks.length; i++)
for (int i = 0; i < this.tanks.length; i++)
{
NBTTagCompound savedTag = new NBTTagCompound();
if(this.tanks[i] != null)
{
this.tanks[i].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
NBTTagCompound savedTag = new NBTTagCompound();
if (this.tanks[i] != null)
{
this.tanks[i].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
}
tag.setTag("reagentTanks", tagList);
NBTTagList attunedTagList = new NBTTagList();
for(Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet())
for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet())
{
NBTTagCompound savedTag = new NBTTagCompound();
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
savedTag.setInteger("amount", entry.getValue());
attunedTagList.appendTag(savedTag);
NBTTagCompound savedTag = new NBTTagCompound();
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
savedTag.setInteger("amount", entry.getValue());
attunedTagList.appendTag(savedTag);
}
tag.setTag("attunedTankMap", attunedTagList);
tag.setTag("customRitualTag", customRitualTag);
}
public void activateRitual(World world, int crystalLevel, EntityPlayer player)
{
if (world.isRemote)
if (world.isRemote)
{
return;
}
String testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord);
if (testRitual.equals(""))
{
player.addChatMessage(new ChatComponentText("Nothing appears to have happened..."));
player.addChatMessage(new ChatComponentText("Nothing appears to have happened..."));
return;
}
@ -199,7 +194,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (!testLevel)
{
player.addChatMessage(new ChatComponentText("Your crystal vibrates pathetically."));
player.addChatMessage(new ChatComponentText("Your crystal vibrates pathetically."));
return;
}
@ -217,30 +212,30 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (currentEssence < Rituals.getCostForActivation(testRitual))
{
player.addChatMessage(new ChatComponentText("You feel a pull, but you are too weak to push any further."));
player.addChatMessage(new ChatComponentText("You feel a pull, but you are too weak to push any further."));
return;
}
if (!world.isRemote)
{
if(!Rituals.startRitual(this, testRitual, player))
{
player.addChatMessage(new ChatComponentText("The ritual appears to actively resist you!"));
return;
}else
{
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
if (!Rituals.startRitual(this, testRitual, player))
{
player.addChatMessage(new ChatComponentText("The ritual appears to actively resist you!"));
return;
} else
{
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
data.markDirty();
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
for (int i = 0; i < 12; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
}
}
}
cooldown = Rituals.getInitialCooldown(testRitual);
@ -259,20 +254,20 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
public void useOnRitualBroken()
{
Rituals.onRitualBroken(this, this.currentRitualString);
Rituals.onRitualBroken(this, this.currentRitualString);
}
@Override
public void updateEntity()
{
if(isRunning && runningTime < 100)
{
runningTime++;
}else if(!isRunning && runningTime > 0)
{
runningTime--;
}
if (isRunning && runningTime < 100)
{
runningTime++;
} else if (!isRunning && runningTime > 0)
{
runningTime--;
}
if (!isActive)
{
return;
@ -292,7 +287,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (!testRunes)
{
Rituals.onRitualBroken(this, currentRitualString);
Rituals.onRitualBroken(this, currentRitualString);
isActive = false;
currentRitualString = "";
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
@ -302,19 +297,19 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0)
{
if(isRunning)
{
isRunning = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
if (isRunning)
{
isRunning = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return;
}else
} else
{
if(!isRunning)
{
isRunning = true;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
if (!isRunning)
{
isRunning = true;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
performRitual(worldObj, xCoord, yCoord, zCoord, currentRitualString);
@ -362,174 +357,168 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
return this.direction;
}
@Override
public World getWorld()
{
return this.getWorldObj();
}
@Override
public World getWorld()
{
return this.getWorldObj();
}
@Override
public int getXCoord()
{
return xCoord;
}
@Override
public int getXCoord()
{
return xCoord;
}
@Override
public int getYCoord()
{
return yCoord;
}
@Override
public int getYCoord()
{
return yCoord;
}
@Override
public int getZCoord()
{
return zCoord;
}
public String getCurrentRitual()
{
return this.currentRitualString;
}
public void setCurrentRitual(String str)
{
this.currentRitualString = str;
}
// @Override
// public Packet getDescriptionPacket()
// {
// return NewPacketHandler.getPacket(this);
// }
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeClientNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
{
super.onDataPacket(net, packet);
readClientNBT(packet.func_148857_g());
}
public AxisAlignedBB getRenderBoundingBox()
{
double renderExtention = 1.0d;
AxisAlignedBB bb = AxisAlignedBB. getBoundingBox(xCoord-renderExtention, yCoord-renderExtention, zCoord-renderExtention, xCoord+1+renderExtention, yCoord+1+renderExtention, zCoord+1+renderExtention);
return bb;
}
/* ISegmentedReagentHandler */
@Override
public int getZCoord()
{
return zCoord;
}
public String getCurrentRitual()
{
return this.currentRitualString;
}
public void setCurrentRitual(String str)
{
this.currentRitualString = str;
}
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeClientNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
{
super.onDataPacket(net, packet);
readClientNBT(packet.func_148857_g());
}
public AxisAlignedBB getRenderBoundingBox()
{
double renderExtention = 1.0d;
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord - renderExtention, yCoord - renderExtention, zCoord - renderExtention, xCoord + 1 + renderExtention, yCoord + 1 + renderExtention, zCoord + 1 + renderExtention);
return bb;
}
/* ISegmentedReagentHandler */
@Override
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
{
if(doFill)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
int totalFill = 0;
boolean useTankLimit = !this.attunedTankMap.isEmpty();
if(resource != null)
{
int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length;
int tanksFilled = 0;
if (doFill)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
int maxFill = resource.amount;
for(int i=this.tanks.length-1; i>=0; i--)
{
ReagentStack remainingStack = resource.copy();
remainingStack.amount = maxFill - totalFill;
boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack);
if(doesReagentMatch)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
}else
{
continue;
}
if(totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
if(tanksFilled >= totalTanksFillable)
{
return totalFill;
}
for(int i=this.tanks.length-1; i>=0; i--)
{
ReagentStack remainingStack = resource.copy();
remainingStack.amount = maxFill - totalFill;
boolean isTankEmpty = tanks[i].getReagent() == null;
if(isTankEmpty)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
}else
{
continue;
}
if(totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
}
int totalFill = 0;
boolean useTankLimit = !this.attunedTankMap.isEmpty();
if (resource != null)
{
int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length;
int tanksFilled = 0;
int maxFill = resource.amount;
for (int i = this.tanks.length - 1; i >= 0; i--)
{
ReagentStack remainingStack = resource.copy();
remainingStack.amount = maxFill - totalFill;
boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack);
if (doesReagentMatch)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
} else
{
continue;
}
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
if (tanksFilled >= totalTanksFillable)
{
return totalFill;
}
for (int i = this.tanks.length - 1; i >= 0; i--)
{
ReagentStack remainingStack = resource.copy();
remainingStack.amount = maxFill - totalFill;
boolean isTankEmpty = tanks[i].getReagent() == null;
if (isTankEmpty)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
} else
{
continue;
}
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
}
return totalFill;
}
@Override
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
{
if(resource == null)
{
return null;
}
if(doDrain)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
int maxDrain = resource.amount;
Reagent reagent = resource.reagent;
int drained = 0;
for(int i=0; i<tanks.length; i++)
{
if(drained >= maxDrain)
{
break;
}
if (resource.isReagentEqual(tanks[i].getReagent()))
if (resource == null)
{
return null;
}
if (doDrain)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
int maxDrain = resource.amount;
Reagent reagent = resource.reagent;
int drained = 0;
for (int i = 0; i < tanks.length; i++)
{
if (drained >= maxDrain)
{
ReagentStack drainStack = tanks[i].drain(maxDrain-drained, doDrain);
if(drainStack != null)
{
drained += drainStack.amount;
}
break;
}
}
if (resource.isReagentEqual(tanks[i].getReagent()))
{
ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
if (drainStack != null)
{
drained += drainStack.amount;
}
}
}
return new ReagentStack(reagent, drained);
}
@ -537,21 +526,21 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
@Override
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
for(int i=0; i<tanks.length; i++)
{
ReagentStack stack = tanks[i].drain(maxDrain, doDrain);
if(stack != null)
{
if(doDrain)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return stack;
}
}
return null;
for (int i = 0; i < tanks.length; i++)
{
ReagentStack stack = tanks[i].drain(maxDrain, doDrain);
if (stack != null)
{
if (doDrain)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return stack;
}
}
return null;
}
@Override
@ -569,70 +558,70 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
@Override
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
{
ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()];
for(int i=0; i<this.getNumberOfTanks(); i++)
{
info[i] = tanks[i].getInfo();
}
ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()];
for (int i = 0; i < this.getNumberOfTanks(); i++)
{
info[i] = tanks[i].getInfo();
}
return info;
}
@Override
public int getNumberOfTanks()
{
return tanks.length;
}
@Override
public int getNumberOfTanks()
{
return tanks.length;
}
@Override
public int getTanksTunedToReagent(Reagent reagent)
{
if(this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null)
{
return this.attunedTankMap.get(reagent);
}
return 0;
}
@Override
public int getTanksTunedToReagent(Reagent reagent)
{
if (this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null)
{
return this.attunedTankMap.get(reagent);
}
return 0;
}
@Override
public void setTanksTunedToReagent(Reagent reagent, int total)
{
if(total == 0 && this.attunedTankMap.containsKey(reagent))
{
this.attunedTankMap.remove(reagent);
return;
}
this.attunedTankMap.put(reagent, new Integer(total));
}
@Override
public void setTanksTunedToReagent(Reagent reagent, int total)
{
if (total == 0 && this.attunedTankMap.containsKey(reagent))
{
this.attunedTankMap.remove(reagent);
return;
}
@Override
public Map<Reagent, Integer> getAttunedTankMap()
{
return this.attunedTankMap;
}
public boolean areTanksEmpty()
{
for(int i=0; i<this.tanks.length; i++)
{
if(tanks[i] != null && tanks[i].getReagent() != null)
{
return false;
}
}
return true;
}
this.attunedTankMap.put(reagent, new Integer(total));
}
@Override
public NBTTagCompound getCustomRitualTag()
{
return this.customRitualTag;
}
@Override
public Map<Reagent, Integer> getAttunedTankMap()
{
return this.attunedTankMap;
}
@Override
public void setCustomRitualTag(NBTTagCompound tag)
{
this.customRitualTag = tag;
}
public boolean areTanksEmpty()
{
for (int i = 0; i < this.tanks.length; i++)
{
if (tanks[i] != null && tanks[i].getReagent() != null)
{
return false;
}
}
return true;
}
@Override
public NBTTagCompound getCustomRitualTag()
{
return this.customRitualTag;
}
@Override
public void setCustomRitualTag(NBTTagCompound tag)
{
this.customRitualTag = tag;
}
}