Jump to content

Recommended Posts

Posted

I have an item called Enchantment Shard, and I want to make it so that when I craft 4 around a book, it gives a random level 1 Enchanted book. Currently, I have, in pre-init,

 

GameRegistry.addRecipe(new EnchantShardHandler(enchantshard));

 

EnchantShardHandler looks like this:

 

 

 

public class EnchantShardHandler implements IRecipe{

 

private ItemStack book;

 

public EnchantShardHandler(Item enchantshard){

GameRegistry.addRecipe(getRecipeOutput(), new Object[]{

" A ",

"ABA",

" A ",

'A', enchantshard, 'B', Items.book

});

}

 

@Override

public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) {

if(this.equals(p_77569_1_))

return true;

else

return false;

}

 

@Override

public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) {

return null;

}

 

@Override

public int getRecipeSize() {

// TODO Auto-generated method stub

return 3;

}

 

@Override

public ItemStack getRecipeOutput() {

book = new ItemStack(Items.book);

int i = (int) (Math.random() * 22);

 

if(i == 0){

book.addEnchantment(Enchantment.protection, 1);

}else if(i == 1){

book.addEnchantment(Enchantment.fireProtection, 1);

}else if(i == 2){

book.addEnchantment(Enchantment.featherFalling, 1);

}else if(i == 3){

book.addEnchantment(Enchantment.blastProtection, 1);

}else if(i == 4){

book.addEnchantment(Enchantment.projectileProtection, 1);

}else if(i == 5){

book.addEnchantment(Enchantment.respiration, 1);

}else if(i == 6){

book.addEnchantment(Enchantment.aquaAffinity, 1);

}else if(i == 7){

book.addEnchantment(Enchantment.thorns, 1);

}else if(i == 8){

book.addEnchantment(Enchantment.sharpness, 1);

}else if(i == 9){

book.addEnchantment(Enchantment.smite, 1);

}else if(i == 10){

book.addEnchantment(Enchantment.baneOfArthropods, 1);

}else if(i == 11){

book.addEnchantment(Enchantment.knockback, 1);

}else if(i == 12){

book.addEnchantment(Enchantment.fireAspect, 1);

}else if(i == 13){

book.addEnchantment(Enchantment.looting, 1);

}else if(i == 14){

book.addEnchantment(Enchantment.efficiency, 1);

}else if(i == 15){

book.addEnchantment(Enchantment.silkTouch, 1);

}else if(i == 16){

book.addEnchantment(Enchantment.unbreaking, 1);

}else if(i == 17){

book.addEnchantment(Enchantment.fortune, 1);

}else if(i == 18){

book.addEnchantment(Enchantment.power, 1);

}else if(i == 19){

book.addEnchantment(Enchantment.punch, 1);

}else if(i == 20){

book.addEnchantment(Enchantment.flame, 1);

}else if(i == 21){

book.addEnchantment(Enchantment.infinity, 1);

}

return book;

}

 

public ItemStack changeBook(){

return getRecipeOutput();

}

 

}

 

 

 

 

I currently have it made so that, when I craft the enchanted book, it is the same until I start minecraft again. Then it makes it different. For instance, I will run my mod, and craft the recipe, and I get an Efficiency 1 book. Then I craft it again, and it always is Efficiency 1. I reboot the game, and it gives me Punch 1 each time.

I have no idea how to make the recipe change output each time.

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



×
×
  • Create New...

Important Information

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