use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent in project BloodMagic by WayofTime.
the class BlockBelljar method getSubBlocks.
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
if (this.equals(ModBlocks.blockCrystalBelljar)) {
par3List.add(new ItemStack(par1, 1, 0));
for (Reagent reagent : ReagentRegistry.reagentList.values()) {
ItemStack stack = new ItemStack(par1, 1, 0);
NBTTagCompound tag = new NBTTagCompound();
ReagentContainer[] tanks = new ReagentContainer[1];
tanks[0] = new ReagentContainer(reagent, 16000, 16000);
NBTTagList tagList = new NBTTagList();
NBTTagCompound savedTag = new NBTTagCompound();
if (tanks[0] != null) {
tanks[0].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
tag.setTag("reagentTanks", tagList);
stack.setTagCompound(tag);
par3List.add(stack);
}
} else {
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent in project BloodMagic by WayofTime.
the class RitualEffectOmegaStalling method performEffect.
@Override
public void performEffect(IMasterRitualStone ritualStone) {
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % 20 != 0) {
return;
}
TileEntity tile = world.getTileEntity(x, y + 5, z);
if (tile instanceof TileEntityBeacon) {
int levels = ((TileEntityBeacon) tile).getLevels();
if (levels >= 4) {
int horizontalRadius = 100;
int verticalRadius = 100;
List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius);
for (EntityPlayer player : playerList) {
if (SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh())) {
Reagent reagent = APISpellHelper.getPlayerReagentType(player);
OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
if (parad != null) {
float costOffset = parad.getCostPerTickOfUse(player);
parad.setOmegaStalling(player, 100);
SoulNetworkHandler.syphonFromNetwork(owner, (int) (getCostPerRefresh() * Math.min(costOffset, 1)));
}
}
}
}
}
}
use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent in project BloodMagic by WayofTime.
the class RitualEffectOmegaTest method performEffect.
@Override
public void performEffect(IMasterRitualStone ritualStone) {
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % 200 != 0) {
return;
}
OmegaStructureParameters param = OmegaStructureHandler.getStructureStabilityFactor(world, x, y, z, 5, new Int3(0, 1, 0));
int stab = param.stability;
int enchantability = param.enchantability;
int enchantmentLevel = param.enchantmentLevel;
if (stab <= 0) {
return;
}
// System.out.println("Stability: " + stab + ", Enchantability: " + enchantability + ", Enchantment Level: " + enchantmentLevel);
double range = 0.5;
List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 1.5, z + 0.5, range, range);
Reagent reagent = null;
Map<Reagent, Integer> reagentMap = new HashMap();
for (int i = 0; i < 4; i++) {
Int3 jarLoc = this.getJarLocation(i);
TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
if (tile instanceof IReagentHandler) {
IReagentHandler container = (IReagentHandler) tile;
ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP);
if (containerInfoArray == null) {
continue;
}
for (ReagentContainerInfo containerInfo : containerInfoArray) {
ReagentStack containedReagent = containerInfo.reagent;
if (containedReagent == null) {
continue;
}
Reagent rea = containedReagent.reagent;
int amt = containedReagent.amount;
if (reagentMap.containsKey(rea)) {
reagentMap.put(rea, reagentMap.get(rea) + amt);
} else {
reagentMap.put(rea, amt);
}
}
}
}
for (Entry<Reagent, Integer> entry : reagentMap.entrySet()) {
if (entry.getValue() >= drainTotal) {
reagent = entry.getKey();
break;
}
}
if (reagent == null) {
return;
}
int tickDuration = isTesting ? 20 * 30 : 15 * 20 * 60 + (int) ((15 * 20 * 60) * Math.sqrt(stab / 700));
int affinity = 0;
for (EntityPlayer player : playerList) {
OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent);
if (waterParadigm != null && waterParadigm.convertPlayerArmour(player, x, y, z, stab, affinity, enchantability, enchantmentLevel)) {
APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration);
APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration);
APISpellHelper.setPlayerReagentType(player, reagent);
APISpellHelper.setCurrentAdditionalMaxHP(player, waterParadigm.getMaxAdditionalHealth());
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(reagent, APISpellHelper.getPlayerCurrentReagentAmount(player), APISpellHelper.getPlayerMaxReagentAmount(player)), (EntityPlayerMP) player);
if (!isTesting) {
int drainLeft = this.drainTotal;
for (int i = 0; i < 4; i++) {
if (drainLeft <= 0) {
break;
}
Int3 jarLoc = this.getJarLocation(i);
TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
if (tile instanceof IReagentHandler) {
IReagentHandler container = (IReagentHandler) tile;
ReagentStack drained = container.drain(ForgeDirection.UP, new ReagentStack(reagent, drainLeft), true);
if (drained != null) {
drainLeft -= drained.amount;
world.markBlockForUpdate(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
world.addWeatherEffect(new EntityLightningBolt(world, x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord));
}
}
}
ritualStone.setActive(false);
}
break;
}
}
}
use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent in project BloodMagic by WayofTime.
the class TEMasterStone method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setBoolean("isActive", isActive);
tag.setString("owner", owner);
tag.setInteger("cooldown", cooldown);
tag.setInteger("var1", var1);
tag.setInteger("direction", direction);
tag.setString("currentRitualString", currentRitualString);
tag.setBoolean("isRunning", isRunning);
tag.setInteger("runningTime", runningTime);
NBTTagList tagList = new NBTTagList();
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);
}
tag.setTag("reagentTanks", tagList);
NBTTagList attunedTagList = new NBTTagList();
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);
}
tag.setTag("attunedTankMap", attunedTagList);
tag.setTag("customRitualTag", customRitualTag);
if (storage != null) {
NBTTagCompound localStorageTag = new NBTTagCompound();
storage.writeToNBT(localStorageTag);
tag.setTag("localStorage", localStorageTag);
}
}
use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent in project BloodMagic by WayofTime.
the class TEMasterStone method drain.
@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())) {
ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
if (drainStack != null) {
drained += drainStack.amount;
}
}
}
return new ReagentStack(reagent, drained);
}
Aggregations