Added Coffee Machine Recipe Handler for the manual and a back button when opening the manual from another inventory

This commit is contained in:
Ellpeck 2015-09-24 23:42:03 +02:00
parent e922db1c61
commit 6b80abe942
10 changed files with 336 additions and 42 deletions

View file

@ -0,0 +1,42 @@
/*
* This file ("BookletChapterCoffee.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.booklet.page.PageCoffeeRecipe;
import ellpeck.actuallyadditions.items.ItemCoffee;
import net.minecraft.item.ItemStack;
import scala.actors.threadpool.Arrays;
import java.util.ArrayList;
public class BookletChapterCoffee extends BookletChapter{
public BookletChapterCoffee(String unlocalizedName, BookletIndexEntry entry, ItemStack displayStack, BookletPage... pages){
super(unlocalizedName, entry, displayStack, getPages(pages));
}
@SuppressWarnings("unchecked")
private static BookletPage[] getPages(BookletPage... pages){
ArrayList<BookletPage> allPages = new ArrayList<BookletPage>();
allPages.addAll(Arrays.asList(pages));
for(ItemCoffee.Ingredient ingredient : ItemCoffee.ingredients){
BookletPage page = new PageCoffeeRecipe(allPages.size()+1, ingredient);
if(!(ingredient instanceof ItemCoffee.MilkIngredient)){
page.setNoText();
}
allPages.add(page);
}
return allPages.toArray(new BookletPage[allPages.size()]);
}
}

View file

@ -69,9 +69,12 @@ public class GuiBooklet extends GuiScreen{
private boolean mouseClicked; private boolean mouseClicked;
public GuiBooklet(){ private GuiScreen parentScreen;
public GuiBooklet(GuiScreen parentScreen){
this.xSize = 146; this.xSize = 146;
this.ySize = 180; this.ySize = 180;
this.parentScreen = parentScreen;
} }
@Override @Override
@ -379,7 +382,10 @@ public class GuiBooklet extends GuiScreen{
} }
} }
else if(button.id == BUTTON_RETURN_ID){ else if(button.id == BUTTON_RETURN_ID){
if(this.currentChapter != null && this.currentChapter != InitBooklet.chapterIntro){ if(this.currentIndexEntry == null){
mc.displayGuiScreen(this.parentScreen);
}
else if(this.currentChapter != null && this.currentChapter != InitBooklet.chapterIntro){
this.openIndexEntry(this.currentIndexEntry, this.pageOpenInIndex, true); this.openIndexEntry(this.currentIndexEntry, this.pageOpenInIndex, true);
} }
else{ else{
@ -431,7 +437,7 @@ public class GuiBooklet extends GuiScreen{
this.indexPageAmount = entry == null ? 1 : entry.chapters.size()/BUTTONS_PER_PAGE+1; this.indexPageAmount = entry == null ? 1 : entry.chapters.size()/BUTTONS_PER_PAGE+1;
this.pageOpenInIndex = entry == null ? 1 : (this.indexPageAmount <= page || page <= 0 ? this.indexPageAmount : page); this.pageOpenInIndex = entry == null ? 1 : (this.indexPageAmount <= page || page <= 0 ? this.indexPageAmount : page);
this.getButton(BUTTON_RETURN_ID).visible = entry != null; this.getButton(BUTTON_RETURN_ID).visible = entry != null || this.parentScreen != null;
this.getButton(BUTTON_FORWARD_ID).visible = this.pageOpenInIndex < this.indexPageAmount; this.getButton(BUTTON_FORWARD_ID).visible = this.pageOpenInIndex < this.indexPageAmount;
this.getButton(BUTTON_BACK_ID).visible = this.pageOpenInIndex > 1; this.getButton(BUTTON_BACK_ID).visible = this.pageOpenInIndex > 1;

View file

@ -78,7 +78,7 @@ public class InitBooklet{
new BookletChapter("crate", entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate)); new BookletChapter("crate", entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate));
//RF Using Blocks //RF Using Blocks
new BookletChapter("coffeeMachine", entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("<rf>", ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue()).addTextReplacement("<coffee>", ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()).addTextReplacement("<water>", ConfigIntValues.COFFEE_MACHINE_WATER_USED.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PageTextOnly(3), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()); new BookletChapterCoffee("coffeeMachine", entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("<rf>", ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue()).addTextReplacement("<coffee>", ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()).addTextReplacement("<water>", ConfigIntValues.COFFEE_MACHINE_WATER_USED.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PageCrafting(3, BlockCrafting.recipeCoffeeMachine).setNoText(), new PageCrafting(4, ItemCrafting.recipeCup).setNoText());
new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("<rf1>", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("<rf2>", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText()); new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("<rf1>", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("<rf2>", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText());
new BookletChapter("furnaceDouble", entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).addTextReplacement("<rf>", ConfigIntValues.FURNACE_ENERGY_USED.getValue())); new BookletChapter("furnaceDouble", entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).addTextReplacement("<rf>", ConfigIntValues.FURNACE_ENERGY_USED.getValue()));
new BookletChapter("miner", entryFunctionalRF, new ItemStack(InitBlocks.blockOreMagnet), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue()).addTextReplacement("<oil>", ConfigIntValues.ORE_MAGNET_OIL_USE.getValue()).addTextReplacement("<range>", ConfigIntValues.ORE_MAGNET_RANGE.getValue()), new PageCrafting(2, BlockCrafting.recipeMiner).setNoText(), new PageCrafting(3, BlockCrafting.recipeCasing).setNoText()); new BookletChapter("miner", entryFunctionalRF, new ItemStack(InitBlocks.blockOreMagnet), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue()).addTextReplacement("<oil>", ConfigIntValues.ORE_MAGNET_OIL_USE.getValue()).addTextReplacement("<range>", ConfigIntValues.ORE_MAGNET_RANGE.getValue()), new PageCrafting(2, BlockCrafting.recipeMiner).setNoText(), new PageCrafting(3, BlockCrafting.recipeCasing).setNoText());

View file

@ -0,0 +1,101 @@
/*
* This file ("PageCoffeeRecipe.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.booklet.page;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.InitBooklet;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.util.Util;
import net.minecraft.item.ItemStack;
public class PageCoffeeRecipe extends BookletPage{
public ItemCoffee.Ingredient ingredient;
public PageCoffeeRecipe(int id, ItemCoffee.Ingredient ingredient){
super(id);
this.ingredient = ingredient;
InitBooklet.pagesWithItemStackData.add(this);
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+19, gui.guiTop+20, 146, 94, 99, 60);
}
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
String strg = "Coffee Machine Recipe";
gui.unicodeRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.unicodeRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
String text = gui.currentPage.getText();
if(text != null && !text.isEmpty()){
gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0);
}
if(this.ingredient.maxAmplifier > 0){
gui.unicodeRenderer.drawString("Maximum Amplifier: "+this.ingredient.maxAmplifier, gui.guiLeft+19+5, gui.guiTop+20+60, 0);
}
for(int i = 0; i < 2; i++){
for(int j = 0; j < 4; j++){
ItemStack stack;
int coordsOffsetX;
int coordsOffsetY;
switch(j){
case 0:
stack = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal());
coordsOffsetX = 39;
coordsOffsetY = 8;
break;
case 1:
stack = new ItemStack(InitItems.itemCoffeeBean);
coordsOffsetX = 5;
coordsOffsetY = 8;
break;
case 2:
stack = new ItemStack(InitItems.itemCoffee);
ItemCoffee.addEffectToStack(stack, this.ingredient);
coordsOffsetX = 39;
coordsOffsetY = 39;
break;
default:
stack = this.ingredient.ingredient;
coordsOffsetX = 82;
coordsOffsetY = 8;
break;
}
if(stack != null){
if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0);
boolean tooltip = i == 1;
int xShow = gui.guiLeft+19+coordsOffsetX;
int yShow = gui.guiTop+20+coordsOffsetY;
if(!tooltip){
renderItem(gui, stack, xShow, yShow, 1.0F);
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, j != 2, mouseClick);
}
}
}
}
}
}
}

View file

@ -44,7 +44,7 @@ public class TooltipEvent{
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]")); event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
} }
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){ if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
GuiBooklet book = new GuiBooklet(); GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen);
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
Minecraft.getMinecraft().displayGuiScreen(book); Minecraft.getMinecraft().displayGuiScreen(book);
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true); book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true);

View file

@ -140,7 +140,7 @@ public class GuiHandler implements IGuiHandler{
case CLOUD: case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world); return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK: case BOOK:
return new GuiBooklet(); return new GuiBooklet(null);
case TOOL_TABLE: case TOOL_TABLE:
return new GuiToolTable(entityPlayer.inventory, tile); return new GuiToolTable(entityPlayer.inventory, tile);
default: default:

View file

@ -27,9 +27,11 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
public class ItemCoffee extends ItemFood implements INameableItem{ public class ItemCoffee extends ItemFood implements INameableItem{
@ -46,12 +48,12 @@ public class ItemCoffee extends ItemFood implements INameableItem{
} }
registerIngredient(new Ingredient(new ItemStack(Items.sugar), new PotionEffect[]{new PotionEffect(Potion.moveSpeed.getId(), 30, 0)}, 4)); registerIngredient(new Ingredient(new ItemStack(Items.sugar), new PotionEffect[]{new PotionEffect(Potion.moveSpeed.getId(), 30, 0)}, 4));
registerIngredient(new Ingredient(new ItemStack(Items.magma_cream), new PotionEffect[]{new PotionEffect(Potion.fireResistance.getId(), 20, 0)}, 1)); registerIngredient(new Ingredient(new ItemStack(Items.magma_cream), new PotionEffect[]{new PotionEffect(Potion.fireResistance.getId(), 20, 0)}, 2));
registerIngredient(new Ingredient(new ItemStack(Items.fish, 1, 3), new PotionEffect[]{new PotionEffect(Potion.waterBreathing.getId(), 10, 0)}, 1)); registerIngredient(new Ingredient(new ItemStack(Items.fish, 1, 3), new PotionEffect[]{new PotionEffect(Potion.waterBreathing.getId(), 10, 0)}, 2));
registerIngredient(new Ingredient(new ItemStack(Items.golden_carrot), new PotionEffect[]{new PotionEffect(Potion.nightVision.getId(), 30, 0)}, 1)); registerIngredient(new Ingredient(new ItemStack(Items.golden_carrot), new PotionEffect[]{new PotionEffect(Potion.nightVision.getId(), 30, 0)}, 2));
registerIngredient(new Ingredient(new ItemStack(Items.ghast_tear), new PotionEffect[]{new PotionEffect(Potion.regeneration.getId(), 5, 0)}, 3)); registerIngredient(new Ingredient(new ItemStack(Items.ghast_tear), new PotionEffect[]{new PotionEffect(Potion.regeneration.getId(), 5, 0)}, 3));
registerIngredient(new Ingredient(new ItemStack(Items.blaze_powder), new PotionEffect[]{new PotionEffect(Potion.damageBoost.getId(), 15, 0)}, 4)); registerIngredient(new Ingredient(new ItemStack(Items.blaze_powder), new PotionEffect[]{new PotionEffect(Potion.damageBoost.getId(), 15, 0)}, 4));
registerIngredient(new Ingredient(new ItemStack(Items.fermented_spider_eye), new PotionEffect[]{new PotionEffect(Potion.invisibility.getId(), 25, 0)}, 1)); registerIngredient(new Ingredient(new ItemStack(Items.fermented_spider_eye), new PotionEffect[]{new PotionEffect(Potion.invisibility.getId(), 25, 0)}, 2));
} }
public ItemCoffee(){ public ItemCoffee(){
@ -62,6 +64,20 @@ public class ItemCoffee extends ItemFood implements INameableItem{
this.setNoRepair(); this.setNoRepair();
} }
@SuppressWarnings("unchecked")
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){
PotionEffect[] effects = getEffectsFromStack(stack);
if(effects != null){
for(PotionEffect effect : effects){
list.add(StringUtil.localize(effect.getEffectName())+" "+(effect.getAmplifier()+1)+", "+StringUtils.ticksToElapsedTime(effect.getDuration()*20));
}
}
else{
list.add("No Effects");
}
}
public static Ingredient getIngredientFromStack(ItemStack stack){ public static Ingredient getIngredientFromStack(ItemStack stack){
for(Ingredient ingredient : ingredients){ for(Ingredient ingredient : ingredients){
if(ingredient.ingredient.copy().isItemEqual(stack)) return ingredient; if(ingredient.ingredient.copy().isItemEqual(stack)) return ingredient;
@ -126,7 +142,7 @@ public class ItemCoffee extends ItemFood implements INameableItem{
if(tag != null){ if(tag != null){
int counter = tag.getInteger("Counter"); int counter = tag.getInteger("Counter");
while(counter > 0){ while(counter > 0){
NBTTagCompound compound = (NBTTagCompound)tag.getTag(counter + ""); NBTTagCompound compound = (NBTTagCompound)tag.getTag(counter+"");
PotionEffect effect = new PotionEffect(compound.getInteger("ID"), compound.getInteger("Duration"), compound.getByte("Amplifier")); PotionEffect effect = new PotionEffect(compound.getInteger("ID"), compound.getInteger("Duration"), compound.getByte("Amplifier"));
if(effect.getPotionID() > 0){ if(effect.getPotionID() > 0){
effects.add(effect); effects.add(effect);
@ -182,8 +198,12 @@ public class ItemCoffee extends ItemFood implements INameableItem{
super.onEaten(stack, world, player); super.onEaten(stack, world, player);
applyPotionEffectsFromStack(stack, player); applyPotionEffectsFromStack(stack, player);
theStack.setItemDamage(theStack.getItemDamage()+1); theStack.setItemDamage(theStack.getItemDamage()+1);
if(theStack.getMaxDamage()-theStack.getItemDamage() < 0) return new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()); if(theStack.getMaxDamage()-theStack.getItemDamage() < 0){
else return theStack; return new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal());
}
else{
return theStack;
}
} }
@Override @Override
@ -194,7 +214,7 @@ public class ItemCoffee extends ItemFood implements INameableItem{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){ public void registerIcons(IIconRegister iconReg){
itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
} }
@Override @Override
@ -218,10 +238,6 @@ public class ItemCoffee extends ItemFood implements INameableItem{
this.maxAmplifier = maxAmplifier; this.maxAmplifier = maxAmplifier;
} }
public String getExtraText(){
return null;
}
public PotionEffect[] getEffects(){ public PotionEffect[] getEffects(){
return this.effects; return this.effects;
} }
@ -231,7 +247,7 @@ public class ItemCoffee extends ItemFood implements INameableItem{
} }
} }
private static class MilkIngredient extends Ingredient{ public static class MilkIngredient extends Ingredient{
public MilkIngredient(ItemStack ingredient){ public MilkIngredient(ItemStack ingredient){
super(ingredient, null, 0); super(ingredient, null, 0);
@ -243,7 +259,9 @@ public class ItemCoffee extends ItemFood implements INameableItem{
ArrayList<PotionEffect> effectsNew = new ArrayList<PotionEffect>(); ArrayList<PotionEffect> effectsNew = new ArrayList<PotionEffect>();
if(effects != null && effects.length > 0){ if(effects != null && effects.length > 0){
for(PotionEffect effect : effects){ for(PotionEffect effect : effects){
if(effect.getAmplifier() > 0) effectsNew.add(new PotionEffect(effect.getPotionID(), effect.getDuration()+120, effect.getAmplifier()-1)); if(effect.getAmplifier() > 0){
effectsNew.add(new PotionEffect(effect.getPotionID(), effect.getDuration()+120, effect.getAmplifier()-1));
}
} }
stack.setTagCompound(new NBTTagCompound()); stack.setTagCompound(new NBTTagCompound());
if(effectsNew.size() > 0){ if(effectsNew.size() > 0){
@ -255,10 +273,5 @@ public class ItemCoffee extends ItemFood implements INameableItem{
return true; return true;
} }
@Override
public String getExtraText(){
return StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.extra.milk");
}
} }
} }

View file

@ -0,0 +1,148 @@
/*
* This file ("ItemAllToolFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemAllToolAA;
import ellpeck.actuallyadditions.util.ItemUtil;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
public class ItemAllToolFixedEnchants extends ItemAllToolAA implements IToolTableRepairItem{
private final int maxToolDamage;
private final EnchantmentCombo[] enchantments;
private ItemStack repairStack;
private int repairPerStack;
private IIcon iconBroken;
public ItemAllToolFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, ItemStack repairStack, int repairPerStack, EnchantmentCombo... enchantments){
super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments;
this.maxToolDamage = this.getMaxDamage();
this.setMaxDamage(this.maxToolDamage+1);
this.repairStack = repairStack;
this.repairPerStack = repairPerStack;
}
public boolean isBroken(ItemStack stack){
return this.isBroken(stack.getItemDamage());
}
private boolean isBroken(int damage){
return damage > this.maxToolDamage;
}
@Override
public boolean hasEffect(ItemStack stack, int pass){
return false;
}
@Override
public boolean isRepairable(){
return false;
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
return this.isRepairable();
}
@Override
public int getItemEnchantability(ItemStack stack){
return 0;
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player){
for(EnchantmentCombo combo : this.enchantments){
ItemUtil.addEnchantment(stack, combo.enchantment, combo.level);
}
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){
for(EnchantmentCombo combo : this.enchantments){
if(!ItemUtil.hasEnchantment(stack, combo.enchantment)){
ItemUtil.addEnchantment(stack, combo.enchantment, combo.level);
}
}
}
@SuppressWarnings("unchecked")
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
ItemStack stack = new ItemStack(item);
for(EnchantmentCombo combo : this.enchantments){
ItemUtil.addEnchantment(stack, combo.enchantment, combo.level);
}
list.add(stack);
}
@Override
public String getItemStackDisplayName(ItemStack stack){
return super.getItemStackDisplayName(stack)+(this.isBroken(stack) ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".broken.desc")+")" : "");
}
@Override
public float getDigSpeed(ItemStack stack, Block block, int meta){
return this.isBroken(stack) ? 0.0F : super.getDigSpeed(stack, block, meta);
}
@Override
public boolean canHarvestBlock(Block block, ItemStack stack){
return !this.isBroken(stack) && super.canHarvestBlock(block, stack);
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack useItem, int useRemaining){
return this.isBroken(stack) ? this.iconBroken : this.itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage){
return this.isBroken(damage) ? this.iconBroken : this.itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.iconBroken = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Broken");
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
}
@Override
public ItemStack getRepairStack(){
return this.repairStack;
}
@Override
public int repairPerStack(){
return this.repairPerStack;
}
}

View file

@ -334,20 +334,6 @@ container.actuallyadditions.xpSolidifier.name=Experience Solidifier
container.actuallyadditions.oreMagnet.name=Magnetic Miner container.actuallyadditions.oreMagnet.name=Magnetic Miner
container.actuallyadditions.cloud.name=Smiley Cloud container.actuallyadditions.cloud.name=Smiley Cloud
#NEI Integration
container.nei.actuallyadditions.crushing.name=Crusher
container.nei.actuallyadditions.crushingDouble.name=Double Crusher
container.nei.actuallyadditions.ballOfHair.name=Ball Of Hair Usage
container.nei.actuallyadditions.compost.name=Compost
container.nei.actuallyadditions.furnaceDouble.name=Double Furnace
container.nei.actuallyadditions.treasureChest.name=Treasure Chest
container.nei.actuallyadditions.treasureChest.info=Items at
container.nei.actuallyadditions.coffee.name=Coffee Machine
container.nei.actuallyadditions.coffee.special=Special Feature
container.nei.actuallyadditions.coffee.maxAmount=Max Amount
container.nei.actuallyadditions.coffee.shift=[SHIFT]!
container.nei.actuallyadditions.coffee.extra.milk=+01:00, -1 Level
#Update Information #Update Information
info.actuallyadditions.update.generic.desc=[{"text":"There is an "},{"text":"Update ","bold":"true"},{"text":"for ","bold":"false"},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"available!","color":"none","bold":"false"}] info.actuallyadditions.update.generic.desc=[{"text":"There is an "},{"text":"Update ","bold":"true"},{"text":"for ","bold":"false"},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"available!","color":"none","bold":"false"}]
info.actuallyadditions.update.versionComp.desc=[{"text":"You have Version "},{"text":"%s","color":"dark_red","italic":"false"},{"text":", the newest one is ","color":"none","italic":"false"},{"text":"%s","color":"dark_green","underlined":"false"},{"text":"!","color":"none","underlined":"false"}] info.actuallyadditions.update.versionComp.desc=[{"text":"You have Version "},{"text":"%s","color":"dark_red","italic":"false"},{"text":", the newest one is ","color":"none","italic":"false"},{"text":"%s","color":"dark_green","underlined":"false"},{"text":"!","color":"none","underlined":"false"}]
@ -470,9 +456,7 @@ booklet.actuallyadditions.chapter.crate.name=Storage Crates
booklet.actuallyadditions.chapter.crate.text.1=<item>Storage Crates<r> are big. <imp>Really big<r>. They hold tons of items, more than 4 chests worth of them. <n><n><i>"F-in' gigantic"<rs><n> -Some Magazine booklet.actuallyadditions.chapter.crate.text.1=<item>Storage Crates<r> are big. <imp>Really big<r>. They hold tons of items, more than 4 chests worth of them. <n><n><i>"F-in' gigantic"<rs><n> -Some Magazine
booklet.actuallyadditions.chapter.coffeeMachine.name=Coffee Machine booklet.actuallyadditions.chapter.coffeeMachine.name=Coffee Machine
booklet.actuallyadditions.chapter.coffeeMachine.text.1=The <item>Coffee Machine<r> basically works like a Brewing Stand, only 20 times more customizable. <n>After inserting an <item>Empty Cup<r>, <coffee> <item>Coffee<r>, which can be <imp>found in the wild, planted and harvested<r>, and <water>mB of <imp>Water<r> and <imp><rf> RF/t<r>, it will be able to brew some coffee for you! <n>This is where the customizable bit comes in, though: You can <imp>choose what potion effects the coffee should get and how long for by dropping in potion ingredients just the way you want your coffee to be<r>!
booklet.actuallyadditions.chapter.coffeeMachine.text.2=Every ingredient has a <imp>base time<r> and a <imp>maximum amount<r> of which it can be inputted into the machine. <n>Here are the ingredients: <n><n>Sugar -> Speed 30s, 4max <n>Magma Cream -> 20s, 1max <n>Pufferfish -> Water Breathing, 10s, 1max <n>Golden Carrot -> Night Vision, 30s, 1max <n>Ghast Tear -> Regeneration, 5s, 3max <n>Blaze Powder -> Strength, 15s, 4max <n>Fermented Spider Eye -> Invisibility, 25s, 1max
booklet.actuallyadditions.chapter.coffeeMachine.text.3=There is one special item, however, that is very powerful for the <item>Coffee Machine<r>: <n>The <item>Milk Bucket<r>. <n>This item is especially powerful, because it <imp>doubles the time of an effect<r> while <imp>taking one amplifier away<r>. But be careful: If you only have an amplifier of 1 on an effect, it'll be removed! <n>To amplify the effect of a certain item, just <imp>put it into multiple slots<r> causing the amplifier of it to rise. <n>When you're ready, just press the button to brew your coffee!
booklet.actuallyadditions.chapter.crusher.name=Crusher and Double Crusher booklet.actuallyadditions.chapter.crusher.name=Crusher and Double Crusher
booklet.actuallyadditions.chapter.crusher.text.1=The <item>Crusher<r> turns every ore, ingot and gem into its corresponding <imp>dust<r> using <rf1> RF/t. <n>When you put in <imp>Ores<r> however, they will yield <imp>2 pieces of dust<r>. <n>The <item>Double Crusher<r> basically does the same, however it can crush two ores at a time and uses <rf2> RF/t. <n><n><i>He's my crush booklet.actuallyadditions.chapter.crusher.text.1=The <item>Crusher<r> turns every ore, ingot and gem into its corresponding <imp>dust<r> using <rf1> RF/t. <n>When you put in <imp>Ores<r> however, they will yield <imp>2 pieces of dust<r>. <n>The <item>Double Crusher<r> basically does the same, however it can crush two ores at a time and uses <rf2> RF/t. <n><n><i>He's my crush

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 15 KiB