Fix some blocks being unchiselable (ex. stone)

This commit is contained in:
tterrag1098 committed 2015-01-15 13:36:53 -05:00
1 parent 1ecc11ea0e
commit 14da0862d4
4 files changed
+26 -18

No files matched your search

@@ -358,9 +358,9 @@ public enum Features {
String group = "carpet." + i;
// TODO needle stuff
// Carving.needle.addVariation(group, Blocks.carpet, i, 0);
// Carving.needle.addVariation(group, carpet, i, 2);
// Carving.needle.addVariation(group, carpet_block, i, 1);
// Carving.needle.addVariation(group, Blocks.carpet, i, 0);
// Carving.needle.addVariation(group, carpet, i, 2);
// Carving.needle.addVariation(group, carpet_block, i, 1);
}
OreDictionary.registerOre("carpet", carpet);
@@ -1989,7 +1989,7 @@ public enum Features {
// 13), "Sandstone snake block body");
Carving.chisel.addVariation("sandstone", sand_snakestone, 1, 16);
Carving.chisel.addVariation("sandstone", sand_snakestone, 13, 17);
// Carving.chisel.registerOre("sandstone", "sandSnakestone");
// Carving.chisel.registerOre("sandstone", "sandSnakestone");
}
},
@@ -2005,7 +2005,7 @@ public enum Features {
// "Stone snake block body");
Carving.chisel.addVariation("stonebrick", stone_snakestone, 1, 16);
Carving.chisel.addVariation("stonebrick", stone_snakestone, 13, 17);
// Carving.chisel.registerOre("snakestoneStone", "snakestoneStone");
// Carving.chisel.registerOre("snakestoneStone", "snakestoneStone");
}
},
@@ -2018,7 +2018,7 @@ public enum Features {
GameRegistry.registerBlock(obsidian_snakestone, ItemCarvable.class, "obsidian_snakestone");
Carving.chisel.addVariation("obsidian", obsidian_snakestone, 1, 16);
Carving.chisel.addVariation("obsidian", obsidian_snakestone, 13, 17);
// Carving.chisel.registerOre("obsidianSnakestone", "obsidianSnakestone");
// Carving.chisel.registerOre("obsidianSnakestone", "obsidianSnakestone");
}
},
@@ -2028,14 +2028,16 @@ 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)
if (Configurations.allowSmoothStone) {
Carving.chisel.addVariation("stonebricksmooth", Blocks.stone, 0, -1);
}
for (int i = 0; i < 4; i++) {
if (i == 1) {
if (Configurations.allowMossy)
Carving.chisel.addVariation("stonebricksmooth", Blocks.stonebrick, i, i);
} else
} else {
Carving.chisel.addVariation("stonebricksmooth", Blocks.stonebrick, i, i);
}
}
stonebricksmooth.carverHelper.addVariation("tile.stoneBrick.4.desc", 4, "stonebrick/smallbricks");
stonebricksmooth.carverHelper.addVariation("tile.stoneBrick.5.desc", 5, "stonebrick/largebricks");
@@ -86,7 +86,10 @@ public class Carving {
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, metadata));
if (ids.length > 0) {
for (int id : ids) {
return groups.getGroupByOre(OreDictionary.getOreName(id));
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
if (oreGroup != null) {
return oreGroup;
}
}
}
@@ -72,7 +72,6 @@ public class RecipeHandlerChisel extends TemplateRecipeHandler {
public PositionedStack getResult() {
return null;
}
}
@Override
@@ -10,8 +10,6 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.apache.commons.lang3.ArrayUtils;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
@@ -53,12 +51,12 @@ public final class ChiselController {
Block block = event.world.getBlock(x, y, z);
int metadata = event.world.getBlockMetadata(x, y, z);
List<ICarvingVariation> list = Carving.chisel.getVariations(block, metadata);
if (list == null || list.isEmpty()) {
break;
}
ICarvingVariation[] variations = list.toArray(new CarvingVariation[] {});
ICarvingVariation[] variations = list.toArray(new CarvingVariation[] {});
if (chisel.canChiselBlock(event.world, x, y, z, block, metadata)) {
ItemStack target = General.getChiselTarget(held);
@@ -70,15 +68,15 @@ public final class ChiselController {
}
}
} else {
int idx = 0;
for (int i = 0; i < variations.length; i++) {
ICarvingVariation v = variations[i];
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
variations = ArrayUtils.remove(variations, i--);
idx = (i + 1) % variations.length; // move to the next in the group
}
}
int index = event.world.rand.nextInt(variations.length);
ICarvingVariation newVar = variations[index];
ICarvingVariation newVar = variations[idx];
setVariation(event.entityPlayer, event.world, x, y, z, newVar, new ItemStack(newVar.getBlock(), 1, newVar.getItemMeta()));
event.entityPlayer.inventory.currentItem = slot;
}
@@ -97,6 +95,12 @@ public final class ChiselController {
* Assumes that the player is holding a chisel
*/
private void setVariation(EntityPlayer player, World world, int x, int y, int z, ICarvingVariation v, ItemStack target) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (block == v.getBlock() && meta == v.getBlockMeta()) {
return; // don't chisel to the same thing
}
PacketHandler.INSTANCE.sendTo(new MessageChiselSound(x, y, z, v), (EntityPlayerMP) player);
world.setBlock(x, y, z, v.getBlock(), v.getBlockMeta(), 3);
((IChiselItem) player.getCurrentEquippedItem().getItem()).onChisel(world, player.inventory, player.inventory.currentItem, player.getCurrentEquippedItem(), target);