This commit is contained in:
pahimar 2013-12-20 06:58:15 -05:00
parent e2378f77b6
commit f0b08b431f
26 changed files with 338 additions and 176 deletions

View file

@ -5,7 +5,6 @@ import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.command.CommandHandler;
import com.pahimar.ee3.configuration.ConfigurationHandler;
import com.pahimar.ee3.creativetab.CreativeTabEE3;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.handler.*;
import com.pahimar.ee3.helper.FluidHelper;
import com.pahimar.ee3.helper.LogHelper;
@ -162,7 +161,6 @@ public class EquivalentExchange3
public void postInit(FMLPostInitializationEvent event)
{
// NOOP
EmcRegistry.lazyInit();
}
@EventHandler

View file

@ -0,0 +1,36 @@
package com.pahimar.ee3.addon;
import com.pahimar.ee3.item.ItemAlchemicalDust;
import com.pahimar.ee3.item.ModItems;
import net.minecraft.item.ItemStack;
public class AddonEquivalentExchange3
{
public static void init()
{
addRecipes();
addPreAssignmentEmcValues();
addPostAssignmentEmcValues();
}
public static void addRecipes()
{
/**
* Alchemical Dust
*/
for (int meta = 0; meta < ItemAlchemicalDust.DEFAULT_EMC_VALUES.length; meta++)
{
AddonHandler.sendPreValueAssignment(new ItemStack(ModItems.alchemicalDust, 1, meta), ItemAlchemicalDust.DEFAULT_EMC_VALUES[meta]);
}
}
private static void addPreAssignmentEmcValues()
{
}
private static void addPostAssignmentEmcValues()
{
}
}

View file

@ -19,9 +19,9 @@ import java.util.List;
*/
public class AddonHandler
{
public static void init()
{
AddonEquivalentExchange3.init();
AddonIndustrialCraft2.init();
}

View file

@ -3,11 +3,14 @@ package com.pahimar.ee3.addon;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.helper.LogHelper;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import java.lang.reflect.InvocationTargetException;
/**
* Equivalent-Exchange-3
* <p/>
@ -17,6 +20,18 @@ import net.minecraftforge.fluids.FluidRegistry;
*/
public class AddonIndustrialCraft2
{
/**
* EmcValues for various IC2 things
*/
private static final EmcValue COPPER_EMC_VALUE = new EmcValue(72);
private static final EmcValue TIN_EMC_VALUE = new EmcValue(256);
private static final EmcValue LEAD_EMC_VALUE = new EmcValue(512);
private static final EmcValue SILVER_EMC_VALUE = new EmcValue(1024);
private static final EmcValue URANIUM_EMC_VALUE = new EmcValue(4096);
private static final EmcValue SULFUR_EMC_VALUE = new EmcValue(512);
private static final EmcValue LITHIUM_EMC_VALUE = new EmcValue(512);
private static final EmcValue SILICON_DIOXIDE_EMC_VALUE = new EmcValue(256);
private static final EmcValue RUBBER_WOOD_EMC_VALUE = new EmcValue(24);
public static void init()
{
@ -25,7 +40,7 @@ public class AddonIndustrialCraft2
addPostAssignmentEmcValues();
}
public static void addRecipes()
private static void addRecipes()
{
/**
* Bronze
@ -167,7 +182,7 @@ public class AddonIndustrialCraft2
AddonHandler.sendAddRecipe(new OreStack("itemRubber"), new OreStack("woodRubber"));
}
public static void addPreAssignmentEmcValues()
private static void addPreAssignmentEmcValues()
{
AddonHandler.sendPreValueAssignment(new OreStack("oreCopper"), COPPER_EMC_VALUE);
AddonHandler.sendPreValueAssignment(new OreStack("oreTin"), TIN_EMC_VALUE);
@ -180,26 +195,35 @@ public class AddonIndustrialCraft2
AddonHandler.sendPreValueAssignment(new OreStack("woodRubber"), RUBBER_WOOD_EMC_VALUE);
}
public static void addPostAssignmentEmcValues()
private static void addPostAssignmentEmcValues()
{
}
/**
* TODO Helper method to grab items from IC2's API
*
*/
public static Item grabIC2ItemByName(String name)
{
try
{
Object object = Class.forName("ic2.api.item.Items").getDeclaredMethod("getItem", String.class).invoke(null, name);
LogHelper.debug(object);
}
catch (NoSuchMethodException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (InvocationTargetException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
/**
* EmcValues for various IC2 things
*/
private static final EmcValue COPPER_EMC_VALUE = new EmcValue(72);
private static final EmcValue TIN_EMC_VALUE = new EmcValue(256);
private static final EmcValue LEAD_EMC_VALUE = new EmcValue(512);
private static final EmcValue SILVER_EMC_VALUE = new EmcValue(1024);
private static final EmcValue URANIUM_EMC_VALUE = new EmcValue(4096);
private static final EmcValue SULFUR_EMC_VALUE = new EmcValue(512);
private static final EmcValue LITHIUM_EMC_VALUE = new EmcValue(512);
private static final EmcValue SILICON_DIOXIDE_EMC_VALUE = new EmcValue(256);
private static final EmcValue RUBBER_WOOD_EMC_VALUE = new EmcValue(24);
return null;
}
}

View file

@ -25,7 +25,6 @@ import java.util.Random;
*/
public class BlockCalcinator extends BlockEE
{
/**
* Is the random generator used by calcinator to drop the inventory contents in random directions.
*/
@ -33,7 +32,6 @@ public class BlockCalcinator extends BlockEE
public BlockCalcinator(int id)
{
super(id, Material.rock);
this.setUnlocalizedName(Strings.CALCINATOR_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
@ -50,21 +48,18 @@ public class BlockCalcinator extends BlockEE
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileCalcinator();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@ -78,7 +73,6 @@ public class BlockCalcinator extends BlockEE
@Override
public void breakBlock(World world, int x, int y, int z, int id, int meta)
{
dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, id, meta);
}
@ -86,7 +80,6 @@ public class BlockCalcinator extends BlockEE
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (player.isSneaking())
{
return false;
@ -109,7 +102,6 @@ public class BlockCalcinator extends BlockEE
private void dropInventory(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))

View file

@ -46,7 +46,7 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
// Render
modelCalcinator.renderPart("Calcinator");
if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_INVENTORY_INDEX) != null)
if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_LEFT_INVENTORY_INDEX) != null || tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_RIGHT_INVENTORY_INDEX) != null)
{
modelCalcinator.renderPart("Dust");
}

View file

@ -2,6 +2,7 @@ package com.pahimar.ee3.emc;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.item.ModItems;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -183,6 +184,12 @@ public class EmcValuesDefault
valueMap.put(new WrappedStack(Item.netherQuartz), new EmcValue(256));
/* Equivalent Exchange 3 */
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 0)), new EmcValue(0.001f));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 1)), new EmcValue(256));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 2)), new EmcValue(2048));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 3)), new EmcValue(8192));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 4)), new EmcValue(73728));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 5)), new EmcValue(4718592));
}
public static Map<WrappedStack, EmcValue> getDefaultValueMap()

View file

@ -17,10 +17,8 @@ import net.minecraft.tileentity.TileEntityFurnace;
*/
public class ContainerCalcinator extends Container
{
public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileCalcinator calcinator)
{
// Add the fuel slot to the container
this.addSlotToContainer(new Slot(calcinator, TileCalcinator.FUEL_INVENTORY_INDEX, 56, 62));
@ -28,7 +26,8 @@ public class ContainerCalcinator extends Container
this.addSlotToContainer(new Slot(calcinator, TileCalcinator.INPUT_INVENTORY_INDEX, 56, 17));
// Add the output results slot to the container
this.addSlotToContainer(new SlotCalcinator(calcinator, TileCalcinator.OUTPUT_INVENTORY_INDEX, 116, 35));
this.addSlotToContainer(new SlotCalcinator(calcinator, TileCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, 116, 35));
this.addSlotToContainer(new SlotCalcinator(calcinator, TileCalcinator.OUTPUT_RIGHT_INVENTORY_INDEX, 136, 35));
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex)
@ -49,14 +48,12 @@ public class ContainerCalcinator extends Container
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack itemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
@ -73,7 +70,6 @@ public class ContainerCalcinator extends Container
*/
if (slotIndex < TileCalcinator.INVENTORY_SIZE)
{
if (!this.mergeItemStack(slotItemStack, TileCalcinator.INVENTORY_SIZE, inventorySlots.size(), false))
{
return null;
@ -81,7 +77,6 @@ public class ContainerCalcinator extends Container
}
else
{
/**
* If the stack being shift-clicked into the Aludel's container
* is a fuel, first try to put it in the fuel slot. If it cannot
@ -90,7 +85,7 @@ public class ContainerCalcinator extends Container
*/
if (TileEntityFurnace.isItemFuel(slotItemStack))
{
if (!this.mergeItemStack(slotItemStack, TileCalcinator.FUEL_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false))
if (!this.mergeItemStack(slotItemStack, TileCalcinator.FUEL_INVENTORY_INDEX, TileCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, false))
{
return null;
}
@ -99,7 +94,7 @@ public class ContainerCalcinator extends Container
/**
* Finally, attempt to put stack into the input slot
*/
else if (!this.mergeItemStack(slotItemStack, TileCalcinator.INPUT_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false))
else if (!this.mergeItemStack(slotItemStack, TileCalcinator.INPUT_INVENTORY_INDEX, TileCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, false))
{
return null;
}

View file

@ -11,7 +11,6 @@ import net.minecraft.item.ItemStack;
*/
public interface IChargeable
{
public abstract short getCharge(ItemStack stack);
public abstract void setCharge(ItemStack stack, short charge);

View file

@ -12,6 +12,5 @@ import net.minecraft.item.ItemStack;
*/
public interface IKeyBound
{
public abstract void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding);
}

View file

@ -13,7 +13,6 @@ import net.minecraft.world.World;
*/
public interface ITransmutationStone
{
public abstract void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack);
public abstract void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack);

View file

@ -24,15 +24,13 @@ import net.minecraft.world.World;
*/
public class ItemAlchemicalBag extends ItemEE
{
private static final String[] ALCHEMICAL_BAG_SUBTYPES = new String[]{"Open", "OpenDrawString", "Closed", "ClosedDrawString"};
private static final String[] ALCHEMICAL_BAG_ICONS = {"Open", "OpenDrawString", "Closed", "ClosedDrawString"};
@SideOnly(Side.CLIENT)
private Icon[] icons;
public ItemAlchemicalBag(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
@ -42,19 +40,17 @@ public class ItemAlchemicalBag extends ItemEE
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
icons = new Icon[ALCHEMICAL_BAG_ICONS.length];
icons = new Icon[ALCHEMICAL_BAG_SUBTYPES.length];
for (int i = 0; i < ALCHEMICAL_BAG_SUBTYPES.length; ++i)
for (int i = 0; i < ALCHEMICAL_BAG_ICONS.length; ++i)
{
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME + ALCHEMICAL_BAG_SUBTYPES[i]);
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME + ALCHEMICAL_BAG_ICONS[i]);
}
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
{
if (!world.isRemote)
{
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN, true);
@ -67,7 +63,6 @@ public class ItemAlchemicalBag extends ItemEE
@Override
public boolean getShareTag()
{
return true;
}
@ -75,14 +70,12 @@ public class ItemAlchemicalBag extends ItemEE
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
return true;
}
@Override
public Icon getIcon(ItemStack itemStack, int renderPass)
{
// If the bag is open
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
{
@ -113,7 +106,6 @@ public class ItemAlchemicalBag extends ItemEE
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int renderPass)
{
if (renderPass == 1)
{
return Integer.parseInt(Colours.PURE_WHITE, 16);
@ -133,27 +125,19 @@ public class ItemAlchemicalBag extends ItemEE
public boolean hasColor(ItemStack itemStack)
{
return ItemHelper.hasColor(itemStack);
}
public int getColor(ItemStack itemStack)
{
return ItemHelper.getColor(itemStack);
}
public void setColor(ItemStack itemStack, int color)
{
if (itemStack != null)
{
if (!(itemStack.getItem() instanceof ItemAlchemicalBag))
// TODO Localize
{
throw new UnsupportedOperationException("Cannot dye non-bags!");
}
else
if (itemStack.getItem() instanceof ItemAlchemicalBag)
{
ItemHelper.setColor(itemStack, color);
}
@ -162,20 +146,16 @@ public class ItemAlchemicalBag extends ItemEE
public void removeColor(ItemStack itemStack)
{
if (itemStack != null)
{
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound != null)
{
NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
if (displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR))
{
displayTagCompound.removeTag(Strings.NBT_ITEM_COLOR);
}
}

View file

@ -5,10 +5,8 @@ import com.pahimar.ee3.lib.Strings;
public class ItemAlchemicalChalk extends ItemEE
{
public ItemAlchemicalChalk(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_CHALK_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);

View file

@ -1,6 +1,7 @@
package com.pahimar.ee3.item;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.lib.Strings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -11,6 +12,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import java.util.ArrayList;
import java.util.List;
/**
@ -22,15 +24,21 @@ import java.util.List;
*/
public class ItemAlchemicalDust extends ItemEE
{
private static final String[] ALCHEMICAL_DUST_NAMES = new String[]{"Ash", "Minium", "Verdant", "Azure", "Amaranthine", "Iridescent"};
public static final String[] ALCHEMICAL_DUST_NAMES = {"Ash", "Minium", "Verdant", "Azure", "Amaranthine", "Iridescent"};
public static final EmcValue[] DEFAULT_EMC_VALUES = {
new EmcValue(0.1f),
new EmcValue(256),
new EmcValue(2048),
new EmcValue(8192),
new EmcValue(73728),
new EmcValue(4718592)
};
@SideOnly(Side.CLIENT)
private Icon[] icons;
public ItemAlchemicalDust(int id)
{
super(id);
this.setHasSubtypes(true);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
@ -40,16 +48,7 @@ public class ItemAlchemicalDust extends ItemEE
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
StringBuilder unlocalizedName = new StringBuilder();
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 5);
unlocalizedName.append("item.");
unlocalizedName.append(Strings.RESOURCE_PREFIX);
unlocalizedName.append(Strings.ALCHEMICAL_DUST_NAME);
unlocalizedName.append(ALCHEMICAL_DUST_NAMES[meta]);
return unlocalizedName.toString();
return String.format("item.%s%s%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, ALCHEMICAL_DUST_NAMES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1)]);
}
@Override
@ -59,56 +58,61 @@ public class ItemAlchemicalDust extends ItemEE
*/
public Icon getIconFromDamage(int meta)
{
int j = MathHelper.clamp_int(meta, 0, 5);
return icons[j];
return icons[MathHelper.clamp_int(meta, 0, ALCHEMICAL_DUST_NAMES.length - 1)];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
icons = new Icon[ALCHEMICAL_DUST_NAMES.length];
for (int i = 0; i < ALCHEMICAL_DUST_NAMES.length; ++i)
{
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_DUST_NAME + ALCHEMICAL_DUST_NAMES[i]);
icons[i] = iconRegister.registerIcon(String.format("%s%s%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, ALCHEMICAL_DUST_NAMES[i]));
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack)
public boolean hasEffect(ItemStack stack, int renderPass)
{
int meta = MathHelper.clamp_int(stack.getItemDamage(), 0, 5);
return meta == 5;
return MathHelper.clamp_int(stack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1) == 5;
}
@Override
public String getItemDisplayName(ItemStack itemStack)
{
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 5);
switch (meta)
switch (MathHelper.clamp_int(itemStack.getItemDamage(), 0, ALCHEMICAL_DUST_NAMES.length - 1))
{
case 0:
{
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
}
case 1:
{
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
}
case 2:
{
return EnumChatFormatting.GREEN + super.getItemDisplayName(itemStack);
}
case 3:
{
return EnumChatFormatting.BLUE + super.getItemDisplayName(itemStack);
}
case 4:
{
return EnumChatFormatting.DARK_PURPLE + super.getItemDisplayName(itemStack);
}
case 5:
{
return EnumChatFormatting.GOLD + super.getItemDisplayName(itemStack);
}
default:
{
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
}
}
}
@ -117,10 +121,17 @@ public class ItemAlchemicalDust extends ItemEE
@SideOnly(Side.CLIENT)
public void getSubItems(int id, CreativeTabs creativeTab, List list)
{
for (int meta = 0; meta < 6; ++meta)
for (int meta = 0; meta < ALCHEMICAL_DUST_NAMES.length; ++meta)
{
list.add(new ItemStack(id, 1, meta));
}
}
@Override
public List<ItemStack> getSubTypes()
{
List<ItemStack> alchemicalDustStacks = new ArrayList<ItemStack>();
return alchemicalDustStacks;
}
}

View file

@ -5,6 +5,9 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.List;
/**
* Equivalent-Exchange-3
@ -15,10 +18,8 @@ import net.minecraft.item.Item;
*/
public class ItemEE extends Item
{
public ItemEE(int id)
{
super(id - Reference.SHIFTED_ID_RANGE_CORRECTION);
maxStackSize = 1;
setNoRepair();
@ -28,7 +29,11 @@ public class ItemEE extends Item
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
public List<ItemStack> getSubTypes()
{
return null;
}
}

View file

@ -12,10 +12,8 @@ import com.pahimar.ee3.lib.Strings;
*/
public class ItemInertStone extends ItemEE
{
public ItemInertStone(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.INERT_STONE_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);

View file

@ -12,10 +12,8 @@ import com.pahimar.ee3.lib.Strings;
*/
public class ItemMiniumShard extends ItemEE
{
public ItemMiniumShard(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.MINIUM_SHARD_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);

View file

@ -20,13 +20,10 @@ import net.minecraft.world.World;
*
* @author pahimar
*/
public class ItemMiniumStone extends ItemEE
implements ITransmutationStone, IKeyBound
public class ItemMiniumStone extends ItemEE implements ITransmutationStone, IKeyBound
{
public ItemMiniumStone(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.MINIUM_STONE_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
@ -35,42 +32,37 @@ public class ItemMiniumStone extends ItemEE
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack itemStack)
public boolean hasEffect(ItemStack itemStack, int renderPass)
{
return ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN) || ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
}
@Override
public String getItemDisplayName(ItemStack itemStack)
{
return EnumChatFormatting.BLUE + super.getItemDisplayName(itemStack);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)
{
return false;
}
@Override
public boolean getShareTag()
{
return true;
}
@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
ItemStack copiedStack = itemStack.copy();
copiedStack.setItemDamage(copiedStack.getItemDamage() + 1);
// Hacky hacky hack hack
// TODO Is this still necessary?
copiedStack.stackSize = 1;
return copiedStack;
@ -79,7 +71,6 @@ public class ItemMiniumStone extends ItemEE
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ)
{
if (world.isRemote)
{
transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
@ -90,7 +81,6 @@ public class ItemMiniumStone extends ItemEE
@Override
public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack)
{
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN, true);
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
}
@ -98,7 +88,6 @@ public class ItemMiniumStone extends ItemEE
@Override
public void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack)
{
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN, true);
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_TRANSMUTATION, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
}
@ -106,14 +95,12 @@ public class ItemMiniumStone extends ItemEE
@Override
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
{
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, sideHit);
}
@Override
public void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding)
{
if (keyBinding.equals(ConfigurationSettings.KEYBINDING_EXTRA))
{
if (!thePlayer.isSneaking())

View file

@ -24,15 +24,12 @@ import net.minecraft.world.World;
*
* @author pahimar
*/
public class ItemPhilosophersStone extends ItemEE
implements ITransmutationStone, IChargeable, IKeyBound
public class ItemPhilosophersStone extends ItemEE implements ITransmutationStone, IChargeable, IKeyBound
{
private int maxChargeLevel;
public ItemPhilosophersStone(int id)
{
super(id);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.PHILOSOPHERS_STONE_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
@ -42,42 +39,37 @@ public class ItemPhilosophersStone extends ItemEE
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack itemStack)
public boolean hasEffect(ItemStack itemStack, int renderPass)
{
return ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN) || ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
}
@Override
public String getItemDisplayName(ItemStack itemStack)
{
return EnumChatFormatting.YELLOW + super.getItemDisplayName(itemStack);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)
{
return false;
}
@Override
public boolean getShareTag()
{
return true;
}
@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
ItemStack copiedStack = itemStack.copy();
copiedStack.setItemDamage(copiedStack.getItemDamage() + 1);
// Hacky hacky hack hack
// TODO Is this still necessary?
copiedStack.stackSize = 1;
return copiedStack;
@ -86,7 +78,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ)
{
if (world.isRemote)
{
transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
@ -97,7 +88,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack)
{
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN, true);
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
}
@ -105,7 +95,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack)
{
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN, true);
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_TRANSMUTATION, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
}
@ -113,21 +102,18 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
{
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, sideHit);
}
@Override
public short getCharge(ItemStack stack)
{
return ItemStackNBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY);
}
@Override
public void setCharge(ItemStack stack, short charge)
{
if (charge <= maxChargeLevel)
{
ItemStackNBTHelper.setShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY, charge);
@ -137,7 +123,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void increaseCharge(ItemStack stack)
{
if (ItemStackNBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) < maxChargeLevel)
{
ItemStackNBTHelper.setShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY, (short) (ItemStackNBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) + 1));
@ -147,7 +132,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void decreaseCharge(ItemStack stack)
{
if (ItemStackNBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) > 0)
{
ItemStackNBTHelper.setShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY, (short) (ItemStackNBTHelper.getShort(stack, Strings.NBT_ITEM_CHARGE_LEVEL_KEY) - 1));
@ -157,7 +141,6 @@ public class ItemPhilosophersStone extends ItemEE
@Override
public void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding)
{
if (keyBinding.equals(ConfigurationSettings.KEYBINDING_EXTRA))
{
if (!thePlayer.isSneaking())

View file

@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
*/
public class ModItems
{
// Mod item instances
public static Item miniumShard;
public static Item inertStone;
@ -28,7 +27,6 @@ public class ModItems
public static void init()
{
// Initialize each mod item individually
miniumShard = new ItemMiniumShard(ItemIds.MINIUM_SHARD);
inertStone = new ItemInertStone(ItemIds.INERT_STONE);

View file

@ -0,0 +1,32 @@
package com.pahimar.ee3.recipe;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.emc.EmcValue;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
/**
* Equivalent-Exchange-3
* <p/>
* CalcinationManager
*
* @author pahimar
*/
public class CalcinationManager
{
public static List<ItemStack> getCalcinationResult(ItemStack itemStack)
{
List<ItemStack> calcinationResults = new ArrayList<ItemStack>();
EmcValue emcValue = EmcRegistry.getEmcValue(itemStack);
if (emcValue != null)
{
// TODO The magic happens here
}
return calcinationResults;
}
}

View file

@ -1,12 +0,0 @@
package com.pahimar.ee3.recipe;
/**
* Equivalent-Exchange-3
* <p/>
* RecipesCalcinator
*
* @author pahimar
*/
public class RecipesCalcinator {
}

View file

@ -1,10 +1,16 @@
package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.lib.Strings;
import net.minecraft.block.BlockFurnace;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntityFurnace;
import java.util.ArrayList;
import java.util.List;
/**
* Equivalent-Exchange-3
@ -20,11 +26,16 @@ public class TileCalcinator extends TileEE implements IInventory
*/
private ItemStack[] inventory;
public static final int INVENTORY_SIZE = 3;
public static final int INVENTORY_SIZE = 4;
public static final int FUEL_INVENTORY_INDEX = 0;
public static final int INPUT_INVENTORY_INDEX = 1;
public static final int OUTPUT_INVENTORY_INDEX = 2;
public static final int OUTPUT_LEFT_INVENTORY_INDEX = 2;
public static final int OUTPUT_RIGHT_INVENTORY_INDEX = 3;
public int remainingBurnTime; // How much longer the Calcinator will burn
public int currentFuelsFuelValue; // The fuel value for the currently burning fuel
public int currentItemCookTime; // How long the current item has been "cooking"
public TileCalcinator()
{
@ -37,7 +48,6 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public int getSizeInventory()
{
return inventory.length;
}
@ -76,7 +86,6 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex)
{
ItemStack itemStack = getStackInSlot(slotIndex);
if (itemStack != null)
{
@ -88,7 +97,6 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
{
inventory[slotIndex] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
@ -99,14 +107,12 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public String getInvName()
{
return this.hasCustomName() ? this.getCustomName() : Strings.CONTAINER_CALCINATOR_NAME;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@ -125,7 +131,6 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
super.readFromNBT(nbtTagCompound);
// Read in the ItemStacks in the inventory from NBT
@ -145,7 +150,6 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
super.writeToNBT(nbtTagCompound);
// Write the ItemStacks in the inventory to NBT
@ -166,21 +170,160 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public boolean isInvNameLocalized()
{
return this.hasCustomName();
}
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
{
return true;
}
@Override
public void updateEntity()
{
boolean isBurning = this.remainingBurnTime > 0;
boolean calcinationOccured = false;
if (this.remainingBurnTime > 0)
{
--this.remainingBurnTime;
}
if (!this.worldObj.isRemote)
{
if (this.remainingBurnTime == 0 && this.canCalcinate())
{
this.currentFuelsFuelValue = this.remainingBurnTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
if (this.remainingBurnTime > 0)
{
calcinationOccured = true;
if (this.inventory[INPUT_INVENTORY_INDEX] != null)
{
--this.inventory[INPUT_INVENTORY_INDEX].stackSize;
if (this.inventory[INPUT_INVENTORY_INDEX].stackSize == 0)
{
this.inventory[INPUT_INVENTORY_INDEX] = this.inventory[INPUT_INVENTORY_INDEX].getItem().getContainerItemStack(inventory[INPUT_INVENTORY_INDEX]);
}
}
}
}
if (this.isBurning() && this.canCalcinate())
{
++this.currentItemCookTime;
if (this.currentItemCookTime == 200)
{
this.currentItemCookTime = 0;
this.calcinateItem();
calcinationOccured = true;
}
}
else
{
this.currentItemCookTime = 0;
}
if (isBurning != this.remainingBurnTime > 0)
{
calcinationOccured = true;
BlockFurnace.updateFurnaceBlockState(this.remainingBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); // TODO Customize
}
}
if (calcinationOccured)
{
this.onInventoryChanged();
}
}
public boolean isBurning()
{
return this.remainingBurnTime > 0;
}
/**
* Determines if with the current inventory we can calcinate an item into dusts
*
* @return
*/
private boolean canCalcinate()
{
if (inventory[INPUT_INVENTORY_INDEX] == null)
{
return false;
}
else
{
// TODO Calcination Manager integration
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
/**
* If we don't get a calcination result, then return false
*/
if (itemstack == null)
{
return false;
}
/**
* If either slot is empty, return true (we have a valid calcination result
*/
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null || this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null)
{
return true;
}
if (!this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(itemstack) && !this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(itemstack))
{
return false;
}
int result = inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + itemstack.stackSize;
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
}
}
public void calcinateItem()
{
if (this.canCalcinate())
{
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = itemstack.copy();
}
else if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(itemstack))
{
inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += itemstack.stackSize;
}
--this.inventory[INPUT_INVENTORY_INDEX].stackSize;
if (this.inventory[INPUT_INVENTORY_INDEX].stackSize <= 0)
{
this.inventory[INPUT_INVENTORY_INDEX] = null;
}
}
}
private List<ItemStack> getDustForItemStack(ItemStack cookedItemStack)
{
List<ItemStack> dustList = new ArrayList<ItemStack>();
return null;
}
@Override
// TODO This is not an ideal toString
public String toString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(super.toString());

View file

@ -18,14 +18,12 @@ import net.minecraftforge.common.ForgeDirection;
*/
public class TileEE extends TileEntity
{
protected ForgeDirection orientation;
protected byte state;
protected String customName;
public TileEE()
{
orientation = ForgeDirection.SOUTH;
state = 0;
customName = "";
@ -45,7 +43,6 @@ public class TileEE extends TileEntity
public void setOrientation(int orientation)
{
this.orientation = ForgeDirection.getOrientation(orientation);
}
@ -63,7 +60,6 @@ public class TileEE extends TileEntity
public boolean hasCustomName()
{
return customName != null && customName.length() > 0;
}
@ -81,14 +77,12 @@ public class TileEE extends TileEntity
public boolean isUseableByPlayer(EntityPlayer player)
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
super.readFromNBT(nbtTagCompound);
if (nbtTagCompound.hasKey(Strings.NBT_TE_DIRECTION_KEY))
@ -110,7 +104,6 @@ public class TileEE extends TileEntity
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
super.writeToNBT(nbtTagCompound);
nbtTagCompound.setByte(Strings.NBT_TE_DIRECTION_KEY, (byte) orientation.ordinal());
@ -125,7 +118,6 @@ public class TileEE extends TileEntity
@Override
public Packet getDescriptionPacket()
{
return PacketTypeHandler.populatePacket(new PacketTileUpdate(xCoord, yCoord, zCoord, orientation, state, customName));
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB