diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index aed36b96a..620310a9c 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -38,6 +38,7 @@ import ellpeck.actuallyadditions.ore.InitOreDict; import ellpeck.actuallyadditions.proxy.IProxy; import ellpeck.actuallyadditions.recipe.FuelHandler; import ellpeck.actuallyadditions.recipe.HairyBallHandler; +import ellpeck.actuallyadditions.recipe.ToolTableHandler; import ellpeck.actuallyadditions.recipe.TreasureChestHandler; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.update.UpdateChecker; @@ -96,6 +97,7 @@ public class ActuallyAdditions{ CrusherCrafting.init(); ItemCrafting.initMashedFoodRecipes(); HairyBallHandler.init(); + ToolTableHandler.init(); TreasureChestHandler.init(); InitForeignPaxels.init(); proxy.postInit(event); diff --git a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt index 815afd926..0f8d6fb3a 100644 --- a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt +++ b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt @@ -142,4 +142,10 @@ -Laser Transport System -Lasers that shoot between different transmitters - -Transmitters can have prisms etc. to change direction, split up or decide if items, fluids or energy should be moved and how much and how fast \ No newline at end of file + -Transmitters can have prisms etc. to change direction, split up or decide if items, fluids or energy should be moved and how much and how fast + +-Tool Table + -Put in any tool and special items + -Make the tool more awesome (Lumberaxe, Battleaxe, Silk Pick, Fortune Pick etc.) + -Every item in the table results in a special feature (e.g. Black Quartz -> Silk, Emeralds -> Fortune etc.) + -> Make drill more endgame, make this midgame stuff \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockToolTable.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockToolTable.java new file mode 100644 index 000000000..0beb8082c --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockToolTable.java @@ -0,0 +1,131 @@ +/* + * This file ("BlockToolTable.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.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityToolTable; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockToolTable extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + private IIcon frontIcon; + + public BlockToolTable(){ + super(Material.wood); + this.setHarvestLevel("axe", 0); + this.setHardness(1.5F); + this.setResistance(5.0F); + this.setStepSound(soundTypeWood); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ + int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; + + if(rotation == 0) world.setBlockMetadataWithNotify(x, y, z, 0, 2); + if(rotation == 1) world.setBlockMetadataWithNotify(x, y, z, 3, 2); + if(rotation == 2) world.setBlockMetadataWithNotify(x, y, z, 1, 2); + if(rotation == 3) world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityToolTable(); + } + + @Override + public IIcon getIcon(int side, int meta){ + if(side == 1 || side == 0) return this.topIcon; + if(side == 3) return this.frontIcon; + return this.blockIcon; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ + int meta = world.getBlockMetadata(x, y, z); + if(side == 1 || side == 0) return this.topIcon; + if(side == meta+2) return this.frontIcon; + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Top"); + this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Front"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityToolTable table = (TileEntityToolTable)world.getTileEntity(x, y, z); + if(table != null){ + player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.TOOL_TABLE.ordinal(), world, x, y, z); + } + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return "blockToolTable"; + } + + public static class TheItemBlock extends ItemBlock{ + + public TheItemBlock(Block block){ + super(block); + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java index ac6c1cd9c..957ad26d2 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java @@ -93,9 +93,14 @@ public class InitBlocks{ public static Block blockSmileyCloud; + public static Block blockToolTable; + public static void init(){ ModUtil.LOGGER.info("Initializing Blocks..."); + blockToolTable = new BlockToolTable(); + BlockUtil.register(blockToolTable); + blockSmileyCloud = new BlockSmileyCloud(); BlockUtil.register(blockSmileyCloud); @@ -294,6 +299,6 @@ public class InitBlocks{ } public static void errorAlreadyRegistered(String str){ - ModUtil.LOGGER.warn(str + " from "+ModUtil.NAME+" is not getting used as it has already been registered by another Mod! If this causes Issues (which it shouldn't!), you can turn this off in the Config File!"); + ModUtil.LOGGER.warn(str+" from "+ModUtil.NAME+" is not getting used as it has already been registered by another Mod! If this causes Issues (which it shouldn't!), you can turn this off in the Config File!"); } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerToolTable.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerToolTable.java new file mode 100644 index 000000000..876cf5cf7 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerToolTable.java @@ -0,0 +1,100 @@ +/* + * This file ("ContainerToolTable.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.inventory; + +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine; +import ellpeck.actuallyadditions.tile.TileEntityToolTable; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +@InventoryContainer +public class ContainerToolTable extends Container{ + + private TileEntityToolTable table; + + public ContainerToolTable(InventoryPlayer inventory, TileEntityBase tile){ + this.table = (TileEntityToolTable)tile; + + this.addSlotToContainer(new SlotOutput(this.table, 0, 115, 25)); + for(int i = 0; i < 3; i++){ + for(int j = 0; j < 2; j++){ + this.addSlotToContainer(new Slot(this.table, j+i*2+1, 35+j*18, 7+i*18)); + } + } + + for(int i = 0; i < 3; i++){ + for(int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 69+i*18)); + } + } + for(int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 127)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.table.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 7; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + + if (theSlot != null && theSlot.getHasStack()){ + ItemStack newStack = theSlot.getStack(); + ItemStack currentStack = newStack.copy(); + + //Slots in Inventory to shift from + if(slot == TileEntityToolTable.SLOT_OUTPUT){ + if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)) return null; + theSlot.onSlotChange(newStack, currentStack); + } + //Other Slots in Inventory excluded + else if(slot >= inventoryStart){ + //Shift from Inventory + //TODO THIS + if(newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CUP.ordinal()){ + if(!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT+1, false)) return null; + } + // + + else if(slot >= inventoryStart && slot <= inventoryEnd){ + if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)) return null; + } + else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)) return null; + } + else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)) return null; + + if (newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + + if (newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index 07bcd446c..88ac745b6 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -77,6 +77,8 @@ public class GuiHandler implements IGuiHandler{ return new ContainerOreMagnet(entityPlayer.inventory, tile); case CLOUD: return new ContainerSmileyCloud(); + case TOOL_TABLE: + return new ContainerToolTable(entityPlayer.inventory, tile); default: return null; } @@ -139,6 +141,8 @@ public class GuiHandler implements IGuiHandler{ return new GuiSmileyCloud(tile, x, y, z, world); case BOOK: return new GuiBooklet(); + case TOOL_TABLE: + return new GuiToolTable(entityPlayer.inventory, tile); default: return null; } @@ -169,7 +173,8 @@ public class GuiHandler implements IGuiHandler{ XP_SOLIDIFIER, ORE_MAGNET, CLOUD, - BOOK(false); + BOOK(false), + TOOL_TABLE; public boolean checkTileEntity; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiToolTable.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiToolTable.java new file mode 100644 index 000000000..1453e0cb8 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiToolTable.java @@ -0,0 +1,58 @@ +/* + * This file ("GuiToolTable.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.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerToolTable; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityToolTable; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiToolTable extends GuiContainer{ + + private TileEntityToolTable table; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiToolTable"); + + public GuiToolTable(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerToolTable(inventory, tile)); + this.table = (TileEntityToolTable)tile; + this.xSize = 176; + this.ySize = 65+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.table.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+65, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 65); + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java new file mode 100644 index 000000000..e221dce39 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java @@ -0,0 +1,46 @@ +/* + * This file ("ToolTableHandler.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.recipe; + +import ellpeck.actuallyadditions.items.InitItems; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; + +public class ToolTableHandler{ + + public static ArrayList recipes = new ArrayList(); + + public static void init(){ + addRecipe(new ItemStack(Items.diamond_pickaxe), new ItemStack(InitItems.itemPhantomConnector), new ItemStack(Blocks.stone_brick_stairs), new ItemStack(Blocks.planks)); + } + + private static void addRecipe(ItemStack tool, ItemStack output, ItemStack... itemsNeeded){ + recipes.add(new Recipe(tool, output, itemsNeeded)); + } + + public static class Recipe{ + + public ItemStack tool; + public ItemStack[] itemsNeeded; + public ItemStack output; + + public Recipe(ItemStack tool, ItemStack output, ItemStack... itemsNeeded){ + this.tool = tool; + this.output = output; + this.itemsNeeded = itemsNeeded; + } + + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java index 047998663..fc1ebaa94 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java @@ -71,6 +71,7 @@ public class TileEntityBase extends TileEntity{ GameRegistry.registerTileEntity(TileEntityXPSolidifier.class, ModUtil.MOD_ID_LOWER+":tileEntityXPSolidifier"); GameRegistry.registerTileEntity(TileEntityOreMagnet.class, ModUtil.MOD_ID_LOWER+":tileEntityOreMagnet"); GameRegistry.registerTileEntity(TileEntitySmileyCloud.class, ModUtil.MOD_ID_LOWER+":tileEntityCloud"); + GameRegistry.registerTileEntity(TileEntityToolTable.class, ModUtil.MOD_ID_LOWER+":tileEntityToolTable"); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityToolTable.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityToolTable.java new file mode 100644 index 000000000..aace0ce61 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityToolTable.java @@ -0,0 +1,37 @@ +/* + * This file ("TileEntityToolTable.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.tile; + +import net.minecraft.item.ItemStack; + +public class TileEntityToolTable extends TileEntityInventoryBase{ + + public static final int SLOT_OUTPUT = 6; + + public TileEntityToolTable(){ + super(7, "toolTable"); + } + + @Override + public void updateEntity(){ + + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return false; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return false; + } +}