Electrical-Age / ElectricalAge

Electrical Age (ELN) is a Minecraft Mod offering the ability to perform large-scale in-game electrical simulations.
https://electrical-age.net/
Other
211 stars 97 forks source link

Piping Lava bucket into the heat furnace slot 2 #129

Open tomevoll opened 10 years ago

tomevoll commented 10 years ago

Piping a bucket of lava in to slot 2 will cause a crash. I assume we are not suppose to pipe into that slot, however, isItemValidForSlot returns true.

---- Minecraft Crash Report ---- // Surprise! Haha. Well, this is awkward.

Time: 9/10/14 10:30 AM Description: Exception in server tick loop

java.lang.ClassCastException: net.minecraft.item.ItemBucket cannot be cast to mods.eln.generic.GenericItemUsingDamage at mods.eln.transparentnode.heatfurnace.HeatFurnaceInventoryProcess.process(HeatFurnaceInventoryProcess.java:38) at mods.eln.sim.Simulator.tick(Simulator.java:499) at cpw.mods.fml.common.eventhandler.ASMEventHandler_582_Simulator_tick_ServerTickEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.onPreServerTick(FMLCommonHandler.java:260) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:536) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:186) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

tomevoll commented 10 years ago

Getting the unlocalizedname also dont work, returns null or a blank string. i have not checked properly what is going on with the name, but i failed to get the name using (itemstack getDisplayName, getunlocalizedname) (block getUnlocalizedname)

JPitman97 commented 10 years ago

We will look into this don't see what is causing this though

tomevoll commented 10 years ago

i checked some more on the name, its not null, but they all return, tile.NodeBlock

master801 commented 10 years ago

@ShadowWarrior979 This is your problem. https://github.com/Dolu1990/ElectricalAge/blob/1.7.2-MNA/mods/eln/transparentnode/electricalfurnace/ElectricalFurnaceProcess.java#L40

You're trying to cast a Class to an item that doesn't have the Class implemented anywhere in the code.

Example: ItemStack stack; //This is a normal ItemStack that doesn't implemented IInterface. ((IInterface)stack).getItem(); //This will error out for sure.

tomevoll commented 10 years ago

ya a try cache on that line eliminates the error, I think preventing items to enter slot 2 would be a better solution. sorry for bad spelling.

maybe check if a item is instanceof ThermalIsolatorElement, when a class calls isItemValidForSlot and if slot is 2 and its not a instance of ThermalIsolatorElement return false?

Dolu1990 commented 10 years ago

Hi, I fix that in next release. Thanks for issue :)

tomevoll commented 10 years ago

any chance rf convertion and ic2 convertion ratio could be upped a bit? it seems incredible hard to get any usable amount of RF from it, even running full 5kw at 800v into a converter, with the new upgrades for speed and so on on TE, the draw is even larger, full 5kw seem to give around 100 RF/t ?

I would really like to use this mod for powering all other mods, not cause this is easier to set up, but its so much fun to play with :)

tomevoll commented 10 years ago

hmm this def, need a bump in convertion, im on 5kw output, me system draw 172 EU/t and ELN cant deliver that amount, MFSU being drained 2014-09-12_11 06 36 2014-09-12_11 07 00

Dolu1990 commented 10 years ago

i have investigate, but i can't reproduct the bug. How do you have put the laval bucket in the slot ? because it's already protected. you use r40 ? For energy convertion ratio. i can put in eln.cfg the ratio.

Dolu1990 commented 10 years ago

I have add into eln.cfg conversion ratio. (come in next release) Using other electrical blocks mod is cool, they all have some part that are prety good. and Electrical age can't do all :)

tomevoll commented 10 years ago

im using 41, i will check again on isItemValid, im using Router Reborn (you can find it on curse, ill give you a link if you cant find it), it wouldnt insert an item there if isitemvalid return false, i will double check my code, it does not insert to other machines returning false, it was the heat furnace , not electrical furnace.

Thank you for adding it in cfg :)

tomevoll commented 10 years ago

k i checked and the heat furnace does return true.

lava

slots[0] is the item located in slot 0 in the router, it checks if the item is valid for the target slot before it will try and transfer it.

tomevoll commented 10 years ago

if you need the deobf version to use in debug i can give you a private link to it

Dolu1990 commented 10 years ago

Enjoying with minecraft inventory implementation XD So the minecraft inventory system has some duplicated and redondant function : From IInventory there is isItemValidForSlot . From ISidedInventory there is getAccessibleSlotsFromSide. So getAccessibleSlotsFromSide is correctly implemented, but isItemValidForSlot is not.

For next update i will try to solve that automaticaly by the code itself :) thanks for issue.

minecraft 1.8 has re implement the inventory system ♥

Dolu1990 commented 10 years ago

oky i have fix that,by the hugliest possible way XD @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { for(int idx = 0;idx < 6;idx++){ int[] lol = getAccessibleSlotsFromSide(idx); for(int hohoho : lol){ if(hohoho == i){ if(canInsertItem(i, itemstack, idx)) return true; } } } return false; }

Normaly all is ok now :)

Dolu1990 commented 10 years ago

It's that no ? isItemValidForSlot ?

tomevoll commented 10 years ago

that should work :) i will test it :)

tomevoll commented 10 years ago

isItemValidForSlot in the tileentity yes. is this updated in git? i just reloaded the latest, but from what i see last change was a day ago, and it still returns true

tomevoll commented 10 years ago

the problem might be caninsertitem, if your tile is ISidedInventory this is called: private boolean canPutStackIntoSlotSided(ISidedInventory target, int OUTPUT_SLOT, SIDE side, ItemStack stack) { if (stack != null) { if (stack.stackSize < stack.getMaxStackSize()) { if (target.canInsertItem(OUTPUT_SLOT, slots[0], side.getCode()) && target.isItemValidForSlot(OUTPUT_SLOT, slots[0])) { if (StackFitInStack(slots[0], stack)) { return true; } } } } else { if (target.canInsertItem(OUTPUT_SLOT, slots[0], side.getCode()) && target.isItemValidForSlot(OUTPUT_SLOT, slots[0])) { if (StackFitInStack(slots[0], stack)) { return true; } } } return false; }

i included image, the formating on code makes it almost unreadable :) code

tomevoll commented 10 years ago

so both canInsert and isValid must be true for it to accually insert the item, if it is not sided inventory or router is in slot mode, it will get a list of available slots from getSizeInventory(). maybe that is a mistake on my part to not check each side when in sloted mode and expecting isItemValid to return the proper response.

According to IInventory it should respond with false if anyone try to insert anything non valid in to the slot.

quote from IInventory: /* * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. /

tomevoll commented 10 years ago

i put this in HeatFurnaceInventory.java and that solves the problem heatfurnace

tomevoll commented 10 years ago

well that works until i put a heating element in it lol I'm not sure what you are using that slot for, but if you don't use it at all in heat furnace just always return false on slot 2,

I tried your code above and that crashes to, with a heat element (fork thing for the electric furnace)

tomevoll commented 10 years ago

this works, a bit messy, but no transfer can be done if the item is not a instanceof ThermalIsolatorElement codefix oh the iso declaration can be removed, i copy pasted part of the code from the processing.

tomevoll commented 10 years ago

i changed my code to check for slots available from all sides when in numbered/sloted mode if the tile is a instance of ISidedInventory, i most likely should have done that to begin with, that should make slot 2 unavalible