More work on in world transmuting, and some initial work on making the

Minium Stone take durability damage.
This commit is contained in:
pahimar 2012-06-29 15:46:39 -04:00
parent e32a973380
commit 8de2738317
5 changed files with 53 additions and 25 deletions

View file

@ -13,14 +13,13 @@ public class CraftingHandler implements ICraftingHandler {
@Override
public void onTakenFromCrafting(EntityPlayer player, ItemStack stack, IInventory craftMatrix) {
// TODO Auto-generated method stub
ItemStack currentItemStack;
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
currentItemStack = craftMatrix.getStackInSlot(i);
if (currentItemStack != null) {
if (currentItemStack.itemID == ModItems.philStone.shiftedIndex) {
if (currentItemStack.itemID == ModItems.miniumStone.shiftedIndex) {
System.out.println(currentItemStack.getItem().getItemName());
ItemPhilosopherStone stone = (ItemPhilosopherStone) currentItemStack.getItem();
currentItemStack.damageItem(1, player);
}
}
}

View file

@ -105,7 +105,7 @@ public class RecipesPhilStone {
/* 8 Iron Block <-> 1 Gold Block */
addRecipe(blockGold, transmutationStone, blockSteel, blockSteel, blockSteel, blockSteel, blockSteel, blockSteel, blockSteel, blockSteel);
addRecipe(new ItemStack(blockSteel), 8, transmutationStone, blockGold);
addRecipe(new ItemStack(blockSteel, 8), transmutationStone, blockGold);
/* 4 Gold Block <-> 1 Diamond Block */
addRecipe(blockDiamond, transmutationStone, blockGold, blockGold, blockGold, blockGold);

View file

@ -0,0 +1,35 @@
package ee3.core.helper;
import ee3.lib.Sounds;
import ee3.lib.TransmuteEquivalencyList;
import net.minecraft.src.Block;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.World;
public class TransmutationHelper {
public static boolean transmuteInWorld(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z) {
int id = world.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlockMaterial(x, y, z) == Material.leaves) {
meta = meta % 4;
}
ItemStack nextItem = TransmuteEquivalencyList.getNextBlockInEquivalencyList(id, meta, entityPlayer.isSneaking());
if (nextItem != null) {
if (Block.blocksList[nextItem.itemID] != null) {
world.setBlockAndMetadataWithNotify(x, y, z, nextItem.itemID, nextItem.getItemDamage());
world.playSoundAtEntity(entityPlayer, Sounds.TRANSMUTE, 0.5F, 1.0F);
return true;
}
}
return false;
}
}

View file

@ -2,46 +2,32 @@ package ee3.item;
import java.util.ArrayList;
import net.minecraft.src.Block;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.World;
import ee3.core.mod_EE3;
import ee3.core.helper.Helper;
import ee3.core.helper.TransmutationHelper;
import ee3.core.interfaces.ITransmuteStone;
import ee3.lib.CustomItemRarity;
import ee3.lib.Sounds;
import ee3.lib.TransmuteEquivalencyList;
public class ItemMiniumStone extends ItemEE implements ITransmuteStone {
public ItemMiniumStone(int i) {
super(i);
this.setMaxDamage(50);
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world,
int x, int y, int z, int l) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l) {
boolean result = TransmutationHelper.transmuteInWorld(itemStack, entityPlayer, world, x, y, z);
int id = world.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlockMaterial(x, y, z) == Material.leaves)
meta = meta % 4;
ItemStack nextItem = TransmuteEquivalencyList.getNextBlockInEquivalencyList(id, meta, entityPlayer.isSneaking());
if (nextItem != null) {
if (Block.blocksList[nextItem.itemID] != null) {
world.setBlockAndMetadataWithNotify(x, y, z, nextItem.itemID, nextItem.getItemDamage());
}
if (result) {
itemStack.damageItem(1, entityPlayer);
}
world.playSoundAtEntity(entityPlayer, Sounds.TRANSMUTE, 0.5F, 1.0F);
return false;
return result;
}
/*

View file

@ -1,12 +1,15 @@
package ee3.item;
import ee3.core.mod_EE3;
import ee3.core.helper.TransmutationHelper;
import ee3.core.interfaces.IItemChargeable;
import ee3.core.interfaces.IItemModal;
import ee3.core.interfaces.ITransmuteStone;
import ee3.lib.CustomItemRarity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
/**
* TODO Class Description
@ -27,6 +30,11 @@ public class ItemPhilosopherStone extends ItemEE implements IItemChargeable, IIt
maxMode = 2;
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l) {
return TransmutationHelper.transmuteInWorld(itemStack, entityPlayer, world, x, y, z);
}
/*
* Returns the custom item rarity type for the item
* @see net.minecraft.src.Item#getRarity(net.minecraft.src.ItemStack)