Jump to content

Recommended Posts

Posted

boolean canConnectEnergy(ForgeDirection from);

ForgeDirection is most of the error

 

Funny. You don't say.  Try reading this post again:

 

some parameters in the methods need to be changed like ForgeDirection to EnumFacing

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ok so i set everything else but i tryied fixing these 2 and i cant figure it our i didnt want to bother u guys again

package cofh.api.energy;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

/**
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
* 
* @author King Lemming
* 
*/
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {

protected int capacity;
protected int maxReceive;
protected int maxExtract;

public ItemEnergyContainer() {

}

public ItemEnergyContainer(int capacity) {

	this(capacity, capacity, capacity);
}

public ItemEnergyContainer(int capacity, int maxTransfer) {

	this(capacity, maxTransfer, maxTransfer);
}

public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {

	this.capacity = capacity;
	this.maxReceive = maxReceive;
	this.maxExtract = maxExtract;
}

public ItemEnergyContainer setCapacity(int capacity) {

	this.capacity = capacity;
	return this;
}

public void setMaxTransfer(int maxTransfer) {

	setMaxReceive(maxTransfer);
	setMaxExtract(maxTransfer);
}

public void setMaxReceive(int maxReceive) {

	this.maxReceive = maxReceive;
}

public void setMaxExtract(int maxExtract) {

	this.maxExtract = maxExtract;
}

/* IEnergyContainerItem */
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {

	if (container.stackTagCompound == null) {
		container.stackTagCompound = new NBTTagCompound();
	}
	int energy = container.stackTagCompound.getInteger("Energy");
	int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));

	if (!simulate) {
		energy += energyReceived;
		container.stackTagCompound.setInteger("Energy", energy);
	}
	return energyReceived;
}

@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {

	if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
		return 0;
	}
	int energy = container.stackTagCompound.getInteger("Energy");
	int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));

	if (!simulate) {
		energy -= energyExtracted;
		container.stackTagCompound.setInteger("Energy", energy);
	}
	return energyExtracted;
}

@Override
public int getEnergyStored(ItemStack container) {

	if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
		return 0;
	}
	return container.stackTagCompound.getInteger("Energy");
}

@Override
public int getMaxEnergyStored(ItemStack container) {

	return capacity;
}

}

stackTagCompound Is the problem there and

 

@Override
public void writeToNBT(NBTTagCompound nbt) {

	super.writeToNBT(nbt);
	storage.writeToNBT(nbt);
}

Im getting an error at void and i have no idea why

Are You Feeling it now Mr.Krabs?

 

GitHub

https://github.com/nuclearelectricity/Nuclear-Electricity

Posted

ItemStack#stackTagCompound was replaced with a setter & getter. ItemStack#setTagCompound() & ItemStack#getTagCompound respectively.

 

writeToNBT was changed from void to NBTTagCompound, meaning you have to return the compound that was passed to it, altered or not.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

		if (container.setTagCompound()  == null) {
		container.setTagCompound()  = new NBTTagCompound();

The method setTagCompound(NBTTagCompound) in the type ItemStack is not applicable for the arguments ()

It kinda tells you exactly what is wrong in the second one(Hint: It's the ()) and the first one is two == not one. When I said stackTagCompound = someTagCompound there was only one.

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

	if (container.setTagCompound()  == null) {
		container.getTagCompound())  = new NBTTagCompound();
	}

Dude im so sorry if im wasting your time. I think i might just try figuring this stuff out by myself after this questions but is this right  :P If not i think i might go slit my wrist and put it in bleach and then call myself an idiot 60000 times

Are You Feeling it now Mr.Krabs?

 

GitHub

https://github.com/nuclearelectricity/Nuclear-Electricity

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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