Jump to content

felesmortis

Members
  • Posts

    3
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

felesmortis's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Sorry, I forgot to post. Re-installing forge/mcp fixed the problem. Thanks anyway. --felesmortis
  2. I have a mod that is working perfectly in eclipse, but whenever I try to get it to run with minecraft, it crashes. I am using minecraft 1.5.2 with forge 7.8.1.737. I've tried running recompile.bat and reobfuscate_srg.bat. I've even tried running reobfuscate.bat. I also tried compiling it through eclipse. None of these options seem to work. When I try the normal method, using recombile.bat etc: Even thought my class is exactly where it should be. When I compile it in eclipse, it loads, however, I get this error: The no such field error happens whether I assign the material in my block class or in my main class. It also happens no matter what material I assign. Thanks. --felesmortis
  3. I'm creating a Universal Electricity compatible automatic miner. I am using minecraft 1.5.2 with forge 7.8.1.737 and the UE API 1.4.0.89. I know that Complex Machines already does this, this is just for fun. Also, I am neither a Java nor a Forge expert, but I know how to use google. Everything I'm asking I've researched. I'm trying to get my autominer to require electricity to run. Normally, I would work on it on my own, but it has been four hours, so I think it is time to look for help. I have a Tile Entity extending TileEntityElectricityStorage and implementing IInventory package felesmortis.autominer; import java.util.ArrayList; import java.util.Random; import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.prefab.tile.TileEntityElectrical; import universalelectricity.prefab.tile.TileEntityElectricityStorage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; public class TileEntityMiner extends TileEntityElectricityStorage implements IInventory { private int[] timeToMake = {-1,-1,-1,-1,-1,-1}; private int[] fullTime = {-1,-1,-1,-1,-1,-1}; ///public BlockMiner block; private ItemStack[] inv; private int ticks = 0; private static Random r = new Random(); private String[] oresFull = OreDictionary.getOreNames(); private String[] ores = getOres(); private double joules = 0; public int scaled = 1; public TileEntityMiner(){ inv = new ItemStack[18]; } private String[] getOres() { ArrayList<String> ores = new ArrayList<String>(); for(int i = 0; i < oresFull.length; i++) { if(oresFull[i].contains("ore")) { ores.add(oresFull[i]); } } return ores.toArray(new String[ores.size()]); } public int getProgressScaled(int scale, int pos){ return scale - (timeToMake[pos] * scale / fullTime[pos]); } public int getJoulesScaled(int scale) { return (int)getJoules() * scale / (int)getMaxJoules(); } public ItemStack isValid(int pos) { ItemStack is = null; boolean flag = true; int pos2 = pos + 6; if(inv[pos] == null || !inv[pos].getItem().equals(Autominer.itemOreUpgrade)){ flag = false; } else { is = ItemOreUpgrade.getStackFromDamage(inv[pos].getItemDamage()); is.stackSize = 1; } if(flag && inv[pos2] != null) if(!inv[pos2].isItemEqual(is)) flag = false; if(flag && inv[pos2] != null && inv[pos2].stackSize == 64) flag = false; if(!flag) { is = null; fullTime[pos] = -1; timeToMake[pos] = -1; } return is; } public boolean isSlotToMine(int pos) { return timeToMake[pos] == 0; } public void addToMiner(ItemStack is, int pos) { int j = pos + 6; is.stackSize = 1; if(inv[j] == null){ inv[j] = is.copy(); } else if(inv[j].isItemEqual(is) && inv[j].stackSize < 64) { inv[j].stackSize += 1; } timeToMake[pos] = getItemMineTime(is); } public int getItemMineTime(ItemStack is) { int i = -1; String name = is.getItemName().toLowerCase(); if(name.contains("stone")) { i = TimesMiner.STONE.time; } else if(name.contains("iron")) i = TimesMiner.IRON.time; else if(name.contains("redstone")) i = TimesMiner.REDSTONE.time; else if(name.contains("gold")) i = TimesMiner.GOLD.time; else if(name.contains("emerald")) i = TimesMiner.EMERALD.time; else if(name.contains("lapis")) i = TimesMiner.LAPIS.time; else if(name.contains("diamond")) i = TimesMiner.DIAMOND.time; else if(name.contains("quartz")) i = TimesMiner.QUARTZ.time; else if(name.contains("certus")) i = TimesMiner.CERTUS.time; else if(name.contains("dirt")) i = TimesMiner.DIRT.time; else if(name.contains("obsidian")) i = TimesMiner.OBSIDIAN.time; else if(name.contains("tin")) i = TimesMiner.TIN.time; else if(name.contains("copper")) i = TimesMiner.COPPER.time; else if(name.contains("osmium")) i = TimesMiner.OSMIUM.time; else if(name.contains("coal")) i = TimesMiner.COAL.time; else i = TimesMiner.UNDEF.time; return i; } public void updateEntity() { super.updateEntity(); scaled = getJoulesScaled(52); ItemStack stack; if(ores != null) for (int i = 0; i < 6; i++) { stack = isValid(i); if(stack != null) { if(fullTime[i] == -1) fullTime[i] = getItemMineTime(stack); if(timeToMake[i] == -1) timeToMake[i] = fullTime[i]; else timeToMake[i] -= 1; if(isSlotToMine(i)) { addToMiner(stack, i); } } } } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int slot) { return inv[slot]; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openChest() {} @Override public void closeChest() {} @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public String getInvName() { return "tco.tileentitytiny"; } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return false; } @Override public boolean isStackValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return false; } @Override public boolean canConnect(ForgeDirection direction) { // TODO fix this return direction.equals(ForgeDirection.NORTH); } @Override public double getMaxJoules() { return 50000; } @Override public ElectricityPack getRequest() { return new ElectricityPack((float) Math.min((this.getMaxJoules() - this.getJoules()), 5000),480); } @Override public double getVoltage() { return 480; } } I just want this box to store energy and use it when it creates ores. However, when I try to call getJoules(), occasionally it returns the value it was initialized. When I called it from the updateEntity() function, it alternates between 0 and the normal value. When I call it from my gui class, or call a function from my tile entity class from my gui class, it always returns 0. package felesmortis.autominer; import java.io.File; import java.io.IOException; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; public class GuiMiner extends GuiContainer { private TileEntityMiner minerInventory; public GuiMiner (InventoryPlayer inventoryPlayer, TileEntityMiner tileEntity) { //the container is instanciated and passed to the superclass for handling super(new ContainerMiner(inventoryPlayer, tileEntity)); this.ySize = 170; minerInventory = tileEntity; } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture("/mods/autominer/textures/gui/autominer.png")); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); int i1; for (int i = 0; i < 6; i++) { i1 = minerInventory.getProgressScaled(14,i); this.drawTexturedModalRect(x + 12 + i * 18, y + 27, 181, 30, 7, i1 + 1); } i1 = minerInventory.getJoulesScaled(52); this.drawTexturedModalRect(x + 165, y + 16 + 52 - i1 + 1, 176, 16 + 52 - i1 + 1, 4, i1 + 1); } } The miner itself works, I'm just looking for help with the getJoules() function occasionally returning the default value. Thanks in advance. --felesmortis
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.