This commit is contained in:
Drullkus committed 2015-01-26 21:01:19 -08:00
commit 418996a716
75 files changed
+1872 -942

No files matched your search

@@ -40,7 +40,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime")
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest")
public class Chisel {
public static final String MOD_ID = "chisel";
@@ -113,8 +113,6 @@ public class Chisel {
Configurations.config.load();
Configurations.refreshConfig();
logger.info("Hey Jared, I wasn't lying");
ChiselTabs.preInit();
Features.preInit();
PacketHandler.init();
@@ -128,11 +126,12 @@ public class Chisel {
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
registerWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
registerWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
registerWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount);
registerWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount);
registerWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount);
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5);
addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5);
addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
proxy.init();
MinecraftForge.EVENT_BUS.register(this);
@@ -141,9 +140,15 @@ public class Chisel {
FMLInterModComms.sendMessage("Waila", "register", "com.cricketcraft.chisel.compat.WailaCompat.register");
}
private void registerWorldgen(Features feature, Block block, int amount) {
private void addWorldgen(Features feature, Block block, double... data) {
if (feature.enabled()) {
GameRegistry.registerWorldGenerator(new GeneratorChisel(block, 32, amount), 1000);
if (data.length == 1) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
} else if (data.length > 1 && data.length < 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
} else if (data.length == 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
}
}
}
@@ -1,5 +1,7 @@
package com.cricketcraft.chisel;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
@@ -12,6 +14,7 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.block.BlockAutoChisel;
import com.cricketcraft.chisel.block.BlockBeaconBase;
import com.cricketcraft.chisel.block.BlockCarvable;
@@ -53,6 +56,7 @@ import com.cricketcraft.chisel.block.IStairsCreator;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.carving.CarvingGroup;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.entity.EntityBallOMoss;
import com.cricketcraft.chisel.entity.EntityCloudInABottle;
@@ -61,6 +65,7 @@ import com.cricketcraft.chisel.init.ChiselBlocks;
import com.cricketcraft.chisel.init.ChiselItems;
import com.cricketcraft.chisel.init.ChiselTabs;
import com.cricketcraft.chisel.item.ItemBallOMoss;
import com.cricketcraft.chisel.item.ItemBlockPresent;
import com.cricketcraft.chisel.item.ItemCarvable;
import com.cricketcraft.chisel.item.ItemCarvableSlab;
import com.cricketcraft.chisel.item.ItemCloudInABottle;
@@ -68,6 +73,7 @@ import com.cricketcraft.chisel.item.ItemSmashingRock;
import com.cricketcraft.chisel.item.ItemUpgrade;
import com.cricketcraft.chisel.item.chisel.ItemChisel;
import com.cricketcraft.chisel.item.chisel.ItemChisel.ChiselType;
import com.google.common.collect.Lists;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.EntityRegistry;
@@ -119,7 +125,8 @@ public enum Features {
BlockCarvable andesite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
andesite.carverHelper.setChiselBlockName("andesite");
andesite.carverHelper.addVariation("tile.andesite.0.desc", 0, "andesite/andesite");
andesite.carverHelper.addVariation("tile.andesite.1.desc", 1, "andesite/polishedAndesite");
andesite.carverHelper.addVariation("tile.andesite.1.desc", 1, "andesite/andesitePolished");
andesite.carverHelper.addVariation("tile.andesite.2.desc", 2, "andesite/andesitePillar");
andesite.carverHelper.registerAll(andesite, "andesite");
Carving.chisel.registerOre("andesite", "andesite");
}
@@ -131,18 +138,23 @@ public enum Features {
void addBlocks() {
BlockCarvable antiBlock = (BlockCarvable) new BlockCarvableAntiBlock().setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
antiBlock.carverHelper.setChiselBlockName("Anti Block");
antiBlock.carverHelper.forbidChiseling = true;
for (int i = 0; i < 16; i++) {
antiBlock.carverHelper.addVariation("tile.antiBlock." + ItemDye.field_150921_b[i] + ".desc", i, "antiblock/" + ItemDye.field_150921_b[i] + "-antiBlock");
}
antiBlock.carverHelper.registerAll(antiBlock, "antiBlock");
Carving.chisel.registerOre("antiBlock", "antiBlock");
antiBlock.carverHelper.registerBlock(antiBlock, "antiBlock");
OreDictionary.registerOre("antiBlock", antiBlock);
}
@Override
void addRecipes() {
// TODO Add a recipe
if (meta == 0) {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.antiBlock, 8, 15), "SSS", "SGS", "SSS", 'S', "stone", 'G', "dustGlowstone"));
}
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.antiBlock, 8, meta), "BBB", "BdB", "BBB",
'd', dyeOres[meta], 'B', new ItemStack(ChiselBlocks.antiBlock, 1, OreDictionary.WILDCARD_VALUE)));
}
@Override
@@ -281,8 +293,7 @@ public enum Features {
// brickCustom.carverHelper.addVariation("tile.brickCustom.4.desc",
// 4, "brickCustom/cracked");
brickCustom.carverHelper.addVariation("tile.brickCustom.5.desc", 5, "brickCustom/aged");
// brickCustom.carverHelper.addVariation("tile.brickCustom.6.desc",
// 6, "brickCustom/mossy");
brickCustom.carverHelper.addVariation("tile.brickCustom.6.desc", 6, "brickCustom/yellow");
brickCustom.carverHelper.registerAll(brickCustom, "brickCustom");
Carving.chisel.registerOre("brickCustom", "brickCustom");
}
@@ -513,6 +524,16 @@ public enum Features {
}
},
COPPER
{
@Override
void addBlocks() {
Carving.chisel.addGroup(new CarvingGroup("copperblock"));
Carving.chisel.registerOre("copperblock", "blockCopper");
}
},
DIAMOND_BLOCK {
@Override
@@ -544,7 +565,8 @@ public enum Features {
BlockCarvable diorite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
diorite.carverHelper.setChiselBlockName("diorite");
diorite.carverHelper.addVariation("tile.diorite.0.desc", 0, "diorite/diorite");
diorite.carverHelper.addVariation("tile.diorite.1.desc", 1, "diorite/polishedDiorite");
diorite.carverHelper.addVariation("tile.diorite.1.desc", 1, "diorite/dioritePolished");
diorite.carverHelper.addVariation("tile.diorite.2.desc", 2, "diorite/dioritePillar");
diorite.carverHelper.registerAll(diorite, "diorite");
Carving.chisel.registerOre("diorite", "diorite");
}
@@ -694,8 +716,9 @@ public enum Features {
// TODO Overlay is WIP
@Override
void addBlocks() {
BlockCarvable futura = (BlockCarvable) new BlockCarvable(Material.rock/* , "futura/screenOverlay-ctm" */).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F)
.setResistance(10F);
BlockCarvable futura = (BlockCarvable) new BlockCarvable(Material.rock/*
* , "futura/screenOverlay-ctm"
*/).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F);
futura.carverHelper.addVariation("tile.futura.0.desc", 0, "futura/WIP/screenMetallicWIP");
futura.carverHelper.addVariation("tile.futura.1.desc", 1, "futura/WIP/screenCyanWIP");
futura.carverHelper.addVariation("tile.futura.2.desc", 2, "futura/WIP/controllerWIP");
@@ -703,6 +726,11 @@ public enum Features {
futura.carverHelper.registerAll(futura, "futura");
Carving.chisel.registerOre("futura", "futura");
}
@Override
void addRecipes() {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.futura, 8, 0), "SBS", "BGB", "SBS", 'S', "stone", 'G', "dustRedstone", 'B', new ItemStack(Blocks.stonebrick, 1)));
}
},
GLASS {
@@ -874,7 +902,8 @@ public enum Features {
BlockCarvable granite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
granite.carverHelper.setChiselBlockName("granite");
granite.carverHelper.addVariation("tile.granite.0.desc", 0, "granite/granite");
granite.carverHelper.addVariation("tile.granite.1.desc", 1, "granite/polishedGranite");
granite.carverHelper.addVariation("tile.granite.1.desc", 1, "granite/granitePolished");
granite.carverHelper.addVariation("tile.granite.2.desc", 2, "granite/granitePillar");
granite.carverHelper.registerAll(granite, "granite");
Carving.chisel.registerOre("granite", "granite");
}
@@ -1100,7 +1129,7 @@ public enum Features {
void addBlocks() {
for (int metadata = 0; metadata < 16; metadata++) {
jackolantern[metadata] = (BlockCarvablePumpkin) new BlockCarvablePumpkin(true).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(1.0F).setBlockName("litpumpkin")
.setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
.setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setLightLevel(1.0f);
jackolantern[metadata].setInformation("pumpkin/pumpkin_face_" + (metadata + 1) + "_on");
GameRegistry.registerBlock(jackolantern[metadata], ("jackolantern" + (metadata + 1)));
Carving.chisel.addVariation("jackolantern", jackolantern[metadata], 0, (metadata + 1));
@@ -1192,6 +1221,22 @@ public enum Features {
@Override
void addBlocks() {
BlockLeaf leaves = (BlockLeaf) new BlockLeaf(Material.leaves).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.2F).setStepSound(Block.soundTypeGrass);
Carving.chisel.addGroup(new CarvingGroup("leaves") {
public List<ICarvingVariation> getVariations() {
if (Configurations.chiselBackToVanillaLeaves) {
return super.getVariations();
} else {
List<ICarvingVariation> ret = Lists.newArrayList();
for (ICarvingVariation v : super.getVariations()) {
if (v.getBlock() != Blocks.leaves && v.getBlock() != Blocks.leaves2) {
ret.add(v);
}
}
return ret;
}
}
});
Carving.chisel.addVariation("leaves", Blocks.leaves, 0, 0);
Carving.chisel.addVariation("leaves", Blocks.leaves, 1, 0);
Carving.chisel.addVariation("leaves", Blocks.leaves, 2, 0);
@@ -1266,7 +1311,7 @@ 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", ItemCarvableSlab.class);
limestone_slab.carverHelper.registerAll(limestone_slab, "limestone_slab", ItemCarvableSlab.class);
registerSlabTop(limestone_slab, limestone_slab.top);
Carving.chisel.registerOre("limestone_slab", "limestone_slab");
@@ -1344,7 +1389,7 @@ 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", ItemCarvableSlab.class);
marble_slab.carverHelper.registerAll(marble_slab, "marble_slab", ItemCarvableSlab.class);
registerSlabTop(marble_slab, marble_slab.top);
Carving.chisel.registerOre("marble_slab", "marble_slab");
@@ -1463,7 +1508,7 @@ 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", ItemCarvableSlab.class);
marble_pillar_slab.carverHelper.registerAll(marble_pillar_slab, "marble_pillar_slab", ItemCarvableSlab.class);
registerSlabTop(marble_pillar_slab, marble_pillar_slab.top);
}
@@ -1481,7 +1526,8 @@ public enum Features {
BlockCarvable nether_brick = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10.0F)
.setStepSound(Block.soundTypeStone);
Carving.chisel.addVariation("nether_brick", Blocks.nether_brick, 0, 0);
// netherBrick.carverHelper.addVariation("Nether brick", 0, Blocks.nether_brick);
// netherBrick.carverHelper.addVariation("Nether brick", 0,
// Blocks.nether_brick);
nether_brick.carverHelper.addVariation("tile.netherBrick.1.desc", 1, "netherbrick/a1-netherbrick-brinstar");
nether_brick.carverHelper.addVariation("tile.netherBrick.2.desc", 2, "netherbrick/a1-netherbrick-classicspatter");
nether_brick.carverHelper.addVariation("tile.netherBrick.3.desc", 3, "netherbrick/a1-netherbrick-guts");
@@ -1637,7 +1683,7 @@ public enum Features {
@Override
void addBlocks() {
BlockCarvablePane paperwall = (BlockCarvablePane) new BlockCarvablePane(Material.ground, true).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setResistance(10F);
BlockCarvablePane paperwall = (BlockCarvablePane) new BlockCarvablePane(Material.ground, true).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setResistance(0.5F);
paperwall.carverHelper.setChiselBlockName("Paper Wall");
paperwall.carverHelper.addVariation("tile.paperwall.0.desc", 0, "paper/box");
paperwall.carverHelper.addVariation("tile.paperwall.1.desc", 1, "paper/throughMiddle");
@@ -1651,11 +1697,27 @@ public enum Features {
paperwall.carverHelper.registerAll(paperwall, "paperwall");
Carving.chisel.registerOre("paperwall", "paperwall");
BlockCarvable paperwall_block = (BlockCarvable) new BlockCarvable(Material.ground).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setResistance(0.5F);
paperwall_block.carverHelper.setChiselBlockName("Paper Wall Block");
paperwall_block.carverHelper.addVariation("tile.paperwall.0.desc", 0, "paper/box");
paperwall_block.carverHelper.addVariation("tile.paperwall.1.desc", 1, "paper/throughMiddle");
paperwall_block.carverHelper.addVariation("tile.paperwall.2.desc", 2, "paper/cross");
paperwall_block.carverHelper.addVariation("tile.paperwall.3.desc", 3, "paper/sixSections");
paperwall_block.carverHelper.addVariation("tile.paperwall.4.desc", 4, "paper/vertical");
paperwall_block.carverHelper.addVariation("tile.paperwall.5.desc", 5, "paper/horizontal");
paperwall_block.carverHelper.addVariation("tile.paperwall.6.desc", 6, "paper/floral");
paperwall_block.carverHelper.addVariation("tile.paperwall.7.desc", 7, "paper/plain");
paperwall_block.carverHelper.addVariation("tile.paperwall.8.desc", 8, "paper/door");
paperwall_block.carverHelper.registerAll(paperwall_block, "paperwall_block");
Carving.chisel.registerOre("paperwall_block", "paperwall_block");
}
@Override
void addRecipes() {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.paperwall, 8), "ppp", "psp", "ppp", ('p'), Items.paper, ('s'), "stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.paperwall_block, 4), "pp", "pp", ('p'), ChiselBlocks.paperwall));
}
},
@@ -1663,17 +1725,17 @@ public enum Features {
@Override
void addBlocks() {
for (int x = 0; x < 16; x++) {
present[x] = (BlockPresent) new BlockPresent(x).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(2.0F).setResistance(10.0F).setBlockName("present");
GameRegistry.registerBlock(present[x], "chest" + x);
Carving.chisel.addVariation("present", present[x], 0, (x + 1));
BlockPresent present = (BlockPresent) new BlockPresent().setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(2.0F).setResistance(10.0F).setBlockName("present");
for (int i = 0; i < 16; i++) {
present.carverHelper.addVariation("tile.present.desc." + i, i, Blocks.chest);
}
present.carverHelper.registerAll(present, "present", ItemBlockPresent.class);
Carving.chisel.registerOre("present", "chest");
}
@Override
void addRecipes() {
GameRegistry.addShapelessRecipe(new ItemStack(ChiselBlocks.present[meta]), new ItemStack(Blocks.chest, 1), new ItemStack(Items.dye, 1, meta));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ChiselBlocks.present, 1, meta), new ItemStack(Blocks.chest, 1), dyeOres[meta]));
}
@Override
@@ -1724,6 +1786,19 @@ public enum Features {
*/
RAILCRAFT("Railcraft"),
RC_ABYSSAL_BLOCK(RAILCRAFT.getRequiredMod(), RAILCRAFT) {
@Override
void addBlocks() {
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 0, 0);
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 1, 1);
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 2, 2);
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 3, 3);
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 4, 4);
Carving.chisel.addVariation("RCAbyssalBlock", GameRegistry.findBlock("Railcraft", "tile.railcraft.brick.abyssal"), 5, 5);
Carving.chisel.registerOre("RCAbyssalBlock", "RCAbyssalBlock");
};
},
RC_BLEACHED_BONE(RAILCRAFT.getRequiredMod(), RAILCRAFT) {
@Override
@@ -1883,7 +1958,8 @@ public enum Features {
@Override
void addRecipes() {
if (meta == 0) {
// The following recipe is due to bugs with Chisel 1.5.1 to 1.5.6a
// The following recipe is due to bugs with Chisel 1.5.1 to
// 1.5.6a
GameRegistry.addRecipe(new ItemStack(Blocks.sandstone, 1, 0), "X", 'X', new ItemStack(ChiselBlocks.sandstone, 1, 0));
// The following recipe is due to bug with Chisel 1.5.6b
GameRegistry.addRecipe(new ItemStack(Blocks.sandstone, 1, 1), "X", 'X', new ItemStack(ChiselBlocks.sandstone, 1, 1));
@@ -1928,7 +2004,7 @@ public enum Features {
@Override
void addItems() {
ItemSmashingRock smashingrock = (ItemSmashingRock) new ItemSmashingRock().setTextureName("Chisel:smashingrock").setCreativeTab(ChiselTabs.tabChisel);
EntityRegistry.registerModEntity(EntitySmashingRock.class, "SmashingRock", 2, Chisel.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntitySmashingRock.class, "SmashingRock", 3, Chisel.instance, 40, 1, true);
GameRegistry.registerItem(smashingrock, "smashingrock");
}
@@ -1981,7 +2057,8 @@ 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");
}
},
@@ -2102,7 +2179,7 @@ public enum Features {
@Override
void addRecipes() {
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.templeblock, 8, 0), "***", "*X*", "***", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.dye, 1, 4));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ChiselBlocks.templeblock, 8, 0), "***", "*X*", "***", '*', new ItemStack(Blocks.stone, 1), 'X', dyeOres[4]));
}
},
@@ -2331,6 +2408,7 @@ public enum Features {
warningSign.carverHelper.addVariation("tile.warningSign.11.desc", 11, "warning/sound");
warningSign.carverHelper.addVariation("tile.warningSign.12.desc", 12, "warning/noentry");
warningSign.carverHelper.addVariation("tile.warningSign.13.desc", 13, "warning/cryogenic");
warningSign.carverHelper.addVariation("tile.warningSign.14.desc", 14, "warning/oxygen");
warningSign.carverHelper.registerAll(warningSign, "warningSign");
Carving.chisel.registerOre("warningSign", "warningSign");
}
@@ -2431,30 +2509,51 @@ public enum Features {
;
private static final String[] dyeOres = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow",
"dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
private static int meta = 0;
static void init() {
Chisel.logger.info("Starting init...");
loadRecipes();
Chisel.logger.info("Init finished.");
}
private static void loadBlocks() {
Chisel.logger.info("Loading blocks...");
int num = 0;
for (Features f : values()) {
if (f.enabled()) {
f.addBlocks();
++num;
} else {
logDisabled(f);
}
}
Chisel.logger.info(num + " Feature's blocks loaded.");
Chisel.logger.info("Loading Tile Entities...");
Chisel.proxy.registerTileEntities();
Chisel.logger.info("Tile Entities loaded.");
}
private static void loadItems() {
Chisel.logger.info("Loading items...");
int num = 0;
for (Features f : values()) {
if (f.enabled()) {
f.addItems();
++num;
} else {
logDisabled(f);
}
}
Chisel.logger.info(num + " Feature's items loaded.");
}
private static void loadRecipes() {
Chisel.logger.info("Loading recipes...");
int num = 0;
for (Features f : values()) {
if (f.enabled()) {
if (f.needsMetaRecipes()) {
@@ -2466,13 +2565,27 @@ public enum Features {
} else {
f.addRecipes();
}
++num;
} else {
logDisabled(f);
}
}
Chisel.logger.info(num + " Feature's recipes loaded.");
}
private static void logDisabled(Features f) {
if (!f.hasParentFeature() && f.parent != null) {
Chisel.logger.info("Skipping feature {} as its parent feature {} was disabled.", Configurations.featureName(f), Configurations.featureName(f.parent));
} else if (!f.hasRequiredMod() && f.getRequiredMod() != null) {
Chisel.logger.info("Skipping feature {} as its required mod {} was missing.", Configurations.featureName(f), f.getRequiredMod());
} else {
Chisel.logger.info("Skipping feature {} as it was disabled in the config.", Configurations.featureName(f));
}
}
public static boolean oneModdedFeatureLoaded() {
for (Features f : values()) {
if (f.getRequiredMod() != null && Loader.isModLoaded(f.getRequiredMod())) {
if (f.hasRequiredMod()) {
return true;
}
}
@@ -2480,8 +2593,10 @@ public enum Features {
}
static void preInit() {
Chisel.logger.info("Starting pre-init...");
loadBlocks();
loadItems();
Chisel.logger.info("Pre-init finished.");
}
private Features parent;
@@ -2518,7 +2633,15 @@ public enum Features {
}
public final boolean enabled() {
return Configurations.featureEnabled(this) && (requiredMod == null || Loader.isModLoaded(requiredMod)) && (parent == null || parent.enabled());
return Configurations.featureEnabled(this) && hasRequiredMod() && hasParentFeature();
}
private final boolean hasParentFeature() {
return parent == null || parent.enabled();
}
private final boolean hasRequiredMod() {
return getRequiredMod() == null || Loader.isModLoaded(getRequiredMod());
}
private String getRequiredMod() {
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api;
public class ChiselAPIProps {
public static final String VERSION = "0.0.1";
public static final String VERSION = "0.0.2";
}
@@ -1,6 +0,0 @@
package com.cricketcraft.chisel.api;
public enum ChiselMode {
SINGLE, CIRCLETHREE, COLLUM, SIDEWAYS
}
@@ -0,0 +1,35 @@
package com.cricketcraft.chisel.api;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import net.minecraft.item.ItemStack;
/**
* Implement this on chisel items which require more control over chisel modes
* (including adding new modes).
*/
public interface IAdvancedChisel {
/**
* Gets the next mode the button in the GUI should switch to given the
* current mode.
*
* @param stack
* The {@link ItemStack} representing the chisel
* @param current
* The {@link IChiselMode} that is currently active
* @return The next {@link IChiselMode} in the loop
*/
public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
/**
* Gets an {@link IChiselMode} instance from a String name
*
* @param chisel
* The {@link ItemStack} representing the chisel
* @param name
* The name of the {@link IChiselMode mode}
* @return An {@link IChiselMode} that has the name {@code name}
*/
public IChiselMode getMode(ItemStack chisel, String name);
}
@@ -1,11 +1,14 @@
package com.cricketcraft.chisel.api;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.carving.CarvableVariation;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
/**
* To be implemented on blocks that can be chiseled and need advanced metadata to variation mapping. Currently not very usable without internal classes.
*/
public interface ICarvable {
/**
@@ -2,14 +2,15 @@ package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
/**
* Implement this on items which can be used to chisel blocks.
*/
public interface IChiselItem extends IChiselMode {
public interface IChiselItem {
/**
* Checks whether the chisel can have its GUI opened
@@ -29,16 +30,13 @@ public interface IChiselItem extends IChiselMode {
*
* @param world
* {@link World} object
* @param inv
* The inventory this chisel is currently in
* @param slot
* The slot index of the chisel in the inventory
* @param chisel
* The {@link ItemStack} representing the chisel
* @param target
* The {@link ItemStack} representing the target item
* The {@link ICarvingVariation} representing the target item
* @return True if the chisel should be damaged. False otherwise.
*/
void onChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target);
boolean onChisel(World world, ItemStack chisel, ICarvingVariation target);
/**
* Called to check if this {@link ItemStack} can be chiseled in this chisel. If not, there will be no possible variants displayed in the GUI.
@@ -47,23 +45,21 @@ public interface IChiselItem extends IChiselMode {
*
* @param world
* {@link World} object
* @param inv
* The inventory this chisel is currently in
* @param slot
* The slot index of the chisel in the inventory
* @param chisel
* The {@link ItemStack} representing the chisel
* @param target
* The {@link ItemStack} representing the target item
* The {@link ICarvingVariation} representing the target item
* @return True if the current target can be chiseled into anything. False otherwise.
*/
boolean canChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target);
boolean canChisel(World world, ItemStack chisel, ICarvingVariation target);
/**
* Allows you to control if your item can chisel this block in the world.
*
* @param world
* World object
* @param player
* {@link EntityPlayer The player} holding the chisel.
* @param x
* X coord of the block being chiseled
* @param y
@@ -76,5 +72,14 @@ public interface IChiselItem extends IChiselMode {
* 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);
boolean canChiselBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int metadata);
/**
* Allows you to control if your item has chiseling modes.
*
* @param chisel
* The {@link ItemStack} representing the chisel.
* @return True if the chisel supports modes. False otherwise.
*/
boolean hasModes(ItemStack chisel);
}
@@ -1,8 +0,0 @@
package com.cricketcraft.chisel.api;
import net.minecraft.item.ItemStack;
public interface IChiselMode {
public ChiselMode getChiselMode(ItemStack itemStack);
}
@@ -1,5 +1,7 @@
package com.cricketcraft.chisel.api.carving;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
public class CarvingUtils {
@@ -27,4 +29,30 @@ public class CarvingUtils {
public static ItemStack getStack(ICarvingVariation variation) {
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
}
private static Field _chisel;
private static boolean errored = false;
private static final String CARVING_CLASS = "com.cricketcraft.chisel.carving.Carving";
/**
* @return The instance of the chisel carving registry from the chisel mod.
* <p>
* If chisel is not installed or some other error occurs this will return null.
*/
public static ICarvingRegistry getChiselRegistry() {
if (errored) {
return null;
}
try {
if (_chisel == null) {
_chisel = Class.forName(CARVING_CLASS).getDeclaredField("chisel");
}
return (ICarvingRegistry) _chisel.get(null);
} catch (Exception e) {
e.printStackTrace();
errored = true;
return getChiselRegistry();
}
}
}
@@ -57,10 +57,18 @@ public interface ICarvingGroup {
List<ICarvingVariation> getVariations();
/**
* Adds a variation to this group.
* Adds a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
*
* @param variation
* An {@link ICarvingVariation} to add to this group
*/
void addVariation(ICarvingVariation variation);
/**
* Removes a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
*
* @param variation
* An {@link ICarvingVariation} to add to this group
*/
boolean removeVariation(ICarvingVariation variation);
}
@@ -0,0 +1,204 @@
package com.cricketcraft.chisel.api.carving;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Represents a registry of {@link ICarvingGroup}s
* <p>
* To obtain chisel's instance of this class, use {@link CarvingUtils#getChiselRegistry()}
*/
public interface ICarvingRegistry {
/* Getters */
/**
* Finds the group the block/meta pair belongs to in the registry.
*
* @param block
* The block of the variation
* @param meta
* The metadata of the variation
* @return The {@link ICarvingGroup} that the block/meta pair belongs to
*/
ICarvingGroup getGroup(Block block, int meta);
/**
* Gets an {@link ICarvingGroup} by its name.
*
* @param name
* The name of the group
* @return An {@link ICarvingGroup}
*/
ICarvingGroup getGroup(String name);
/**
* Gets the {@link ICarvingVariation} instance represented by this block/meta pair.
*
* @param block
* The block of the variatoin
* @param meta
* The metadata of the variation
* @return The {@link ICarvingVariation} containing this block/meta pair
*/
ICarvingVariation getVariation(Block block, int meta);
/**
* Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair.
*
* @param block
* The block of the variation
* @param meta
* The metadata of the variation
* @return All of the {@link ICarvingVariation}s in the group that contains this block/meta pair
*/
List<ICarvingVariation> getGroupVariations(Block block, int meta);
/**
* Gets the oredict name for the group that contains this block/meta pair.
*
* @param block
* The block of the variation
* @param meta
* The metadata of the variation
* @return A string oredict name for the group
*/
String getOreName(Block block, int meta);
/**
* Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items.
*
* @param chiseled
* The {@link ItemStack} being chiseled
* @return A list of stacks that can be chiseled from the passed {@link ItemStack stack}
*/
List<ItemStack> getItemsForChiseling(ItemStack chiseled);
/**
* Gets the sound resource string for the group represented by this block/meta pair.
*
* @param block
* The block of the variation
* @param metadata
* The metadata of the variation
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
*/
public String getVariationSound(Block block, int metadata);
/**
* Gets the sound resource string for the group represented by this item/meta pair.
* <p>
* Mostly a convenience for calling {@link #getVariationSound(Block, int)} with {@link Block#getBlockFromItem(Item)}.
*
* @param item
* The item of the variation
* @param metadata
* The metadata of the variation
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
*/
public String getVariationSound(Item item, int metadata);
/**
* @return A list of all registered group names, sorted alphabetically.
*/
List<String> getSortedGroupNames();
/* Setters */
/**
* Adds a variation to the registry.
*
* @param groupName
* The name of the group to add to.
* @param block
* The block of the variation
* @param metadata
* The metadata of the variation
* @param order
* The order of the variation in the list of all variations in the group. Higher numbers are sorted at the end.
*/
void addVariation(String groupName, Block block, int metadata, int order);
/**
* Adds a variation to the registry.
*
* @param groupName
* The name of the group to add to
* @param variation
* The {@link ICarvingVariation} to add
*/
void addVariation(String groupName, ICarvingVariation variation);
/**
* Adds a group to the registry.
*
* @param group
* The {@link ICarvingGroup} to add.
*/
void addGroup(ICarvingGroup group);
/**
* Removes a group from the registry.
* <p>
* This in effect removes all variations associated with the group, though they are not explicitly removed from the object. If you maintain a reference to the {@link ICarvingGroup} that is
* removed, it will still contain its variations.
*
* @param groupName
* The name of the group to remove.
* @return The {@link ICarvingGroup} that was removed.
*/
ICarvingGroup removeGroup(String groupName);
/**
* Removes a varaition with the passed {@link Block} and metadata from the registry. If this variation is registered with mutiple groups, it will remove it from all of them.
*
* @param block
* The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata
* The metadata of the {@link ICarvingVariation variation}
* @return The ICarvingVariation that was removed. Null if nothing was removed.
*/
ICarvingVariation removeVariation(Block block, int metadata);
/**
* Removes a varaition with the passed {@link Block} and metadata from the registry, but only from the specified {@link ICarvingGroup} name.
*
* @param block
* The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata
* The metadata of the {@link ICarvingVariation variation}
* @param group
* The name of the group that the variation should be removed from
* @return The ICarvingVariation that was removed. Null if nothing was removed.
*/
ICarvingVariation removeVariation(Block block, int metadata, String group);
/**
* Registers a group to an oredict name.
* <p>
* Doing this means that all blocks that are registered to this oredict name will act as if they are a part of this group.
*
* @param groupName
* The name of the group
* @param oreName
* The oredict name
*/
void registerOre(String groupName, String oreName);
/**
* Sets the sound resource for a group.
* <p>
* This is the sound that is used when a block from this group is chiseled. <br/>
* Does <i>not</i> need to be explicitly set.
*
* @param name
* The name of the group
* @param sound
* The resource string for the sound
*/
void setVariationSound(String name, String sound);
}
@@ -0,0 +1,18 @@
package com.cricketcraft.chisel.api.carving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IChiselMode {
void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation);
/**
* Implemented implicitly by enums. If your IChiselMode is not an enum
* constant, this needs to be implemented explicitly.
*
* @return The name of the mode.
*/
String name();
}
@@ -1,19 +1,16 @@
package com.cricketcraft.chisel.block;
import java.util.Iterator;
import java.util.Random;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
@@ -21,46 +18,42 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPresent extends BlockChest implements ICarvable {
public class BlockPresent extends Block implements ICarvable {
private final Random random = new Random();
private int type;
public CarvableHelper carverHelper;
private float minX, minY, minZ, maxX, maxY, maxZ;
public BlockPresent(int type) {
super(1);
this.type = type;
public BlockPresent() {
super(Material.wood);
carverHelper = new CarvableHelper();
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0875F, 0.9365F);
minX = 0.0625F;
minZ = 0.0625F;
maxX = 0.9375F;
maxY = 0.875F;
maxZ = 0.9375F;
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public String getKindOfChest(int type) {
public String getModelTexture(int type) {
return "textures/blocks/present/presentChest" + type;
}
private static boolean isCatSittingOnMe(World world, int x, int y, int z) {
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)).iterator();
EntityOcelot ocelot;
do {
if (!iterator.hasNext()) {
return false;
}
Entity entity = (Entity) iterator.next();
ocelot = (EntityOcelot) entity;
} while (!ocelot.isSitting());
return true;
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
@@ -79,96 +72,23 @@ public class BlockPresent extends BlockChest implements ICarvable {
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack itemStack) {
Block front = world.getBlock(x, y, z - 1);
Block back = world.getBlock(x, y, z + 1);
Block left = world.getBlock(x - 1, y, z);
Block right = world.getBlock(x + 1, y, z);
byte metadata = 0;
int rot = MathHelper.floor_double((entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (rot == 0) {
metadata = 2;
}
if (rot == 1) {
metadata = 5;
}
if (rot == 2) {
metadata = 3;
}
if (rot == 3) {
metadata = 4;
}
if (front != this && back != this && left != this && right != this) {
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
} else {
if ((front == this || back == this) && (metadata == 4 || metadata == 5)) {
if (front == this) {
world.setBlockMetadataWithNotify(x, y, z - 1, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x, y, z + 1, metadata, 3);
}
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
if ((left == this || right == this) && (metadata == 2 || metadata == 3)) {
if (left == this) {
world.setBlockMetadataWithNotify(x - 1, y, z, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x + 1, y, z, metadata, 3);
}
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
}
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
int l = 0;
if (world.getBlock(x - 1, y, z) == this) {
++l;
}
if (world.getBlock(x + 1, y, z) == this) {
++l;
}
if (world.getBlock(x, y, z - 1) == this) {
++l;
}
if (world.getBlock(x, y, z + 1) == this) {
++l;
}
return l > 1 ? false : (areSurroundingBlocksMe(world, x, y - 1, z) ? false : (areSurroundingBlocksMe(world, x, y + 1, z) ? false : (areSurroundingBlocksMe(world, x, y, z - 1) ? false
: !areSurroundingBlocksMe(world, x, y, z + 1))));
}
private boolean areSurroundingBlocksMe(World world, int x, int y, int z) {
return world.getBlock(x, y, z) != this ? false : (world.getBlock(x - 1, y, z) == this ? true : (world.getBlock(x + 1, y, z) == this ? true : (world.getBlock(x, y, z - 1) == this ? true
: world.getBlock(x, y, z + 1) == this)));
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
super.onNeighborBlockChange(world, x, y, z, neighbor);
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
if (tileEntityPresent != null) {
tileEntityPresent.updateContainingBlockInfo();
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, heading, 3);
te.findConnections();
if (te.isConnected()) {
TileEntityPresent other = te.getConnection();
world.setBlockMetadataWithNotify(other.xCoord, other.yCoord, other.zCoord, heading, 3);
}
te.setType(stack.getItemDamage());
world.markBlockForUpdate(x, y, z);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
if (tileEntityPresent != null) {
@@ -176,28 +96,7 @@ public class BlockPresent extends BlockChest implements ICarvable {
ItemStack itemStack = tileEntityPresent.getStackInSlot(c);
if (itemStack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemStack.stackSize > 0; world.spawnEntityInWorld(entityItem)) {
int stack = random.nextInt(21) + 10;
if (stack > itemStack.stackSize) {
stack = itemStack.stackSize;
}
itemStack.stackSize -= stack;
entityItem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemStack.getItem(), stack, itemStack.getItemDamage()));
float motion = 0.05F;
entityItem.motionX = random.nextGaussian() * motion;
entityItem.motionY = random.nextGaussian() * motion + 0.2F;
entityItem.motionZ = random.nextGaussian() * motion;
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
}
dropBlockAsItem(world, x, y, z, itemStack);
}
}
@@ -208,23 +107,75 @@ public class BlockPresent extends BlockChest implements ICarvable {
}
@Override
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityPresent(type);
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) {
if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
player.openGui(Chisel.instance, 2, world, x, y, z);
return true;
}
return false;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction) {
if (!canProvidePower()) {
return 0;
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
}
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
if (me == null) {
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
int x = me.xCoord, y = me.yCoord, z = me.zCoord;
if (me.isConnected()) {
ForgeDirection dir = me.getConnectionDir();
if (dir != ForgeDirection.NORTH && (!me.isParent() || dir == ForgeDirection.SOUTH)) {
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ);
} else {
return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ);
}
}
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
}
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
if (!te.isConnected()) {
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
} else {
int players = ((TileEntityPresent) world.getTileEntity(x, y, z)).numPlayersUsing;
return MathHelper.clamp_int(players, 0, 15);
ForgeDirection dir = te.getConnectionDir();
switch (dir) {
case EAST:
setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F);
break;
case NORTH:
setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F);
break;
case SOUTH:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1);
break;
case WEST:
setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
default:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
}
}
}
@Override
public boolean hasTileEntity(int metadata) {
return true;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int strength) {
return strength == 1 ? isProvidingWeakPower(world, x, y, z, strength) : 0;
public TileEntity createTileEntity(World world, int metadata) {
return new TileEntityPresent();
}
@Override
@@ -234,7 +185,11 @@ public class BlockPresent extends BlockChest implements ICarvable {
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
return Container.calcRedstoneFromInventory(getInventory(world, x, y, z));
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPresent) {
return Container.calcRedstoneFromInventory((TileEntityPresent) te);
}
return 0;
}
@Override
@@ -243,47 +198,10 @@ public class BlockPresent extends BlockChest implements ICarvable {
this.blockIcon = register.registerIcon("planks_oak");
}
public IInventory getInventory(World world, int x, int y, int z) {
Object object = world.getTileEntity(x, y, z);
if (object == null) {
return null;
} else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
return null;
} else if (isCatSittingOnMe(world, x, y, z)) {
return null;
} else if (world.getBlock(x - 1, y, z) == this && (world.isSideSolid(x - 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y - 1, z))) {
return null;
} else if (world.getBlock(x + 1, y, z) == this && (world.isSideSolid(x + 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y + 1, z))) {
return null;
} else if (world.getBlock(x, y, z - 1) == this && (world.isSideSolid(x, y + 1, z - 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z - 1))) {
return null;
} else if (world.getBlock(x, y, z + 1) == this && (world.isSideSolid(x, y + 1, z + 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z + 1))) {
return null;
} else {
if (world.getBlock(x - 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x - 1, y, z), (IInventory) object);
}
if (world.getBlock(x + 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x + 1, y, z), (IInventory) object);
}
if (world.getBlock(x, y, z - 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z - 1), (IInventory) object);
}
if (world.getBlock(x, y, z + 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z + 1), (IInventory) object);
}
return (IInventory) object;
}
}
@Override
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
TileEntity te = world.getTileEntity(x, y, z);
return te instanceof TileEntityPresent ? carverHelper.getVariation(((TileEntityPresent) te).getType()) : carverHelper.getVariation(metadata);
}
@Override
@@ -1,6 +1,6 @@
package com.cricketcraft.chisel.block.tileentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -21,6 +21,7 @@ import com.cricketcraft.chisel.init.ChiselItems;
import com.cricketcraft.chisel.network.PacketHandler;
import com.cricketcraft.chisel.network.message.MessageAutoChisel;
import com.cricketcraft.chisel.network.message.MessageSlotUpdate;
import com.cricketcraft.chisel.utils.General;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -58,7 +59,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
public static final int maxRot = 60;
public static final int rotAmnt = 15;
public float chiselRot;
public boolean chiseling = false;
public boolean chiseling = false, breakChisel = false;;
public int toChisel = 1;
private ItemStack lastBase;
@@ -177,7 +178,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target
private boolean canBeMadeFrom(ItemStack from, ItemStack to) {
ArrayList<ItemStack> results = Carving.chisel.getItems(from);
List<ItemStack> results = Carving.chisel.getItemsForChiseling(from);
for (ItemStack s : results) {
if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) {
return true;
@@ -207,9 +208,19 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
private void chiselItem(int chiseled) {
if (!worldObj.isRemote) {
((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, this, CHISEL, inventory[CHISEL], inventory[TARGET]);
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true), worldObj.provider.dimensionId);
boolean breakChisel = false;
if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[TARGET]))) {
inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1);
if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) {
setInventorySlotContents(CHISEL, null);
breakChisel = true;
}
}
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId);
} else {
if (breakChisel) {
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false);
}
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
chiseling = false;
if (lastBase != null) {
@@ -269,7 +280,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
if (worldObj.isRemote && slot == BASE && stack != null) {
lastBase = stack.copy();
}
@@ -318,7 +329,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
switch (slot) {
case BASE:
case TARGET:
return !Carving.chisel.getItems(itemStack).isEmpty();
return !Carving.chisel.getItemsForChiseling(itemStack).isEmpty();
case OUTPUT:
return false;
case CHISEL:
@@ -361,7 +372,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
} else if (inventory[slot] == null) {
return null;
} else {
ghostItem.setEntityItemStack(new ItemStack(inventory[slot].getItem(), 1, inventory[slot].getItemDamage()));
ghostItem.setEntityItemStack(inventory[slot].copy());
return ghostItem;
}
}
@@ -401,14 +412,15 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
}
}
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound) {
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound, boolean breakChisel) {
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
this.toChisel = chiseled;
if (playSound) {
this.chiseling = true;
}
this.breakChisel = breakChisel;
}
public ItemStack getLastBase() {
return lastBase == null ? null : lastBase.copy();
}
@@ -1,110 +1,271 @@
package com.cricketcraft.chisel.block.tileentity;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.inventory.ContainerPresent;
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
import com.cricketcraft.chisel.init.ChiselBlocks;
import com.cricketcraft.chisel.network.PacketHandler;
import com.cricketcraft.chisel.network.message.MessagePresentConnect;
public class TileEntityPresent extends TileEntityChest {
public class TileEntityPresent extends TileEntity implements IInventory {
public int type;
private int ticksSinceSync;
public TileEntityPresent(int type) {
this.type = type;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
}
private TileEntityPresent connection = null;
private ForgeDirection cachedDir = null;
private boolean isParent;
private ItemStack[] inventory = new ItemStack[27];
private int type;
private boolean autoSearch = true;
@Override
public void updateEntity() {
super.updateEntity();
this.checkForAdjacentChests();
++this.ticksSinceSync;
float f;
if (isConnected() && connection.isInvalid()) {
disconnect();
}
if (!this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) {
this.numPlayersUsing = 0;
f = 5.0F;
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord - f, this.yCoord - f,
this.zCoord - f, this.xCoord + 1 + f, this.yCoord + 1 + f, this.zCoord + 1 + f));
Iterator iterator = list.iterator();
if (autoSearch && worldObj != null /* ugh */) {
if (cachedDir != null) {
connectTo(cachedDir);
} else {
findConnections();
}
autoSearch = false;
}
}
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
public boolean isConnected() {
return connection != null;
}
if (entityplayer.openContainer instanceof ContainerPresent) {
IInventory iinventory = ((ContainerChest) entityplayer.openContainer).getLowerChestInventory();
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) {
if (present.type == type && !present.isConnected() && Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) {
connection = present;
connection.connection = this;
connection.cachedDir = dir.getOpposite();
cachedDir = dir;
isParent = !present.isParent;
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId);
return true;
}
return false;
}
if (iinventory == this || iinventory instanceof InventoryLargePresent && ((InventoryLargePresent) iinventory).isPartOfLargePresent(this)) {
++this.numPlayersUsing;
public boolean connectTo(ForgeDirection dir) {
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
if (te instanceof TileEntityPresent) {
return connectTo((TileEntityPresent) te, dir);
}
return false;
}
public void disconnect() {
if (isConnected()) {
this.connection.cachedDir = null;
this.connection.connection = null;
this.cachedDir = null;
this.connection = null;
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false), worldObj.provider.dimensionId);
}
}
public TileEntityPresent getConnection() {
return connection;
}
public ForgeDirection getConnectionDir() {
return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir;
}
public boolean isParent() {
return isParent || !isConnected();
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public void findConnections() {
if (!isConnected()) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
if (connectTo(dir)) {
break;
}
}
}
}
}
public TileEntityPresent getParent() {
return isParent || connection == null ? this : connection;
}
this.prevLidAngle = this.lidAngle;
f = 0.1F;
double d2;
@Override
public AxisAlignedBB getRenderBoundingBox() {
return ChiselBlocks.present.getBoundingBox(this);
}
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
double d1 = this.xCoord + 0.5D;
d2 = this.zCoord + 0.5D;
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagList nbttaglist = new NBTTagList();
if (this.adjacentChestZPos != null) {
d2 += 0.5D;
for (int i = 0; i < inventory.length; ++i)
{
if (inventory[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
if (this.adjacentChestXPos != null) {
d1 += 0.5D;
}
this.worldObj.playSoundEffect(d1, this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
float f1 = this.lidAngle;
if (this.numPlayersUsing > 0) {
this.lidAngle += f;
} else {
this.lidAngle -= f;
}
if (this.lidAngle > 1.0F) {
this.lidAngle = 1.0F;
}
float f2 = 0.5F;
if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
d2 = this.xCoord + 0.5D;
double d0 = this.zCoord + 0.5D;
if (this.adjacentChestZPos != null) {
d0 += 0.5D;
}
if (this.adjacentChestXPos != null) {
d2 += 0.5D;
}
this.worldObj.playSoundEffect(d2, this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.lidAngle < 0.0F) {
this.lidAngle = 0.0F;
}
tag.setTag("Items", nbttaglist);
tag.setBoolean("isParent", isParent);
tag.setInteger("presentType", type);
if (cachedDir != null) {
tag.setInteger("conDir", cachedDir.ordinal());
}
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
inventory = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255;
if (j >= 0 && j < inventory.length)
{
inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.isParent = tag.getBoolean("isParent");
this.type = tag.getInteger("presentType");
if (tag.hasKey("conDir")) {
cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
}
autoSearch = true;
}
/* IInventory */
@Override
public int getSizeInventory() {
return isConnected() ? inventory.length + connection.inventory.length : inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
if (slot >= inventory.length) {
return isConnected() ? connection.inventory[slot % inventory.length] : null;
} else {
return inventory[slot];
}
}
@Override
public ItemStack decrStackSize(int slot, int amount)
{
ItemStack[] inv = inventory;
if (isConnected() && slot >= inventory.length) {
inv = connection.inventory;
}
if (inv[slot] != null)
{
ItemStack itemstack;
if (inv[slot].stackSize <= amount)
{
itemstack = inv[slot];
inv[slot] = null;
this.markDirty();
return itemstack;
}
else
{
itemstack = inv[slot].splitStack(amount);
if (inv[slot].stackSize == 0)
{
inv[slot] = null;
}
this.markDirty();
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
if (slot < inventory.length) {
inventory[slot] = stack;
} else if (isConnected()) {
connection.inventory[slot % inventory.length] = stack;
}
}
@Override
public String getInventoryName() {
return "chisel.present";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return true;
}
@Override
public void openInventory() {
;
}
@Override
public void closeInventory() {
;
}
@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
return true;
}
}
@@ -38,9 +38,6 @@ public class CarvableHelper {
public static final int V4 = 7;
public static final int CTMX = 8;
public CarvableHelper() {
}
public ArrayList<CarvableVariation> variations = new ArrayList<CarvableVariation>();
CarvableVariation[] map = new CarvableVariation[16];
public boolean forbidChiseling = false;
@@ -258,7 +255,7 @@ public class CarvableHelper {
}
public void registerAll(Block block, String name) {
register(block, name, ItemCarvable.class);
registerAll(block, name, ItemCarvable.class);
}
public void registerBlock(Block block, String name) {
@@ -270,7 +267,7 @@ public class CarvableHelper {
GameRegistry.registerBlock(block, cl, name);
}
public void register(Block block, String name, Class<? extends ItemCarvable> cl) {
public void registerAll(Block block, String name, Class<? extends ItemCarvable> cl) {
registerBlock(block, name, cl);
registerVariations(name, block);
}
@@ -9,7 +9,7 @@ import com.cricketcraft.chisel.client.render.TextureSubmap;
public class CarvableVariation {
public String blockName;
private String description;
public String descriptionUnloc;
public int metadata;
public int kind;
@@ -30,11 +30,11 @@ public class CarvableVariation {
public TextureSubmap submapSmall;
public String getDescription() {
return I18n.format(description);
return I18n.format(descriptionUnloc);
}
public void setDescriptionUnloc(String desc) {
this.description = desc;
this.descriptionUnloc = desc;
}
static class CarvableVariationCTM {
@@ -12,19 +12,34 @@ import net.minecraftforge.oredict.OreDictionary;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
public class Carving {
public class Carving implements ICarvingRegistry {
GroupList groups = new GroupList();
public static final Carving chisel = new Carving();
public static final ICarvingRegistry chisel = new Carving();
public static final Carving needle = new Carving();
private Carving() {
}
public List<ICarvingVariation> getVariations(Block block, int metadata) {
@Override
public ICarvingVariation getVariation(Block block, int metadata) {
ICarvingGroup g = getGroup(block, metadata);
if (g != null) {
for (ICarvingVariation v : g.getVariations()) {
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
return v;
}
}
}
return null;
}
@Override
public List<ICarvingVariation> getGroupVariations(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null)
return null;
@@ -32,7 +47,8 @@ public class Carving {
return group.getVariations();
}
public String getOre(Block block, int metadata) {
@Override
public String getOreName(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null)
return null;
@@ -40,12 +56,24 @@ public class Carving {
return group.getOreName();
}
public ArrayList<ItemStack> getItems(ItemStack chiseledItem) {
@Override
public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) {
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
int damage = chiseledItem.getItemDamage();
ICarvingGroup group = null;
int[] oreids = OreDictionary.getOreIDs(chiseledItem);
for (int i : oreids) {
group = groups.getGroupByOre(OreDictionary.getOreName(i));
if (group != null) {
break;
}
}
if (group == null) {
group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage());
}
ICarvingGroup group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), damage);
if (group == null)
return items;
@@ -82,8 +110,9 @@ public class Carving {
return items;
}
@Override
public ICarvingGroup getGroup(Block block, int metadata) {
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, metadata));
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
if (ids.length > 0) {
for (int id : ids) {
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
@@ -96,17 +125,44 @@ public class Carving {
return groups.getGroup(block, metadata);
}
@Override
public ICarvingGroup getGroup(String name) {
return groups.getGroupByName(name);
}
@Override
public ICarvingGroup removeGroup(String groupName) {
ICarvingGroup g = groups.getGroupByName(groupName);
return groups.remove(g) ? g : null;
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata) {
return removeVariation(block, metadata, null);
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
return groups.removeVariation(block, metadata, group);
}
@Override
public void addVariation(String groupName, Block block, int metadata, int order) {
if (block == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
}
ICarvingVariation variation = new CarvingVariation(block, metadata, order);
addVariation(groupName, variation);
}
@Override
public void addVariation(String groupName, ICarvingVariation variation) {
if (groupName == null) {
throw new NullPointerException("Cannot add variation to null group name.");
} else if (variation == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null variation.");
}
ICarvingGroup group = groups.getGroupByName(groupName);
@@ -118,10 +174,12 @@ public class Carving {
groups.addVariation(groupName, variation);
}
@Override
public void addGroup(ICarvingGroup group) {
groups.add(group);
}
@Override
public void registerOre(String name, String oreName) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
@@ -131,6 +189,7 @@ public class Carving {
}
}
@Override
public void setVariationSound(String name, String sound) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
@@ -140,16 +199,19 @@ public class Carving {
}
}
@Override
public String getVariationSound(Block block, int metadata) {
return getVariationSound(Item.getItemFromBlock(block), metadata);
}
@Override
public String getVariationSound(Item item, int metadata) {
ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata);
String sound = group == null ? null : group.getSound();
return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound;
}
@Override
public List<String> getSortedGroupNames() {
List<String> names = new ArrayList<String>();
names.addAll(groups.getNames());
@@ -7,7 +7,6 @@ import java.util.List;
import com.cricketcraft.chisel.api.carving.CarvingUtils;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
public class CarvingGroup implements ICarvingGroup {
@@ -23,7 +22,7 @@ public class CarvingGroup implements ICarvingGroup {
}
public List<ICarvingVariation> getVariations() {
return ImmutableList.copyOf(variations);
return Lists.newArrayList(variations);
}
@Override
@@ -37,6 +36,17 @@ public class CarvingGroup implements ICarvingGroup {
}
});
}
@Override
public boolean removeVariation(ICarvingVariation variation) {
ICarvingVariation toRemove = null;
for (ICarvingVariation v : variations) {
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
toRemove = v;
}
}
return toRemove == null ? false : variations.remove(toRemove);
}
@Override
public String getName() {
@@ -3,6 +3,7 @@ package com.cricketcraft.chisel.carving;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.block.Block;
@@ -11,6 +12,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
public class GroupList implements Set<ICarvingGroup> {
@@ -129,6 +131,15 @@ public class GroupList implements Set<ICarvingGroup> {
@Override
public boolean remove(Object o) {
if (o instanceof ICarvingGroup) {
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if (lookup.get(v).getName().equals(((ICarvingGroup) o).getName())) {
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return groups.remove(((ICarvingGroup) o).getName()) != null;
}
return false;
@@ -205,6 +216,28 @@ public class GroupList implements Set<ICarvingGroup> {
return groups.keySet();
}
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
ICarvingGroup g = null;
if (group != null) {
g = groups.get(group);
if (g == null) {
throw new IllegalArgumentException("No such group " + group);
}
groups.remove(g.getName());
}
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if ((g == null || lookup.get(v).getName().equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) {
lookup.get(v).removeVariation(v.v);
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return toRemove.isEmpty() ? null : toRemove.get(0).v;
}
@Override
public String toString() {
return groups.toString();
@@ -165,7 +165,7 @@ public class GeneralChiselClient {
}
public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z) {
if (Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0) {
if (Configurations.particlesTickrate != 0 || tick++ % Configurations.particlesTickrate != 0) {
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
@@ -2,12 +2,10 @@ 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;
@@ -1,5 +1,6 @@
package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
@@ -8,15 +9,23 @@ import net.minecraft.inventory.Slot;
import org.lwjgl.opengl.GL11;
import com.cricketcraft.chisel.api.IAdvancedChisel;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.inventory.ContainerChisel;
import com.cricketcraft.chisel.inventory.InventoryChiselSelection;
import com.cricketcraft.chisel.inventory.SlotChiselInput;
import com.cricketcraft.chisel.item.chisel.ChiselMode;
import com.cricketcraft.chisel.network.PacketHandler;
import com.cricketcraft.chisel.network.message.MessageChiselMode;
import com.cricketcraft.chisel.utils.General;
import com.cricketcraft.chisel.utils.GeneralClient;
public class GuiChisel extends GuiContainer {
public EntityPlayer player;
public ContainerChisel container;
private IChiselMode currentMode;
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu) {
super(new ContainerChisel(iinventory, menu));
@@ -33,12 +42,42 @@ public class GuiChisel extends GuiContainer {
inventorySlots.onContainerClosed(player);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
currentMode = General.getChiselMode(container.chisel);
if (showMode()) {
int x = this.width / 2 - 120;
int y = this.height / 2 - 6;
buttonList.add(new GuiButton(0, x, y, 53, 20, ""));
setButtonText();
}
}
private void setButtonText() {
((GuiButton) buttonList.get(0)).displayString = I18n.format(container.inventory.getInventoryName() + ".mode." + currentMode.name().toLowerCase());
}
private boolean showMode() {
if (container.chisel != null && container.chisel.getItem() instanceof IChiselItem) {
return ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
}
return false;
}
@Override
protected void drawGuiContainerForegroundLayer(int j, int i) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
String line = I18n.format(this.container.inventory.getInventoryName() + ".title");
fontRendererObj.drawSplitString(line, 50 - fontRendererObj.getStringWidth(line) / 2, 60, 40, 0x404040);
if (showMode()) {
line = I18n.format(this.container.inventory.getInventoryName() + ".mode");
fontRendererObj.drawString(line, fontRendererObj.getStringWidth(line) / 2 + 6, 85, 0x404040);
}
}
@Override
@@ -56,13 +95,29 @@ public class GuiChisel extends GuiContainer {
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
protected void actionPerformed(GuiButton button) {
if (button.id == 0) {
if (container.chisel != null && container.chisel.getItem() instanceof IAdvancedChisel) {
IAdvancedChisel item = (IAdvancedChisel) container.chisel.getItem();
currentMode = item.getNextMode(container.chisel, currentMode);
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
} else {
currentMode = ChiselMode.next(currentMode);
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
setButtonText();
}
}
super.actionPerformed(button);
}
@Override
protected void func_146977_a(Slot slot) {
if (slot instanceof SlotChiselInput) {
@@ -38,6 +38,12 @@ public class BlockAdvancedMarbleRenderer implements ISimpleBlockRenderingHandler
int meta = world.getBlockMetadata(x, y, z);
CarvableVariation var = ((ICarvable) block).getVariation(world, x, y, z, meta);
if (rendererOld.hasOverrideBlockTexture()) {
// breaking anim
rendererOld.renderStandardBlock(block, x, y, z);
return true;
}
switch (var == null ? 0 : var.kind) {
case CarvableHelper.CTMX:
@@ -229,7 +229,11 @@ public class BlockMarblePaneRenderer implements ISimpleBlockRenderingHandler {
if (iconPane == null || iconTop == null || iconSide == null)
return false;
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
if (renderer.hasOverrideBlockTexture()) {
paneRenderer.set(x, y, z, renderer.overrideBlockTexture, renderer.overrideBlockTexture, renderer.overrideBlockTexture);
} else {
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
}
boolean connectsNorth = block.canPaneConnectToBlock(world.getBlock(x, y, z - 1));
boolean connectsSouth = block.canPaneConnectToBlock(world.getBlock(x, y, z + 1));
@@ -48,15 +48,22 @@ public class BlockMarblePillarRenderer implements ISimpleBlockRenderingHandler {
int metadata = world.getBlockMetadata(x, y, z);
if (block.carverHelper.variations.get(metadata).kind != CarvableHelper.CTMV) {
block.sides[0] = block.carverHelper.getIcon(0, metadata);
block.sides[1] = block.carverHelper.getIcon(1, metadata);
block.sides[2] = block.carverHelper.getIcon(2, metadata);
block.sides[3] = block.carverHelper.getIcon(3, metadata);
block.sides[4] = block.carverHelper.getIcon(4, metadata);
block.sides[5] = block.carverHelper.getIcon(5, metadata);
//Probably not the best way to handle this...
if(metadata > block.carverHelper.variations.size())
{
metadata = block.carverHelper.variations.size() - 1;
}
else {
if (block.carverHelper.variations.get(metadata).kind != CarvableHelper.CTMV) {
block.sides[0] = block.carverHelper.getIcon(0, metadata);
block.sides[1] = block.carverHelper.getIcon(1, metadata);
block.sides[2] = block.carverHelper.getIcon(2, metadata);
block.sides[3] = block.carverHelper.getIcon(3, metadata);
block.sides[4] = block.carverHelper.getIcon(4, metadata);
block.sides[5] = block.carverHelper.getIcon(5, metadata);
return renderer.renderStandardBlock(block, x, y, z);
return renderer.renderStandardBlock(block, x, y, z);
}
}
boolean yp = connected(world, x, y + 1, z, block, metadata);
@@ -56,14 +56,18 @@ public class RenderBlocksColumn extends RenderBlocks {
sides[4] = iconTop;
sides[5] = iconTop;
if (xp && xn)
sides[0] = submap.icons[2];
else if (xp)
sides[0] = submap.icons[3];
else
// for some reason along the x axis the bottom texture on the ends is backwards. This flips it around.
if (xp && xn) {
sides[1] = submap.icons[2];
sides[0] = sides[1];
} else if (xp) {
sides[1] = submap.icons[3];
sides[0] = submap.icons[1];
sides[1] = sides[2] = sides[3] = sides[0];
} else {
sides[1] = submap.icons[1];
sides[0] = submap.icons[3];
}
sides[2] = sides[3] = sides[1];
} else {
boolean zp = connected(blockAccess, x, y, z + 1, block, metadata);
boolean zn = connected(blockAccess, x, y, z - 1, block, metadata);
@@ -1,74 +0,0 @@
package com.cricketcraft.chisel.client.render.item;
import net.minecraft.client.model.ModelChest;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.block.BlockPresent;
import cpw.mods.fml.client.FMLClientHandler;
public class ItemPresentRenderer implements IItemRenderer {
private final ModelChest model = new ModelChest();
BlockPresent present;
private int meta;
public ItemPresentRenderer(int type) {
present = new BlockPresent(type);
this.meta = type;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Chisel.MOD_ID, present.getKindOfChest(meta) + ".png"));
switch (type) {
case ENTITY:
renderBlock(0.0F, 1.0F, 0.0F);
break;
case EQUIPPED:
renderBlock(0.5F, 1.5F, 0.5F);
break;
case EQUIPPED_FIRST_PERSON:
renderBlock(0.5F, 1.0F, 0.5F);
break;
case INVENTORY:
renderInventory(1.0F, 1.0F, 1.0F);
break;
default:
break;
}
}
private void renderBlock(float x, float y, float z) {
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
GL11.glScaled(-1, -1, 1);
model.renderAll();
GL11.glPopMatrix();
}
private void renderInventory(float x, float y, float z) {
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
GL11.glRotatef(180F, 1F, 0, 0);
GL11.glRotatef(-90F, 0, 1F, 0);
GL11.glScalef(1.0F, 1.0F, 1.0F);
model.renderAll();
GL11.glPopMatrix();
}
}
@@ -83,7 +83,7 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator tes = Tessellator.instance;
IIcon icon = block.getIcon(0, 0);
IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0);
tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tes.setColorOpaque_F(1, 1, 1);
tes.addTranslation(x, y, z + 1);
@@ -92,9 +92,13 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
Vertex n = f.faceNormal;
tes.setNormal(n.x, n.y, n.z);
for (int i = 0; i < f.vertices.length; i++) {
Vertex v = f.vertices[i];
Vertex vert = f.vertices[i];
TextureCoordinate t = f.textureCoordinates[i];
tes.addVertexWithUV(v.x, v.y, v.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16));
if (!renderer.hasOverrideBlockTexture()) {
tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16));
} else {
tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16));
}
}
}
}
@@ -186,9 +190,6 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
renderItem.doRender(item, 0, 0, 0, 0, 0);
settings.fancyGraphics = was;
glPopMatrix();
} else {
autoChisel.chiselRot = 0;
autoChisel.chiseling = false;
}
}
}
@@ -1,126 +1,144 @@
package com.cricketcraft.chisel.client.render.tile;
import net.minecraft.block.Block;
import java.util.HashMap;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.model.ModelLargeChest;
import net.minecraft.client.renderer.tileentity.TileEntityChestRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.block.BlockPresent;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.init.ChiselBlocks;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.client.FMLClientHandler;
public class RenderPresent extends TileEntityChestRenderer {
public class RenderPresent extends TileEntitySpecialRenderer implements IItemRenderer {
private ModelChest smallChest = new ModelChest();
private ModelChest largeChest = new ModelLargeChest();
public RenderPresent() {
}
private HashMap<Integer, ResourceLocation> textureCache = Maps.newHashMap();
public void renderTileEntityAt(TileEntityPresent present, double x, double y, double z, float partialTicks) {
int i;
if (!present.hasWorldObj()) {
i = 0;
} else {
Block block = present.getBlockType();
i = present.getBlockMetadata();
if (block instanceof BlockPresent && i == 0) {
try {
((BlockPresent) block).func_149954_e(present.getWorldObj(), present.xCoord, present.yCoord, present.zCoord);
} catch (ClassCastException e) {
FMLLog.severe("[Chisel 2] Attempted to render a present at %d, %d, %d that was not a present", present.xCoord, present.yCoord, present.zCoord);
}
i = present.getBlockMetadata();
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
int meta = present.getBlockMetadata();
bindTexture(present);
if (!present.isConnected()) {
GL11.glRotatef(90 * meta + 180, 0, 1, 0);
switch(present.getBlockMetadata()) {
case 0:
GL11.glTranslatef(-1, 0, -1);
break;
case 1:
GL11.glTranslatef(0, 0, -1);
break;
case 3:
GL11.glTranslatef(-1, 0, 0);
break;
}
present.checkForAdjacentChests();
smallChest.renderAll();
} else if (present.isParent()) {
ForgeDirection dir = present.getConnectionDir();
switch(dir) {
case NORTH:
GL11.glRotatef(-90, 0, 1, 0);
GL11.glTranslatef(0, 0, -1);
break;
case SOUTH:
GL11.glRotatef(-90, 0, 1, 0);
GL11.glTranslatef(-1, 0, -1);
break;
case WEST:
GL11.glTranslatef(-1, 0, 0);
break;
default:
break;
}
if (meta == 0 || meta == 3) {
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(-2, 0, -1);
}
largeChest.renderAll();
}
if (present.adjacentChestZNeg == null && present.adjacentChestXNeg == null) {
BlockPresent blockPresent = (BlockPresent) present.getWorldObj().getBlock(present.xCoord, present.yCoord, present.zCoord);
ModelChest smallOrLargeChest;
if (present.adjacentChestZPos == null && present.adjacentChestXPos == null) {
smallOrLargeChest = smallChest;
this.bindTexture(new ResourceLocation(Chisel.MOD_ID, blockPresent.getKindOfChest(present.type) + ".png"));
} else {
smallOrLargeChest = largeChest;
this.bindTexture(new ResourceLocation(Chisel.MOD_ID, blockPresent.getKindOfChest(present.type) + "_double.png"));
}
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
short short1 = 0;
if (i == 2) {
short1 = 180;
}
if (i == 3) {
short1 = 0;
}
if (i == 4) {
short1 = 90;
}
if (i == 5) {
short1 = -90;
}
if (i == 2 && present.adjacentChestXPos != null) {
GL11.glTranslatef(1.0F, 0.0F, 0.0F);
}
if (i == 5 && present.adjacentChestZPos != null) {
GL11.glTranslatef(0.0F, 0.0F, -1.0F);
}
GL11.glRotatef(short1, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f1 = present.prevLidAngle + (present.lidAngle - present.prevLidAngle) * partialTicks;
float f2;
if (present.adjacentChestZNeg != null) {
f2 = present.adjacentChestZNeg.prevLidAngle + (present.adjacentChestZNeg.lidAngle - present.adjacentChestZNeg.prevLidAngle) * partialTicks;
if (f2 > f1) {
f1 = f2;
}
}
if (present.adjacentChestXNeg != null) {
f2 = present.adjacentChestXNeg.prevLidAngle + (present.adjacentChestXNeg.lidAngle - present.adjacentChestXNeg.prevLidAngle) * partialTicks;
if (f2 > f1) {
f1 = f2;
}
}
f1 = 1.0F - f1;
f1 = 1.0F - f1 * f1 * f1;
smallOrLargeChest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
smallOrLargeChest.renderAll();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
private void bindTexture(TileEntityPresent present) {
int idx = present.getType() + (present.isConnected() ? 0 : 16);
ResourceLocation rl = textureCache.get(idx);
if (rl == null) {
String res = ChiselBlocks.present.getModelTexture(present.getType());
res += present.isConnected() ? "_double.png" : ".png";
rl = new ResourceLocation("chisel", res);
textureCache.put(idx, rl);
}
bindTexture(rl);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTicks) {
this.renderTileEntityAt((TileEntityPresent) tileEntity, x, y, z, partialTicks);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Chisel.MOD_ID, ChiselBlocks.present.getModelTexture(item.getItemDamage()) + ".png"));
switch (type) {
case ENTITY:
renderBlock(0.0F, 1.0F, 0.0F);
break;
case EQUIPPED:
renderBlock(0.5F, 1.5F, 0.5F);
break;
case EQUIPPED_FIRST_PERSON:
renderBlock(0.5F, 1.0F, 0.5F);
break;
case INVENTORY:
renderInventory(1.0F, 1.0F, 1.0F);
break;
default:
break;
}
}
private void renderBlock(float x, float y, float z) {
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
GL11.glScaled(-1, -1, 1);
smallChest.renderAll();
GL11.glPopMatrix();
}
private void renderInventory(float x, float y, float z) {
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
GL11.glRotatef(180F, 1F, 0, 0);
GL11.glRotatef(-90F, 0, 1F, 0);
GL11.glScalef(1.0F, 1.0F, 1.0F);
smallChest.renderAll();
GL11.glPopMatrix();
}
}
@@ -22,6 +22,7 @@ public class Configurations {
public static boolean chiselRecipe;
public static boolean enableFMP;
public static boolean chiselStoneToCobbleBricks;
public static boolean chiselBackToVanillaLeaves;
public static int marbleAmount;
public static int limestoneAmount;
@@ -39,11 +40,14 @@ public class Configurations {
public static int ironChiselMaxDamage;
public static int diamondChiselMaxDamage;
public static boolean ironChiselCanLeftClick;
public static boolean ironChiselHasModes;
public static int ironChiselAttackDamage;
public static int diamondChiselAttackDamage;
public static boolean useRoadLineTool;
public static String getRoadLineTool;
public static int roadLineToolLevel;
public static boolean refreshConfig() {
String category;
@@ -59,6 +63,7 @@ public class Configurations {
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);
chiselBackToVanillaLeaves = config.get(category, "chiselBackToVanillaLeaves", false, "If this is true, you can chisel from the chisel leaves back to vanilla ones. If it is false, you cannot.").getBoolean(false);
/* worldgen */
category = "worldgen";
@@ -78,19 +83,23 @@ public class Configurations {
.getBoolean(true);
/* chisel */
category = "chisel";
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", true, "If this is true, the iron chisel can left click chisel blocks. If false, it cannot.").getBoolean();
ironChiselHasModes = config.get(category, "ironChiselHasModes", false, "If this is true, the iron chisel can change its chisel mode just as the diamond chisel can.").getBoolean();
ironChiselAttackDamage = config.get(category, "ironChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the iron chisel inflicts when it is used to attack an entity.").getInt();
diamondChiselAttackDamage = config.get(category, "diamondChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the diamond chisel inflicts when it is used to attack an entity.").getInt();
/* block */
category = "block";
useRoadLineTool = config.get(category, "useRoadLineTool", false, "Should the road line require a tool to break (If false, road lines can be broken in Adventure)").getBoolean();
getRoadLineTool = config.get(category, "getRoadLineTool","pickaxe","The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)").getString();
roadLineToolLevel = config.get(category, "roadLineToolLevel",0,"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0").getInt();
getRoadLineTool = config.get(category, "getRoadLineTool", "pickaxe", "The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)").getString();
roadLineToolLevel = config.get(category, "roadLineToolLevel", 0,
"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0")
.getInt();
if (config.hasChanged()) {
config.save();
}
@@ -101,8 +110,8 @@ public class Configurations {
return config.get("features", featureName(feature), true).getBoolean(true) && refreshConfig();
}
// this makes the old camelCase names from the new CONSTANT_CASE names
private static String featureName(Features feature) {
/** Makes the old camelCase names from the new CONSTANT_CASE names */
public static String featureName(Features feature) {
String[] words = feature.name().toLowerCase(Locale.ENGLISH).split("_");
if (words.length == 1) {
return words[0];
@@ -89,6 +89,7 @@ public final class ChiselBlocks {
public static final BlockCarvable mossy_templeblock = null;
public static final BlockCarvable factoryblock = null;
public static final BlockCarvablePane paperwall = null;
public static final BlockCarvable paperwall_block = null;
public static final BlockCarvable woolen_clay = null;
public static final BlockCarvable laboratoryblock = null;
@@ -111,7 +112,9 @@ public final class ChiselBlocks {
public static final BlockCarvable bloodRune = null;
public static final BlockCarvable bloodBrick = null;
public static final BlockPresent present = null;
// Arrays can't be final because of how @ObjectHolder works
public static BlockCarvableStairs[] marbleStairs = new BlockCarvableStairs[8];
public static BlockCarvableStairs[] limestoneStairs = new BlockCarvableStairs[8];
@@ -122,8 +125,6 @@ public final class ChiselBlocks {
public static BlockCarvable[] planks = new BlockCarvable[6];
public static BlockPresent[] present = new BlockPresent[16];
public static BlockCarvablePumpkin[] pumpkin = new BlockCarvablePumpkin[16];
public static BlockCarvablePumpkin[] jackolantern = new BlockCarvablePumpkin[16];
@@ -103,7 +103,7 @@ public class ContainerAutoChisel extends Container {
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);
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(autoChisel, chiseled, false, false), player.worldObj.provider.dimensionId);
}
return ret;
@@ -7,6 +7,7 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.item.chisel.ItemChisel;
import com.cricketcraft.chisel.utils.General;
@@ -18,7 +19,7 @@ public class ContainerChisel extends Container {
int currentIndex;
public ItemStack chisel;
public boolean finished;
public Carving carving;
public ICarvingRegistry carving;
public ContainerChisel(InventoryPlayer inventoryplayer, InventoryChiselSelection inv) {
inventory = inv;
@@ -128,7 +129,7 @@ public class ContainerChisel extends Container {
public void onChiselSlotChanged() {
ItemStack stack = playerInventory.mainInventory[currentIndex];
if (!stack.isItemEqual(chisel))
if (stack == null || !stack.isItemEqual(chisel))
finished = true;
if (finished)
@@ -1,6 +1,6 @@
package com.cricketcraft.chisel.inventory;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.item.chisel.ItemChisel;
import com.cricketcraft.chisel.utils.General;
public class InventoryChiselSelection implements IInventory {
@@ -120,10 +121,10 @@ public class InventoryChiselSelection implements IInventory {
if (Block.getBlockFromItem(item) == null)
return;
if (!((IChiselItem) chisel.getItem()).canChisel(container.playerInventory.player.worldObj, this, container.playerInventory.currentItem, chisel, chiseledItem))
if (!((IChiselItem) chisel.getItem()).canChisel(container.playerInventory.player.worldObj, chisel, General.getVariation(chiseledItem)))
return;
ArrayList<ItemStack> list = container.carving.getItems(chiseledItem);
List<ItemStack> list = container.carving.getItemsForChiseling(chiseledItem);
activeVariations = 0;
while (activeVariations < normalSlots && activeVariations < list.size()) {
@@ -1,103 +0,0 @@
package com.cricketcraft.chisel.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class InventoryLargePresent implements IInventory {
private String name;
private IInventory upper, lower;
public InventoryLargePresent(String name, IInventory upper, IInventory lower) {
this.name = name;
if (upper == null) {
upper = lower;
}
if (lower == null) {
lower = upper;
}
this.upper = upper;
this.lower = lower;
}
@Override
public int getSizeInventory() {
return upper.getSizeInventory() + lower.getSizeInventory();
}
public boolean isPartOfLargePresent(IInventory inventory) {
return upper == inventory || lower == inventory;
}
@Override
public ItemStack getStackInSlot(int slot) {
return slot >= upper.getSizeInventory() ? lower.getStackInSlot(slot - upper.getSizeInventory()) : upper.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize(int slot, int size) {
return slot >= upper.getSizeInventory() ? lower.getStackInSlot(slot - upper.getSizeInventory()) : upper.getStackInSlot(slot);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return slot >= upper.getSizeInventory() ? lower.getStackInSlotOnClosing(slot - upper.getSizeInventory()) : upper.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
if (slot >= upper.getSizeInventory()) {
lower.setInventorySlotContents(slot - upper.getSizeInventory(), stack);
} else {
upper.setInventorySlotContents(slot, stack);
}
}
@Override
public String getInventoryName() {
return upper.hasCustomInventoryName() ? upper.getInventoryName() : (lower.hasCustomInventoryName() ? lower.getInventoryName() : name);
}
@Override
public boolean hasCustomInventoryName() {
return upper.hasCustomInventoryName() || lower.hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit() {
return upper.getInventoryStackLimit();
}
@Override
public void markDirty() {
upper.markDirty();
lower.markDirty();
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return upper.isUseableByPlayer(player) && lower.isUseableByPlayer(player);
}
@Override
public void openInventory() {
upper.openInventory();
lower.openInventory();
}
@Override
public void closeInventory() {
upper.closeInventory();
;
lower.closeInventory();
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return true;
}
}
@@ -4,8 +4,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.utils.General;
import com.cricketcraft.chisel.utils.GeneralClient;
public class SlotChiselSelection extends Slot {
@@ -55,8 +59,18 @@ public class SlotChiselSelection extends Slot {
selInventory.updateItems();
((IChiselItem)container.chisel.getItem()).onChisel(player.worldObj, player.inventory, player.inventory.currentItem, container.chisel, crafted);
if (((IChiselItem) container.chisel.getItem()).onChisel(player.worldObj, container.chisel, General.getVariation(crafted))) {
container.chisel.damageItem(1, player);
if (container.chisel.stackSize <= 0) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
}
}
if (player.worldObj.isRemote) {
String sound = Carving.chisel.getVariationSound(crafted.getItem(), crafted.getItemDamage());
GeneralClient.playChiselSound(player.worldObj, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), sound);
}
/*
* ItemStack stack=player.inventory.getItemStack();
*
@@ -3,20 +3,18 @@ package com.cricketcraft.chisel.item.chisel;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.oredict.OreDictionary;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.carving.CarvingVariation;
import com.cricketcraft.chisel.network.PacketHandler;
import com.cricketcraft.chisel.network.message.MessageChiselSound;
import com.cricketcraft.chisel.utils.General;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -24,6 +22,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public final class ChiselController {
public static final ChiselController INSTANCE = new ChiselController();
private long lastTickClick = 0;
private ChiselController() {
}
@@ -50,21 +50,35 @@ public final class ChiselController {
z = event.z;
Block block = event.world.getBlock(x, y, z);
int metadata = event.world.getBlockMetadata(x, y, z);
List<ICarvingVariation> list = Carving.chisel.getVariations(block, metadata);
ICarvingGroup group = Carving.chisel.getGroup(block, metadata);
if (list == null || list.isEmpty()) {
break;
if (group == null) {
return;
}
List<ICarvingVariation> list = group.getVariations();
main: for (ItemStack stack : OreDictionary.getOres(group.getOreName())) {
ICarvingVariation v = General.getVariation(stack);
for (ICarvingVariation check : list) {
if (check.getBlock() == v.getBlock() && check.getBlockMeta() == v.getBlockMeta()) {
continue main;
}
}
list.add(General.getVariation(stack));
}
ICarvingVariation[] variations = list.toArray(new CarvingVariation[] {});
ICarvingVariation[] variations = list.toArray(new ICarvingVariation[] {});
if (chisel.canChiselBlock(event.world, x, y, z, block, metadata)) {
if (chisel.canChiselBlock(event.world, event.entityPlayer, x, y, z, block, metadata)) {
ItemStack target = General.getChiselTarget(held);
IChiselMode mode = General.getChiselMode(held);
ForgeDirection sideHit = ForgeDirection.VALID_DIRECTIONS[event.face];
if (target != null) {
for (ICarvingVariation v : variations) {
if (v.getBlock() == Block.getBlockFromItem(target.getItem()) && v.getBlockMeta() == target.getItemDamage()) {
setVariation(event.entityPlayer, event.world, x, y, z, v, target);
mode.chiselAll(event.entityPlayer, event.world, x, y, z, sideHit, v);
}
}
} else {
@@ -73,17 +87,24 @@ public final class ChiselController {
ICarvingVariation v = variations[i];
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
idx = (i + 1) % variations.length; // move to the next in the group
break;
}
}
ICarvingVariation newVar = variations[idx];
setVariation(event.entityPlayer, event.world, x, y, z, newVar, new ItemStack(newVar.getBlock(), 1, newVar.getItemMeta()));
mode.chiselAll(event.entityPlayer, event.world, x, y, z, sideHit, newVar);
event.entityPlayer.inventory.currentItem = slot;
}
}
break;
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
// Make sure we have not responded this tick
if (event.world.getTotalWorldTime() == lastTickClick) {
break;
} else {
lastTickClick = event.world.getTotalWorldTime();
}
if (!event.world.isRemote && chisel.canOpenGui(event.world, event.entityPlayer, held)) {
event.entityPlayer.openGui(Chisel.instance, 0, event.world, 0, 0, 0);
}
@@ -91,18 +112,4 @@ 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);
}
}
@@ -0,0 +1,125 @@
package com.cricketcraft.chisel.item.chisel;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.network.PacketHandler;
import com.cricketcraft.chisel.network.message.MessageChiselSound;
public enum ChiselMode implements IChiselMode {
SINGLE {
@Override
public void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation) {
setVariation(player, world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z), variation);
}
},
PANEL {
@Override
public void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) {
setVariation(player, world, x + dx, y, z + dy, block, meta, variation);
} else if (side == ForgeDirection.EAST || side == ForgeDirection.WEST) {
setVariation(player, world, x, y + dy, z + dx, block, meta, variation);
} else {
setVariation(player, world, x + dx, y + dy, z, block, meta, variation);
}
}
}
}
},
COLUMN {
@Override
public void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
int facing = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
for (int i = -1; i <= 1; i++) {
if (side != ForgeDirection.DOWN && side != ForgeDirection.UP) {
setVariation(player, world, x, y + i, z, block, meta, variation);
} else {
if (facing == 0 || facing == 2) {
setVariation(player, world, x, y, z + i, block, meta, variation);
} else {
setVariation(player, world, x + i, y, z, block, meta, variation);
}
}
}
}
},
ROW {
@Override
public void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
int facing = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
for (int i = -1; i <= 1; i++) {
if (side != ForgeDirection.DOWN && side != ForgeDirection.UP) {
if (side == ForgeDirection.EAST || side == ForgeDirection.WEST) {
setVariation(player, world, x, y, z + i, block, meta, variation);
} else {
setVariation(player, world, x + i, y, z, block, meta, variation);
}
} else {
if (facing == 0 || facing == 2) {
setVariation(player, world, x + i, y, z, block, meta, variation);
} else {
setVariation(player, world, x, y, z + i, block, meta, variation);
}
}
}
}
};
/**
* Assumes that the player is holding a chisel
*/
private static void setVariation(EntityPlayer player, World world, int x, int y, int z, Block origBlock, int origMeta, ICarvingVariation v) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
ItemStack held = player.getCurrentEquippedItem();
if (block == v.getBlock() && meta == v.getBlockMeta()) {
return; // don't chisel to the same thing
}
if (origBlock != block || origMeta != meta) {
return; // don't chisel if this doesn't match the target block (for the AOE modes)
}
if (held != null && held.getItem() instanceof IChiselItem) {
world.setBlock(x, y, z, v.getBlock(), v.getBlockMeta(), 3);
boolean breakChisel = false;
if (((IChiselItem) player.getCurrentEquippedItem().getItem()).onChisel(world, player.getCurrentEquippedItem(), v)) {
player.getCurrentEquippedItem().damageItem(1, player);
if (player.getCurrentEquippedItem().stackSize <= 0) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
breakChisel = true;
}
}
PacketHandler.INSTANCE.sendTo(new MessageChiselSound(x, y, z, v, breakChisel), (EntityPlayerMP) player);
}
}
public static ChiselMode next(IChiselMode currentMode) {
if (currentMode instanceof ChiselMode) {
ChiselMode[] values = values();
return values[(((ChiselMode) currentMode).ordinal() + 1) % values.length];
}
return SINGLE;
}
}
@@ -3,35 +3,41 @@ package com.cricketcraft.chisel.item.chisel;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.ChiselMode;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.utils.GeneralClient;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class ItemChisel extends Item implements IChiselItem {
public enum ChiselType {
IRON(Configurations.ironChiselMaxDamage), DIAMOND(Configurations.diamondChiselMaxDamage);
IRON(Configurations.ironChiselMaxDamage, Configurations.ironChiselAttackDamage),
DIAMOND(Configurations.diamondChiselMaxDamage, Configurations.diamondChiselAttackDamage);
final int maxDamage;
final int attackDamage;
ChiselType(int maxDamage) {
ChiselType(int maxDamage, int attackDamage) {
this.maxDamage = maxDamage;
this.attackDamage = attackDamage;
}
}
public static Carving carving = Carving.chisel;
public static ICarvingRegistry carving = Carving.chisel;
private ChiselType type;
@@ -39,7 +45,6 @@ public class ItemChisel extends Item implements IChiselItem {
super();
this.type = type;
setMaxStackSize(1);
setHasSubtypes(true);
setTextureName(Chisel.MOD_ID + ":chisel_" + type.name().toLowerCase());
MinecraftForge.EVENT_BUS.register(this);
}
@@ -60,16 +65,19 @@ public class ItemChisel extends Item implements IChiselItem {
@SuppressWarnings({ "unchecked", "rawtypes" })
@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++) {
if (i == 0 || type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick) {
list.add(StatCollector.translateToLocal(unloc + i));
}
String base = "item.chisel.chisel.desc.";
String gui = I18n.format(base + "gui");
String lc1 = I18n.format(base + "lc1");
String lc2 = I18n.format(base + "lc2");
String modes = I18n.format(base + "modes");
list.add(gui);
if (type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick) {
list.add(lc1);
list.add(lc2);
}
if (type == ChiselType.DIAMOND) {
if (type == ChiselType.DIAMOND || Configurations.ironChiselHasModes) {
list.add("");
list.add(StatCollector.translateToLocal(getUnlocalizedName(stack) + ".desc"));
list.add(modes);
}
}
@@ -78,38 +86,42 @@ public class ItemChisel extends Item implements IChiselItem {
return true;
}
@SuppressWarnings("rawtypes")
@Override
public ChiselMode getChiselMode(ItemStack itemStack) {
return ChiselMode.SINGLE;
public Multimap getAttributeModifiers(ItemStack stack) {
Multimap<String, AttributeModifier> multimap = HashMultimap.create();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Chisel Damage", type.attackDamage, 0));
return multimap;
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
stack.damageItem(1, attacker);
return super.hitEntity(stack, attacker, target);
}
@Override
public boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel) {
return true;
}
@Override
public boolean canChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target) {
public boolean canChisel(World world, ItemStack chisel, ICarvingVariation target) {
return true;
}
@Override
public void onChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target) {
if (Configurations.allowChiselDamage) {
chisel.setItemDamage(chisel.getItemDamage() + 1);
}
if (world.isRemote) {
String sound = carving.getVariationSound(target.getItem(), target.getItemDamage());
EntityPlayer player = Chisel.proxy.getClientPlayer();
GeneralClient.playChiselSound(world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), sound);
} else if (chisel.getItemDamage() >= chisel.getMaxDamage()) {
inv.decrStackSize(slot, 1);
}
public boolean onChisel(World world, ItemStack chisel, ICarvingVariation target) {
return Configurations.allowChiselDamage;
}
@Override
public boolean canChiselBlock(World world, int x, int y, int z, Block block, int metadata) {
public boolean canChiselBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int metadata) {
return type == ChiselType.DIAMOND || Configurations.ironChiselCanLeftClick;
}
@Override
public boolean hasModes(ItemStack chisel) {
return type == ChiselType.DIAMOND || Configurations.ironChiselHasModes;
}
}
@@ -2,7 +2,9 @@ package com.cricketcraft.chisel.network;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.network.message.MessageAutoChisel;
import com.cricketcraft.chisel.network.message.MessageChiselMode;
import com.cricketcraft.chisel.network.message.MessageChiselSound;
import com.cricketcraft.chisel.network.message.MessagePresentConnect;
import com.cricketcraft.chisel.network.message.MessageSlotUpdate;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
@@ -18,5 +20,7 @@ public class PacketHandler {
INSTANCE.registerMessage(MessageChiselSound.Handler.class, MessageChiselSound.class, id++, Side.CLIENT);
INSTANCE.registerMessage(MessageSlotUpdate.Handler.class, MessageSlotUpdate.class, id++, Side.CLIENT);
INSTANCE.registerMessage(MessageAutoChisel.Handler.class, MessageAutoChisel.class, id++, Side.CLIENT);
INSTANCE.registerMessage(MessageChiselMode.Handler.class, MessageChiselMode.class, id++, Side.SERVER);
INSTANCE.registerMessage(MessagePresentConnect.Handler.class, MessagePresentConnect.class, id++, Side.CLIENT);
}
}
@@ -18,16 +18,17 @@ public class MessageAutoChisel extends MessageCoords {
}
ItemStack base;
boolean playSound;
boolean playSound, breakChisel;
int chiseled;
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound) {
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound, boolean breakChisel) {
super(tile);
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
if (base != null) {
base = base.copy();
}
this.playSound = playSound;
this.breakChisel = breakChisel;
this.chiseled = chiseled;
}
@@ -35,6 +36,7 @@ public class MessageAutoChisel extends MessageCoords {
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeBoolean(playSound);
buf.writeBoolean(breakChisel);
buf.writeInt(chiseled);
ByteBufUtils.writeItemStack(buf, base);
}
@@ -43,6 +45,7 @@ public class MessageAutoChisel extends MessageCoords {
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
this.playSound = buf.readBoolean();
this.breakChisel = buf.readBoolean();
this.chiseled = buf.readInt();
this.base = ByteBufUtils.readItemStack(buf);
}
@@ -53,7 +56,7 @@ public class MessageAutoChisel extends MessageCoords {
TileEntity te = message.getTileEntity(ctx);
if (te instanceof TileEntityAutoChisel) {
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound);
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound, message.breakChisel);
}
return null;
}
@@ -0,0 +1,51 @@
package com.cricketcraft.chisel.network.message;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import com.cricketcraft.chisel.api.IAdvancedChisel;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.item.chisel.ChiselMode;
import com.cricketcraft.chisel.utils.General;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
public class MessageChiselMode implements IMessage {
public MessageChiselMode(){
}
private String mode;
public MessageChiselMode(IChiselMode iChiselMode) {
this.mode = iChiselMode.name();
}
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, mode);
}
@Override
public void fromBytes(ByteBuf buf) {
this.mode = ByteBufUtils.readUTF8String(buf);
}
public static class Handler implements IMessageHandler<MessageChiselMode, IMessage> {
@Override
public IMessage onMessage(MessageChiselMode message, MessageContext ctx) {
ItemStack stack = ctx.getServerHandler().playerEntity.getCurrentEquippedItem();
if (stack != null && stack.getItem() instanceof IChiselItem) {
if (stack.getItem() instanceof IAdvancedChisel) {
General.setChiselMode(stack, ((IAdvancedChisel) stack.getItem()).getMode(stack, message.mode));
} else {
General.setChiselMode(stack, ChiselMode.valueOf(message.mode));
}
}
return null;
}
}
}
@@ -2,9 +2,10 @@ package com.cricketcraft.chisel.network.message;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.carving.CarvingVariation;
import com.cricketcraft.chisel.client.GeneralChiselClient;
import com.cricketcraft.chisel.item.chisel.ItemChisel;
import com.cricketcraft.chisel.network.message.base.MessageCoords;
@@ -21,11 +22,13 @@ public class MessageChiselSound extends MessageCoords {
private int block;
private byte meta;
private boolean breakChisel;
public MessageChiselSound(int x, int y, int z, ICarvingVariation v) {
public MessageChiselSound(int x, int y, int z, ICarvingVariation v, boolean breakChisel) {
super(x, y, z);
this.block = Block.getIdFromBlock(v.getBlock());
this.meta = (byte) v.getBlockMeta();
this.breakChisel = breakChisel;
}
@Override
@@ -33,6 +36,7 @@ public class MessageChiselSound extends MessageCoords {
super.toBytes(buf);
buf.writeInt(block);
buf.writeByte(meta);
buf.writeBoolean(breakChisel);
}
@Override
@@ -40,6 +44,7 @@ public class MessageChiselSound extends MessageCoords {
super.fromBytes(buf);
block = buf.readInt();
meta = buf.readByte();
breakChisel = buf.readBoolean();
}
public static class Handler implements IMessageHandler<MessageChiselSound, IMessage> {
@@ -48,6 +53,10 @@ public class MessageChiselSound extends MessageCoords {
public IMessage onMessage(MessageChiselSound message, MessageContext ctx) {
String sound = ItemChisel.carving.getVariationSound(Block.getBlockById(message.block), message.meta);
GeneralChiselClient.spawnChiselEffect(message.x, message.y, message.z, sound);
if (message.breakChisel) {
EntityPlayer player = Chisel.proxy.getClientPlayer();
player.renderBrokenItemStack(player.getCurrentEquippedItem());
}
return null;
}
}
@@ -0,0 +1,60 @@
package com.cricketcraft.chisel.network.message;
import io.netty.buffer.ByteBuf;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.network.message.base.MessageCoords;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
public class MessagePresentConnect extends MessageCoords {
private ForgeDirection dir;
private boolean connect;
public MessagePresentConnect() {
super();
}
public MessagePresentConnect(TileEntityPresent present, ForgeDirection dir, boolean connecting) {
super(present);
this.dir = dir;
this.connect = connecting;
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeInt(dir.ordinal());
buf.writeBoolean(connect);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readInt()];
connect = buf.readBoolean();
}
public static class Handler implements IMessageHandler<MessagePresentConnect, IMessage> {
@Override
public IMessage onMessage(MessagePresentConnect message, MessageContext ctx) {
TileEntity te = message.getTileEntity(ctx);
if (te instanceof TileEntityPresent) {
if (message.connect) {
((TileEntityPresent) te).connectTo(message.dir);
} else {
((TileEntityPresent) te).disconnect();
}
}
return null;
}
}
}
@@ -23,7 +23,6 @@ import com.cricketcraft.chisel.client.render.BlockSnakeStoneRenderer;
import com.cricketcraft.chisel.client.render.BlockTexturedOreRenderer;
import com.cricketcraft.chisel.client.render.RenderStandardBlockNoSunlight;
import com.cricketcraft.chisel.client.render.item.ItemChiselRenderer;
import com.cricketcraft.chisel.client.render.item.ItemPresentRenderer;
import com.cricketcraft.chisel.client.render.tile.RenderAutoChisel;
import com.cricketcraft.chisel.client.render.tile.RenderPresent;
import com.cricketcraft.chisel.entity.EntityBallOMoss;
@@ -65,11 +64,9 @@ public class ClientProxy extends CommonProxy {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.autoChisel), rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAutoChisel.class, rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPresent.class, new RenderPresent());
for (int x = 0; x < 16; x++) {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.present[x]), new ItemPresentRenderer(x));
}
RenderPresent rp = new RenderPresent();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.present), rp);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPresent.class, rp);
RenderingRegistry.registerEntityRenderingHandler(EntityCloudInABottle.class, new RenderSnowball(ChiselItems.cloudinabottle));
RenderingRegistry.registerEntityRenderingHandler(EntityBallOMoss.class, new RenderSnowball(ChiselItems.ballomoss));
@@ -12,7 +12,7 @@ public class CommonProxy {
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileEntityAutoChisel.class, "autoChisel");
GameRegistry.registerTileEntity(TileEntityPresent.class, "tile.present.present");
GameRegistry.registerTileEntity(TileEntityPresent.class, "tile.chisel.present");
}
public void preInit() {
@@ -2,6 +2,7 @@ package com.cricketcraft.chisel.utils;
import java.util.Random;
import joptsimple.internal.Strings;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -14,6 +15,13 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.cricketcraft.chisel.api.IAdvancedChisel;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.carving.Carving;
import com.cricketcraft.chisel.carving.CarvingVariation;
import com.cricketcraft.chisel.item.chisel.ChiselMode;
public class General {
public static Random rand = new Random();
@@ -98,8 +106,8 @@ public class General {
public static final String[] sGNames = new String[] { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink", "Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green",
"Red", "Black" };
public static final String[] featureColors = new String[] { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "darkgray", "lightgray", "cyan", "purple", "blue", "brown", "green",
"red", "black" };
public static final String[] featureColors = new String[] { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "darkgray", "lightgray", "cyan", "purple", "blue", "brown",
"green", "red", "black" };
public static void setChiselTarget(ItemStack chisel, ItemStack target) {
initTag(chisel);
@@ -115,4 +123,29 @@ public class General {
stack.setTagCompound(new NBTTagCompound());
}
}
private static final String MODE_KEY = "chiselMode";
public static IChiselMode getChiselMode(ItemStack chisel) {
if (chisel.stackTagCompound == null || Strings.isNullOrEmpty(chisel.stackTagCompound.getString(MODE_KEY))) {
initTag(chisel);
chisel.stackTagCompound.setString(MODE_KEY, ChiselMode.SINGLE.name());
}
String name = chisel.stackTagCompound.getString(MODE_KEY);
if (chisel.getItem() instanceof IAdvancedChisel) {
return ((IAdvancedChisel)chisel.getItem()).getMode(chisel, name);
}
return Enum.valueOf(ChiselMode.class, chisel.stackTagCompound.getString(MODE_KEY));
}
public static void setChiselMode(ItemStack chisel, IChiselMode mode) {
initTag(chisel);
chisel.stackTagCompound.setString(MODE_KEY, mode.name());
}
public static ICarvingVariation getVariation(ItemStack stack) {
ICarvingVariation v = Carving.chisel.getVariation(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
return v == null ? new CarvingVariation(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 99) : v;
}
}
@@ -1,34 +1,64 @@
package com.cricketcraft.chisel.world;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.IWorldGenerator;
public class GeneratorChisel implements IWorldGenerator {
WorldGenMinable gen;
int amount;
private class WorldGenInfo {
public GeneratorChisel(Block block, int count, int am) {
gen = new WorldGenMinable(block, count);
amount = am;
private int amount;
private int minY, maxY;
private double chance;
private WorldGenInfo(int amount, int minY, int maxY, double chance) {
this.amount = amount;
this.minY = minY;
this.maxY = maxY;
this.chance = chance;
}
}
protected void genStandardOre(World world, Random random, int x, int z, int bot, int top) {
for (int l = 0; l < amount; ++l) {
int i1 = x + random.nextInt(16);
int j1 = bot + random.nextInt(top - bot);
int k1 = z + random.nextInt(16);
gen.generate(world, random, i1, j1, k1);
public static final GeneratorChisel INSTANCE = new GeneratorChisel();
private final Map<WorldGenMinable, WorldGenInfo> map = Maps.newHashMap();
public void addFeature(Block block, int count, int amount) {
addFeature(block, count, amount, 40, 128);
}
public void addFeature(Block block, int count, int amount, int minY, int maxY) {
addFeature(block, count, amount, minY, maxY, 1);
}
public void addFeature(Block block, int count, int amount, int minY, int maxY, double chance) {
map.put(new WorldGenMinable(block, count), new WorldGenInfo(amount, minY, maxY, chance));
}
protected void genStandardOre(WorldGenMinable gen, WorldGenInfo info, World world, Random random, int x, int z) {
for (int l = 0; l < info.amount; ++l) {
if (random.nextDouble() < info.chance) {
int avgX = x + random.nextInt(16);
int avgY = info.minY + random.nextInt(info.maxY - info.minY) + 1;
int avgZ = z + random.nextInt(16);
gen.generate(world, random, avgX, avgY, avgZ);
}
}
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
genStandardOre(world, random, chunkX * 16, chunkZ * 16, 40, 128);
for (WorldGenMinable gen : map.keySet()) {
genStandardOre(gen, map.get(gen), world, random, chunkX * 16, chunkZ * 16);
}
}
}