Add config option for left click chiseling. Fix chisel recipes.

This commit is contained in:
tterrag1098 committed 2015-01-09 03:03:37 -05:00
1 parent 876f7492e8
commit 8f9cc76bd5
5 files changed
+41 -15

No files matched your search

@@ -1,5 +1,6 @@
package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -18,4 +19,22 @@ public interface IChiselItem extends IChiselMode {
*/
void onChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target);
/**
* Allows you to control if your item can chisel this block in the world.
*
* @param world
* World object
* @param x
* X coord of the block being chiseled
* @param y
* Y coord of the block being chiseled
* @param z
* Z coord of the block being chiseled
* @param block
* The {@link Block} being chiseled
* @param metadata
* The blocks' metadata
* @return True if the chiseling should take place. False otherwise.
*/
boolean canChiselBlock(World world, int x, int y, int z, Block block, int metadata);
}
@@ -37,7 +37,8 @@ public class Configurations {
public static boolean allowChiselDamage;
public static int ironChiselMaxDamage;
public static int diamondChiselMaxDamage;
public static boolean ironChiselCanLeftClick;
public static boolean refreshConfig() {
String category;
@@ -76,7 +77,8 @@ public class Configurations {
allowChiselDamage = config.get(category, "allowChiselDamage", true, "Should the chisel be damageable and take damage when it chisels something.").getBoolean();
ironChiselMaxDamage = config.get(category, "ironChiselMaxDamage", 500, "The max damage of the standard iron chisel. Default: 500.").getInt();
diamondChiselMaxDamage = config.get(category, "diamondChiselMaxDamage", 5000, "The max damage of the diamond chisel. Default: 5000").getInt();
ironChiselCanLeftClick = config.get(category, "ironChiselCanLeftClick", false, "If this is true, the iron chisel can left click chisel blocks. If false, it cannot.").getBoolean();
if (config.hasChanged()) {
config.save();
}
@@ -325,11 +325,11 @@ public enum Features {
@Override
void addRecipes() {
if (Configurations.chiselRecipe) {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel, 1), " YY", " YY", "X ", 'X', Items.stick, 'Y', Items.iron_ingot));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel, 1, 1), " YY", " YY", "x ", 'x', "stickWood", 'Y', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel), " YY", " YY", "X ", 'X', "stickWood", 'Y', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.diamondChisel), " YY", " YY", "x ", 'x', "stickWood", 'Y', "gemDiamond"));
} else {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel, 1), " Y", "X ", 'X', Items.stick, 'Y', Items.iron_ingot));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel, 1, 1), " y", "x ", 'x', "stickWood", 'y', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.chisel), " Y", "X ", 'X', "stickWood", 'Y', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselItems.diamondChisel), " Y", "X ", 'X', "stickWood", 'Y', "gemDiamond"));
}
}
},
@@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import org.apache.commons.lang3.ArrayUtils;
@@ -41,10 +40,11 @@ public final class ChiselController {
ItemStack held = event.entityPlayer.getCurrentEquippedItem();
int slot = event.entityPlayer.inventory.currentItem;
// TODO config for diamond only
if (held == null || !(held.getItem() instanceof IChiselItem)) {
return;
}
IChiselItem chisel = (IChiselItem) held.getItem();
switch (event.action) {
case LEFT_CLICK_BLOCK:
@@ -55,7 +55,7 @@ public final class ChiselController {
int metadata = event.world.getBlockMetadata(x, y, z);
CarvingVariation[] variations = Carving.chisel.getVariations(block, metadata);
if (variations != null) {
if (variations != null && chisel.canChiselBlock(event.world, x, y, z, block, metadata)) {
ItemStack target = General.getChiselTarget(held);
if (target != null) {
@@ -84,9 +84,6 @@ public final class ChiselController {
event.entityPlayer.openGui(Chisel.instance, 0, event.world, 0, 0, 0);
break;
}
if (event.action == Action.LEFT_CLICK_BLOCK) {
}
}
/**
@@ -2,6 +2,7 @@ package com.cricketcraft.chisel.item.chisel;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
@@ -60,10 +61,12 @@ public class ItemChisel extends Item implements IChiselItem {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean held) {
String unloc = "item.chisel.chisel.desc."; // TODO this is hacky
for (int i = 0; i < 3; i ++) {
list.add(StatCollector.translateToLocal(unloc + i));
for (int i = 0; i < 3; i++) {
if (i == 0 || type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick) {
list.add(StatCollector.translateToLocal(unloc + i));
}
}
if (type == ChiselType.DIAMOND) {
list.add("");
list.add(StatCollector.translateToLocal(getUnlocalizedName(stack) + ".desc"));
@@ -96,4 +99,9 @@ public class ItemChisel extends Item implements IChiselItem {
}
}
}
@Override
public boolean canChiselBlock(World world, int x, int y, int z, Block block, int metadata) {
return type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick;
}
}