Jump to content

Custom furnace that uses longer time when... [solved]


Recommended Posts

Posted

Hi, is there a way I can turn this code:

 

 

package com.xetosphere.arcane.tileentity;

import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

import com.xetosphere.arcane.item.ModItems;
import com.xetosphere.arcane.lib.Strings;
import com.xetosphere.arcane.recipe.DuplicatorRecipes;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class TileDuplicator extends TileARC implements IInventory {

private ItemStack[] inventory;

public static final int INVENTORY_SIZE = 3;

public static final int INPUT_INVENTORY_INDEX = 0;
public static final int DUST_INVENTORY_INDEX = 1;
public static final int OUTPUT_INVENTORY_INDEX = 2;

public int duplicatorDupleTime;
public int currentItemDupleTime;
public int duplicatorDupledTime2;

public TileDuplicator() {

	inventory = new ItemStack[iNVENTORY_SIZE];
}

public int getSizeInventory() {

	return inventory.length;
}

public ItemStack getStackInSlot(int slot) {

	return inventory[slot];
}

public ItemStack decrStackSize(int slot, int ammount) {

	ItemStack itemStack = getStackInSlot(slot);
	if (itemStack != null) {
		if (itemStack.stackSize <= ammount) {
			setInventorySlotContents(slot, null);
		} else {
			itemStack = itemStack.splitStack(ammount);
			if (itemStack.stackSize == 0) {
				setInventorySlotContents(slot, null);
			}
		}
	}

	return itemStack;
}

public ItemStack getStackInSlotOnClosing(int slot) {

	ItemStack itemStack = getStackInSlot(slot);
	if (itemStack != null) {
		setInventorySlotContents(slot, null);
	}

	return itemStack;
}

public void setInventorySlotContents(int slot, ItemStack itemStack) {

	inventory[slot] = itemStack;
	if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
		itemStack.stackSize = getInventoryStackLimit();
	}
}

public String getInvName() {

	return this.hasCustomName() ? this.getCustomName() : Strings.CONTAINER_DUPLICATOR_NAME;
}

public int getInventoryStackLimit() {

	return 64;
}

public void openChest() {

}

public void closeChest() {

}

public void readFromNBT(NBTTagCompound nbtTagCompound) {

	super.readFromNBT(nbtTagCompound);

	NBTTagList tagList = nbtTagCompound.getTagList("Items");
	inventory = new ItemStack[this.getSizeInventory()];
	for (int i = 0; i < tagList.tagCount(); ++i) {
		NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(i);
		byte slot = tagCompound.getByte("Slot");
		if (slot >= 0 && slot < inventory.length) {
			inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
		}

		this.duplicatorDupleTime = nbtTagCompound.getShort("FuseTime");
		this.duplicatorDupledTime2 = nbtTagCompound.getShort("TimeSpent");
	}
}

public void writeToNBT(NBTTagCompound nbtTagCompound) {

	super.writeToNBT(nbtTagCompound);

	nbtTagCompound.setShort("FuseTime", (short) this.duplicatorDupleTime);
	nbtTagCompound.setShort("TimeSpent", (short) this.duplicatorDupledTime2);

	NBTTagList tagList = new NBTTagList();
	for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
		if (inventory[currentIndex] != null) {
			NBTTagCompound tagCompound = new NBTTagCompound();
			tagCompound.setByte("Slot", (byte) currentIndex);
			inventory[currentIndex].writeToNBT(tagCompound);
			tagList.appendTag(tagCompound);
		}
	}

	nbtTagCompound.setTag("Items", tagList);
}

public boolean isInvNameLocalized() {

	return this.hasCustomName();
}

public boolean isItemValidForSlot(int i, ItemStack itemStack) {

	return true;
}

public String toString() {

	StringBuilder stringBuilder = new StringBuilder();

	stringBuilder.append(super.toString());

	stringBuilder.append("TileDuplicator Data - ");
	for (int i = 0; i < inventory.length; i++) {
		if (i != 0) {
			stringBuilder.append(", ");
		}

		if (inventory[i] != null) {
			stringBuilder.append(String.format("inventory[%d]: %s", i, inventory[i].toString()));
		} else {
			stringBuilder.append(String.format("inventory[%d]: empty", i));
		}
	}

	stringBuilder.append("\n");

	return stringBuilder.toString();
}

@SideOnly(Side.CLIENT)
public int getCookProgressTimeScaled(int par1) {

	return this.duplicatorDupledTime2 * par1 / 400;
}

@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1) {

	if (this.currentItemDupleTime == 0) {
		this.currentItemDupleTime = 400;
	}

	return this.duplicatorDupleTime * par1 / this.currentItemDupleTime;
}

public boolean isBurning() {

	return this.duplicatorDupleTime > 0;
}

public void updateEntity() {

	boolean flag = this.duplicatorDupleTime > 0;
	boolean flag1 = false;

	if (this.duplicatorDupleTime > 0) {
		--this.duplicatorDupleTime;
	}

	if (!this.worldObj.isRemote) {
		if (this.duplicatorDupleTime == 0 && this.canSmelt()) {
			this.currentItemDupleTime = this.duplicatorDupleTime = getItemBurnTime(this.inventory[DUST_INVENTORY_INDEX]);
			if (this.duplicatorDupleTime > 0) {
				flag1 = true;
				if (this.inventory[DUST_INVENTORY_INDEX] != null) {
					--this.inventory[DUST_INVENTORY_INDEX].stackSize;
					if (this.inventory[DUST_INVENTORY_INDEX].stackSize == 0) {
						this.inventory[DUST_INVENTORY_INDEX] = this.inventory[DUST_INVENTORY_INDEX].getItem().getContainerItemStack(inventory[DUST_INVENTORY_INDEX]);
					}
				}
			}
		}

		if (this.isBurning() && this.canSmelt()) {
			++this.duplicatorDupledTime2;

			if (this.duplicatorDupledTime2 == 400) {
				this.duplicatorDupledTime2 = 0;
				this.smeltItem();
				flag1 = true;
			}

		} else {

			this.duplicatorDupledTime2 = 0;

		}

		if (flag != this.duplicatorDupleTime > 0) {
			flag1 = true;
		}

	}

	if (flag1) {
		this.onInventoryChanged();
	}
}

private boolean canSmelt() {

	if (this.inventory[iNPUT_INVENTORY_INDEX] == null) {

		return false;

	} else {

		ItemStack itemstack = DuplicatorRecipes.dupling().getDuplingResult(this.inventory[iNPUT_INVENTORY_INDEX]);

		if (itemstack == null) return false;
		if (this.inventory[OUTPUT_INVENTORY_INDEX] == null) return true;
		if (!this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(itemstack)) return false;
		int result = inventory[OUTPUT_INVENTORY_INDEX].stackSize + itemstack.stackSize;

		return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
	}
}

public void smeltItem() {

	if (this.canSmelt()) {

		ItemStack itemstack = DuplicatorRecipes.dupling().getDuplingResult(this.inventory[iNPUT_INVENTORY_INDEX]);

		if (this.inventory[OUTPUT_INVENTORY_INDEX] == null) {

			this.inventory[OUTPUT_INVENTORY_INDEX] = itemstack.copy();

		} else if (this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(itemstack)) {

			inventory[OUTPUT_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;
		}
	}
}

public static int getItemBurnTime(ItemStack itemStack) {

	if (itemStack == null) {
		return 0;
	}

	int i = itemStack.getItem().itemID;
	int meta = itemStack.getItemDamage();

	if (i == ModItems.magicDust.itemID && meta == 0) return 400;

	return GameRegistry.getFuelValue(itemStack);
}

public static boolean isItemFuel(ItemStack itemStack) {

	return getItemBurnTime(itemStack) > 0;
}

}

 

 

and change it so that when I take a diamond in, it will take longer time till it finishes compared to when I put something else inside it.

Posted

This gave me net.minecraft.util.ReportedException.

 

Saying this:

 

2013-09-29 20:26:19 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Rendering screen

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1045)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:836)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.main.Main.main(Main.java:93)

2013-09-29 20:26:19 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-09-29 20:26:19 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

2013-09-29 20:26:19 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException

2013-09-29 20:26:19 [iNFO] [sTDERR] at com.xetosphere.arcane.tileentity.TileDuplicator.getTimeRequired(TileDuplicator.java:305)

2013-09-29 20:26:19 [iNFO] [sTDERR] at com.xetosphere.arcane.tileentity.TileDuplicator.getCookProgressTimeScaled(TileDuplicator.java:174)

2013-09-29 20:26:19 [iNFO] [sTDERR] at com.xetosphere.arcane.client.gui.inventory.GuiDuplicator.drawGuiContainerBackgroundLayer(GuiDuplicator.java:49)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:111)

2013-09-29 20:26:19 [iNFO] [sTDERR] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)

2013-09-29 20:26:19 [iNFO] [sTDERR] ... 9 more

 

I put getTimeRequired(inventory[iNPUT_INVENTORY_INDEX]) at all places where there was 400 before exept for the place where the fuel gets how long it should burn.

 

I also get a nullpointer exception telling me this:

 

at com.xetosphere.arcane.tileentity.TileDuplicator.getTimeRequired(TileDuplicator.java:305)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at com.xetosphere.arcane.tileentity.TileDuplicator.getCookProgressTimeScaled(TileDuplicator.java:174)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at com.xetosphere.arcane.client.gui.inventory.GuiDuplicator.drawGuiContainerBackgroundLayer(GuiDuplicator.java:49)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:111)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:836)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2013-09-29 20:26:19 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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