Option to skip empty slots in Sigil of Holding (#807)

* Option to skip empty slots in Sigil of Holding
This commit is contained in:
Arcaratus 2016-06-17 18:46:33 -04:00 committed by Nick Ignoffo
parent 466f26d80b
commit 6680e8be49
3 changed files with 45 additions and 9 deletions

View file

@ -142,6 +142,7 @@ public class ConfigHandler
// Client
public static boolean alwaysRenderRoutingLines;
public static boolean invisibleSpectralBlocks;
public static boolean sigilHoldingSkipsEmptySlots;
// Compat
public static int wailaAltarDisplayMode;
@ -290,6 +291,7 @@ public class ConfigHandler
config.addCustomCategoryComment(category, "Client only settings");
alwaysRenderRoutingLines = config.getBoolean("alwaysRenderRoutingLines", category, false, "Always renders the beams between routing nodes. If false, only renders while a Node Router is being held.");
invisibleSpectralBlocks = config.get(category, "invisibleSpectralBlocks", true, "Spectral Blocks (Used by the Suppression Sigil to store fluids) will not render at all. If false, a see through texture will render. [default: true]").setRequiresMcRestart(true).getBoolean();
sigilHoldingSkipsEmptySlots = config.getBoolean( "sigilHoldingSkipsEmptySlots", category, false, "The Sigil of Holding will skip empty sigil slots if set to true.");
category = "Compatibility";
config.addCustomCategoryComment(category, "Compatibility settings");

View file

@ -219,15 +219,14 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
}
}
public static ItemStack getCurrentSigil(ItemStack itemStack)
public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot)
{
if (itemStack.getItem() instanceof ItemSigilHolding)
{
ItemStack[] itemStacks = getInternalInventory(itemStack);
if (itemStacks != null)
{
return itemStacks[getCurrentItemOrdinal(itemStack)];
}
return itemStacks[slot == 5 ? 4 : slot];
else return null;
}
return null;
@ -279,12 +278,41 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable
return inv;
}
public static void cycleSigil(ItemStack itemStack, int mode)
public static void cycleToNextSigil(ItemStack itemStack, int mode)
{
if (itemStack.getItem() instanceof ItemSigilHolding)
{
initModeTag(itemStack);
itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, mode);
int index;
int currentIndex = getCurrentItemOrdinal(itemStack);
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
if (currentItemStack == null)
return;
if (mode < 0)
{
index = next(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
{
index = next(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
}
else
{
index = prev(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack == null)
{
index = prev(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
}
itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, index);
}
}

View file

@ -5,6 +5,7 @@ import java.util.List;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.ConfigHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
@ -168,9 +169,14 @@ public class ClientHandler
private void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel)
{
int mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode);
ItemSigilHolding.cycleSigil(stack, mode);
int mode = dWheel;
if (ConfigHandler.sigilHoldingSkipsEmptySlots)
{
mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode);
}
ItemSigilHolding.cycleToNextSigil(stack, mode);
BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode));
}