mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-10-25 20:22:32 +00:00
Lossless blood orb capacity (#126)
This commit is contained in:
1 parent
88002582b9
commit
1544c1bf0d
7 files changed
+75
-16
No files matched your search
@@ -5,23 +5,28 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData {
|
||||
|
||||
public int currentEssence;
|
||||
public int maxEssence;
|
||||
public int maxOrb;
|
||||
|
||||
public LifeEssenceNetwork(String par1Str) {
|
||||
super(par1Str);
|
||||
currentEssence = 0;
|
||||
// can be lower than currentEssence (overfilled) with runes of the orb
|
||||
maxEssence = 1;
|
||||
maxOrb = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
currentEssence = nbttagcompound.getInteger("currentEssence");
|
||||
maxEssence = nbttagcompound.getInteger("maxEssence");
|
||||
maxOrb = nbttagcompound.getInteger("maxOrb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("currentEssence", currentEssence);
|
||||
nbttagcompound.setInteger("maxEssence", maxEssence);
|
||||
nbttagcompound.setInteger("maxOrb", maxOrb);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import WayofTime.alchemicalWizardry.api.event.ItemBindEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.ItemDrainInContainerEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
@@ -36,6 +37,10 @@ public class SoulNetworkHandler {
|
||||
return syphonFromNetwork(event.ownerNetwork, event.drainAmount) >= damageToBeDone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getMaxEssence(String ownerName)} to get maximum soul network capacity
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getCurrentMaxOrb(String ownerName) {
|
||||
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
if (mcServer == null) {
|
||||
@@ -53,6 +58,28 @@ public class SoulNetworkHandler {
|
||||
return data.maxOrb;
|
||||
}
|
||||
|
||||
public static int getMaxEssence(String ownerName) {
|
||||
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
if (mcServer == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = mcServer.worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.maxEssence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setMaxEssenceToMax(String ownerName, int maxEssence)} to set maximum soul network
|
||||
* capacity
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setMaxOrbToMax(String ownerName, int maxOrb) {
|
||||
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
if (mcServer == null) {
|
||||
@@ -71,6 +98,28 @@ public class SoulNetworkHandler {
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
public static void setMaxEssenceToMax(String ownerName, int maxEssence) {
|
||||
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
if (mcServer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
World world = mcServer.worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
data.maxEssence = Math.max(maxEssence, data.maxEssence);
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getMaxEssence(String ownerName)} to get maximum soul network capacity
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getMaximumForOrbTier(int maxOrb) {
|
||||
switch (maxOrb) {
|
||||
case 1:
|
||||
@@ -327,6 +376,14 @@ public class SoulNetworkHandler {
|
||||
}
|
||||
|
||||
public static boolean checkAndSetItemPlayer(ItemStack item, EntityPlayer player) {
|
||||
if (item.getItem() instanceof IBloodOrb orb) {
|
||||
String currentOwner = item.hasTagCompound() ? item.getTagCompound().getString("ownerName") : "";
|
||||
String thisPlayer = getUsername(player);
|
||||
if (currentOwner.isEmpty() || currentOwner.equals(thisPlayer)) {
|
||||
setMaxEssenceToMax(thisPlayer, orb.getMaxEssence());
|
||||
}
|
||||
}
|
||||
|
||||
if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true;
|
||||
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
@@ -482,8 +482,7 @@ public class AlchemicalWizardryEventHooks {
|
||||
NewPacketHandler.INSTANCE.sendTo(
|
||||
NewPacketHandler.getLPPacket(
|
||||
SoulNetworkHandler.getCurrentEssence(ownerName),
|
||||
SoulNetworkHandler
|
||||
.getMaximumForOrbTier(SoulNetworkHandler.getCurrentMaxOrb(ownerName))),
|
||||
SoulNetworkHandler.getMaxEssence(ownerName)),
|
||||
(EntityPlayerMP) entityLiving);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +69,15 @@ public class CommandSN extends CommandBase {
|
||||
func_152373_a(icommandsender, this, "commands.soulnetwork.get.success", currentEssence, owner);
|
||||
} else if ("fillMax".equalsIgnoreCase(astring[1])) {
|
||||
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
|
||||
int orbTier = SoulNetworkHandler.getCurrentMaxOrb(owner);
|
||||
int maxForOrb = SoulNetworkHandler.getMaximumForOrbTier(orbTier);
|
||||
int fillAmount = maxForOrb - currentEssence;
|
||||
int maxForUser = SoulNetworkHandler.getMaxEssence(owner);
|
||||
int fillAmount = maxForUser - currentEssence;
|
||||
SoulNetworkHandler.addCurrentEssenceToMaximum(owner, fillAmount, fillAmount);
|
||||
func_152373_a(icommandsender, this, "commands.soulnetwork.fillMax.success", owner);
|
||||
} else if ("create".equalsIgnoreCase(astring[1])) {
|
||||
int orbTier = parseIntBounded(icommandsender, astring[2], 1, 6);
|
||||
SoulNetworkHandler.setMaxOrbToMax(proxyPlayerName.getDisplayName(), orbTier);
|
||||
func_152373_a(icommandsender, this, "commands.soulnetwork.create.success", owner, orbTier);
|
||||
int desiredCapacity = parseInt(icommandsender, astring[2]);
|
||||
SoulNetworkHandler.setMaxEssenceToMax(proxyPlayerName.getDisplayName(), desiredCapacity);
|
||||
int actualCapacity = SoulNetworkHandler.getMaxEssence(proxyPlayerName.getDisplayName());
|
||||
func_152373_a(icommandsender, this, "commands.soulnetwork.create.success", owner, actualCapacity);
|
||||
} else {
|
||||
throw new CommandException("commands.soulnetwork.notACommand");
|
||||
}
|
||||
|
||||
+4
-6
@@ -85,9 +85,8 @@ public class SubCommandNetwork extends SubCommandBase {
|
||||
if (args.length == 3) {
|
||||
if (isInteger(args[2])) {
|
||||
int amount = Integer.parseInt(args[2]);
|
||||
int maxOrb = SoulNetworkHandler
|
||||
.getMaximumForOrbTier(SoulNetworkHandler.getCurrentMaxOrb(givenName));
|
||||
SoulNetworkHandler.addCurrentEssenceToMaximum(givenName, amount, maxOrb);
|
||||
int maxEssence = SoulNetworkHandler.getMaxEssence(givenName);
|
||||
SoulNetworkHandler.addCurrentEssenceToMaximum(givenName, amount, maxEssence);
|
||||
displaySuccessString(commandSender, "commands.network.add.success", amount, givenName);
|
||||
} else {
|
||||
displayErrorString(commandSender, "commands.error.arg.invalid");
|
||||
@@ -152,9 +151,8 @@ public class SubCommandNetwork extends SubCommandBase {
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
int maxOrb = SoulNetworkHandler
|
||||
.getMaximumForOrbTier(SoulNetworkHandler.getCurrentMaxOrb(givenName));
|
||||
SoulNetworkHandler.setCurrentEssence(givenName, maxOrb);
|
||||
int maxEssence = SoulNetworkHandler.getMaxEssence(givenName);
|
||||
SoulNetworkHandler.setCurrentEssence(givenName, maxEssence);
|
||||
displaySuccessString(commandSender, "commands.network.cap.success", givenName);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ commands.soulnetwork.noPlayer=There is no player specified
|
||||
commands.soulnetwork.noCommand=There is no command specified
|
||||
commands.soulnetwork.notACommand=That is not a valid command
|
||||
commands.soulnetwork.fillMax.success=Successfully filled %s's Soul Network to their orb max!
|
||||
commands.soulnetwork.create.success=Successfully created %s's Soul Network (Orb tier: %d)
|
||||
commands.soulnetwork.create.success=Successfully created %s's Soul Network (Capacity: %d)
|
||||
|
||||
#Tooltips
|
||||
tooltip.activationcrystal.creativeonly=Creative Only - activates any ritual
|
||||
|
||||
@@ -389,7 +389,7 @@ commands.soulnetwork.noPlayer=没有指定玩家
|
||||
commands.soulnetwork.noCommand=命令不够详细
|
||||
commands.soulnetwork.notACommand=这不是有效的命令
|
||||
commands.soulnetwork.fillMax.success=成功填满 %s 的气血宝珠!
|
||||
commands.soulnetwork.create.success=成功创建 %s 的灵魂网络(气血宝珠等级: %d)
|
||||
commands.soulnetwork.create.success=成功创建 %s 的灵魂网络(容量: %d)
|
||||
|
||||
#Tooltips
|
||||
tooltip.activationcrystal.creativeonly=创造模式独有 - 激活任何仪式
|
||||
|
||||
Reference in new issue
Block a user