Magic capsules!

This commit is contained in:
MysteriousAges committed 2013-01-10 22:40:04 -08:00
1 parent b49fbd7ccc
commit 2e6964af8e
7 files changed
+196 -37

No files matched your search

+2 -2
View File
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sun Jan 06 16:13:04 PST 2013
build.number=57
#Thu Jan 10 21:53:25 PST 2013
build.number=60
+1 -1
View File
@@ -17,7 +17,7 @@
<property name="mc.version" value="1.4.7"/>
<property name="forge.version" value="6.6.0.491"/>
<property name="thaumicbees.version" value="1.0.701"/>
<property name="thaumicbees.version" value="1.1.702"/>
<!-- for local deployment only, not used by main -->
<property name="deploy.type" value="previews" />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 51 KiB

+170 -23
View File
@@ -1,13 +1,23 @@
package thaumicbees.item;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.recipes.RecipeManagers;
import thaumicbees.main.CommonProxy;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;
public class ItemCapsule extends Item
{
@@ -27,30 +37,34 @@ public class ItemCapsule extends Item
}
}
public enum Liquids
public enum Liquid
{ // Incidentally, Item meta is the liquid ID.
EMPTY("", 16),
WATER("water", 17),
LAVA("lava", 18),
BIOMASS("biomass", 19),
BIOFUEL("biofuel", 20),
OIL("oil", 21),
FUEL("fuel", 22),
SEEDOIL("seedoil", 23),
HONEY("honey", 24),
JUICE("juice", 25),
MILK("milk", 26),
EMPTY("", "Empty", 16),
WATER("water", "Water", 17),
LAVA("lava", "Lava", 18),
BIOMASS("biomass", "Biomass", 19),
BIOFUEL("biofuel", "Biofuel", 20),
OIL("Oil", "Oil", 21),
FUEL("Fuel", "Fuel", 22),
SEEDOIL("seedoil", "Seed Oil", 23),
HONEY("honey", "Honey", 24),
JUICE("juice", "Juice", 25),
CRUSHEDICE("", "Crushed Ice", 26),
MILK("milk", "Milk", 27),
;
public String liquidId;
public String liquidID;
public String displayName;
public int iconIdx;
public boolean available = true;
private Liquids(String l, int idx)
private Liquid(String l, String display, int idx)
{
this.liquidId = l;
this.liquidID = l;
this.displayName = display;
this.iconIdx = idx;
}
}
private Type capsuleType;
public ItemCapsule(Type type, int itemId)
@@ -58,7 +72,73 @@ public class ItemCapsule extends Item
super(itemId);
this.capsuleType = type;
this.setTextureFile(CommonProxy.TCBEES_LIQUIDS_IMAGE);
this.setCreativeTab(CreativeTabs.tabMaterials);
this.setCreativeTab(CreativeTabs.tabMisc);
this.setHasSubtypes(true);
}
@Override
public String getItemDisplayName(ItemStack itemStack)
{
return Liquid.values()[itemStack.getItemDamage()].displayName + " " + this.capsuleType.name;
}
public ItemStack getCapsuleForLiquid(Liquid l)
{
return new ItemStack(this, 1, l.ordinal());
}
public void setUpLiquids()
{
ItemStack empty = new ItemStack(this, 1, 0);
ItemStack filled;
LiquidStack liquid = null;
for (Liquid l : Liquid.values())
{
switch (l)
{
case EMPTY:
liquid = null;
break;
case WATER:
liquid = new LiquidStack(Block.waterStill, this.capsuleType.capacity);
break;
case LAVA:
liquid = new LiquidStack(Block.lavaStill, this.capsuleType.capacity);
break;
default:
liquid = LiquidDictionary.getLiquid(l.liquidID, this.capsuleType.capacity);
break;
}
if (liquid != null)
{
filled = new ItemStack(this, 1, l.ordinal());
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(liquid, filled, empty));
// Register with Squeezer/Bottler
RecipeManagers.bottlerManager.addRecipe(5, liquid, empty, filled);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] {filled} , liquid,
ItemManager.wax.getStackForType(ItemWax.WaxType.MAGIC), 20);
}
else
{
l.available = false;
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs tab, List itemList)
{
for (Liquid l : Liquid.values())
{
if (l.available)
{
itemList.add(new ItemStack(this, 1, l.ordinal()));
}
}
}
@Override
@@ -73,9 +153,9 @@ public class ItemCapsule extends Item
public int getIconFromDamageForRenderPass(int metadata, int pass)
{
int index = 0;
if (pass == 1)
if (pass == 0)
{
index = Liquids.values()[metadata].iconIdx;
index = Liquid.values()[metadata].iconIdx;
}
else
{
@@ -89,13 +169,80 @@ public class ItemCapsule extends Item
{
return 2;
}
@Override
/* @Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, true);
if (mop != null && mop.typeOfHit == EnumMovingObjectType.TILE)
{
int i = mop.blockX;
int j = mop.blockY;
int k = mop.blockZ;
int targetedId = world.getBlockId(i, j, k);
int targetedMeta = world.getBlockMetadata(i, j, k);
// Check whether there is valid container for the liquid.
LiquidContainerData container = LiquidHelper.getEmptyContainer(itemStack, new LiquidStack(targetedId, 2, targetedMeta));
if (container != null)
{
// Search for a slot to stow a filled container in player's
// inventory
int slot = getMatchingItemSlot(player, container.filled);
if (slot >= 0)
{
if (player.inventory.getStackInSlot(slot) == null)
{
player.inventory.setInventorySlotContents(slot, container.filled.copy());
}
else
{
player.inventory.getStackInSlot(slot).stackSize++;
}
// Remove consumed empty container
itemStack.stackSize--;
// Notify player that his inventory has changed.
Proxies.net.inventoryChangeNotify(player);
}
}
}
return itemStack;
}
private int getMatchingItemSlot(EntityPlayer player, ItemStack itemStack)
{
int matchingSlot = -1;
int emptySlot = -1;
ItemStack[] inventory = player.inventory.mainInventory;
for (int i = 0; i < inventory.length; ++i)
{
// Check to see if this is an empty slot.
if (inventory[i] == null)
{
// Set our empty Slot counter if not already set.
if (emptySlot == -1)
{
emptySlot = i;
}
}
else
{
// See if contents of slot matches our target itemStack.
}
}
if (matchingSlot == -1)
{
matchingSlot = emptySlot;
}
return matchingSlot;
}*/
}
@@ -32,16 +32,6 @@ public class ItemManager
//----- Liquid Capsules --------------------
public static ItemCapsule magicCapsule;
public static ItemCapsule magicCapsuleWater;
public static ItemCapsule magicCapsuleLava;
public static ItemCapsule magicCapsuleBiomass;
public static ItemCapsule magicCapsuleBiofuel;
public static ItemCapsule magicCapsuleOil;
public static ItemCapsule magicCapsuleFuel;
public static ItemCapsule magicCapsuleSeedOil;
public static ItemCapsule magicCapsuleHoney;
public static ItemCapsule magicCapsuleJuice;
public static ItemCapsule magicCapsuleIce;
//----- Thaumcraft Items -------------------
public static Item tcFilledJar;
@@ -70,6 +60,7 @@ public class ItemManager
ItemManager.drops = new ItemDrop(configFile.getItem("drop", itemIDBase++).getInt());
ItemManager.miscResources = new ItemMiscResources(configFile.getItem("miscResources", itemIDBase++).getInt());
// 0x8700C6 = purpleish.
BackpackDefinition def = new BackpackDefinition("thaumaturge", "Thaumaturge's Backpack", 0x8700C6);
ItemManager.thaumaturgeBackpackT1 =
BackpackManager.backpackInterface.addBackpack(configFile.getItem("thaumaturgePack1", itemIDBase++).getInt(),
@@ -77,11 +68,15 @@ public class ItemManager
ItemManager.thaumaturgeBackpackT2 =
BackpackManager.backpackInterface.addBackpack(configFile.getItem("thaumaturgePack2", itemIDBase++).getInt(),
def, EnumBackpackType.T2);
ItemManager.magicCapsule = new ItemCapsule(ItemCapsule.Type.MAGIC, configFile.getItem("magicCapsule", itemIDBase++).getInt());
}
public static void setupCrafting()
{
ItemStack inputStack; // Variable to hold forestry items
// Essentia bottles
ItemStack output = new ItemStack(tcEssentiaBottle);
output.stackSize = 8;
GameRegistry.addRecipe(output, new Object[]
@@ -99,6 +94,14 @@ public class ItemManager
'W', ItemManager.wax
});
// Magic capsules
output = new ItemStack(magicCapsule); output.stackSize = 4;
GameRegistry.addRecipe(output, new Object[]
{
"WWW",
'W', ItemManager.wax.getStackForType(ItemWax.WaxType.MAGIC)
});
output = new ItemStack(tcMiscResource, 1, ThaumcraftCompat.TCMiscResource.KNOWLEDGE_FRAGMENT.ordinal());
GameRegistry.addShapelessRecipe(output, new Object[]
{
@@ -208,5 +211,11 @@ public class ItemManager
BeeManager.inducers.put(output, 80);
}
public static void postInit()
{
// Forestry liquids aren't registered until PostInit, that's why we wait until now to register them.
ItemManager.magicCapsule.setUpLiquids();
}
}
@@ -84,6 +84,9 @@ public class ThaumicBees
@Mod.PostInit
public void postInit(FMLPostInitializationEvent event)
{
// Item Manager has a couple tasks left to it at this point...
ItemManager.postInit();
// Forestry has init'd by this point.
MinecraftForge.EVENT_BUS.register(this);
}
@@ -9,6 +9,6 @@ public class VersionInfo
public static final String Logo = "/gfx/thaumicbees/logo.png";
public static final String Depends = "required-after:Forestry@[1.7.0.1,);required-after:Thaumcraft@[3.0.1c,)";
public static final String Depends = "required-after:Forestry@[1.7.0.2,);required-after:Thaumcraft@[3.0.1c,)";
}