Implemented "Shift + Left Click" for ItemDiviner to get previous Ritual

This commit is contained in:
Berknam 2014-10-09 00:17:13 +01:00
parent 297567a417
commit f7026a0800
2 changed files with 49 additions and 0 deletions

View file

@ -384,6 +384,27 @@ public class Rituals
return firstKey;
}
public static String getPreviousRitualKey(String key)
{
boolean hasSpotted = false;
String lastKey = keyList.get(keyList.size()-1);
for(String str : keyList)
{
if(str.equals(key))
{
hasSpotted = true;
}
if(hasSpotted)
{
return lastKey;
}
lastKey = str;
}
return lastKey;
}
public static MRSRenderer getRendererForKey(String ritualID)
{

View file

@ -5,6 +5,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -257,6 +258,33 @@ public class ItemRitualDiviner extends EnergyItems
return par1ItemStack;
}
@Override
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
{
if(entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entityLiving;
if(player.isSneaking() && !player.isSwingInProgress)
{
int maxRitualID = Rituals.getNumberOfRituals();
String currentRitualID = this.getCurrentRitual(stack);
this.setCurrentRitual(stack, Rituals.getPreviousRitualKey(currentRitualID));
if (entityLiving.worldObj.isRemote)
{
IChatComponent chatmessagecomponent = new ChatComponentText("Current Ritual: " + Rituals.getNameOfRitual(this.getCurrentRitual(stack)));
//chatmessagecomponent.func_111072_b("Current Essence: " + data.currentEssence + "LP");
//chatmessagecomponent.addText("Current Ritual: " + Rituals.getNameOfRitual(this.getCurrentRitual(par1ItemStack)));
player.addChatComponentMessage(chatmessagecomponent);
}
}
}
return false;
}
public String getCurrentRitual(ItemStack par1ItemStack)
{
if (par1ItemStack.stackTagCompound == null)