Added the Resolute Ivy.

This commit is contained in:
Lizbeth Rika committed 2015-03-31 22:10:31 +01:00
1 parent 188c1024f6
commit 6987de56b6
8 files changed
+181

No files matched your search

@@ -15,6 +15,7 @@ import net.minecraft.item.Item;
import net.minecraft.util.StatCollector;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.item.ItemKeepIvy;
import vazkii.botania.common.item.ItemRegenIvy;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -31,6 +32,8 @@ public final class TooltipHandler {
if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemRegenIvy.TAG_REGEN, false))
event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasIvy"));
if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemKeepIvy.TAG_KEEP, false))
event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasKeepIvy"));
}
}
@@ -91,6 +91,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
addItem(ModItems.slingshot);
addItem(ModItems.vineBall);
addItem(ModItems.regenIvy);
addItem(ModItems.keepIvy);
addItem(ModItems.worldSeed);
addItem(ModItems.overgrowthSeed);
addBlock(ModBlocks.enchantedSoil);
@@ -0,0 +1,68 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Mar 31, 2015, 9:23:22 PM (GMT)]
*/
package vazkii.botania.common.crafting.recipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import vazkii.botania.api.item.IPhantomInkable;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.item.ItemKeepIvy;
import vazkii.botania.common.item.ModItems;
public class KeepIvyRecipe implements IRecipe {
@Override
public boolean matches(InventoryCrafting var1, World var2) {
boolean foundIvy = false;
boolean foundItem = false;
for(int i = 0; i < var1.getSizeInventory(); i++) {
ItemStack stack = var1.getStackInSlot(i);
if(stack != null) {
if(stack.getItem() == ModItems.keepIvy)
foundIvy = true;
else if(!foundItem)
foundItem = true;
else return false;
}
}
return foundIvy && foundItem;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1) {
ItemStack item = null;
for(int i = 0; i < var1.getSizeInventory(); i++) {
ItemStack stack = var1.getStackInSlot(i);
if(stack != null && stack.getItem() != ModItems.keepIvy)
item = stack;
}
ItemStack copy = item.copy();
ItemNBTHelper.setBoolean(copy, ItemKeepIvy.TAG_KEEP, true);
return copy;
}
@Override
public int getRecipeSize() {
return 10;
}
@Override
public ItemStack getRecipeOutput() {
return null;
}
}
@@ -0,0 +1,104 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Mar 31, 2015, 9:11:23 PM (GMT)]
*/
package vazkii.botania.common.item;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.crafting.recipe.KeepIvyRecipe;
import vazkii.botania.common.lib.LibItemNames;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemKeepIvy extends ItemMod {
public static final String TAG_KEEP = "Botania_keepIvy";
private static final String TAG_PLAYER_KEPT_DROPS = "Botania_playerKeptDrops";
private static final String TAG_DROP_COUNT = "dropCount";
private static final String TAG_DROP_PREFIX = "dropPrefix";
public ItemKeepIvy() {
setUnlocalizedName(LibItemNames.KEEP_IVY);
GameRegistry.addRecipe(new KeepIvyRecipe());
RecipeSorter.register("botania:keepIvy", KeepIvyRecipe.class, Category.SHAPELESS, "");
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onPlayerDrops(PlayerDropsEvent event) {
List<EntityItem> keeps = new ArrayList();
for(EntityItem item : event.drops) {
ItemStack stack = item.getEntityItem();
if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false))
keeps.add(item);
}
if(keeps.size() > 0) {
event.drops.removeAll(keeps);
NBTTagCompound cmp = new NBTTagCompound();
cmp.setInteger(TAG_DROP_COUNT, keeps.size());
int i = 0;
for(EntityItem keep : keeps) {
ItemStack stack = keep.getEntityItem();
NBTTagCompound cmp1 = new NBTTagCompound();
stack.writeToNBT(cmp1);
cmp.setTag(TAG_DROP_PREFIX + i, cmp1);
i++;
}
NBTTagCompound data = event.entityPlayer.getEntityData();
if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG))
data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound());
NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp);
}
}
@SubscribeEvent
public void onPlayerRespawn(PlayerRespawnEvent event) {
NBTTagCompound data = event.player.getEntityData();
if(data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) {
NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS);
int count = cmp1.getInteger(TAG_DROP_COUNT);
for(int i = 0; i < count; i++) {
NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i);
ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2);
if(stack != null) {
ItemStack copy = stack.copy();
ItemNBTHelper.setBoolean(copy, TAG_KEEP, false);
event.player.inventory.addItemStackToInventory(copy);
}
}
cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound());
}
}
}
@@ -230,6 +230,7 @@ public final class ModItems {
public static Item lokiRing;
public static Item aesirRing;
public static Item dice;
public static Item keepIvy;
public static void init() {
lexicon = new ItemLexicon();
@@ -356,6 +357,7 @@ public final class ModItems {
lokiRing = new ItemLokiRing();
aesirRing = new ItemAesirRing();
dice = new ItemDice();
keepIvy = new ItemKeepIvy();
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
for(int i = 0; i < 16; i++) {
@@ -137,6 +137,7 @@ public final class LibItemNames {
public static final String LOKI_RING = "lokiRing";
public static final String AESIR_RING = "aesirRing";
public static final String DICE = "dice";
public static final String KEEP_IVY = "keepIvy";
public static final String[] LENS_NAMES = new String[] {
"lensNormal",