1

1.7.2 Modding problems. Help please

BlazeAxtrius's Avatar BlazeAxtrius2/11/14 4:22 pm
1 emeralds 930 7
2/16/2014 2:55 pm
BlazeAxtrius's Avatar BlazeAxtrius
Hello everyone,
I have a problem with 3 classes. I will put the code here so if you can help please do.


public class SlotRailsCraftingTable extends Slot
{
/** The craft matrix inventory linked to this result slot.*/
private final IInventory craftMatrix;
/** The player that is using the GUI where this slot resides.*/
private EntityPlayer thePlayer;
/*** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.*/
private int amountCrafted;
public SlotRailsCraftingTable(EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3IInventory, int par4, int par5, int par6)
{
super(par3IInventory, par4, par5, par6);
this.thePlayer = par1EntityPlayer;
this.craftMatrix = par2IInventory;
}
/*** Check if the stack is a valid item for this slot. Always true beside for the armor slots.*/
public boolean isItemValid(ItemStack par1ItemStack)
{
return true;
}
/*** Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.*/
public ItemStack decrStackSize(int par1)
{
if (this.getHasStack())
{
this.amountCrafted += Math.min(par1, this.getStack().stackSize);
}
return super.decrStackSize(par1);
}
/*** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an internal count then calls onCrafting(item).*/
protected void onCrafting(ItemStack par1ItemStack, int par2)
{
this.amountCrafted += par2;
this.onCrafting(par1ItemStack);
}
/*** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.*/
protected void onCrafting(ItemStack par1ItemStack)
{
par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
this.amountCrafted = 0;
if (par1ItemStack == Block.workbench.blockID)
{
this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
}
else if (par1ItemStack == Item.pickaxeWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
}
else if (par1ItemStack == Block.furnaceIdle.blockID)
{
this.thePlayer.addStat(AchievementList.buildFurnace, 1);
}
else if (par1ItemStack == Item.hoeWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildHoe, 1);
}
else if (par1ItemStack == Item.bread.itemID)
{
this.thePlayer.addStat(AchievementList.makeBread, 1);
}
else if (par1ItemStack == Item.cake.itemID)
{
this.thePlayer.addStat(AchievementList.bakeCake, 1);
}
else if (par1ItemStack== Item.pickaxeStone.itemID)
{
this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
}
else if (par1ItemStack == Item.swordWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildSword, 1);
}
else if (par1ItemStack == Block.enchantmentTable.blockID)
{
this.thePlayer.addStat(AchievementList.enchantments, 1);
}
else if (par1ItemStack == Block.bookShelf.blockID)
//else if (par1ItemStack.itemID == Block.bookShelf.blockID)
{
this.thePlayer.addStat(AchievementList.bookcase, 1);
}
}
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
this.onCrafting(par2ItemStack);
for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
{
ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
if (itemstack1 != null)
{
this.craftMatrix.decrStackSize(i, 1);
if (itemstack1.getItem().hasContainerItem())
{
ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
itemstack2 = null;
}
if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
{
if (this.craftMatrix.getStackInSlot(i) == null)
{
this.craftMatrix.setInventorySlotContents(i, itemstack2);
}
else
{
this.thePlayer.dropOneItem(itemstack2);
}
}
}
}
}
}
}


The problem with the code here is this part :
if (par1ItemStack == Block.workbench.blockID) the error is "workbench cannot be resolved or it is not a field". The other lines like this one are with the same error.


The other problems are in these lines.

GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
this.thePlayer.dropOneItem(itemstack2);
-----------------------------------------------------------------------------------------------------------
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting)
{
return new ItemStack(recipeOutput.stackSize, recipeOutput.stackSize, recipeOutput.getItemDamage());
}
-----------------------------------------------------------------------------------------------------------
public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
{
int i = 0;
ItemStack itemstack = null;
ItemStack itemstack1 = null;
int j;
for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j)
{
ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);
if (itemstack2 != null)
{
if (i == 0)
{
itemstack = itemstack2;
}
if (i == 1)
{
itemstack1 = itemstack2;
}
++i;
}
}
if (i == 2 && ItemStack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isRepairable())
{
Item item = Item.itemsList[itemstack.itemID];
int k = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
int l = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
int i1 = k + l + item.getMaxDamage() * 5 / 100;
int j1 = item.getMaxDamage() - i1;
if (j1 < 0)
{
j1 = 0;
}
return new ItemStack(itemstack.itemID, 1, j1);
}
else
{
for (j = 0; j < this.recipes.size(); ++j)
{
IRecipe irecipe = (IRecipe)this.recipes.get(j);
if (irecipe.matches(par1InventoryCrafting, par2World))
{
return irecipe.getCraftingResult(par1InventoryCrafting);
}
}
return null;
}
}

The Bold words are where the errors are.
If anyone needs any information please tell me. Thanks for the help in advance.
Posted by BlazeAxtrius's Avatar
BlazeAxtrius
Level 53 : Grandmaster Artist
20

Create an account or sign in to comment.

7

1
02/16/2014 2:55 pm
Level 53 : Grandmaster Artist
BlazeAxtrius
BlazeAxtrius's Avatar
[21:54:27] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[21:54:28] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/BlazeAxtrius/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1024/forgeSrc-1.7.2-10.12.0.1024.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!
[21:54:28] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!
[21:54:28] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/BlazeAxtrius/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1024/forgeSrc-1.7.2-10.12.0.1024.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it
[21:54:28] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing


Anyone any idea how to fix that error? Minecraft cant load.
When i install it minecraft starts normally but when i put my mod in to work on it. It shows this error.
1
02/12/2014 3:38 pm
Level 53 : Grandmaster Artist
BlazeAxtrius
BlazeAxtrius's Avatar
Ok so i just need to fix that part.

public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
{
int i = 0;
ItemStack itemstack = null;
ItemStack itemstack1 = null;
int j;
for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j)
{
ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);
if (itemstack2 != null)
{
if (i == 0)
{
itemstack = itemstack2;
}
if (i == 1)
{
itemstack1 = itemstack2;
}
++i;
}
}
if (i == 2 && ItemStack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isRepairable())
{
Item item = Item.itemsList[itemstack.itemID];
int k = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
int l = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
int i1 = k + l + item.getMaxDamage() * 5 / 100;
int j1 = item.getMaxDamage() - i1;
if (j1 < 0)
{
j1 = 0;
}
return new ItemStack(itemstack.itemID, 1, j1);
}
else
{
for (j = 0; j < this.recipes.size(); ++j)
{
IRecipe irecipe = (IRecipe)this.recipes.get(j);
if (irecipe.matches(par1InventoryCrafting, par2World))
{
return irecipe.getCraftingResult(par1InventoryCrafting);
}
}
return null;
}
}
1
02/11/2014 4:28 pm
Level 57 : Grandmaster Programmer
bmanrules
bmanrules's Avatar
You no longer us Item IDs, but instead you use:

Item.field_150901_e.getObject("arrow");

or similar code for blocks, which can be found in Blocks.java
1
02/11/2014 4:36 pm
Level 53 : Grandmaster Artist
BlazeAxtrius
BlazeAxtrius's Avatar
It doesnt recognize this field_150901_e.
I just have these options.
Item.getIdFromItem(p_150891_0_)
Item.getItemById(p_150899_0_)
Item.getItemFromBlock(p_150898_0_)
1
02/11/2014 4:57 pm
Level 57 : Grandmaster Programmer
bmanrules
bmanrules's Avatar
Sorry I'm using an outdated version of MCP. Use getIdFromItem()
1
02/12/2014 12:01 am
Level 53 : Grandmaster Artist
BlazeAxtrius
BlazeAxtrius's Avatar
and i get an error here :

if (par1ItemStack == Block.getIdFromBlock(workbench))
{
this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
}
else if (par1ItemStack == Item.getIdFromItem(pickaxeWood))
{
this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
1
02/11/2014 4:25 pm
Level 23 : Expert Archer
Gamecool 10
Gamecool 10's Avatar
Hmm...

I can't wait until I practice Java this summer again, I can't understand a thing here.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome