mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Started Booklet, looking good!
This commit is contained in:
parent
79b2abefca
commit
46332e7beb
23 changed files with 448 additions and 207 deletions
|
@ -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")
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
23
src/main/java/ellpeck/gemification/booklet/Chapter.java
Normal file
23
src/main/java/ellpeck/gemification/booklet/Chapter.java
Normal file
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
14
src/main/java/ellpeck/gemification/booklet/ChapterList.java
Normal file
14
src/main/java/ellpeck/gemification/booklet/ChapterList.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ellpeck.gemification.booklet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChapterList{
|
||||
|
||||
public static ArrayList<Chapter> chapterList = new ArrayList<Chapter>();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
149
src/main/java/ellpeck/gemification/booklet/GuiInfoBook.java
Normal file
149
src/main/java/ellpeck/gemification/booklet/GuiInfoBook.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
47
src/main/java/ellpeck/gemification/booklet/ItemInfoBook.java
Normal file
47
src/main/java/ellpeck/gemification/booklet/ItemInfoBook.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<CrucibleRecipe> recipes = new ArrayList<CrucibleRecipe>();
|
||||
|
||||
@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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<GemType> gemList = new ArrayList<GemType>();
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 301 B |
Loading…
Reference in a new issue