diff --git a/gradle.properties b/gradle.properties index e4c88c93..c44b0c99 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ minecraft_version=1.7.10 forge_version=10.13.2.1277 waila_version=1.5.3 -ccl_version=1.1.1.95 -ccc_version=1.0.2.11 -nei_version=1.0.2.26 -fmp_version=1.1.0.297 +ccl_version=1.1.1.110 +ccc_version=1.0.4.29 +nei_version=1.0.3.74 +fmp_version=1.1.1.320 projectId='225236' \ No newline at end of file diff --git a/src/main/java/com/cricketcraft/chisel/Features.java b/src/main/java/com/cricketcraft/chisel/Features.java index 946b1f50..4c0e0eb1 100644 --- a/src/main/java/com/cricketcraft/chisel/Features.java +++ b/src/main/java/com/cricketcraft/chisel/Features.java @@ -63,8 +63,8 @@ import com.cricketcraft.chisel.init.ChiselItems; import com.cricketcraft.chisel.init.ChiselTabs; import com.cricketcraft.chisel.item.ItemBallOMoss; import com.cricketcraft.chisel.item.ItemCarvable; +import com.cricketcraft.chisel.item.ItemCarvableSlab; import com.cricketcraft.chisel.item.ItemCloudInABottle; -import com.cricketcraft.chisel.item.ItemMarbleSlab; import com.cricketcraft.chisel.item.ItemSmashingRock; import com.cricketcraft.chisel.item.ItemUpgrade; import com.cricketcraft.chisel.item.chisel.ItemChisel; @@ -197,6 +197,16 @@ public enum Features { ItemUpgrade upgrade = (ItemUpgrade) new ItemUpgrade("upgrade").setCreativeTab(ChiselTabs.tabChisel); GameRegistry.registerItem(upgrade, "upgrade"); } + + @Override + void addRecipes() { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.upgrade, 1, 0), new Object[] { "IEI", "EUE", "RRR", 'I', "ingotIron", 'E', Items.emerald, 'R', Items.redstone, 'U', + Items.sugar })); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.upgrade, 1, 1), new Object[] { "IEI", "EUE", "RRR", 'I', "ingotIron", 'E', Items.emerald, 'R', Items.redstone, 'U', + Blocks.hopper })); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.upgrade, 1, 2), new Object[] { "IEI", "EUE", "RRR", 'I', "ingotIron", 'E', Items.emerald, 'R', Items.redstone, 'U', + Blocks.crafting_table })); + } }, BALL_OF_MOSS { @@ -481,7 +491,7 @@ public enum Features { @Override void addBlocks() { - BlockCarvableSand colored_sand = (BlockCarvableSand) new BlockCarvableSand().setCreativeTab(ChiselTabs.tabOtherChiselBlocks); + BlockCarvableSand colored_sand = (BlockCarvableSand) new BlockCarvableSand().setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setStepSound(Block.soundTypeSand); colored_sand.carverHelper.setChiselBlockName("Colored Sand"); for (int i = 0; i < 16; i++) @@ -1279,7 +1289,7 @@ public enum Features { OreDictionary.registerOre("limestone", limestone); Carving.chisel.registerOre("limestone", "limestone"); - BlockCarvable limestone_slab = (BlockCarvableSlab) new BlockCarvableSlab(limestone).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F); + BlockCarvableSlab limestone_slab = (BlockCarvableSlab) new BlockCarvableSlab(limestone).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F); limestone_slab.carverHelper.setChiselBlockName("Limestone Slab"); limestone_slab.carverHelper.addVariation("tile.limestoneSlab.0.desc", 0, "limestone"); limestone_slab.carverHelper.addVariation("tile.limestoneSlab.1.desc", 1, "limestone/terrain-cobbsmalltilelight"); @@ -1297,7 +1307,8 @@ public enum Features { limestone_slab.carverHelper.addVariation("tile.limestoneSlab.13.desc", 13, "limestone/terrain-pistonback-lightfour"); limestone_slab.carverHelper.addVariation("tile.limestoneSlab.14.desc", 14, "limestone/terrain-pistonback-lightmarker"); limestone_slab.carverHelper.addVariation("tile.limestoneSlab.15.desc", 15, "limestone/terrain-pistonback-lightpanel"); - limestone_slab.carverHelper.register(limestone_slab, "limestone_slab", ItemMarbleSlab.class); + limestone_slab.carverHelper.register(limestone_slab, "limestone_slab", ItemCarvableSlab.class); + GameRegistry.registerBlock(limestone_slab.top, Block.blockRegistry.getNameForObject(limestone_slab) + "_top"); Carving.chisel.registerOre("limestone_slab", "limestone_slab"); BlockMarbleStairsMaker makerLimestoneStairs = new BlockMarbleStairsMaker(limestone); @@ -1356,7 +1367,7 @@ public enum Features { OreDictionary.registerOre("blockMarble", marble); Carving.chisel.registerOre("marble", "marble"); - BlockCarvable marble_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble).setHardness(2.0F).setResistance(10F); + BlockCarvableSlab marble_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble).setHardness(2.0F).setResistance(10F); marble_slab.carverHelper.setChiselBlockName("Marble Slab"); marble_slab.carverHelper.addVariation("tile.marbleSlab.0.desc", 0, "marble"); marble_slab.carverHelper.addVariation("tile.marbleSlab.1.desc", 1, "marbleslab/a1-stoneornamental-marblebrick"); @@ -1374,7 +1385,8 @@ public enum Features { marble_slab.carverHelper.addVariation("tile.marbleSlab.13.desc", 13, "marbleslab/marble-arranged-bricks"); marble_slab.carverHelper.addVariation("tile.marbleSlab.14.desc", 14, "marbleslab/marble-fancy-bricks"); marble_slab.carverHelper.addVariation("tile.marbleSlab.15.desc", 15, "marbleslab/marble-blocks"); - marble_slab.carverHelper.register(marble_slab, "marble_slab", ItemMarbleSlab.class); + marble_slab.carverHelper.register(marble_slab, "marble_slab", ItemCarvableSlab.class); + GameRegistry.registerBlock(marble_slab.top, Block.blockRegistry.getNameForObject(marble_slab) + "_top"); Carving.chisel.registerOre("marble_slab", "marble_slab"); BlockMarbleStairsMaker makerMarbleStairs = new BlockMarbleStairsMaker(marble); @@ -1455,7 +1467,7 @@ public enum Features { marble_pillar.carverHelper.register(marble_pillar, "marble_pillar"); Carving.chisel.setGroupClass("marble_pillar", "marble"); - BlockCarvable marble_pillar_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble_pillar).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F) + BlockCarvableSlab marble_pillar_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble_pillar).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F) .setStepSound(Block.soundTypeStone); marble_pillar_slab.carverHelper.setChiselBlockName("Marble Pillar Slab"); if (Configurations.oldPillars) { @@ -1493,7 +1505,8 @@ public enum Features { marble_pillar_slab.carverHelper.addVariation("tile.marblePillarSlab.14.desc", 14, "marblepillarslab/carved"); marble_pillar_slab.carverHelper.addVariation("tile.marblePillarSlab.15.desc", 15, "marblepillarslab/ornamental"); } - marble_pillar_slab.carverHelper.register(marble_pillar_slab, "marble_pillar_slab", ItemMarbleSlab.class); + marble_pillar_slab.carverHelper.register(marble_pillar_slab, "marble_pillar_slab", ItemCarvableSlab.class); + GameRegistry.registerBlock(marble_pillar_slab.top, Block.blockRegistry.getNameForObject(marble_pillar_slab) + "_top"); } @Override @@ -2021,6 +2034,8 @@ public enum Features { void addBlocks() { BlockCarvable stonebricksmooth = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(1.5F).setResistance(10.0F) .setStepSound(Block.soundTypeStone); + if (Configurations.allowSmoothStone) + Carving.chisel.addVariation("stonebricksmooth", Blocks.stone, 0, -1); for (int i = 0; i < 4; i++) { if (i == 1) { if (Configurations.allowMossy) diff --git a/src/main/java/com/cricketcraft/chisel/block/BlockCarvableSlab.java b/src/main/java/com/cricketcraft/chisel/block/BlockCarvableSlab.java index 34dc90df..23d4afcc 100644 --- a/src/main/java/com/cricketcraft/chisel/block/BlockCarvableSlab.java +++ b/src/main/java/com/cricketcraft/chisel/block/BlockCarvableSlab.java @@ -13,6 +13,7 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java index 02ab2c8d..11a14ec5 100644 --- a/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java @@ -272,7 +272,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory if (worldObj.isRemote && slot == BASE && stack != null) { lastBase = stack.copy(); - lastBase.stackSize++; } if (!worldObj.isRemote) { diff --git a/src/main/java/com/cricketcraft/chisel/carving/Carving.java b/src/main/java/com/cricketcraft/chisel/carving/Carving.java index 1d6d7e17..05366412 100644 --- a/src/main/java/com/cricketcraft/chisel/carving/Carving.java +++ b/src/main/java/com/cricketcraft/chisel/carving/Carving.java @@ -1,12 +1,11 @@ package com.cricketcraft.chisel.carving; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -100,9 +99,6 @@ public class Carving { } public CarvingGroup getGroup(Block block, int metadata) { - if (block.equals(Blocks.stone)) - block = Blocks.stonebrick; - // Check name first CarvingGroup res; int i = OreDictionary.getOreID(block.getUnlocalizedName()); @@ -124,7 +120,7 @@ public class Carving { return null; } - CarvingGroup getGroup(String name) { + public CarvingGroup getGroup(String name) { CarvingGroup group = carvingGroupsByName.get(name); if (group == null) { group = new CarvingGroup(name); @@ -181,7 +177,12 @@ public class Carving { return blockGroup.sound; } - public Collection getGroups() { - return carvingGroupsByVariation.values(); + public List getSortedGroupNames() { + List names = new ArrayList(); + for (String s : carvingGroupsByName.keySet()) { + names.add(s); + } + Collections.sort(names); + return names; } } diff --git a/src/main/java/com/cricketcraft/chisel/carving/CarvingGroup.java b/src/main/java/com/cricketcraft/chisel/carving/CarvingGroup.java index 73e4c10d..09c40808 100644 --- a/src/main/java/com/cricketcraft/chisel/carving/CarvingGroup.java +++ b/src/main/java/com/cricketcraft/chisel/carving/CarvingGroup.java @@ -17,8 +17,17 @@ public class CarvingGroup { String oreName; List variations = new ArrayList(); - + public List getVariations() { return ImmutableList.copyOf(variations); } -} \ No newline at end of file + + public String getName() { + return name; + } + + public String getOreName() { + return oreName; + } + +} diff --git a/src/main/java/com/cricketcraft/chisel/carving/CarvingVariation.java b/src/main/java/com/cricketcraft/chisel/carving/CarvingVariation.java index 20fa16ca..99da0f9e 100644 --- a/src/main/java/com/cricketcraft/chisel/carving/CarvingVariation.java +++ b/src/main/java/com/cricketcraft/chisel/carving/CarvingVariation.java @@ -1,6 +1,7 @@ package com.cricketcraft.chisel.carving; import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; public class CarvingVariation implements Comparable { @@ -20,4 +21,9 @@ public class CarvingVariation implements Comparable { public Block block; public int meta; public int damage; + + public ItemStack getStack() { + return new ItemStack(block, 1, damage); + } + } diff --git a/src/main/java/com/cricketcraft/chisel/client/gui/GuiAutoChisel.java b/src/main/java/com/cricketcraft/chisel/client/gui/GuiAutoChisel.java index 81ecdf03..4584664e 100644 --- a/src/main/java/com/cricketcraft/chisel/client/gui/GuiAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/client/gui/GuiAutoChisel.java @@ -2,10 +2,12 @@ package com.cricketcraft.chisel.client.gui; import java.util.List; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; @@ -59,5 +61,20 @@ public class GuiAutoChisel extends GuiContainer { int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + + for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) { + if (autochisel.getStackInSlot(i) == null) { + drawSlotOverlay(this, x, y, inventorySlots.getSlot(i), xSize, 0, 8); + } + } + + if (autochisel.getStackInSlot(TileEntityAutoChisel.CHISEL) == null) { + drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0); + } + } + + public static void drawSlotOverlay(GuiContainer gui, int x, int y, Slot slot, int u, int v, int padding) { + padding /= 2; + gui.drawTexturedModalRect(x + (slot.xDisplayPosition - padding), y + (slot.yDisplayPosition - padding), u, v, 18 + padding, 18 + padding); } } diff --git a/src/main/java/com/cricketcraft/chisel/client/gui/GuiChisel.java b/src/main/java/com/cricketcraft/chisel/client/gui/GuiChisel.java index 301368d9..38353a33 100644 --- a/src/main/java/com/cricketcraft/chisel/client/gui/GuiChisel.java +++ b/src/main/java/com/cricketcraft/chisel/client/gui/GuiChisel.java @@ -53,6 +53,14 @@ public class GuiChisel extends GuiContainer { GeneralClient.bind(texture); drawTexturedModalRect(i, j, 0, 0, xSize, ySize); + + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + + Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots); + if (main.getStack() == null) { + GuiAutoChisel.drawSlotOverlay(this, x + 14, y + 14, main, 0, ySize, 60); + } } @Override diff --git a/src/main/java/com/cricketcraft/chisel/compat/NEIChiselConfig.java b/src/main/java/com/cricketcraft/chisel/compat/NEIChiselConfig.java new file mode 100644 index 00000000..cc2c0a7f --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/compat/NEIChiselConfig.java @@ -0,0 +1,29 @@ +package com.cricketcraft.chisel.compat; + +import net.minecraft.item.ItemStack; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; + +import com.cricketcraft.chisel.Chisel; + +import cpw.mods.fml.common.registry.GameRegistry; + +public class NEIChiselConfig implements IConfigureNEI { + + @Override + public String getName() { + return "Chisel NEI Plugin"; + } + + @Override + public String getVersion() { + return Chisel.VERSION; + } + + @Override + public void loadConfig() { + API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "limestone_slab_top"))); + API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_slab_top"))); + API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_pillar_slab_top"))); + } +} diff --git a/src/main/java/com/cricketcraft/chisel/compat/nei/NEIChiselConfig.java b/src/main/java/com/cricketcraft/chisel/compat/nei/NEIChiselConfig.java new file mode 100644 index 00000000..4e1a85fc --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/compat/nei/NEIChiselConfig.java @@ -0,0 +1,27 @@ +package com.cricketcraft.chisel.compat.nei; + +import com.cricketcraft.chisel.Chisel; + +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; + +public class NEIChiselConfig implements IConfigureNEI { + + @Override + public String getName() { + return Chisel.MOD_NAME; + } + + @Override + public String getVersion() { + return Chisel.VERSION; + } + + @Override + public void loadConfig() { + RecipeHandlerChisel handler = new RecipeHandlerChisel(); + API.registerRecipeHandler(handler); + API.registerUsageHandler(handler); + } + +} diff --git a/src/main/java/com/cricketcraft/chisel/compat/nei/RecipeHandlerChisel.java b/src/main/java/com/cricketcraft/chisel/compat/nei/RecipeHandlerChisel.java index 272a09dc..1fb59e3e 100644 --- a/src/main/java/com/cricketcraft/chisel/compat/nei/RecipeHandlerChisel.java +++ b/src/main/java/com/cricketcraft/chisel/compat/nei/RecipeHandlerChisel.java @@ -1,105 +1,186 @@ package com.cricketcraft.chisel.compat.nei; +import java.awt.Point; import java.awt.Rectangle; +import java.util.ArrayList; import java.util.List; -import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; import com.cricketcraft.chisel.carving.Carving; import com.cricketcraft.chisel.carving.CarvingGroup; import com.cricketcraft.chisel.carving.CarvingVariation; -import com.cricketcraft.chisel.client.gui.GuiChisel; -import com.google.common.collect.Lists; public class RecipeHandlerChisel extends TemplateRecipeHandler { + private static final int SLOTS_PER_PAGE = 45; + + public class CachedChiselRecipe extends CachedRecipe { + + private List input = new ArrayList(); + private List outputs = new ArrayList(); + public Point focus; + + public CachedChiselRecipe(List variations, ItemStack base, ItemStack focus) { + PositionedStack pStack = new PositionedStack(base != null ? base : variations, 74, 4); + pStack.setMaxSize(1); + this.input.add(pStack); + + int row = 0; + int col = 0; + for (ItemStack v : variations) { + this.outputs.add(new PositionedStack(v, 3 + 18 * col, 37 + 18 * row)); + + if (focus != null && NEIServerUtils.areStacksSameTypeCrafting(focus, v)) { + this.focus = new Point(2 + 18 * col, 36 + 18 * row); + } + + col++; + if (col > 8) { + col = 0; + row++; + } + } + } + + public CachedChiselRecipe(List variations) { + this(variations, null, null); + } + + @Override + public List getIngredients() { + return this.getCycledIngredients(cycleticks / 20, this.input); + } + + @Override + public List getOtherStacks() { + return this.outputs; + } + + @Override + public PositionedStack getResult() { + return null; + } + + } + @Override public String getRecipeName() { - return "Chiseling"; + return "Chisel"; } @Override public String getGuiTexture() { - return "Chisel:textures/chisel2Gui.png"; - } - - public PositionedStack getResult() { - return null; - } - - @Override - public Class getGuiClass() { - return GuiChisel.class; - } - - @Override - public String getOverlayIdentifier() { - return "EnderIOSagMill"; - } - - @Override - public void loadTransferRects() { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(149, 32, 16, 16), "ChiselRecipes", new Object[0])); - } - - public void loadCraftingRecipes(String outputId, Object... results) { - // is this right? idk - for (CarvingGroup g : Carving.chisel.getGroups()) { - arecipes.add(new CachedChiselRecipe(g)); - } - } - - @Override - public void loadCraftingRecipes(final ItemStack result) { - // unfinished - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - // unfinished + return "Chisel:textures/chiselNEI.png"; } @Override public void drawBackground(int recipeIndex) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 130); + + Point focus = ((CachedChiselRecipe) this.arecipes.get(recipeIndex)).focus; + if (focus != null) { + GuiDraw.drawTexturedModalRect(focus.x, focus.y, 166, 0, 18, 18); + } } - public class CachedChiselRecipe extends TemplateRecipeHandler.CachedRecipe { + @Override + public int recipiesPerPage() { + return 1; + } - private PositionedStack input; - private List outputs; + @Override + public void loadTransferRects() { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "chisel2.chisel", new Object[0])); + } - @Override - public List getIngredients() { - return Lists.newArrayList(input); - } - - @Override - public PositionedStack getResult() { - return outputs.size() > 0 ? outputs.get(0) : null; - } - - public CachedChiselRecipe(CarvingGroup group) { - this.outputs = Lists.newArrayList(); - for (CarvingVariation v : group.getVariations()) { - if (this.input == null) { - this.input = new PositionedStack(stack(v), 10, 10); + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("chisel2.chisel")) { + for (String name : Carving.chisel.getSortedGroupNames()) { + CarvingGroup g = Carving.chisel.getGroup(name); + if (!g.getVariations().isEmpty()) { + addCached(getVariationStacks(g)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (String name : Carving.chisel.getSortedGroupNames()) { + CarvingGroup g = Carving.chisel.getGroup(name); + List variations = getVariationStacks(g); + for (ItemStack stack : variations) { + if (NEIServerUtils.areStacksSameTypeCrafting(stack, result)) { + addCached(variations, null, result); } - outputs.add(new PositionedStack(stack(v), 50, 10)); } } - - private ItemStack stack(CarvingVariation v) { - return new ItemStack(v.block, 1, v.damage); + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (String name : Carving.chisel.getSortedGroupNames()) { + CarvingGroup g = Carving.chisel.getGroup(name); + List variations = getVariationStacks(g); + for (ItemStack stack : variations) { + if (NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) { + addCached(variations, ingredient, null); + } + } } } -} \ No newline at end of file + + private void addCached(List variations, ItemStack base, ItemStack focus) { + if (variations.size() > SLOTS_PER_PAGE) { + List> parts = new ArrayList>(); + int size = variations.size(); + for (int i = 0; i < size; i += SLOTS_PER_PAGE) { + parts.add(new ArrayList(variations.subList(i, Math.min(size, i + SLOTS_PER_PAGE)))); + } + for (List part : parts) { + this.arecipes.add(new CachedChiselRecipe(part, base, focus)); + } + } else { + this.arecipes.add(new CachedChiselRecipe(variations, base, focus)); + } + } + + private void addCached(List variations) { + addCached(variations, null, null); + } + + private static List getVariationStacks(CarvingGroup g) { + List stacks = new ArrayList(); + for (CarvingVariation v : g.getVariations()) { + stacks.add(v.getStack()); + } + String oreName = g.getOreName(); + if (oreName != null) { + check: for (ItemStack ore : OreDictionary.getOres(oreName)) { + for (ItemStack stack : stacks) { + if (NEIServerUtils.areStacksSameTypeCrafting(stack, ore)) { + continue check; + } + } + stacks.add(ore.copy()); + } + } + return stacks; + } + +} diff --git a/src/main/java/com/cricketcraft/chisel/config/Configurations.java b/src/main/java/com/cricketcraft/chisel/config/Configurations.java index 06b9d95a..dfb63382 100644 --- a/src/main/java/com/cricketcraft/chisel/config/Configurations.java +++ b/src/main/java/com/cricketcraft/chisel/config/Configurations.java @@ -18,6 +18,7 @@ public class Configurations { public static boolean ghostCloud; public static int factoryBlockAmount; public static boolean allowMossy; + public static boolean allowSmoothStone; public static boolean chiselRecipe; public static boolean enableFMP; public static boolean chiselStoneToCobbleBricks; @@ -54,6 +55,7 @@ public class Configurations { ghostCloud = config.get(category, "doesCloudRenderLikeGhost", true).getBoolean(true); factoryBlockAmount = config.get(category, "amountYouGetFromFactoryBlockCrafting", 32).getInt(32); allowMossy = config.get(category, "allowCobbleToMossyInChisel", true).getBoolean(true); + allowSmoothStone = config.get(category, "allowSmoothStoneToStoneBricksAndBack", true).getBoolean(true); chiselRecipe = config.get(category, "chiselAlternateRecipe", false, "Use alternative crafting recipe for the chisel").getBoolean(false); enableFMP = config.get(category, "enableFMP", true, "Do you want to enable FMP").getBoolean(true); chiselStoneToCobbleBricks = config.get(category, "chiselStoneToCobbleBricks", true, "Chisel stone to cobblestone and bricks by left clicking.").getBoolean(false); diff --git a/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java b/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java index 4b116c2a..7081e191 100644 --- a/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java @@ -8,19 +8,21 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel; +import com.cricketcraft.chisel.network.PacketHandler; +import com.cricketcraft.chisel.network.message.MessageAutoChisel; public class ContainerAutoChisel extends Container { - public static TileEntityAutoChisel autoChisel; - public static EntityPlayer player; + public TileEntityAutoChisel autoChisel; + public EntityPlayer player; public ContainerAutoChisel(InventoryPlayer player, TileEntityAutoChisel tileEntityAutoChisel) { - ContainerAutoChisel.player = player.player; + this.player = player.player; autoChisel = tileEntityAutoChisel; addSlot(tileEntityAutoChisel, 0, 53, 15); - addSlot(tileEntityAutoChisel, 1, 78, 51); + addSlot(tileEntityAutoChisel, 1, 78, 52); addSlot(tileEntityAutoChisel, 2, 103, 15); addSlot(tileEntityAutoChisel, 3, 8, 62); addSlot(tileEntityAutoChisel, 4, 151, 11); @@ -92,6 +94,23 @@ public class ContainerAutoChisel extends Container { return itemStack; } + @Override + public ItemStack slotClick(int slotId, int p_75144_2_, int p_75144_3_, EntityPlayer player) { + if (slotId >= 0 && slotId < this.inventorySlots.size()) { + Slot slot = (Slot) this.inventorySlots.get(slotId); + ItemStack stack = slot.getStack(); + ItemStack ret = super.slotClick(slotId, p_75144_2_, p_75144_3_, player); + + if (!player.worldObj.isRemote && slot.slotNumber == TileEntityAutoChisel.BASE && !ItemStack.areItemStacksEqual(stack, slot.getStack())) { + int chiseled = stack == null ? 0 : slot.getStack() == null ? stack.stackSize : stack.stackSize - slot.getStack().stackSize; + PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(autoChisel, chiseled, false), player.worldObj.provider.dimensionId); + } + + return ret; + } + return super.slotClick(slotId, p_75144_2_, p_75144_3_, player); + } + /** * Added validation of slot input * diff --git a/src/main/java/com/cricketcraft/chisel/inventory/ContainerChisel.java b/src/main/java/com/cricketcraft/chisel/inventory/ContainerChisel.java index 682d565c..3f9df4a4 100644 --- a/src/main/java/com/cricketcraft/chisel/inventory/ContainerChisel.java +++ b/src/main/java/com/cricketcraft/chisel/inventory/ContainerChisel.java @@ -62,7 +62,8 @@ public class ContainerChisel extends Container { @Override public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { - if (par3 == 2 && par2 == currentIndex) + // we need to subtract away all the other slots + if (par1 - inventory.getSizeInventory() - 27 == currentIndex) return null; return super.slotClick(par1, par2, par3, par4EntityPlayer); diff --git a/src/main/java/com/cricketcraft/chisel/item/ItemCarvableSlab.java b/src/main/java/com/cricketcraft/chisel/item/ItemCarvableSlab.java new file mode 100644 index 00000000..a7e02f45 --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/item/ItemCarvableSlab.java @@ -0,0 +1,72 @@ +package com.cricketcraft.chisel.item; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.cricketcraft.chisel.block.BlockCarvableSlab; + +public class ItemCarvableSlab extends ItemCarvable { + + public ItemCarvableSlab(Block block) { + super(block); + } + + @Override + public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) { + return true; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz) { + BlockCarvableSlab block = (BlockCarvableSlab) Block.getBlockFromItem(this); + int meta = stack.getItemDamage(); + + ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side]; + Block clicked = world.getBlock(x, y, z); + + // the position of the block that we are attempting to place at + int x2 = x + dir.offsetX; + int y2 = y + dir.offsetY; + int z2 = z + dir.offsetZ; + + Block at = world.getBlock(x2, y2, z2); + + boolean metaEquals = world.getBlockMetadata(x2, y2, z2) == meta; + // if the metadata at the place target matches, and the block there matches either the top of bottom slab, try to fill in the rest of the block + if (metaEquals && ((at == block.top && (dir == ForgeDirection.DOWN || hy == 1.0D)) || (at == block.bottom && (dir == ForgeDirection.UP || hy == 0)))) { + place(stack, world, x2, y2, z2, block.master, meta); + return true; + } + + // else if the block clicked on is a top or bottom slab of this type, try to fill in that block if possible + boolean clickedMetaEquals = world.getBlockMetadata(x, y, z) == meta; + if (clickedMetaEquals && ((clicked == block.bottom && dir == ForgeDirection.UP) || (clicked == block.top && dir == ForgeDirection.DOWN))) { + place(stack, world, x, y, z, block.master, meta); + return true; + } + + // finally just try to place a normal slab + if (metaEquals || at.isReplaceable(world, x, y, z)) { + boolean top = hy > 0.5D && dir != ForgeDirection.UP || dir == ForgeDirection.DOWN; + Block toPlace = top ? block.top : block.bottom; + // if we can replace the clicked block do so + if (clicked.isReplaceable(world, x, y, z)) { + place(stack, world, x, y, z, toPlace, meta); + } else { + place(stack, world, x2, y2, z2, toPlace, meta); + } + return true; + } + return false; + } + + private void place(ItemStack stack, World world, int x, int y, int z, Block toPlace, int metadata) { + world.setBlock(x, y, z, toPlace, metadata, 2); + stack.stackSize -= 1; + world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, this.field_150939_a.stepSound.func_150496_b(), (this.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, + this.field_150939_a.stepSound.getPitch() * 0.8F); + } +} diff --git a/src/main/java/com/cricketcraft/chisel/item/ItemMarbleSlab.java b/src/main/java/com/cricketcraft/chisel/item/ItemMarbleSlab.java deleted file mode 100644 index 884e364c..00000000 --- a/src/main/java/com/cricketcraft/chisel/item/ItemMarbleSlab.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.cricketcraft.chisel.item; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import com.cricketcraft.chisel.block.BlockCarvableSlab; - -public class ItemMarbleSlab extends ItemCarvable { - - public ItemMarbleSlab(Block block) { - super(block); - } - - @Override - public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) { - BlockCarvableSlab block = (BlockCarvableSlab) Block.getBlockFromItem(this); - - switch (side) { - case 0: - --y; - break; - case 1: - ++y; - break; - case 2: - --z; - break; - case 3: - ++z; - break; - case 4: - --x; - break; - case 5: - ++x; - break; - } - - Block targetBlock = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - return (targetBlock.equals(block) || targetBlock.equals(block.top)) && meta == stack.getItemDamage() || world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity) null, stack); - - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz) { - BlockCarvableSlab block = (BlockCarvableSlab) Block.getBlockFromItem(this); - - Block targetBlock = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - boolean metaMatches = meta == stack.getItemDamage(); - - if (metaMatches && side == 0 && targetBlock.equals(block.top)) { - world.setBlock(x, y, z, block.master, meta, 2); - stack.stackSize -= 1; - return true; - } else if (metaMatches && side == 1 && targetBlock.equals(block.bottom)) { - world.setBlock(x, y, z, block.master, meta, 2); - stack.stackSize -= 1; - return true; - } - - boolean result = super.onItemUse(stack, player, world, x, y, z, side, hz, hy, hz); - - switch (side) { - case 0: - --y; - break; - case 1: - ++y; - break; - case 2: - --z; - break; - case 3: - ++z; - break; - case 4: - --x; - break; - case 5: - ++x; - break; - } - - targetBlock = world.getBlock(x, y, z); - meta = world.getBlockMetadata(x, y, z); - - if (!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta == stack.getItemDamage()) { - world.setBlock(x, y, z, block.master, meta, 2); - return true; - } - - if (!result) - return false; - - if (side != 0 && (side == 1 || hy <= 0.5D)) - return true; - - // TODO allow top slabs - // world.setBlock(x, y, z, block.top, meta, 2); - return true; - } -} diff --git a/src/main/resources/assets/chisel/textures/autochisel-gui.png b/src/main/resources/assets/chisel/textures/autochisel-gui.png index 05503451..9fad5cea 100644 Binary files a/src/main/resources/assets/chisel/textures/autochisel-gui.png and b/src/main/resources/assets/chisel/textures/autochisel-gui.png differ diff --git a/src/main/resources/assets/chisel/textures/chisel2Gui.png b/src/main/resources/assets/chisel/textures/chisel2Gui.png index c581c605..ef0f5852 100644 Binary files a/src/main/resources/assets/chisel/textures/chisel2Gui.png and b/src/main/resources/assets/chisel/textures/chisel2Gui.png differ diff --git a/src/main/resources/assets/chisel/textures/chiselNEI.png b/src/main/resources/assets/chisel/textures/chiselNEI.png new file mode 100644 index 00000000..f74a713d Binary files /dev/null and b/src/main/resources/assets/chisel/textures/chiselNEI.png differ