diff --git a/src/assets/undergroundbiomes/lang/en_US.lang b/src/assets/undergroundbiomes/lang/en_US.lang old mode 100644 new mode 100755 index 0ed024f..e9057d1 --- a/src/assets/undergroundbiomes/lang/en_US.lang +++ b/src/assets/undergroundbiomes/lang/en_US.lang @@ -85,6 +85,198 @@ tile.metamorphicBrickSlab.migmatite.name=Migmatite Brick Slab tile.anthraciteCoal.name=Anthracite Coal Block +# Underground Biomes Constructs localization +# =============================== +# Blocks + +tile.igneousStone.redGranite.stairs.name=Red Granite Stairs +tile.igneousStone.blackGranite.stairs.name=Black Granite Stairs +tile.igneousStone.rhyolite.stairs.name=Rhyolite Stairs +tile.igneousStone.andesite.stairs.name=Andesite Stairs +tile.igneousStone.gabbro.stairs.name=Gabbro Stairs +tile.igneousStone.basalt.stairs.name=Basalt Stairs +tile.igneousStone.komatiite.stairs.name=Komatiite Stairs +tile.igneousStone.dacite.stairs.name=Dacite Stairs + +tile.igneousCobblestone.redGranite.stairs.name=Red Granite Cobblestone Stairs +tile.igneousCobblestone.blackGranite.stairs.name=Black Granite Cobblestone Stairs +tile.igneousCobblestone.rhyolite.stairs.name=Rhyolite Cobblestone Stairs +tile.igneousCobblestone.andesite.stairs.name=Andesite Cobblestone Stairs +tile.igneousCobblestone.gabbro.stairs.name=Gabbro Cobblestone Stairs +tile.igneousCobblestone.basalt.stairs.name=Basalt Cobblestone Stairs +tile.igneousCobblestone.komatiite.stairs.name=Komatiite Cobblestone Stairs +tile.igneousCobblestone.dacite.stairs.name=Dacite Cobblestone Stairs + +tile.igneousStoneBrick.redGranite.stairs.name=Red Granite Brick Stairs +tile.igneousStoneBrick.blackGranite.stairs.name=Black Granite Brick Stairs +tile.igneousStoneBrick.rhyolite.stairs.name=Rhyolite Brick Stairs +tile.igneousStoneBrick.andesite.stairs.name=Andesite Brick Stairs +tile.igneousStoneBrick.gabbro.stairs.name=Gabbro Brick Stairs +tile.igneousStoneBrick.basalt.stairs.name=Basalt Brick Stairs +tile.igneousStoneBrick.komatiite.stairs.name=Komatiite Brick Stairs +tile.igneousStoneBrick.dacite.stairs.name=Dacite Brick Stairs + +tile.metamorphicStone.gneiss.stairs.name=Gneiss Stairs +tile.metamorphicStone.eclogite.stairs.name=Eclogite Stairs +tile.metamorphicStone.marble.stairs.name=Marble Stairs +tile.metamorphicStone.quartzite.stairs.name=Quartzite Stairs +tile.metamorphicStone.blueschist.stairs.name=Blue Schist Stairs +tile.metamorphicStone.greenschist.stairs.name=Green Schist Stairs +tile.metamorphicStone.soapstone.stairs.name=Soapstone Stairs +tile.metamorphicStone.migmatite.stairs.name=Migmatite Stairs + +tile.metamorphicCobblestone.gneiss.stairs.name=Gneiss Cobblestone Stairs +tile.metamorphicCobblestone.eclogite.stairs.name=Eclogite Cobblestone Stairs +tile.metamorphicCobblestone.marble.stairs.name=Marble Cobblestone Stairs +tile.metamorphicCobblestone.quartzite.stairs.name=Quartzite Cobblestone Stairs +tile.metamorphicCobblestone.blueschist.stairs.name=Blue Schist Cobblestone Stairs +tile.metamorphicCobblestone.greenschist.stairs.name=Green Schist Cobblestone Stairs +tile.metamorphicCobblestone.soapstone.stairs.name=Soapstone Cobblestone Stairs +tile.metamorphicCobblestone.migmatite.stairs.name=Migmatite Cobblestone Stairs + +tile.metamorphicStoneBrick.gneiss.stairs.name=Gneiss Brick Stairs +tile.metamorphicStoneBrick.eclogite.stairs.name=Eclogite Brick Stairs +tile.metamorphicStoneBrick.marble.stairs.name=Marble Brick Stairs +tile.metamorphicStoneBrick.quartzite.stairs.name=Quartzite Brick Stairs +tile.metamorphicStoneBrick.blueschist.stairs.name=Blue Schist Brick Stairs +tile.metamorphicStoneBrick.greenschist.stairs.name=Green Schist Brick Stairs +tile.metamorphicStoneBrick.soapstone.stairs.name=Soapstone Brick Stairs +tile.metamorphicStoneBrick.migmatite.stairs.name=Migmatite Brick Stairs + +tile.sedimentaryStone.limestone.stairs.name=Limestone Stairs +tile.sedimentaryStone.chalk.stairs.name=Chalk Stairs +tile.sedimentaryStone.shale.stairs.name=Shale Stairs +tile.sedimentaryStone.siltstone.stairs.name=Siltstone Stairs +tile.sedimentaryStone.ligniteBlock.stairs.name=Lignite Block Stairs +tile.sedimentaryStone.dolomite.stairs.name=Dolomite Stairs +tile.sedimentaryStone.greywacke.stairs.name=Greywacke Stairs +tile.sedimentaryStone.chert.stairs.name=Chert Stairs + +tile.igneousStone.redGranite.wall.name=Red Granite Wall +tile.igneousStone.blackGranite.wall.name=Black Granite Wall +tile.igneousStone.rhyolite.wall.name=Rhyolite Wall +tile.igneousStone.andesite.wall.name=Andesite Wall +tile.igneousStone.gabbro.wall.name=Gabbro Wall +tile.igneousStone.basalt.wall.name=Basalt Wall +tile.igneousStone.komatiite.wall.name=Komatiite Wall +tile.igneousStone.dacite.wall.name=Dacite Wall + +tile.igneousCobblestone.redGranite.wall.name=Red Granite Cobblestone Wall +tile.igneousCobblestone.blackGranite.wall.name=Black Granite Cobblestone Wall +tile.igneousCobblestone.rhyolite.wall.name=Rhyolite Cobblestone Wall +tile.igneousCobblestone.andesite.wall.name=Andesite Cobblestone Wall +tile.igneousCobblestone.gabbro.wall.name=Gabbro Cobblestone Wall +tile.igneousCobblestone.basalt.wall.name=Basalt Cobblestone Wall +tile.igneousCobblestone.komatiite.wall.name=Komatiite Cobblestone Wall +tile.igneousCobblestone.dacite.wall.name=Dacite Cobblestone Wall + +tile.igneousStoneBrick.redGranite.wall.name=Red Granite Brick Wall +tile.igneousStoneBrick.blackGranite.wall.name=Black Granite Brick Wall +tile.igneousStoneBrick.rhyolite.wall.name=Rhyolite Brick Wall +tile.igneousStoneBrick.andesite.wall.name=Andesite Brick Wall +tile.igneousStoneBrick.gabbro.wall.name=Gabbro Brick Wall +tile.igneousStoneBrick.basalt.wall.name=Basalt Brick Wall +tile.igneousStoneBrick.komatiite.wall.name=Komatiite Brick Wall +tile.igneousStoneBrick.dacite.wall.name=Dacite Brick Wall + +tile.metamorphicStone.gneiss.wall.name=Gneiss Wall +tile.metamorphicStone.eclogite.wall.name=Eclogite Wall +tile.metamorphicStone.marble.wall.name=Marble Wall +tile.metamorphicStone.quartzite.wall.name=Quartzite Wall +tile.metamorphicStone.blueschist.wall.name=Blue Schist Wall +tile.metamorphicStone.greenschist.wall.name=Green Schist Wall +tile.metamorphicStone.soapstone.wall.name=Soapstone Wall +tile.metamorphicStone.migmatite.wall.name=Migmatite Wall + +tile.metamorphicCobblestone.gneiss.wall.name=Gneiss Cobblestone Wall +tile.metamorphicCobblestone.eclogite.wall.name=Eclogite Cobblestone Wall +tile.metamorphicCobblestone.marble.wall.name=Marble Cobblestone Wall +tile.metamorphicCobblestone.quartzite.wall.name=Quartzite Cobblestone Wall +tile.metamorphicCobblestone.blueschist.wall.name=Blue Schist Cobblestone Wall +tile.metamorphicCobblestone.greenschist.wall.name=Green Schist Cobblestone Wall +tile.metamorphicCobblestone.soapstone.wall.name=Soapstone Cobblestone Wall +tile.metamorphicCobblestone.migmatite.wall.name=Migmatite Cobblestone Wall + +tile.metamorphicStoneBrick.gneiss.wall.name=Gneiss Brick Wall +tile.metamorphicStoneBrick.eclogite.wall.name=Eclogite Brick Wall +tile.metamorphicStoneBrick.marble.wall.name=Marble Brick Wall +tile.metamorphicStoneBrick.quartzite.wall.name=Quartzite Brick Wall +tile.metamorphicStoneBrick.blueschist.wall.name=Blue Schist Brick Wall +tile.metamorphicStoneBrick.greenschist.wall.name=Green Schist Brick Wall +tile.metamorphicStoneBrick.soapstone.wall.name=Soapstone Brick Wall +tile.metamorphicStoneBrick.migmatite.wall.name=Migmatite Brick Wall + +tile.sedimentaryStone.limestone.wall.name=Limestone Wall +tile.sedimentaryStone.chalk.wall.name=Chalk Wall +tile.sedimentaryStone.shale.wall.name=Shale Wall +tile.sedimentaryStone.siltstone.wall.name=Siltstone Wall +tile.sedimentaryStone.ligniteBlock.wall.name=Lignite Block Wall +tile.sedimentaryStone.dolomite.wall.name=Dolomite Wall +tile.sedimentaryStone.greywacke.wall.name=Greywacke Wall +tile.sedimentaryStone.chert.wall.name=Chert Wall +tile.igneousStone.redGranite.button.name=Red Granite Button +tile.igneousStone.blackGranite.button.name=Black Granite Button +tile.igneousStone.rhyolite.button.name=Rhyolite Button +tile.igneousStone.andesite.button.name=Andesite Button +tile.igneousStone.gabbro.button.name=Gabbro Button +tile.igneousStone.basalt.button.name=Basalt Button +tile.igneousStone.komatiite.button.name=Komatiite Button +tile.igneousStone.dacite.button.name=Dacite Button + +tile.igneousCobblestone.redGranite.button.name=Red Granite Cobblestone Button +tile.igneousCobblestone.blackGranite.button.name=Black Granite Cobblestone Button +tile.igneousCobblestone.rhyolite.button.name=Rhyolite Cobblestone Button +tile.igneousCobblestone.andesite.button.name=Andesite Cobblestone Button +tile.igneousCobblestone.gabbro.button.name=Gabbro Cobblestone Button +tile.igneousCobblestone.basalt.button.name=Basalt Cobblestone Button +tile.igneousCobblestone.komatiite.button.name=Komatiite Cobblestone Button +tile.igneousCobblestone.dacite.button.name=Dacite Cobblestone Button + +tile.igneousStoneBrick.redGranite.button.name=Red Granite Brick Button +tile.igneousStoneBrick.blackGranite.button.name=Black Granite Brick Button +tile.igneousStoneBrick.rhyolite.button.name=Rhyolite Brick Button +tile.igneousStoneBrick.andesite.button.name=Andesite Brick Button +tile.igneousStoneBrick.gabbro.button.name=Gabbro Brick Button +tile.igneousStoneBrick.basalt.button.name=Basalt Brick Button +tile.igneousStoneBrick.komatiite.button.name=Komatiite Brick Button +tile.igneousStoneBrick.dacite.button.name=Dacite Brick Button + +tile.metamorphicStone.gneiss.button.name=Gneiss Button +tile.metamorphicStone.eclogite.button.name=Eclogite Button +tile.metamorphicStone.marble.button.name=Marble Button +tile.metamorphicStone.quartzite.button.name=Quartzite Button +tile.metamorphicStone.blueschist.button.name=Blue Schist Button +tile.metamorphicStone.greenschist.button.name=Green Schist Button +tile.metamorphicStone.soapstone.button.name=Soapstone Button +tile.metamorphicStone.migmatite.button.name=Migmatite Button + +tile.metamorphicCobblestone.gneiss.button.name=Gneiss Cobblestone Button +tile.metamorphicCobblestone.eclogite.button.name=Eclogite Cobblestone Button +tile.metamorphicCobblestone.marble.button.name=Marble Cobblestone Button +tile.metamorphicCobblestone.quartzite.button.name=Quartzite Cobblestone Button +tile.metamorphicCobblestone.blueschist.button.name=Blue Schist Cobblestone Button +tile.metamorphicCobblestone.greenschist.button.name=Green Schist Cobblestone Button +tile.metamorphicCobblestone.soapstone.button.name=Soapstone Cobblestone Button +tile.metamorphicCobblestone.migmatite.button.name=Migmatite Cobblestone Button + +tile.metamorphicStoneBrick.gneiss.button.name=Gneiss Brick Button +tile.metamorphicStoneBrick.eclogite.button.name=Eclogite Brick Button +tile.metamorphicStoneBrick.marble.button.name=Marble Brick Button +tile.metamorphicStoneBrick.quartzite.button.name=Quartzite Brick Button +tile.metamorphicStoneBrick.blueschist.button.name=Blue Schist Brick Button +tile.metamorphicStoneBrick.greenschist.button.name=Green Schist Brick Button +tile.metamorphicStoneBrick.soapstone.button.name=Soapstone Brick Button +tile.metamorphicStoneBrick.migmatite.button.name=Migmatite Brick Button + +tile.sedimentaryStone.limestone.button.name=Limestone Button +tile.sedimentaryStone.chalk.button.name=Chalk Button +tile.sedimentaryStone.shale.button.name=Shale Button +tile.sedimentaryStone.siltstone.button.name=Siltstone Button +tile.sedimentaryStone.ligniteBlock.button.name=Lignite Block Button +tile.sedimentaryStone.dolomite.button.name=Dolomite Button +tile.sedimentaryStone.greywacke.button.name=Greywacke Button +tile.sedimentaryStone.chert.button.name=Chert Button + # Items item.ligniteCoal.name=Lignite diff --git a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java old mode 100644 new mode 100755 index b9a7b62..8f71cbf --- a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java +++ b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java @@ -38,6 +38,8 @@ import exterminatorJeff.undergroundBiomes.common.item.*; import exterminatorJeff.undergroundBiomes.common.command.*; +import exterminatorJeff.undergroundBiomes.constructs.UndergroundBiomesConstructs; + @Mod(modid = "UndergroundBiomes", name = "Underground Biomes", version = "0.4.2a") @NetworkMod(clientSideRequired = true, serverSideRequired = true) @@ -100,6 +102,15 @@ public class UndergroundBiomes private String excludeDimensions; private int vanillaStoneCrafting; + + private UndergroundBiomesConstructs constructs; + private static boolean buttonsOn; + private static boolean stairsOn; + private static boolean wallsOn; + + public static boolean buttonsOn() {return buttonsOn;} + public static boolean stairsOn() {return stairsOn;} + public static boolean wallsOn() {return wallsOn;} public static int biomeSize = 45; @@ -139,6 +150,12 @@ public void preInit(FMLPreInitializationEvent event) excludeDimensions = config.get(Configuration.CATEGORY_GENERAL, "excludeDimensionIDs", "-1,1", "Comma-separated list of dimension IDs, used only if include list is *").getString(); includeDimensions = config.get(Configuration.CATEGORY_GENERAL, "includeDimensionIDs", "*", "Comma-separated list of dimension IDs, put * to use exclude list").getString(); vanillaStoneCrafting = config.get(Configuration.CATEGORY_GENERAL, "vanillaStoneCrafting", 3, "0 = none; 1 = one rock; 2 = with redstone; 3 = 2x2 stone, lose 3; 4 = 2x2 stone").getInt(); + buttonsOn = config.get(Configuration.CATEGORY_GENERAL, + "UndergroundBiomesButtons", true, "Provide Buttons for non-brick Underground Biomes blocks").getBoolean(true); + stairsOn = config.get(Configuration.CATEGORY_GENERAL, + "UndergroundBiomesStairs", true, "Provide Stairs for Underground Biomes blocks").getBoolean(true); + wallsOn = config.get(Configuration.CATEGORY_GENERAL, + "UndergroundBiomesStairs", true, "Provide Walls for Underground Biomes blocks").getBoolean(true); if (includeDimensions.equals("*")) { @@ -213,6 +230,10 @@ public void preInit(FMLPreInitializationEvent event) tabModItems.iconID = ligniteCoal.itemID; proxy.setUpBlockNames(); + + constructs = new UndergroundBiomesConstructs(); + constructs.preInit(event); + } @Init @@ -220,7 +241,9 @@ public void load(FMLInitializationEvent event) { addOreDicts(); addRecipes(); - + + constructs.load(event); + MinecraftForge.EVENT_BUS.register(this); } @@ -255,6 +278,8 @@ public void postInit(FMLPostInitializationEvent event) throws Exception e.printStackTrace(System.err); } } + + constructs.postInit(event); } @ServerStarting @@ -371,6 +396,9 @@ public static int oreDictifyStone() throws Exception { continue; } + // supress alterations overriding construct recipes + if (UndergroundBiomesConstructs.overridesRecipe((IRecipe)obj)) continue; + if (obj instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes)obj; diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java new file mode 100755 index 0000000..e21f0d5 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java @@ -0,0 +1,160 @@ +/* + * Author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs; + +import exterminatorJeff.undergroundBiomes.common.UndergroundBiomes; + +import exterminatorJeff.undergroundBiomes.constructs.block.UndergroundBiomesButton; +import exterminatorJeff.undergroundBiomes.constructs.block.UBButtonGroup; +import exterminatorJeff.undergroundBiomes.constructs.block.UBStairsBase; +import exterminatorJeff.undergroundBiomes.constructs.block.UBStairsGroup; +import exterminatorJeff.undergroundBiomes.constructs.block.UBWallBase; +import exterminatorJeff.undergroundBiomes.constructs.block.UBWallGroup; + +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; + +import exterminatorJeff.undergroundBiomes.constructs.util.Zeno410Logger; +import java.util.logging.Logger; +import java.util.logging.Level; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockButton; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockWall; +import net.minecraftforge.common.Configuration; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.PreInit; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +/** + * + * @author curtisadams + */ +//@Mod(modid = "UndergroundBiomesConstructs", name = "Underground Biomes Constructs", version = "0.0.4") +//@NetworkMod(clientSideRequired = true, serverSideRequired = true) +public class UndergroundBiomesConstructs { + + public static int subdivisionBlockCount = 4; // 8 types, 2 per class + + private UBStairsGroup stoneStair; + private int stoneStairID; + + private UBWallGroup stoneWall; + private int stoneWallID; + + private UBButtonGroup stoneButtons; + private int stoneButtonID; + + public Configuration config; + + private UndergroundBiomesBlockList ubBlockList; + + //private static Zeno410Logger logger = new Zeno410Logger("UndergroundBiomesConstructs"); + + //@PreIni + public void preInit(FMLPreInitializationEvent event) { + config = new Configuration(event.getSuggestedConfigurationFile()); + config.load(); + + if (UndergroundBiomes.buttonsOn()) preInitButtons(); + if (UndergroundBiomes.stairsOn()) preInitStairs(); + if (UndergroundBiomes.wallsOn()) preInitWalls(); + } + + public void preInitStairs() { + stoneStair = new UBStairsGroup(); + stoneStairID = config.getBlock("Universal Biomes Stairs ID:", 2012).getInt(); + } + + public void preInitWalls() { + stoneWall = new UBWallGroup(); + stoneWallID = config.getBlock("Universal Biomes Wall ID:", 2013).getInt(); + } + + public void preInitButtons() { + stoneButtons = new UBButtonGroup(); + stoneButtonID = config.getBlock("Universal Biomes Button ID:", 2014).getInt(); + } + //@Init + public void load(FMLInitializationEvent event) { + + ubBlockList = new UndergroundBiomesBlockList(); + GameRegistry.registerTileEntity(UndergroundBiomesTileEntity.class, "UndergroundBiomesTileEntity"); + + //logger.logger().log(Level.INFO, "buttons " + UndergroundBiomes.buttonsOn()); + //logger.logger().log(Level.INFO, "Stairs " + UndergroundBiomes.stairsOn()); + //logger.logger().log(Level.INFO, "walls " + UndergroundBiomes.wallsOn()); + if (UndergroundBiomes.buttonsOn()) loadButtons(); + if (UndergroundBiomes.stairsOn()) loadStairs(); + if (UndergroundBiomes.wallsOn()) loadWalls(); + } + + private void loadStairs(){ + stoneStair.baseBlock = ubBlockList.sedimentaryStone; + stoneStair.baseID = ubBlockList.sedimentaryStone.blockID; + stoneStair.define(stoneStairID); + + } + private void loadWalls() { + stoneWall.baseBlock = ubBlockList.sedimentaryStone; + stoneWall.baseID = ubBlockList.sedimentaryStone.blockID; + stoneWall.define(stoneWallID); + } + + private void loadButtons() { + stoneButtons.baseBlock = ubBlockList.sedimentaryStone; + stoneButtons.baseID = ubBlockList.sedimentaryStone.blockID; + stoneButtons.define(stoneButtonID); + } + public void postInit(FMLPostInitializationEvent event) throws Exception { + + } + + public static boolean overridesRecipe(IRecipe recipe) { + // this determines if oredictifying a recipe will override a constructs recipe + // right now it's overly simplistic and assumes anything producing a construct being made + // is an override + if (recipe == null) return false; + Object output = null; + try { + output = recipe.getRecipeOutput().getItem(); + } catch (Exception e) { + return false; + } + if (!(output instanceof ItemBlock)) {return false;} + //logger.logger().log(Level.INFO, output.getClass().toString()); + Block blockMade = Block.blocksList[((ItemBlock)output).getBlockID()]; + if (UndergroundBiomes.buttonsOn()) { + if (blockMade instanceof BlockButton) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } + } + if (UndergroundBiomes.stairsOn()) { + if (blockMade instanceof BlockStairs) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } + } + if (UndergroundBiomes.wallsOn()) { + if (blockMade instanceof BlockWall) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } + } + return false; + } +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java new file mode 100755 index 0000000..c901912 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java @@ -0,0 +1,32 @@ +/** + * + * @author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs.block; +import net.minecraft.block.Block; + +public class BlockList { + public static int blockCount = 4096; + + public static class Search { + + public static Block name(String name) { + // returns the block with that name or null if not found; + for (int i = 0; i itemClass() { + return ItemUBButton.class; + } + + Block definedBlock() { + return new UndergroundBiomesButton(constructID); + } + +} + diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBConstructGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBConstructGroup.java new file mode 100755 index 0000000..43ade4c --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBConstructGroup.java @@ -0,0 +1,88 @@ +/* + * author Zeno410 + * This is an abstract class for defining a group of similar objects based on the + * Underground Biomes block classes + * Each object is created by a combination of a block and a tileEntity which has + * an integer index into a master list of UB blocks + */ + +package exterminatorJeff.undergroundBiomes.constructs.block; + +import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; + +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlock; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +public abstract class UBConstructGroup { + public Integer constructID; + public int baseID; + public BlockMetadataBase baseBlock; + public final String name; + public Block construct; // the block representing the group of constructs + + public UBConstructGroup(String _name) { + name = _name; + } + + public void define(int _constructID) { + constructID = _constructID; + construct = definedBlock(); + GameRegistry.registerBlock( construct, itemClass(),name); + addRecipes(); + + } + + public void addRecipes() { + for (int ubIndex = 0; ubIndex itemClass(); // the class to handle items + + abstract void addRecipe(ProductItemDefiner product, StoneItemDefiner stone); // + + public BlockMetadataBase baseBlock() { + return baseBlock; + } + + /* the next two inner classes wrap references out of the package so descendent + * classes have minimal imports and couplings */ + + class StoneItemDefiner { + // this inner class hides the references to UndergroundBiomesBlockList + final int stoneIndex; + + StoneItemDefiner(int _stoneIndex) {stoneIndex = _stoneIndex;} + + public final ItemStack stackOf(int items) { + UndergroundBiomesBlock stone = UndergroundBiomesBlockList.indexed(stoneIndex); + return new ItemStack(stone.ubBlock,items,stone.metadata); + } + + public final ItemStack one() {return stackOf(1);} + } + + class ProductItemDefiner { + // this inner class wraps the stoneIndex for "standard" UBConstruct item group + // the assumption is that a damage index of x indicates that stone + final int stoneIndex; + + ProductItemDefiner(int _stoneIndex) {stoneIndex = _stoneIndex;} + + public final ItemStack stackOf(int items) { + return new ItemStack(construct,items,stoneIndex); + } + + public final ItemStack one() {return stackOf(1);} + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java new file mode 100755 index 0000000..9f92ba7 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java @@ -0,0 +1,182 @@ +/* Base class for the block that can support stairs of any UB stone + * Author Zeno410 + */ + + +package exterminatorJeff.undergroundBiomes.constructs.block; +import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBStairs; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlock; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; + + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.BlockStairs; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.world.IBlockAccess; +import net.minecraft.util.Icon; +import net.minecraft.item.ItemStack; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.entity.Entity; + +import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; + +public class UBStairsBase extends BlockStairs implements ITileEntityProvider, IconKludgeable { + + public UBStairsBase( + int theID, BlockMetadataBase _baseBlock, int metadata) { + super(theID,_baseBlock,metadata); + this.setUnlocalizedName("stairs"); + this.setLightOpacity(4); + // make the item here; + new ItemUBStairs(this); + } + + public boolean hasTileEntity(int metadata) {return true;} + + public TileEntity createNewTileEntity(World world) { + return new UndergroundBiomesTileEntity(); + + } + @Override + public void onBlockAdded(World par1World, int x, int y, int z){ + super.onBlockAdded(par1World, x, y, z); + } + + /** + * ejects contained items into the world, and notifies neighbours of an update, as appropriate + * + * no action; normally removes the TileEntity. However, the tile entity is needed for the item drop + * procedure. The actual drop is at the end of getBlockDropped. Kludgey. + */ + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6){} + + /** + * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile + * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter + */ + + public final UndergroundBiomesTileEntity ubTileEntity(IBlockAccess world, int x, int y, int z) { + UndergroundBiomesTileEntity result; + result = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); + return result; + } + + public final UndergroundBiomesBlock ubBlock(World world, int x, int y, int z) { + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock safeUBBlock(IBlockAccess world, int x, int y, int z) { + // this is needed for block breaking; there seems to be a call to getHardness after + // the block is already gone + UndergroundBiomesTileEntity entity = ubTileEntity(world,x,y,z); + if (entity == null) return ubBlock(0); + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock ubBlock(int reference) { + return UndergroundBiomesBlockList.indexed(reference); + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) + { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public float getBlockHardness(World world, int x, int y, int z){ + return safeUBBlock(world,x,y,z).hardness(); + } + + public void setIconKludge(Icon kludged) { + iconKludgeFromHell = kludged; + //hitCount = 7; + } + private Icon iconKludgeFromHell; + private int hitCount; + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int side, int metadata){ + //hitCount--; + //if (hitCount == 0) iconKludgeFromHell= null; + return iconKludgeFromHell; + //return ubBlock(metadata).icon(); + } + + @Override + public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z) { + setIconKludge(safeUBBlock(world,x,y,z).icon()); + return super.getMixedBrightnessForBlock(world,x,y,z); + } + @Override + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side){ + int metadataFromEntity = ((UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z))).masterIndex(); + return ubBlock(metadataFromEntity).icon(); + } + + @Override + public void getSubBlocks(int id, CreativeTabs tabs, List list){ + //list.add(new ItemStack(id, 1, 0)); + } + + @Override + public boolean isGenMineableReplaceable(World world, int x, int y, int z, int target){ + return true; + } + + public float getBlockExplosionResistance(int meta){ + //return block 0 value to avoid a crash + return 6.0f *ubBlock(0).explosionResistance(); + } + + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, + double explosionX, double explosionY, double explosionZ){ + return 6.0f *ubBlock(world,x,y,z).explosionResistance(); + } + + public int getRenderType(){return 10;} + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + public ItemStack itemDropped(int metadata, Random random, int fortune, int y){ + return new ItemStack(this.blockID, 1, metadata); + } + + public String getBlockName(int meta) { + return ubBlock(meta).name(); + } + + public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + + int count = quantityDropped(metadata, fortune, world.rand); + for(int i = 0; i < count; i++) + { + int id = idDropped(metadata, world.rand, fortune); + if (id > 0) + { + ret.add(new ItemStack(id, 1, ubTileEntity(world,x,y,z).masterIndex())); + } + } + + world.removeBlockTileEntity(x, y, z); + return ret; + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java new file mode 100755 index 0000000..4225c96 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java @@ -0,0 +1,38 @@ +/** + * + * @author Zeno410 + * + * Constructor for the Stairs group + */ + +package exterminatorJeff.undergroundBiomes.constructs.block; + +import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBStairs; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +import net.minecraftforge.oredict.ShapedOreRecipe; + + +public class UBStairsGroup extends UBConstructGroup { + + public UBStairsGroup() {super("stairs");} + + void addRecipe(ProductItemDefiner product, StoneItemDefiner stone) { + GameRegistry.addRecipe(new ShapedOreRecipe( + product.stackOf(4), " X", " XX", "XXX", 'X', stone.one())); + } + + Class itemClass() { + return ItemUBStairs.class; + } + + Block definedBlock() { + int metadata = 0;// needed for BlockStairs ancestor + return new UBStairsBase(constructID,baseBlock(),metadata); + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java new file mode 100755 index 0000000..c5cf7b5 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java @@ -0,0 +1,192 @@ +/** + * + * @author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs.block; +import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBWall; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlock; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; + +import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.BlockWall; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.world.IBlockAccess; +import net.minecraft.util.Icon; +import net.minecraft.item.ItemStack; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.entity.Entity; + +public class UBWallBase extends BlockWall implements ITileEntityProvider, IconKludgeable{ + + public UBWallBase(int theID, BlockMetadataBase _baseBlock) { + super(theID, _baseBlock); + this.setUnlocalizedName("wall"); + // make the item here; + new ItemUBWall(this); + this.isBlockContainer = true; + } + + @Override + public boolean hasTileEntity(int metadata) {return true;} + + public TileEntity createNewTileEntity(World world) { + return new UndergroundBiomesTileEntity(); + + } + @Override + public void onBlockAdded(World par1World, int x, int y, int z){ + super.onBlockAdded(par1World, x, y, z); + } + + /** + * ejects contained items into the world, and notifies neighbours of an update, as appropriate + * + * no action; normally removes the TileEntity. However, the tile entity is needed for the item drop + * procedure. The actual drop is at the end of getBlockDropped. Kludgey. + */ + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6){} + + /** + * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile + * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter + */ + + public final UndergroundBiomesTileEntity ubTileEntity(IBlockAccess world, int x, int y, int z) { + UndergroundBiomesTileEntity result; + result = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); + return result; + } + + public final UndergroundBiomesBlock ubBlock(IBlockAccess world, int x, int y, int z) { + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock safeUBBlock(IBlockAccess world, int x, int y, int z) { + UndergroundBiomesTileEntity entity = ubTileEntity(world,x,y,z); + if (entity == null) return ubBlock(0); + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock ubBlock(int reference) { + return UndergroundBiomesBlockList.indexed(reference); + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) + { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public float getBlockHardness(World world, int x, int y, int z){ + return safeUBBlock(world,x,y,z).hardness(); + } + + public void setIconKludge(Icon kludged) { + iconKludgeFromHell = kludged; + hitCount = 100; + } + private Icon iconKludgeFromHell; + private int hitCount; + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int side, int metadata){ + hitCount--; + if (hitCount == 0) { + //iconKludgeFromHell= null; + //throw new RuntimeException("no icon set up"); + } + + return iconKludgeFromHell; + //return ubBlock(metadata).icon(); + } + + @Override + public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z) { + setIconKludge(safeUBBlock(world,x,y,z).icon()); + return super.getMixedBrightnessForBlock(world,x,y,z); + } + @Override + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side){ + //logger.logger().log(Level.INFO,"texture " + x + " " + y + " " + z); + int metadataFromEntity = ((UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z))).masterIndex(); + return ubBlock(metadataFromEntity).icon(); + } + + @Override + public void getSubBlocks(int id, CreativeTabs tabs, List list){ + //list.add(new ItemStack(id, 1, 0)); + } + + @Override + public boolean isGenMineableReplaceable(World world, int x, int y, int z, int target){ + return true; + } + + public float getBlockExplosionResistance(int meta){ + return 6.0f *ubBlock(0).explosionResistance(); + } + + @Override + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, + double explosionX, double explosionY, double explosionZ){ + return 6.0f *ubBlock(world,x,y,z).explosionResistance(); + } + + @Override + public int getRenderType(){return 32;} + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + public ItemStack itemDropped(int metadata, Random random, int fortune, int y){ + return new ItemStack(this.blockID, 1, metadata); + } + + public String getBlockName(int meta) { + return ubBlock(meta).name(); + } + + @Override + public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { + return true; + } + + @Override + public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + + int count = quantityDropped(metadata, fortune, world.rand); + for(int i = 0; i < count; i++) + { + int id = idDropped(metadata, world.rand, fortune); + if (id > 0) + { + ret.add(new ItemStack(id, 1, ubTileEntity(world,x,y,z).masterIndex())); + //ret.add(new ItemStack(id, 1, metadata)); + } + } + + world.removeBlockTileEntity(x, y, z); + return ret; + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java new file mode 100755 index 0000000..ffe15eb --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java @@ -0,0 +1,33 @@ +/** + * + * @author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs.block; +import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBWall; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +import net.minecraftforge.oredict.ShapedOreRecipe; + +public class UBWallGroup extends UBConstructGroup { + + public UBWallGroup() {super("wall");} + + void addRecipe(ProductItemDefiner product, StoneItemDefiner stone) { + GameRegistry.addRecipe(new ShapedOreRecipe( + product.stackOf(6), " ", "XXX", "XXX", 'X', stone.one())); + } + + Class itemClass() { + return ItemUBWall.class; + } + + Block definedBlock() { + return new UBWallBase(constructID,baseBlock()); + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java new file mode 100755 index 0000000..83bb9c6 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java @@ -0,0 +1,154 @@ +package exterminatorJeff.undergroundBiomes.constructs.block; + +import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBButton; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlock; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.BlockButton; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.world.IBlockAccess; +import net.minecraft.util.Icon; +import net.minecraft.item.ItemStack; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.entity.Entity; + +/** + * + * @author Zeno410 + */ +public class UndergroundBiomesButton extends BlockButton implements ITileEntityProvider, IconKludgeable{ + + public UndergroundBiomesButton(int theID) { + super(theID, true); + this.setUnlocalizedName("button"); + // make the item here; + new ItemUBButton(this); + this.isBlockContainer = true; + } + public boolean hasTileEntity(int metadata) {return true;} + + public TileEntity createNewTileEntity(World world) { + return new UndergroundBiomesTileEntity(); + + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6){} + + public final UndergroundBiomesTileEntity ubTileEntity(IBlockAccess world, int x, int y, int z) { + UndergroundBiomesTileEntity result; + result = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); + return result; + } + + public final UndergroundBiomesBlock ubBlock(World world, int x, int y, int z) { + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock safeUBBlock(IBlockAccess world, int x, int y, int z) { + UndergroundBiomesTileEntity entity = ubTileEntity(world,x,y,z); + if (entity == null) return ubBlock(0); + return UndergroundBiomesBlockList.indexed(ubTileEntity(world,x,y,z).masterIndex()); + } + + public final UndergroundBiomesBlock ubBlock(int reference) { + return UndergroundBiomesBlockList.indexed(reference); + } + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) + { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public float getBlockHardness(World world, int x, int y, int z){ + return safeUBBlock(world,x,y,z).hardness(); + } + + public void setIconKludge(Icon kludged) { + iconKludgeFromHell = kludged; + //hitCount = 7; + } + private Icon iconKludgeFromHell; + private int hitCount; + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int side, int metadata){ + //hitCount--; + //if (hitCount == 0) iconKludgeFromHell= null; + return iconKludgeFromHell; + //return ubBlock(metadata).icon(); + } + + @Override + public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z) { + setIconKludge(safeUBBlock(world,x,y,z).icon()); + return super.getMixedBrightnessForBlock(world,x,y,z); + } + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side){ + //logger.logger().log(Level.INFO,"texture " + x + " " + y + " " + z); + int metadataFromEntity = ((UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z))).masterIndex(); + return ubBlock(metadataFromEntity).icon(); + } + + @Override + public void getSubBlocks(int id, CreativeTabs tabs, List list){ + //list.add(new ItemStack(id, 1, 0)); + } + + @Override + public boolean isGenMineableReplaceable(World world, int x, int y, int z, int target){ + return true; + } + + public float getBlockExplosionResistance(int meta){ + //return 6.0f * metadataBase.getBlockExplosionResistance(meta); + throw new RuntimeException(); + } + + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, + double explosionX, double explosionY, double explosionZ){ + return 6.0f *ubBlock(world,x,y,z).explosionResistance(); + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + public ItemStack itemDropped(int metadata, Random random, int fortune, int y){ + return new ItemStack(this.blockID, 1, metadata); + } + + public String getBlockName(int meta) { + return ubBlock(meta).name(); + } + + @Override + public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + + int count = quantityDropped(metadata, fortune, world.rand); + for(int i = 0; i < count; i++) + { + int id = idDropped(metadata, world.rand, fortune); + if (id > 0) + {ret.add(new ItemStack(id, 1, ubTileEntity(world,x,y,z).masterIndex()));} + } + + world.removeBlockTileEntity(x, y, z); + return ret; + }} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/entity/UndergroundBiomesTileEntity.java b/src/exterminatorJeff/undergroundBiomes/constructs/entity/UndergroundBiomesTileEntity.java new file mode 100755 index 0000000..aeff525 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/entity/UndergroundBiomesTileEntity.java @@ -0,0 +1,49 @@ +/** + * + * @author Zeno410 + * from tutorial by WiduX + */ +package exterminatorJeff.undergroundBiomes.constructs.entity; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.NBTTagCompound; + + +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; + +public class UndergroundBiomesTileEntity extends TileEntity { + public static String IndexName = "index"; + private int masterIndex; + + public UndergroundBiomesTileEntity() {} + // must be no parameters for Forge + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + masterIndex = nbt.getInteger(IndexName); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger(IndexName, masterIndex); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tileTag = new NBTTagCompound(); + this.writeToNBT(tileTag); + return new Packet132TileEntityData(this.xCoord,this.yCoord, this.zCoord,0,tileTag); + } + + public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { + this.readFromNBT(packet.customParam1); + } + + public final int masterIndex() {return masterIndex;} + + public final void setMasterIndex(int index) {masterIndex = index;} +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBButton.java b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBButton.java new file mode 100755 index 0000000..51b730a --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBButton.java @@ -0,0 +1,23 @@ +package exterminatorJeff.undergroundBiomes.constructs.item; + +/** + * + * @author zeno410 + */ + +import net.minecraft.block.Block; + +public class ItemUBButton extends ItemUndergroundBiomesConstruct{ + + public ItemUBButton(Block block){ + super(block); + } + + public ItemUBButton(int ID, Block block){ + super(ID,block); + } + + @Override + public String groupName() {return "button";} + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBStairs.java b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBStairs.java new file mode 100755 index 0000000..cf30555 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBStairs.java @@ -0,0 +1,25 @@ +/* + * Author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs.item; + + +import net.minecraft.block.Block; + + +public class ItemUBStairs extends ItemUndergroundBiomesConstruct { + //private Zeno410Logger logger = new Zeno410Logger("ItemMetadataStairs"); + + public ItemUBStairs(Block block){ + super(block); + } + + public ItemUBStairs(int ID, Block block){ + super(ID,block); + } + + @Override + public String groupName() {return "stairs";} + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBWall.java b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBWall.java new file mode 100755 index 0000000..dfd88d5 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBWall.java @@ -0,0 +1,23 @@ +package exterminatorJeff.undergroundBiomes.constructs.item; +import net.minecraft.block.Block; + + +/** + * + * @author Zeno410 + */ +public class ItemUBWall extends ItemUndergroundBiomesConstruct { + //private Zeno410Logger logger = new Zeno410Logger("ItemMetadataWall"); + + public ItemUBWall(Block block){ + super(block); + } + + public ItemUBWall(int ID, Block block){ + super(ID,block); + } + + @Override + public String groupName() {return "wall";} + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java new file mode 100755 index 0000000..9e8ec1e --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java @@ -0,0 +1,156 @@ +package exterminatorJeff.undergroundBiomes.constructs.item; + +import exterminatorJeff.undergroundBiomes.constructs.block.IconKludgeable; + +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlock; +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * + * @author Zeno410 + */ +public abstract class ItemUndergroundBiomesConstruct extends ItemBlock { + + public static int NO_PRIOR_METADATA = 0; + + private IconKludgeable theBlock; + final int blockID; + + public ItemUndergroundBiomesConstruct(Block block){ + super(block.blockID - 256); + this.theBlock = (IconKludgeable)block; + blockID = block.blockID; + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setUnlocalizedName("wall"); + } + + public ItemUndergroundBiomesConstruct(int ID, Block block){ + this(block); + if (block.blockID != ID + 256) { + throw new RuntimeException("Mismatch between item ID " + ID + + " and block " + block.getUnlocalizedName() + " block # " + block.blockID); + } + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int side, float par8, float par9, float par10) + { + int i1 = world.getBlockId(x, y, z); + + if (i1 != Block.vine.blockID && i1 != Block.tallGrass.blockID && i1 != Block.deadBush.blockID + && (Block.blocksList[i1] == null || !Block.blocksList[i1].isBlockReplaceable(world, x, y, z))) { + if (side == 0) {--y;} + + if (side == 1) { ++y;} + + if (side == 2) {--z;} + + if (side == 3) {++z;} + + if (side == 4) {--x;} + + if (side == 5) {++x;} + + } + + if (par1ItemStack.stackSize == 0) { return false; } + + if (y == 255 && Block.blocksList[this.blockID].blockMaterial.isSolid()) + {return false;} + + if (true) //(World.canPlaceEntityOnSide(this.blockID, x, y, z, false, side, par2EntityPlayer, par1ItemStack)) + { + Block block = Block.blocksList[this.blockID]; + int j1 = this.getMetadata(par1ItemStack.getItemDamage()); + int k1 = Block.blocksList[this.blockID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, NO_PRIOR_METADATA); + + if (placeBlockAt(par1ItemStack, par2EntityPlayer, world, x, y, z, side, par8, par9, par10, k1)) + { + world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + + // set the TileEntity data + UndergroundBiomesTileEntity target = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); + target.setMasterIndex(par1ItemStack.getItemDamage()); + return true; + } + else + { + return false; + } + } + + public final UndergroundBiomesBlock ubBlock(int reference) { + return UndergroundBiomesBlockList.indexed(reference); + } + public int getMetadata(int damage){ return damage;} + + @SideOnly(Side.CLIENT) + @Override + public Icon getIconFromDamage(int damage){ + UndergroundBiomesBlock source = ubBlock(damage); + Icon found = source.icon(); + //throw new RuntimeException(); + return source.icon(); + //return theBlock.getIcon(2, getMetadata(damage)); + } + + private void setIconKludge(Icon kludged) { + theBlock.setIconKludge(kludged); + } + + @Override + public int getDamage(ItemStack stack) { + int result = super.getDamage(stack); + setIconKludge(getIconFromDamage(result)); + return result; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + int result = super.getDisplayDamage(stack); + setIconKludge(getIconFromDamage(result)); + return result; + } + + private Icon iconKludgeFromHell; + /* this is a really scary kludge. Item rendering code for some items gets the block + * without carrying through the damage information. To get around this I intercept the + * closest previous call which does carry the needing info and set a variable in the block class + */ + @Override + public int getColorFromItemStack(ItemStack itemStack, int side){ + int damage = itemStack.getItemDamage(); + iconKludgeFromHell = ubBlock(damage).icon(); + setIconKludge(iconKludgeFromHell); + return super.getColorFromItemStack( itemStack, side); + } + + @Override + public void registerIcons(IconRegister par1IconRegister){} + + public abstract String groupName(); + + @Override + public String getUnlocalizedName(ItemStack stack){ + //int meta = getMetadata(stack.getItemDamage()); + String name = ubBlock(stack.getItemDamage()).getUnlocalizedName(); + + //String name = theBlock.getBlockName(meta); + return name + "." + groupName(); + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlock.java b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlock.java new file mode 100755 index 0000000..7137add --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlock.java @@ -0,0 +1,37 @@ +package exterminatorJeff.undergroundBiomes.constructs.util; +import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; + + +import net.minecraft.util.Icon; +import net.minecraft.item.ItemStack; + +/** + * + * @author Zeno410 + */ + +public class UndergroundBiomesBlock { + // A hook that lets us get to one particular block + public final BlockMetadataBase ubBlock; + public final int metadata; + public UndergroundBiomesBlock(BlockMetadataBase _ubBlock, int _metadata) { + ubBlock = _ubBlock; metadata = _metadata; + } + + public final Icon icon() {return ubBlock.getIcon(2, metadata);} + + public final String name() {return ubBlock.getBlockName(metadata);} + + public final float hardness() {return ubBlock.getBlockHardness(metadata);} + + public final float explosionResistance() {return ubBlock.getBlockExplosionResistance(metadata);} + + public final ItemStack stack(int items) {return new ItemStack(ubBlock,items,metadata);} + + public final ItemStack one() {return stack(1);} + + public final String getUnlocalizedName() { + return ubBlock.getUnlocalizedName()+"."+ubBlock.getBlockTypeName(metadata); + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java new file mode 100755 index 0000000..274f8a9 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java @@ -0,0 +1,70 @@ +package exterminatorJeff.undergroundBiomes.constructs.util; + +import exterminatorJeff.undergroundBiomes.common.UndergroundBiomes; +import exterminatorJeff.undergroundBiomes.constructs.block.BlockList; +import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; + + +/** + * + * @author Zeno410 + */ +public class UndergroundBiomesBlockList { + // namespace for references into the underground biome block system + + public static final int detailedBlockCount = 7*8; // number of different type including the subcategories + + private static UndergroundBiomesBlock [] stored; // a singleton instance + public final BlockMetadataBase igneousStone = (BlockMetadataBase)UndergroundBiomes.igneousStone; + public final BlockMetadataBase igneousCobblestone = (BlockMetadataBase)UndergroundBiomes.igneousCobblestone; + public final BlockMetadataBase igneousStoneBrick = (BlockMetadataBase)UndergroundBiomes.igneousStoneBrick; + public final BlockMetadataBase metamorphicStone = (BlockMetadataBase)UndergroundBiomes.metamorphicStone; + public final BlockMetadataBase metamorphicCobblestone = (BlockMetadataBase)UndergroundBiomes.metamorphicCobblestone; + public final BlockMetadataBase metamorphicStoneBrick = (BlockMetadataBase)UndergroundBiomes.metamorphicStoneBrick; + public final BlockMetadataBase sedimentaryStone = (BlockMetadataBase)UndergroundBiomes.sedimentaryStone; + + public UndergroundBiomesBlock[] definitionsIndex; + + private UndergroundBiomesBlock [] definitions() { + // gets a list of definitions and saves in a particular order + UndergroundBiomesBlock result [] = new UndergroundBiomesBlock[detailedBlockCount]; + int i = 0; + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(metamorphicStone,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(metamorphicCobblestone,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(metamorphicStoneBrick,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(igneousStone,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(igneousCobblestone,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(igneousStoneBrick,j); + } + for (int j = 0; j < 8; j++) { + result[i++] = new UndergroundBiomesBlock(sedimentaryStone,j); + } + return result; + } + + public static BlockMetadataBase blockMetadataBaseNamed(String name) { + return (BlockMetadataBase)(BlockList.Search.mustFindName(name)); + } + + public static UndergroundBiomesBlock indexed(int index) { + return stored[index]; + } + // not using the singleton pattern because the definitions can't be gotten too early + public UndergroundBiomesBlockList() { + definitionsIndex = definitions(); + if (stored != null) throw new RuntimeException(); + stored = this.definitionsIndex; + } + +} diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/util/Zeno410Logger.java b/src/exterminatorJeff/undergroundBiomes/constructs/util/Zeno410Logger.java new file mode 100755 index 0000000..044c60c --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/util/Zeno410Logger.java @@ -0,0 +1,59 @@ +/* + * author Zeno410 + * using code by Lars Vogel + */ + +package exterminatorJeff.undergroundBiomes.constructs.util; +import java.io.IOException; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class Zeno410Logger { + static private FileHandler fileTxt; + static private SimpleFormatter formatterTxt; + + static private FileHandler fileHTML; + static private Formatter formatterHTML; + + private Logger logger; + + static public Logger globalLogger() { + + Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + + logger.setLevel(Level.ALL); + /*try { + fileTxt = new FileHandler("/Zeno410Logging.txt"); + } catch (IOException ex) { + throw new RuntimeException(ex); + } catch (SecurityException ex) { + throw new RuntimeException(ex); + }*/ + + // Create txt Formatter + formatterTxt = new SimpleFormatter(); + //fileTxt.setFormatter(formatterTxt); + //logger.addHandler(fileTxt); + logger.log(Level.INFO,"Starting"); + return logger; + } + + public Logger logger() {return logger;} + + public Zeno410Logger(String name) { + logger = Logger.getLogger(name); + try { + fileTxt = new FileHandler("/"+name+".txt"); + } catch (IOException ex) { + throw new RuntimeException(ex); + } catch (SecurityException ex) { + throw new RuntimeException(ex); + } + formatterTxt = new SimpleFormatter(); + fileTxt.setFormatter(formatterTxt); + logger.addHandler(fileTxt); + } +}