Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to make a furnace for my mod, however, the var1 and var2 variables appear not defined for some reason. If anyone could help, that'd be great.

 

 

package me.ryancp.zeldamod;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

public class ZeldaForgeTileEntity extends TileEntity implements IInventory{
private ItemStack[] inventory;

public ZeldaForgeTileEntity() {
	inventory = new ItemStack[1];
}

@Override
public int getSizeInventory() {

	return inventory.length;
}

@Override
public ItemStack getStackInSlot(int p_70301_1_) {

	return inventory[1];
}

@Override
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
	ItemStack itemstack = getStackInSlot(var1);
	if(itemstack != null) {
		if(itemstack.stackSize <= var2) {
			setInventorySlotContents(var1, null);
		}
		else {
			itemstack = itemstack.splitStack(var2);
			onInventoryChanged();
		}
	}
	return itemstack;
}

private void onInventoryChanged() {

}

@Override
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
	ItemStack itemstack = getStackInSlot(var1);
	setInventorySlotContents(var1, null);
	return itemstack;
}

@Override
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
	inventory[var1] = var2;
	if(var2 != null && var.stackSize > getInventoryStackLimit()) {
		var2.stackSize = getInventoryStackLimit();

	}

}

@Override
public String getInventoryName() {

	return "Forge";
}

@Override
public boolean hasCustomInventoryName() {

	return true;
}

@Override
public int getInventoryStackLimit() {

	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
	if(var1.getDistanceSq(xCoord = (int) 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64) {
		return true;
	}else {
		return false;
	}
}

@Override
public void openInventory() {

}

@Override
public void closeInventory() {


}

@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {

	return true;
}

}

 

 

There's 10 types of people in this world; Those that understand binary and those that don't.

Hi

 

var1 and var2 are not defined because you haven't defined them.  you need to use the parameters passed to the method.

 

-TGG

  • Author

Thanks, *facepalms at my failure*.

There's 10 types of people in this world; Those that understand binary and those that don't.

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.