Calcinators now produce dust

This commit is contained in:
pahimar 2013-12-23 22:13:57 -05:00
parent b69954c4c5
commit 60423c1421
10 changed files with 145 additions and 49 deletions

View file

@ -26,7 +26,6 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
if (tileEntity instanceof TileCalcinator)
{
TileCalcinator tileCalcinator = (TileCalcinator) tileEntity;
@ -46,9 +45,39 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
// Render
modelCalcinator.renderPart("Calcinator");
if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_LEFT_INVENTORY_INDEX) != null || tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_RIGHT_INVENTORY_INDEX) != null)
if (tileCalcinator.getCombinedOutputSize() > 0)
{
GL11.glPushMatrix();
// Reverse previous rotation to get back into a workable frame of reference
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glRotatef(-45F, 0F, 1F, 0F);
// TODO Handle colouring the dusts as per their meta in the calcinator inventory
GL11.glColor3b((byte) 32, (byte) 128, (byte) 192);
if (tileCalcinator.getCombinedOutputSize() <= 32)
{
GL11.glScalef(0.25F, 0.25F, 0.25F);
GL11.glTranslatef(0.0F, 2.20F, -2.1125F);
}
else if (tileCalcinator.getCombinedOutputSize() <= 64)
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(-0.0125F, 0.75F, -0.7125F);
}
else if (tileCalcinator.getCombinedOutputSize() <= 128)
{
// NOOP
}
// Reapply previous rotation to get it back to a viewable state
GL11.glRotatef(45F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
// Render the dust in the Calcinator bowl
modelCalcinator.renderPart("Dust");
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_LIGHTING);

View file

@ -33,6 +33,7 @@ public class ItemConfiguration
ItemIds.ALCHEMICAL_DUST = itemConfiguration.getItem(Strings.ALCHEMICAL_DUST_NAME, ItemIds.ALCHEMICAL_DUST_DEFAULT).getInt(ItemIds.ALCHEMICAL_DUST_DEFAULT);
ItemIds.ALCHEMICAL_BAG = itemConfiguration.getItem(Strings.ALCHEMICAL_BAG_NAME, ItemIds.ALCHEMICAL_BAG_DEFAULT).getInt(ItemIds.ALCHEMICAL_BAG_DEFAULT);
ItemIds.ALCHEMICAL_CHALK = itemConfiguration.getItem(Strings.ALCHEMICAL_CHALK_NAME, ItemIds.ALCHEMICAL_CHALK_DEFAULT).getInt(ItemIds.ALCHEMICAL_CHALK_DEFAULT);
ItemIds.DIVINING_ROD = itemConfiguration.getItem(Strings.DIVINING_ROD_NAME, ItemIds.DIVINING_ROD_DEFAULT).getInt(ItemIds.DIVINING_ROD_DEFAULT);
/* Item durability configs */
ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY = itemConfiguration.get(CATEGORY_DURABILITY, ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_CONFIGNAME, ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_DEFAULT).getInt(ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_DEFAULT);

View file

@ -35,7 +35,6 @@ public class ItemHelper
*/
public static boolean equals(ItemStack first, ItemStack second)
{
return (comparator.compare(first, second) == 0);
}
@ -46,24 +45,21 @@ public class ItemHelper
public static String toString(ItemStack itemStack)
{
if (itemStack != null)
{
return String.format("%sxitemStack[%s:%s:%s:%s]", itemStack.stackSize, itemStack.itemID, itemStack.getItemDamage(), itemStack.getUnlocalizedName(), itemStack.getItem().getClass().getCanonicalName());
}
return "itemStack[null]";
return "null";
}
public static boolean hasColor(ItemStack itemStack)
{
return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) && itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR);
}
public static int getColor(ItemStack itemStack)
{
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null)
@ -80,7 +76,6 @@ public class ItemHelper
public static void setColor(ItemStack itemStack, int color)
{
if (itemStack != null)
{
@ -106,7 +101,6 @@ public class ItemHelper
public static void dropMiniumShard(EntityPlayer player, EntityLivingBase entity)
{
if (GeneralHelper.isHostileEntity(entity))
{
rand = Math.random();

View file

@ -0,0 +1,15 @@
package com.pahimar.ee3.item;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.lib.Strings;
public class ItemDiviningRod extends ItemEE
{
public ItemDiviningRod(int id)
{
super(id);
this.setHasSubtypes(true);
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.DIVINING_ROD_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
}
}

View file

@ -6,6 +6,8 @@ import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.ShapedOreRecipe;
/**
* Equivalent-Exchange-3
@ -24,6 +26,7 @@ public class ModItems
public static ItemEE alchemicalDust;
public static ItemEE alchemicalBag;
public static ItemEE alchemicalChalk;
public static ItemEE diviningRod;
public static void init()
{
@ -35,6 +38,7 @@ public class ModItems
alchemicalDust = new ItemAlchemicalDust(ItemIds.ALCHEMICAL_DUST);
alchemicalBag = new ItemAlchemicalBag(ItemIds.ALCHEMICAL_BAG);
alchemicalChalk = new ItemAlchemicalChalk(ItemIds.ALCHEMICAL_CHALK);
diviningRod = new ItemDiviningRod(ItemIds.DIVINING_ROD);
// Set container items
miniumStone.setContainerItem(miniumStone);
@ -48,10 +52,12 @@ public class ModItems
GameRegistry.registerItem(alchemicalDust, Strings.ALCHEMICAL_DUST_NAME);
GameRegistry.registerItem(alchemicalBag, Strings.ALCHEMICAL_BAG_NAME);
GameRegistry.registerItem(alchemicalChalk, Strings.ALCHEMICAL_CHALK_NAME);
GameRegistry.registerItem(diviningRod, Strings.DIVINING_ROD_NAME);
// Add recipes for items
GameRegistry.addRecipe(new ItemStack(inertStone), new Object[]{"sis", "igi", "sis", 's', Block.stone, 'i', Item.ingotIron, 'g', Item.ingotGold});
GameRegistry.addRecipe(new ItemStack(miniumStone), new Object[]{"sss", "sis", "sss", 's', miniumShard, 'i', inertStone});
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(diviningRod), new Object[]{" s ", " s ", "s s", 's', Item.stick}));
GameRegistry.addShapelessRecipe(new ItemStack(alchemicalChalk), new ItemStack(Item.clay), new ItemStack(Item.dyePowder.itemID, 1, 15), new ItemStack(Item.dyePowder.itemID, 1, 15), new ItemStack(Item.dyePowder.itemID, 1, 15), new ItemStack(Item.dyePowder.itemID, 1, 15));
}
}

View file

@ -18,6 +18,7 @@ public class ItemIds
public static int ALCHEMICAL_DUST_DEFAULT = 27004;
public static int ALCHEMICAL_BAG_DEFAULT = 27005;
public static int ALCHEMICAL_CHALK_DEFAULT = 27006;
public static int DIVINING_ROD_DEFAULT = 27007;
/* Current item ids */
public static int MINIUM_SHARD;
@ -27,4 +28,5 @@ public class ItemIds
public static int ALCHEMICAL_DUST;
public static int ALCHEMICAL_BAG;
public static int ALCHEMICAL_CHALK;
public static int DIVINING_ROD;
}

View file

@ -57,6 +57,7 @@ public class Strings
public static final String ALCHEMICAL_DUST_NAME = "alchemicalDust";
public static final String ALCHEMICAL_BAG_NAME = "alchemicalBag";
public static final String ALCHEMICAL_CHALK_NAME = "alchemicalChalk";
public static final String DIVINING_ROD_NAME = "diviningRod";
/* TileEntity name constants */
public static final String TE_CALCINATOR_NAME = "tileCalcinator";

View file

@ -2,12 +2,10 @@ package com.pahimar.ee3.recipe;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.helper.ItemHelper;
import com.pahimar.ee3.item.ModItems;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.TreeMap;
/**
@ -19,17 +17,22 @@ import java.util.TreeMap;
*/
public class CalcinationManager
{
private static Random random = new Random();
public static List<ItemStack> getCalcinationResult(ItemStack calcinedStack)
// TODO Random chance to get an extra item in the stack
public static ItemStack getCalcinationResult(ItemStack calcinedStack)
{
ItemStack itemStack = calcinedStack.copy();
itemStack.stackSize = 1;
List<ItemStack> calcinationResults = new ArrayList<ItemStack>();
TreeMap<EmcValue, ItemStack> sortedItems = new TreeMap<EmcValue, ItemStack>();
for (ItemStack dustStack : ModItems.alchemicalDust.getSubTypes())
{
// If the item to be calcined is an alchemical dust, return null (you cannot calcine what's already been calcined)
if (ItemHelper.equals(itemStack, dustStack))
{
return null;
}
if (EmcRegistry.getInstance().hasEmcValue(dustStack))
{
sortedItems.put(EmcRegistry.getInstance().getEmcValue(dustStack), dustStack);
@ -40,7 +43,7 @@ public class CalcinationManager
{
if (sortedItems.containsKey(EmcRegistry.getInstance().getEmcValue(itemStack)))
{
calcinationResults.add(sortedItems.get(EmcRegistry.getInstance().getEmcValue(itemStack)));
return sortedItems.get(EmcRegistry.getInstance().getEmcValue(itemStack));
}
else
{
@ -48,19 +51,17 @@ public class CalcinationManager
if (sortedItems.lowerEntry(EmcRegistry.getInstance().getEmcValue(itemStack)) == null)
{
calcinationResults.add(new ItemStack(ModItems.alchemicalDust, 1, 0));
return new ItemStack(ModItems.alchemicalDust, 1, 0);
}
else
{
calcinationResults.add(sortedItems.lowerEntry(EmcRegistry.getInstance().getEmcValue(itemStack)).getValue());
return sortedItems.lowerEntry(EmcRegistry.getInstance().getEmcValue(itemStack)).getValue();
}
}
}
else
{
calcinationResults.add(new ItemStack(ModItems.alchemicalDust, 1, 0));
return new ItemStack(ModItems.alchemicalDust, 1, 0);
}
return calcinationResults;
}
}

View file

@ -1,10 +1,9 @@
package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.lib.Strings;
import net.minecraft.block.BlockFurnace;
import com.pahimar.ee3.recipe.CalcinationManager;
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;
@ -183,30 +182,32 @@ public class TileCalcinator extends TileEE implements IInventory
public void updateEntity()
{
boolean isBurning = this.remainingBurnTime > 0;
boolean calcinationOccured = false;
boolean inventoryChanged = false;
// If the Calcinator still has burn time, decrement it
if (this.remainingBurnTime > 0)
{
--this.remainingBurnTime;
this.remainingBurnTime--;
}
if (!this.worldObj.isRemote)
{
if (this.remainingBurnTime == 0 && this.canCalcinate())
{
// TODO Effect burn speed by fuel quality
this.currentFuelsFuelValue = this.remainingBurnTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
if (this.remainingBurnTime > 0)
{
calcinationOccured = true;
inventoryChanged = true;
if (this.inventory[INPUT_INVENTORY_INDEX] != null)
if (this.inventory[FUEL_INVENTORY_INDEX] != null)
{
--this.inventory[INPUT_INVENTORY_INDEX].stackSize;
--this.inventory[FUEL_INVENTORY_INDEX].stackSize;
if (this.inventory[INPUT_INVENTORY_INDEX].stackSize == 0)
if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0)
{
this.inventory[INPUT_INVENTORY_INDEX] = this.inventory[INPUT_INVENTORY_INDEX].getItem().getContainerItemStack(inventory[INPUT_INVENTORY_INDEX]);
this.inventory[FUEL_INVENTORY_INDEX] = this.inventory[FUEL_INVENTORY_INDEX].getItem().getContainerItemStack(inventory[FUEL_INVENTORY_INDEX]);
}
}
}
@ -214,13 +215,13 @@ public class TileCalcinator extends TileEE implements IInventory
if (this.isBurning() && this.canCalcinate())
{
++this.currentItemCookTime;
this.currentItemCookTime++;
if (this.currentItemCookTime == 200)
{
this.currentItemCookTime = 0;
this.calcinateItem();
calcinationOccured = true;
inventoryChanged = true;
}
}
else
@ -230,12 +231,12 @@ public class TileCalcinator extends TileEE implements IInventory
if (isBurning != this.remainingBurnTime > 0)
{
calcinationOccured = true;
BlockFurnace.updateFurnaceBlockState(this.remainingBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); // TODO Customize
inventoryChanged = true;
// TODO Add in world effects to show that we are making dust
}
}
if (calcinationOccured)
if (inventoryChanged)
{
this.onInventoryChanged();
}
@ -259,13 +260,12 @@ public class TileCalcinator extends TileEE implements IInventory
}
else
{
// TODO Calcination Manager integration
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
ItemStack alchemicalDustStack = CalcinationManager.getCalcinationResult(this.inventory[INPUT_INVENTORY_INDEX]);
/**
* If we don't get a calcination result, then return false
*/
if (itemstack == null)
if (alchemicalDustStack == null)
{
return false;
}
@ -278,14 +278,35 @@ public class TileCalcinator extends TileEE implements IInventory
return true;
}
if (!this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(itemstack) && !this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(itemstack))
boolean leftEquals = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack);
int leftResult = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + alchemicalDustStack.stackSize;
boolean rightEquals = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack);
int rightResult = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize + alchemicalDustStack.stackSize;
if (!leftEquals && !rightEquals)
{
return false;
}
int result = inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + itemstack.stackSize;
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
else if (leftEquals && !rightEquals)
{
return leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize();
}
else if (!leftEquals && rightEquals)
{
return rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize();
}
else
{
if (leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize())
{
return true;
}
else
{
return rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize();
}
}
}
}
@ -293,18 +314,26 @@ public class TileCalcinator extends TileEE implements IInventory
{
if (this.canCalcinate())
{
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
ItemStack alchemicalDustStack = CalcinationManager.getCalcinationResult(this.inventory[INPUT_INVENTORY_INDEX]);
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = itemstack.copy();
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = alchemicalDustStack.copy();
}
else if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(itemstack))
else if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack))
{
inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += itemstack.stackSize;
inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += alchemicalDustStack.stackSize;
}
else if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] = alchemicalDustStack.copy();
}
else if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack))
{
inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize += alchemicalDustStack.stackSize;
}
--this.inventory[INPUT_INVENTORY_INDEX].stackSize;
this.inventory[INPUT_INVENTORY_INDEX].stackSize--;
if (this.inventory[INPUT_INVENTORY_INDEX].stackSize <= 0)
{
@ -349,4 +378,21 @@ public class TileCalcinator extends TileEE implements IInventory
return stringBuilder.toString();
}
public int getCombinedOutputSize()
{
int result = 0;
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null)
{
result += this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize;
}
if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null)
{
result += this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize;
}
return result;
}
}

View file

@ -17,6 +17,7 @@ item.ee3:alchemicalDustAmaranthine.name=Amaranthine Dust [WIP]
item.ee3:alchemicalDustIridescent.name=Iridescent Dust [WIP]
item.ee3:alchemicalBag.name=Alchemical Bag [WIP]
item.ee3:alchemicalChalk.name=Alchemical Chalk [WIP]
item.ee3:diviningRod.name=Divining Rod [WIP]
# Block localizations
tile.ee3:calcinator.name=Calcinator [WIP]