diff --git a/src/main/java/ellpeck/gemification/Gemification.java b/src/main/java/ellpeck/gemification/Gemification.java index 4090b293a..7773c3b86 100644 --- a/src/main/java/ellpeck/gemification/Gemification.java +++ b/src/main/java/ellpeck/gemification/Gemification.java @@ -8,7 +8,8 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import ellpeck.gemification.blocks.InitBlocks; -import ellpeck.gemification.crafting.CrucibleCraftingManager; +import ellpeck.gemification.booklet.ChapterList; +import ellpeck.gemification.crafting.InitCrafting; import ellpeck.gemification.gen.OreGen; import ellpeck.gemification.inventory.GuiHandler; import ellpeck.gemification.items.InitItems; @@ -28,6 +29,7 @@ public class Gemification{ @SuppressWarnings("unused") @EventHandler() public void preInit(FMLPreInitializationEvent event){ + ChapterList.init(); InitBlocks.init(); InitItems.init(); proxy.preInit(); @@ -36,11 +38,11 @@ public class Gemification{ @SuppressWarnings("unused") @EventHandler() public void init(FMLInitializationEvent event){ - CrucibleCraftingManager.instance.initRecipes(); - proxy.init(); + InitCrafting.init(); GuiHandler.init(); OreGen.init(); TileEntityBase.init(); + proxy.init(); } @SuppressWarnings("unused") diff --git a/src/main/java/ellpeck/gemification/blocks/BlockContainerBase.java b/src/main/java/ellpeck/gemification/blocks/BlockContainerBase.java new file mode 100644 index 000000000..554ccaccc --- /dev/null +++ b/src/main/java/ellpeck/gemification/blocks/BlockContainerBase.java @@ -0,0 +1,47 @@ +package ellpeck.gemification.blocks; + +import ellpeck.gemification.tile.TileEntityInventoryBase; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import java.util.Random; + +public abstract class BlockContainerBase extends BlockContainer{ + + public BlockContainerBase(Material mat) { + super(mat); + } + + public TileEntityInventoryBase dropInventory(World world, int x, int y, int z) { + TileEntityInventoryBase tileEntity = (TileEntityInventoryBase) world.getTileEntity(x, y, z); + for (int i = 0; i < tileEntity.getSizeInventory(); i++) { + ItemStack itemStack = tileEntity.getStackInSlot(i); + if (itemStack != null && itemStack.stackSize > 0) { + Random rand = new Random(); + float dX = rand.nextFloat() * 0.8F + 0.1F; + float dY = rand.nextFloat() * 0.8F + 0.1F; + float dZ = rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); + if (itemStack.hasTagCompound()) + entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + float factor = 0.05F; + entityItem.motionX = rand.nextGaussian() * factor; + entityItem.motionY = rand.nextGaussian() * factor + 0.2F; + entityItem.motionZ = rand.nextGaussian() * factor; + world.spawnEntityInWorld(entityItem); + itemStack.stackSize = 0; + } + } + return tileEntity; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, meta); + } +} diff --git a/src/main/java/ellpeck/gemification/blocks/BlockCrucible.java b/src/main/java/ellpeck/gemification/blocks/BlockCrucible.java index 4fc22d4f9..fac176c5b 100644 --- a/src/main/java/ellpeck/gemification/blocks/BlockCrucible.java +++ b/src/main/java/ellpeck/gemification/blocks/BlockCrucible.java @@ -1,26 +1,28 @@ package ellpeck.gemification.blocks; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import ellpeck.gemification.Gemification; import ellpeck.gemification.creative.CreativeTab; import ellpeck.gemification.inventory.GuiHandler; import ellpeck.gemification.tile.TileEntityCrucible; +import ellpeck.gemification.tile.TileEntityInventoryBase; import ellpeck.gemification.util.Util; import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import java.util.Random; +import java.util.List; -public class BlockCrucible extends BlockContainer{ +public class BlockCrucible extends BlockContainerBase{ protected BlockCrucible(){ super(Material.rock); @@ -56,31 +58,28 @@ public class BlockCrucible extends BlockContainer{ this.blockIcon = Blocks.hopper.getIcon(0, 0); } - public void breakBlock(World world, int x, int y, int z, Block block, int meta){ - this.dropInventory(world, x, y, z); - super.breakBlock(world, x, y, z, block, meta); - } - - public void dropInventory(World world, int x, int y, int z){ - TileEntityCrucible tileEntity = (TileEntityCrucible)world.getTileEntity(x, y, z); - for (int i = 0; i < tileEntity.getSizeInventory(); i++){ - ItemStack itemStack = tileEntity.getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0){ - Random rand = new Random(); - float dX = rand.nextFloat() * 0.8F + 0.1F; - float dY = rand.nextFloat() * 0.8F + 0.1F; - float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if (itemStack.hasTagCompound()) entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); - float factor = 0.05F; - entityItem.motionX = rand.nextGaussian() * factor; - entityItem.motionY = rand.nextGaussian() * factor + 0.2F; - entityItem.motionZ = rand.nextGaussian() * factor; - world.spawnEntityInWorld(entityItem); - itemStack.stackSize = 0; - } - } + public TileEntityInventoryBase dropInventory(World world, int x, int y, int z){ + TileEntityCrucible tileEntity = (TileEntityCrucible)super.dropInventory(world, x, y, z); if(tileEntity.currentFluid != Util.fluidNone) world.setBlock(x, y, z, Blocks.flowing_water); + return tileEntity; } + public static class ItemBlockCrucible extends ItemBlock { + + public ItemBlockCrucible(Block block){ + super(block); + setHasSubtypes(false); + } + + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName(); + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc")); + else list.add(Util.shiftForInfo()); + } + } } diff --git a/src/main/java/ellpeck/gemification/blocks/BlockCrucibleFire.java b/src/main/java/ellpeck/gemification/blocks/BlockCrucibleFire.java index 5d04073ec..96bcfac80 100644 --- a/src/main/java/ellpeck/gemification/blocks/BlockCrucibleFire.java +++ b/src/main/java/ellpeck/gemification/blocks/BlockCrucibleFire.java @@ -7,21 +7,22 @@ import ellpeck.gemification.Gemification; import ellpeck.gemification.creative.CreativeTab; import ellpeck.gemification.inventory.GuiHandler; import ellpeck.gemification.tile.TileEntityCrucibleFire; +import ellpeck.gemification.util.Util; import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import java.util.List; import java.util.Random; -public class BlockCrucibleFire extends BlockContainer{ +public class BlockCrucibleFire extends BlockContainerBase{ protected BlockCrucibleFire(){ super(Material.rock); @@ -58,32 +59,6 @@ public class BlockCrucibleFire extends BlockContainer{ this.blockIcon = Blocks.hopper.getIcon(0, 0); } - public void breakBlock(World world, int x, int y, int z, Block block, int meta){ - this.dropInventory(world, x, y, z); - super.breakBlock(world, x, y, z, block, meta); - } - - public void dropInventory(World world, int x, int y, int z){ - TileEntityCrucibleFire tileEntity = (TileEntityCrucibleFire)world.getTileEntity(x, y, z); - for (int i = 0; i < tileEntity.getSizeInventory(); i++){ - ItemStack itemStack = tileEntity.getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0){ - Random rand = new Random(); - float dX = rand.nextFloat() * 0.8F + 0.1F; - float dY = rand.nextFloat() * 0.8F + 0.1F; - float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if(itemStack.hasTagCompound()) entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); - float factor = 0.05F; - entityItem.motionX = rand.nextGaussian() * factor; - entityItem.motionY = rand.nextGaussian() * factor + 0.2F; - entityItem.motionZ = rand.nextGaussian() * factor; - world.spawnEntityInWorld(entityItem); - itemStack.stackSize = 0; - } - } - } - @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random rand){ if(((TileEntityCrucibleFire)world.getTileEntity(x, y, z)).isBurning()){ @@ -93,4 +68,23 @@ public class BlockCrucibleFire extends BlockContainer{ } } } + + public static class ItemBlockCrucibleFire extends ItemBlock { + + public ItemBlockCrucibleFire(Block block){ + super(block); + setHasSubtypes(false); + } + + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName(); + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc")); + else list.add(Util.shiftForInfo()); + } + } } \ No newline at end of file diff --git a/src/main/java/ellpeck/gemification/blocks/InitBlocks.java b/src/main/java/ellpeck/gemification/blocks/InitBlocks.java index a299ff722..dc10de477 100644 --- a/src/main/java/ellpeck/gemification/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/gemification/blocks/InitBlocks.java @@ -15,9 +15,9 @@ public class InitBlocks{ blockCrucible = new BlockCrucible(); blockCrucibleFire = new BlockCrucibleFire(); - GameRegistry.registerBlock(oreGem, ItemBlockOreGem.class, oreGem.getUnlocalizedName().substring(5)); - GameRegistry.registerBlock(blockCrucible, ItemBlockCrucible.class, blockCrucible.getUnlocalizedName().substring(5)); - GameRegistry.registerBlock(blockCrucibleFire, ItemBlockCrucibleFire.class, blockCrucibleFire.getUnlocalizedName().substring(5)); + GameRegistry.registerBlock(oreGem, OreGem.ItemBlockOreGem.class, oreGem.getUnlocalizedName().substring(5)); + GameRegistry.registerBlock(blockCrucible, BlockCrucible.ItemBlockCrucible.class, blockCrucible.getUnlocalizedName().substring(5)); + GameRegistry.registerBlock(blockCrucibleFire, BlockCrucibleFire.ItemBlockCrucibleFire.class, blockCrucibleFire.getUnlocalizedName().substring(5)); } diff --git a/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucible.java b/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucible.java deleted file mode 100644 index 888ed2da0..000000000 --- a/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucible.java +++ /dev/null @@ -1,31 +0,0 @@ -package ellpeck.gemification.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.gemification.util.Util; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -import java.util.List; - -public class ItemBlockCrucible extends ItemBlock { - - public ItemBlockCrucible(Block block){ - super(block); - setHasSubtypes(false); - } - - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName(); - } - - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc")); - else list.add(Util.shiftForInfo()); - } -} diff --git a/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucibleFire.java b/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucibleFire.java deleted file mode 100644 index 037afc698..000000000 --- a/src/main/java/ellpeck/gemification/blocks/ItemBlockCrucibleFire.java +++ /dev/null @@ -1,31 +0,0 @@ -package ellpeck.gemification.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.gemification.util.Util; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -import java.util.List; - -public class ItemBlockCrucibleFire extends ItemBlock { - - public ItemBlockCrucibleFire(Block block){ - super(block); - setHasSubtypes(false); - } - - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName(); - } - - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc")); - else list.add(Util.shiftForInfo()); - } -} diff --git a/src/main/java/ellpeck/gemification/blocks/ItemBlockOreGem.java b/src/main/java/ellpeck/gemification/blocks/ItemBlockOreGem.java deleted file mode 100644 index 9176e2923..000000000 --- a/src/main/java/ellpeck/gemification/blocks/ItemBlockOreGem.java +++ /dev/null @@ -1,43 +0,0 @@ -package ellpeck.gemification.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.gemification.util.Util; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -import java.util.List; - -public class ItemBlockOreGem extends ItemBlock { - - public ItemBlockOreGem(Block block){ - super(block); - setHasSubtypes(true); - } - - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + Util.gemList.get(stack.getItemDamage()).name.substring(5); - } - - public int getMetadata(int i) { - return i; - } - - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - if(Util.isShiftPressed()){ - for(int i = 0; i < Util.gemList.size(); i++){ - if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemList.get(i).name.substring(5) + ".desc")); - } - list.add(EnumChatFormatting.BOLD + StatCollector.translateToLocal("tooltip.gemIsOre.desc")); - } - else{ - list.add(Util.shiftForInfo()); - } - } -} diff --git a/src/main/java/ellpeck/gemification/blocks/OreGem.java b/src/main/java/ellpeck/gemification/blocks/OreGem.java index c04377d68..f77a1f67a 100644 --- a/src/main/java/ellpeck/gemification/blocks/OreGem.java +++ b/src/main/java/ellpeck/gemification/blocks/OreGem.java @@ -9,9 +9,13 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; import java.util.List; import java.util.Random; @@ -60,4 +64,34 @@ public class OreGem extends Block{ textures[i] = iconReg.registerIcon(Util.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5)); } } + + public static class ItemBlockOreGem extends ItemBlock { + + public ItemBlockOreGem(Block block){ + super(block); + setHasSubtypes(true); + } + + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + Util.gemList.get(stack.getItemDamage()).name.substring(5); + } + + public int getMetadata(int i) { + return i; + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(Util.isShiftPressed()){ + for(int i = 0; i < Util.gemList.size(); i++){ + if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemList.get(i).name.substring(5) + ".desc")); + } + list.add(EnumChatFormatting.BOLD + StatCollector.translateToLocal("tooltip.gemIsOre.desc")); + } + else{ + list.add(Util.shiftForInfo()); + } + } + } } diff --git a/src/main/java/ellpeck/gemification/booklet/Chapter.java b/src/main/java/ellpeck/gemification/booklet/Chapter.java new file mode 100644 index 000000000..bef076e90 --- /dev/null +++ b/src/main/java/ellpeck/gemification/booklet/Chapter.java @@ -0,0 +1,23 @@ +package ellpeck.gemification.booklet; + +import net.minecraft.util.StatCollector; + +public class Chapter{ + + public final int ID; + public final String name; + public final int pageAmount; + public final boolean hasCraftingRecipe; + public String[] pageTexts; + + public Chapter(int ID, String name, int pageAmount, boolean hasCraftingRecipe){ + this.ID = ID; + this.name = name; + this.pageAmount = pageAmount; + this.hasCraftingRecipe = hasCraftingRecipe; + this.pageTexts = new String[pageAmount]; + for(int i = 0; i < pageTexts.length; i++){ + this.pageTexts[i] = StatCollector.translateToLocal("infoBook." + this.name + ".page" + i + ".text"); + } + } +} diff --git a/src/main/java/ellpeck/gemification/booklet/ChapterList.java b/src/main/java/ellpeck/gemification/booklet/ChapterList.java new file mode 100644 index 000000000..f80368b96 --- /dev/null +++ b/src/main/java/ellpeck/gemification/booklet/ChapterList.java @@ -0,0 +1,14 @@ +package ellpeck.gemification.booklet; + +import java.util.ArrayList; + +public class ChapterList{ + + public static ArrayList chapterList = new ArrayList(); + + public static void init(){ + chapterList.add(new Chapter(0, "testChapterOne", 2, false)); + chapterList.add(new Chapter(1, "testChapterTwo", 3, false)); + chapterList.add(new Chapter(2, "testChapterThree", 2, false)); + } +} diff --git a/src/main/java/ellpeck/gemification/booklet/ContainerInfoBook.java b/src/main/java/ellpeck/gemification/booklet/ContainerInfoBook.java new file mode 100644 index 000000000..bb6208f32 --- /dev/null +++ b/src/main/java/ellpeck/gemification/booklet/ContainerInfoBook.java @@ -0,0 +1,16 @@ +package ellpeck.gemification.booklet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +public class ContainerInfoBook extends Container { + + @SuppressWarnings("unused") + public ContainerInfoBook(EntityPlayer player){ + + } + + public boolean canInteractWith(EntityPlayer player){ + return true; + } +} diff --git a/src/main/java/ellpeck/gemification/booklet/GuiInfoBook.java b/src/main/java/ellpeck/gemification/booklet/GuiInfoBook.java new file mode 100644 index 000000000..31bf2f1f3 --- /dev/null +++ b/src/main/java/ellpeck/gemification/booklet/GuiInfoBook.java @@ -0,0 +1,149 @@ +package ellpeck.gemification.booklet; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.gemification.util.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +public class GuiInfoBook extends GuiScreen{ + + public static final ResourceLocation resLoc = new ResourceLocation(Util.MOD_ID, "textures/gui/guiInfoBook.png"); + + public final int xSize = 180; + public final int ySize = 180; + + public Chapter mainChapter = new Chapter(-1, "mainChapter", 0, false); + + public int currentPage = 0; + public Chapter currentChapter = mainChapter; + + public ChangePageButton nextPageButton; + public ChangePageButton prevPageButton; + public ChangePageButton mainPageButton; + + @SuppressWarnings("unused") + public GuiInfoBook(EntityPlayer player){ + + } + + @SuppressWarnings("all") + public void initGui(){ + this.buttonList.clear(); + + int xPos = (this.width-this.xSize)/2; + int yPos = (this.height-this.ySize)/2; + + this.addMainChapterButtons(); + this.nextPageButton = new ChangePageButton(-3, xPos+180, yPos+170); + this.prevPageButton = new ChangePageButton(-2, xPos-18, yPos+170); + this.mainPageButton = new ChangePageButton(-1, xPos, yPos-15); + this.buttonList.add(nextPageButton); + this.buttonList.add(prevPageButton); + this.buttonList.add(mainPageButton); + + this.updateButtons(); + } + + @SuppressWarnings("all") + public void addMainChapterButtons(){ + int xPos = (this.width-this.xSize)/2; + int yPos = (this.height-this.ySize)/2; + + int size = ChapterList.chapterList.size(); + for(int i = 0; i < size; i++){ + this.buttonList.add(new InvisiButton(i, xPos + 15, yPos + 15 + 11*i, 150, 10, StatCollector.translateToLocal("infoBook." + ChapterList.chapterList.get(i).name + ".title"))); + } + } + + public void updateButtons(){ + this.nextPageButton.visible = this.currentChapter.pageAmount > 0 && this.currentPage < this.currentChapter.pageAmount-1; + this.prevPageButton.visible = this.currentPage > 0; + this.mainPageButton.visible = this.currentChapter != this.mainChapter; + for(int i = 0; i < ChapterList.chapterList.size(); i++){ + ((GuiButton)this.buttonList.get(i)).visible = this.currentChapter == mainChapter; + } + + System.out.println(currentPage); + } + + @SuppressWarnings("static-access") + public void actionPerformed(GuiButton button){ + if(button == this.nextPageButton) this.currentPage++; + else if(button == this.prevPageButton) this.currentPage--; + else if(button == this.mainPageButton){ + this.currentPage = 0; + this.currentChapter = this.mainChapter; + } + else this.currentChapter = ChapterList.chapterList.get(button.id); + this.updateButtons(); + } + + public void drawScreen(int x, int y, float f){ + this.drawDefaultBackground(); + GL11.glColor4f(1F, 1F, 1F, 1F); + + int xPos = (this.width-this.xSize)/2; + int yPos = (this.height-this.ySize)/2; + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(xPos, yPos, 0, 0, this.xSize, this.ySize); + + super.drawScreen(x, y, f); + } + + @SideOnly(Side.CLIENT) + static class ChangePageButton extends GuiButton{ + /** + * Type of the button + * -3: Next Page + * -2: Previous Page + * -1: Back to main Page + */ + private final int buttonType; + + public ChangePageButton(int ID, int x, int y){ + super(ID, x, y, 18, ID == -1 ? 14 : 10, ""); + this.buttonType = ID; + } + + public void drawButton(Minecraft mc, int mouseX, int mouseY){ + if (this.visible){ + boolean isHoverOver = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(GuiInfoBook.resLoc); + + int posX = 0; + int posY = 180; + if(this.buttonType == -2) posY += 10; + else if(this.buttonType == -1) posY += 20; + if(isHoverOver) posX += 18; + this.drawTexturedModalRect(this.xPosition, this.yPosition, posX, posY, 18, this.buttonType == -1 ? 14 : 10); + } + } + } + + @SideOnly(Side.CLIENT) + static class InvisiButton extends GuiButton{ + public InvisiButton(int ID, int x, int y, int width, int height, String text){ + super(ID, x, y, width, height, text); + } + + public void drawButton(Minecraft mc, int mouseX, int mouseY){ + if (this.visible){ + boolean isHoverOver = false; + if(mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) isHoverOver = true; + mc.fontRenderer.drawString((isHoverOver ? ((char)167+"2" + (char)167+"n") : "") + this.displayString, this.xPosition, this.yPosition + (this.height - 8) / 2, 0); + } + } + } + + public boolean doesGuiPauseGame(){ + return false; + } +} diff --git a/src/main/java/ellpeck/gemification/booklet/ItemInfoBook.java b/src/main/java/ellpeck/gemification/booklet/ItemInfoBook.java new file mode 100644 index 000000000..27a2c0f68 --- /dev/null +++ b/src/main/java/ellpeck/gemification/booklet/ItemInfoBook.java @@ -0,0 +1,47 @@ +package ellpeck.gemification.booklet; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.gemification.Gemification; +import ellpeck.gemification.creative.CreativeTab; +import ellpeck.gemification.inventory.GuiHandler; +import ellpeck.gemification.util.Util; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.List; + +public class ItemInfoBook extends Item { + + public ItemInfoBook(){ + this.setCreativeTab(CreativeTab.instance); + this.setUnlocalizedName("itemInfoBook"); + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc")); + else list.add(Util.shiftForInfo()); + } + + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(Util.MOD_ID + ":" + this.getUnlocalizedName().substring(5)); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if (!world.isRemote){ + player.openGui(Gemification.instance, GuiHandler.guiInfoBook, world, (int)player.posX, (int)player.posY, (int)player.posZ); + } + return stack; + } +} diff --git a/src/main/java/ellpeck/gemification/crafting/CrucibleCraftingManager.java b/src/main/java/ellpeck/gemification/crafting/CrucibleCraftingManager.java index 9163ad219..3f34d90e9 100644 --- a/src/main/java/ellpeck/gemification/crafting/CrucibleCraftingManager.java +++ b/src/main/java/ellpeck/gemification/crafting/CrucibleCraftingManager.java @@ -1,12 +1,10 @@ package ellpeck.gemification.crafting; import ellpeck.gemification.util.GemType; -import ellpeck.gemification.util.Util; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; import java.util.HashMap; @@ -16,11 +14,6 @@ public class CrucibleCraftingManager{ public static final CrucibleCraftingManager instance = new CrucibleCraftingManager(); public static ArrayList recipes = new ArrayList(); - @SuppressWarnings("all") - public void initRecipes(){ - this.addRecipe(new ItemStack(Blocks.acacia_stairs), Util.fluidChromeDiopside, 200, new Object[]{"ccc", "cgc", "ccc", 'c', Blocks.cobblestone, 'g', new ItemStack(Items.stick)}); - } - @SuppressWarnings("unchecked, static-access") public void addRecipe(ItemStack output, GemType fluidNeeded, int processTimeNeeded, Object ... recipe){ String s = ""; @@ -51,10 +44,10 @@ public class CrucibleCraftingManager{ ItemStack stack1 = null; if (recipe[i + 1] instanceof Item){ - stack1 = new ItemStack((Item)recipe[i + 1], 1, 32767); + stack1 = new ItemStack((Item)recipe[i + 1], 1, OreDictionary.WILDCARD_VALUE); } else if (recipe[i + 1] instanceof Block){ - stack1 = new ItemStack((Block)recipe[i + 1], 1, 32767); + stack1 = new ItemStack((Block)recipe[i + 1], 1, OreDictionary.WILDCARD_VALUE); } else if (recipe[i + 1] instanceof ItemStack){ stack1 = (ItemStack)recipe[i + 1]; @@ -102,7 +95,7 @@ public class CrucibleCraftingManager{ int k = 0; for (int j = 0; j < maxSlot - minSlot + 1; j++){ if (slots[minSlot + j] != null && inputs[j] != null && slots[minSlot + j].getItem() == inputs[j].getItem()){ - if(inputs[j].getItemDamage() == 32767 || inputs[j].getItemDamage() == slots[minSlot + j].getItemDamage()) { + if(inputs[j].getItemDamage() == OreDictionary.WILDCARD_VALUE || inputs[j].getItemDamage() == slots[minSlot + j].getItemDamage()) { k++; } } diff --git a/src/main/java/ellpeck/gemification/crafting/InitCrafting.java b/src/main/java/ellpeck/gemification/crafting/InitCrafting.java new file mode 100644 index 000000000..713b2e63a --- /dev/null +++ b/src/main/java/ellpeck/gemification/crafting/InitCrafting.java @@ -0,0 +1,21 @@ +package ellpeck.gemification.crafting; + +import cpw.mods.fml.common.registry.GameRegistry; +import ellpeck.gemification.blocks.InitBlocks; +import ellpeck.gemification.items.InitItems; +import ellpeck.gemification.util.Util; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class InitCrafting { + + public static void init(){ + GameRegistry.addRecipe(new ItemStack(InitBlocks.blockCrucible), "i i", "gcg", "iii", 'i', Items.iron_ingot, 'g', new ItemStack(InitItems.itemGem, 1, OreDictionary.WILDCARD_VALUE), 'c', Items.cauldron); + GameRegistry.addRecipe(new ItemStack(InitBlocks.blockCrucibleFire), "ccc", "cac", "sss", 'c', Blocks.cobblestone, 'a', Items.cauldron, 's', Blocks.stone_slab); + + CrucibleCraftingManager.instance.addRecipe(new ItemStack(Blocks.acacia_stairs), Util.chromeDiopside, 200, "ccc", "cgc", "ccc", 'c', Blocks.cobblestone, 'g', Items.stick); + } + +} diff --git a/src/main/java/ellpeck/gemification/inventory/GuiHandler.java b/src/main/java/ellpeck/gemification/inventory/GuiHandler.java index 599ee2eb8..4f15e0b78 100644 --- a/src/main/java/ellpeck/gemification/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/gemification/inventory/GuiHandler.java @@ -3,6 +3,8 @@ package ellpeck.gemification.inventory; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import ellpeck.gemification.Gemification; +import ellpeck.gemification.booklet.ContainerInfoBook; +import ellpeck.gemification.booklet.GuiInfoBook; import ellpeck.gemification.inventory.container.ContainerCrucible; import ellpeck.gemification.inventory.container.ContainerCrucibleFire; import ellpeck.gemification.inventory.gui.GuiCrucible; @@ -17,6 +19,7 @@ public class GuiHandler implements IGuiHandler { public static final int guiCrucible = 0; public static final int guiCrucibleFire = 1; + public static final int guiInfoBook = 2; public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) { TileEntityBase tile = (TileEntityBase)world.getTileEntity(x, y, z); @@ -25,6 +28,8 @@ public class GuiHandler implements IGuiHandler { return new ContainerCrucible(entityPlayer.inventory, (TileEntityCrucible)tile); case guiCrucibleFire: return new ContainerCrucibleFire(entityPlayer.inventory, (TileEntityCrucibleFire)tile); + case guiInfoBook: + return new ContainerInfoBook(entityPlayer); default: return null; @@ -38,6 +43,8 @@ public class GuiHandler implements IGuiHandler { return new GuiCrucible(entityPlayer.inventory, (TileEntityCrucible)tile); case guiCrucibleFire: return new GuiCrucibleFire(entityPlayer.inventory, (TileEntityCrucibleFire)tile); + case guiInfoBook: + return new GuiInfoBook(entityPlayer); default: return null; diff --git a/src/main/java/ellpeck/gemification/inventory/gui/GuiCrucibleFire.java b/src/main/java/ellpeck/gemification/inventory/gui/GuiCrucibleFire.java index 52aeaa8b6..b587fd29c 100644 --- a/src/main/java/ellpeck/gemification/inventory/gui/GuiCrucibleFire.java +++ b/src/main/java/ellpeck/gemification/inventory/gui/GuiCrucibleFire.java @@ -33,8 +33,4 @@ public class GuiCrucibleFire extends GuiContainer{ this.drawTexturedModalRect(guiLeft + 96, guiTop + 10 + 12 - i, 176, 12 - i, 14, i + 1); } } - - public void drawScreen(int par1, int par2, float par3){ - super.drawScreen(par1, par2, par3); - } } diff --git a/src/main/java/ellpeck/gemification/items/InitItems.java b/src/main/java/ellpeck/gemification/items/InitItems.java index 3b63e0617..09c1842e8 100644 --- a/src/main/java/ellpeck/gemification/items/InitItems.java +++ b/src/main/java/ellpeck/gemification/items/InitItems.java @@ -1,17 +1,21 @@ package ellpeck.gemification.items; -import net.minecraft.item.Item; import cpw.mods.fml.common.registry.GameRegistry; +import ellpeck.gemification.booklet.ItemInfoBook; +import net.minecraft.item.Item; public class InitItems { public static Item itemGem; + public static Item itemInfoBook; public static void init(){ itemGem = new ItemGem(); + itemInfoBook = new ItemInfoBook(); GameRegistry.registerItem(itemGem, itemGem.getUnlocalizedName().substring(5)); + GameRegistry.registerItem(itemInfoBook, itemInfoBook.getUnlocalizedName().substring(5)); } } diff --git a/src/main/java/ellpeck/gemification/util/GemType.java b/src/main/java/ellpeck/gemification/util/GemType.java index ddaed25cb..136765175 100644 --- a/src/main/java/ellpeck/gemification/util/GemType.java +++ b/src/main/java/ellpeck/gemification/util/GemType.java @@ -2,8 +2,8 @@ package ellpeck.gemification.util; public class GemType { - public int ID; - public String name; + public final int ID; + public final String name; public GemType(int ID, String name, boolean shouldAddToList){ this.ID = ID; diff --git a/src/main/java/ellpeck/gemification/util/Util.java b/src/main/java/ellpeck/gemification/util/Util.java index 4e593a4e3..592c004e6 100644 --- a/src/main/java/ellpeck/gemification/util/Util.java +++ b/src/main/java/ellpeck/gemification/util/Util.java @@ -1,12 +1,12 @@ package ellpeck.gemification.util; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import org.lwjgl.input.Keyboard; import java.util.ArrayList; -public class Util { +@SuppressWarnings("unused") +public class Util{ public static final String MOD_ID = "gemification"; public static final String NAME = "Gemification"; @@ -14,22 +14,22 @@ public class Util { public static ArrayList gemList = new ArrayList(); - public static final GemType fluidOnyx = new GemType(0, "Onyx", true); - public static final GemType fluidAlmandineGarnet = new GemType(1, "AlmandineGarnet", true); - public static final GemType fluidChromeDiopside = new GemType(2, "ChromeDiopside", true); - public static final GemType fluidJasper = new GemType(3, "Jasper", true); - public static final GemType fluidSodalite = new GemType(4, "Sodalite", true); - public static final GemType fluidIolite = new GemType(5, "Iolite", true); - public static final GemType fluidSmithsonite = new GemType(6, "Smithsonite", true); - public static final GemType fluidDanburite = new GemType(7, "Danburite", true); - public static final GemType fluidHematite = new GemType(8, "Hematite", true); - public static final GemType fluidLepidolite = new GemType(9, "Lepidolite", true); - public static final GemType fluidTourmaline = new GemType(10, "Tourmaline", true); - public static final GemType fluidSphene = new GemType(11, "Sphene", true); - public static final GemType fluidParaibaTourlamine = new GemType(12, "ParaibaTourlamine", true); - public static final GemType fluidRhodochrosite = new GemType(13, "Rhodochrosite", true); - public static final GemType fluidClinohumite = new GemType(14, "Clinohumite", true); - public static final GemType fluidGoshenite = new GemType(15, "Goshenite", true); + public static final GemType onyx = new GemType(0, "Onyx", true); + public static final GemType almandineGarnet = new GemType(1, "AlmandineGarnet", true); + public static final GemType chromeDiopside = new GemType(2, "ChromeDiopside", true); + public static final GemType jasper = new GemType(3, "Jasper", true); + public static final GemType sodalite = new GemType(4, "Sodalite", true); + public static final GemType iolite = new GemType(5, "Iolite", true); + public static final GemType smithsonite = new GemType(6, "Smithsonite", true); + public static final GemType danburite = new GemType(7, "Danburite", true); + public static final GemType hematite = new GemType(8, "Hematite", true); + public static final GemType lepidolite = new GemType(9, "Lepidolite", true); + public static final GemType tourmaline = new GemType(10, "Tourmaline", true); + public static final GemType sphene = new GemType(11, "Sphene", true); + public static final GemType paraibaTourlamine = new GemType(12, "ParaibaTourlamine", true); + public static final GemType rhodochrosite = new GemType(13, "Rhodochrosite", true); + public static final GemType clinohumite = new GemType(14, "Clinohumite", true); + public static final GemType goshenite = new GemType(15, "Goshenite", true); public static final GemType fluidWater = new GemType(16, "Water", false); public static final GemType fluidNone = new GemType(17, "None", false); @@ -38,6 +38,6 @@ public class Util { } public static String shiftForInfo() { - return ((char)167+"2" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("tooltip.shiftForInfo.desc")); + return (char)167+"2" + (char)167+"o" + StatCollector.translateToLocal("tooltip.shiftForInfo.desc"); } } diff --git a/src/main/resources/assets/gemification/textures/gui/guiInfoBook.png b/src/main/resources/assets/gemification/textures/gui/guiInfoBook.png new file mode 100644 index 000000000..8cdb81568 Binary files /dev/null and b/src/main/resources/assets/gemification/textures/gui/guiInfoBook.png differ diff --git a/src/main/resources/assets/gemification/textures/items/itemInfoBook.png b/src/main/resources/assets/gemification/textures/items/itemInfoBook.png new file mode 100644 index 000000000..4784fed1b Binary files /dev/null and b/src/main/resources/assets/gemification/textures/items/itemInfoBook.png differ