From ca0db978ea17a6fa0d911560540a85d195e62b65 Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Sat, 31 Aug 2013 14:50:58 -0700 Subject: [PATCH 1/8] Branch Switch Switching files from master to 1.6.1 --- .../UndergroundBiomesConstructs.java | 103 ++++++++++ .../constructs/block/Blocklist.java | 32 ++++ .../constructs/block/IconKludgeable.java | 14 ++ .../constructs/block/UBButtonGroup.java | 36 ++++ .../constructs/block/UBConstructGroup.java | 88 +++++++++ .../constructs/block/UBStairsBase.java | 176 +++++++++++++++++ .../constructs/block/UBStairsGroup.java | 38 ++++ .../constructs/block/UBWallBase.java | 178 ++++++++++++++++++ .../constructs/block/UBWallGroup.java | 33 ++++ .../block/UndergroundBiomesButton.java | 149 +++++++++++++++ .../entity/UndergroundBiomesTileEntity.java | 49 +++++ .../constructs/item/ItemUBButton.java | 23 +++ .../constructs/item/ItemUBStairs.java | 25 +++ .../constructs/item/ItemUBWall.java | 23 +++ .../item/ItemUndergroundBiomesConstruct.java | 142 ++++++++++++++ .../util/UndergroundBiomesBlock.java | 37 ++++ .../util/UndergroundBiomesBlockList.java | 69 +++++++ .../constructs/util/Zeno410Logger.java | 59 ++++++ 18 files changed, 1274 insertions(+) create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/Blocklist.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/IconKludgeable.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBButtonGroup.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBConstructGroup.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/entity/UndergroundBiomesTileEntity.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBButton.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBStairs.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUBWall.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlock.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java create mode 100755 src/exterminatorJeff/undergroundBiomes/constructs/util/Zeno410Logger.java diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java new file mode 100755 index 0000000..7affc2c --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java @@ -0,0 +1,103 @@ +/* + * Author Zeno410 + */ + +package exterminatorJeff.undergroundBiomes.constructs; + +import exterminatorJeff.undergroundBiomes.constructs.block.UBButtonGroup; +import exterminatorJeff.undergroundBiomes.constructs.block.UBStairsGroup; +import exterminatorJeff.undergroundBiomes.constructs.block.UBWallGroup; + +import exterminatorJeff.undergroundBiomes.constructs.util.UndergroundBiomesBlockList; +import exterminatorJeff.undergroundBiomes.constructs.entity.UndergroundBiomesTileEntity; + +import net.minecraftforge.common.Configuration; + +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; + + //@PreInit + public void preInit(FMLPreInitializationEvent event) { + config = new Configuration(event.getSuggestedConfigurationFile()); + config.load(); + + stoneStair = new UBStairsGroup(); + stoneStairID = config.getBlock("Universal Biomes Stairs ID:", 2012).getInt(); + + preInitWalls(); + preInitButtons(); + } + + 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"); + + loadStairs(); + loadWalls(); + loadButtons(); + } + + 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 { + + } + +} 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..a6ba845 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java @@ -0,0 +1,176 @@ +/* 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(World 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(World 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(); + } + + 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..a8a155f --- /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), "XXX", " XX", " X", '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..65c5d8b --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java @@ -0,0 +1,178 @@ +/** + * + * @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(World 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(World 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 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 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..6f05987 --- /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(5), " ", "XXX", "X X", '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..aed4ebf --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java @@ -0,0 +1,149 @@ +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(World 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(World 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(); + } + + 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..e002aa9 --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java @@ -0,0 +1,142 @@ +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); + } + + 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..850f4df --- /dev/null +++ b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java @@ -0,0 +1,69 @@ +package exterminatorJeff.undergroundBiomes.constructs.util; + +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 = blockMetadataBaseNamed("tile.igneousStone"); + public final BlockMetadataBase igneousCobblestone = blockMetadataBaseNamed("tile.igneousCobblestone"); + public final BlockMetadataBase igneousStoneBrick = blockMetadataBaseNamed("tile.igneousStoneBrick"); + public final BlockMetadataBase metamorphicStone = blockMetadataBaseNamed("tile.metamorphicStone"); + public final BlockMetadataBase metamorphicCobblestone = blockMetadataBaseNamed("tile.metamorphicCobblestone"); + public final BlockMetadataBase metamorphicStoneBrick = blockMetadataBaseNamed("tile.metamorphicStoneBrick"); + public final BlockMetadataBase sedimentaryStone = blockMetadataBaseNamed("tile.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); + } +} From 98d6a26ec05eb889d0c601f46527ca4470b8ed74 Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Sat, 31 Aug 2013 15:19:40 -0700 Subject: [PATCH 2/8] UB control changes Modifying UndergroundBiomes.java to make calls to UndergroundBiomesConstructs --- .../common/UndergroundBiomes.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java diff --git a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java old mode 100644 new mode 100755 index b9a7b62..3b40ff4 --- 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,8 @@ public class UndergroundBiomes private String excludeDimensions; private int vanillaStoneCrafting; + + private UndergroundBiomesConstructs constructs; public static int biomeSize = 45; @@ -213,6 +217,10 @@ public void preInit(FMLPreInitializationEvent event) tabModItems.iconID = ligniteCoal.itemID; proxy.setUpBlockNames(); + + constructs = new UndergroundBiomesConstructs(); + constructs.preInit(event); + } @Init @@ -220,7 +228,9 @@ public void load(FMLInitializationEvent event) { addOreDicts(); addRecipes(); - + + constructs.load(event); + MinecraftForge.EVENT_BUS.register(this); } @@ -255,6 +265,8 @@ public void postInit(FMLPostInitializationEvent event) throws Exception e.printStackTrace(System.err); } } + + constructs.postInit(event); } @ServerStarting From 66577cdefbb09b24902482c56cc771c0b614dbdc Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Sat, 31 Aug 2013 15:21:47 -0700 Subject: [PATCH 3/8] Rename Blocklist.java to BlockList.java --- .../constructs/block/{Blocklist.java => BlockList.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/exterminatorJeff/undergroundBiomes/constructs/block/{Blocklist.java => BlockList.java} (100%) mode change 100755 => 100644 diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/Blocklist.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java old mode 100755 new mode 100644 similarity index 100% rename from src/exterminatorJeff/undergroundBiomes/constructs/block/Blocklist.java rename to src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java From ea4abe11063af7ce6fd7b520552981331e90e24c Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Sat, 31 Aug 2013 15:29:24 -0700 Subject: [PATCH 4/8] English language construct translation --- src/assets/undergroundbiomes/lang/en_US.lang | 192 +++++++++++++++++++ 1 file changed, 192 insertions(+) mode change 100644 => 100755 src/assets/undergroundbiomes/lang/en_US.lang 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..c760367 --- 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.wall.redGranite.wall.name=Red Granite Brick Wall +tile.igneousStoneBrick.wall.blackGranite.wall.name=Black Granite Brick Wall +tile.igneousStoneBrick.wall.rhyolite.wall.name=Rhyolite Brick Wall +tile.igneousStoneBrick.wall.andesite.wall.name=Andesite Brick Wall +tile.igneousStoneBrick.wall.gabbro.wall.name=Gabbro Brick Wall +tile.igneousStoneBrick.wall.basalt.wall.name=Basalt Brick Wall +tile.igneousStoneBrick.wall.komatiite.wall.name=Komatiite Brick Wall +tile.igneousStoneBrick.wall.dacite.wall.name=Dacite Brick Wall + +tile.metamorphicStone.wall.gneiss.wall.name=Gneiss Wall +tile.metamorphicStone.wall.eclogite.wall.name=Eclogite Wall +tile.metamorphicStone.wall.marble.wall.name=Marble Wall +tile.metamorphicStone.wall.quartzite.wall.name=Quartzite Wall +tile.metamorphicStone.wall.blueschist.wall.name=Blue Schist Wall +tile.metamorphicStone.wall.greenschist.wall.name=Green Schist Wall +tile.metamorphicStone.wall.soapstone.wall.name=Soapstone Wall +tile.metamorphicStone.wall.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 From 36a1c5f5b1b8e2f24d1781110afec3ee10e91598 Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Mon, 2 Sep 2013 21:12:16 -0700 Subject: [PATCH 5/8] Bug fixes --- src/assets/undergroundbiomes/lang/en_US.lang | 34 +++++------ .../common/UndergroundBiomes.java | 16 ++++++ .../UndergroundBiomesConstructs.java | 56 ++++++++++++++++--- .../constructs/block/BlockList.java | 0 .../constructs/block/UBButtonGroup.java | 6 +- .../constructs/block/UBStairsGroup.java | 2 +- .../constructs/block/UBWallBase.java | 15 ++++- .../constructs/block/UBWallGroup.java | 2 +- .../item/ItemUndergroundBiomesConstruct.java | 14 +++++ .../util/UndergroundBiomesBlockList.java | 15 ++--- 10 files changed, 121 insertions(+), 39 deletions(-) mode change 100644 => 100755 src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java diff --git a/src/assets/undergroundbiomes/lang/en_US.lang b/src/assets/undergroundbiomes/lang/en_US.lang index c760367..e9057d1 100755 --- a/src/assets/undergroundbiomes/lang/en_US.lang +++ b/src/assets/undergroundbiomes/lang/en_US.lang @@ -170,23 +170,23 @@ 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.wall.redGranite.wall.name=Red Granite Brick Wall -tile.igneousStoneBrick.wall.blackGranite.wall.name=Black Granite Brick Wall -tile.igneousStoneBrick.wall.rhyolite.wall.name=Rhyolite Brick Wall -tile.igneousStoneBrick.wall.andesite.wall.name=Andesite Brick Wall -tile.igneousStoneBrick.wall.gabbro.wall.name=Gabbro Brick Wall -tile.igneousStoneBrick.wall.basalt.wall.name=Basalt Brick Wall -tile.igneousStoneBrick.wall.komatiite.wall.name=Komatiite Brick Wall -tile.igneousStoneBrick.wall.dacite.wall.name=Dacite Brick Wall - -tile.metamorphicStone.wall.gneiss.wall.name=Gneiss Wall -tile.metamorphicStone.wall.eclogite.wall.name=Eclogite Wall -tile.metamorphicStone.wall.marble.wall.name=Marble Wall -tile.metamorphicStone.wall.quartzite.wall.name=Quartzite Wall -tile.metamorphicStone.wall.blueschist.wall.name=Blue Schist Wall -tile.metamorphicStone.wall.greenschist.wall.name=Green Schist Wall -tile.metamorphicStone.wall.soapstone.wall.name=Soapstone Wall -tile.metamorphicStone.wall.migmatite.wall.name=Migmatite 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 diff --git a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java index 3b40ff4..1465ce8 100755 --- a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java +++ b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java @@ -104,6 +104,13 @@ public class UndergroundBiomes 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; @@ -143,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 Stairs for Underground Biomes blocks").getBoolean(true); if (includeDimensions.equals("*")) { @@ -383,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 index 7affc2c..9b5a67b 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java @@ -4,14 +4,26 @@ 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 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; @@ -43,20 +55,22 @@ public class UndergroundBiomesConstructs { private int stoneButtonID; public Configuration config; - private UndergroundBiomesBlockList ubBlockList; - //@PreInit + //@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(); - - preInitWalls(); - preInitButtons(); } public void preInitWalls() { @@ -74,9 +88,9 @@ public void load(FMLInitializationEvent event) { ubBlockList = new UndergroundBiomesBlockList(); GameRegistry.registerTileEntity(UndergroundBiomesTileEntity.class, "UndergroundBiomesTileEntity"); - loadStairs(); - loadWalls(); - loadButtons(); + if (UndergroundBiomes.buttonsOn()) loadButtons(); + if (UndergroundBiomes.stairsOn()) loadStairs(); + if (UndergroundBiomes.wallsOn()) loadWalls(); } private void loadStairs(){ @@ -100,4 +114,28 @@ 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;} + Block blockMade = Block.blocksList[((ItemBlock)output).getBlockID()]; + if (UndergroundBiomes.buttonsOn()) { + if (blockMade instanceof BlockButton) return true; + } + if (UndergroundBiomes.stairsOn()) { + if (blockMade instanceof BlockStairs) {return true;} + } + if (UndergroundBiomes.wallsOn()) { + if (blockMade instanceof BlockWall) return true; + } + return false; + } } diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/BlockList.java old mode 100644 new mode 100755 diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBButtonGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBButtonGroup.java index cd2ba23..428021f 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBButtonGroup.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBButtonGroup.java @@ -5,6 +5,7 @@ * Constructor for the button group */ package exterminatorJeff.undergroundBiomes.constructs.block; +import exterminatorJeff.undergroundBiomes.common.UndergroundBiomes; import exterminatorJeff.undergroundBiomes.constructs.item.ItemUBButton; import cpw.mods.fml.common.registry.GameRegistry; @@ -19,7 +20,10 @@ public class UBButtonGroup extends UBConstructGroup { public UBButtonGroup() {super("button");} void addRecipe(ProductItemDefiner product,StoneItemDefiner stone) { - + // suppress brick buttons + int sourceID = stone.one().itemID; + if (sourceID == UndergroundBiomes.igneousStoneBrick.blockID) return; + if (sourceID == UndergroundBiomes.metamorphicStoneBrick.blockID) return; GameRegistry.addRecipe(new ShapedOreRecipe( product.stackOf(2), " ", " X ", " X ", 'X', stone.one())); } diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java index a8a155f..4225c96 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsGroup.java @@ -23,7 +23,7 @@ public class UBStairsGroup extends UBConstructGroup { void addRecipe(ProductItemDefiner product, StoneItemDefiner stone) { GameRegistry.addRecipe(new ShapedOreRecipe( - product.stackOf(4), "XXX", " XX", " X", 'X', stone.one())); + product.stackOf(4), " X", " XX", "XXX", 'X', stone.one())); } Class itemClass() { diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java index 65c5d8b..5916bc6 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java @@ -99,15 +99,19 @@ public float getBlockHardness(World world, int x, int y, int z){ public void setIconKludge(Icon kludged) { iconKludgeFromHell = kludged; - //hitCount = 7; + 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; + hitCount--; + if (hitCount == 0) { + iconKludgeFromHell= null; + throw new RuntimeException("no icon set up"); + } + return iconKludgeFromHell; //return ubBlock(metadata).icon(); } @@ -155,6 +159,11 @@ 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) { diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java index 6f05987..ffe15eb 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallGroup.java @@ -19,7 +19,7 @@ public class UBWallGroup extends UBConstructGroup { void addRecipe(ProductItemDefiner product, StoneItemDefiner stone) { GameRegistry.addRecipe(new ShapedOreRecipe( - product.stackOf(5), " ", "XXX", "X X", 'X', stone.one())); + product.stackOf(6), " ", "XXX", "XXX", 'X', stone.one())); } Class itemClass() { diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java index e002aa9..9e8ec1e 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/item/ItemUndergroundBiomesConstruct.java @@ -112,6 +112,20 @@ 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 diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java index 850f4df..274f8a9 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/util/UndergroundBiomesBlockList.java @@ -1,5 +1,6 @@ package exterminatorJeff.undergroundBiomes.constructs.util; +import exterminatorJeff.undergroundBiomes.common.UndergroundBiomes; import exterminatorJeff.undergroundBiomes.constructs.block.BlockList; import exterminatorJeff.undergroundBiomes.common.block.BlockMetadataBase; @@ -14,13 +15,13 @@ public class UndergroundBiomesBlockList { 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 = blockMetadataBaseNamed("tile.igneousStone"); - public final BlockMetadataBase igneousCobblestone = blockMetadataBaseNamed("tile.igneousCobblestone"); - public final BlockMetadataBase igneousStoneBrick = blockMetadataBaseNamed("tile.igneousStoneBrick"); - public final BlockMetadataBase metamorphicStone = blockMetadataBaseNamed("tile.metamorphicStone"); - public final BlockMetadataBase metamorphicCobblestone = blockMetadataBaseNamed("tile.metamorphicCobblestone"); - public final BlockMetadataBase metamorphicStoneBrick = blockMetadataBaseNamed("tile.metamorphicStoneBrick"); - public final BlockMetadataBase sedimentaryStone = blockMetadataBaseNamed("tile.sedimentaryStone"); + 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; From f142ea5d01ee7cd1c12ef0176ec7c66a439f0c3e Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Mon, 2 Sep 2013 21:26:18 -0700 Subject: [PATCH 6/8] Config changes --- .../undergroundBiomes/common/UndergroundBiomes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java index 1465ce8..8f71cbf 100755 --- a/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java +++ b/src/exterminatorJeff/undergroundBiomes/common/UndergroundBiomes.java @@ -155,7 +155,7 @@ public void preInit(FMLPreInitializationEvent event) 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 Stairs for Underground Biomes blocks").getBoolean(true); + "UndergroundBiomesStairs", true, "Provide Walls for Underground Biomes blocks").getBoolean(true); if (includeDimensions.equals("*")) { From 42b7fc8c97ed323b9b446b8109c28a44786e4573 Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Wed, 4 Sep 2013 13:13:11 -0700 Subject: [PATCH 7/8] Supressing recipes with Oredictify off --- .../UndergroundBiomesConstructs.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java index 9b5a67b..e21f0d5 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/UndergroundBiomesConstructs.java @@ -16,6 +16,10 @@ 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; @@ -58,6 +62,8 @@ public class UndergroundBiomesConstructs { private UndergroundBiomesBlockList ubBlockList; + //private static Zeno410Logger logger = new Zeno410Logger("UndergroundBiomesConstructs"); + //@PreIni public void preInit(FMLPreInitializationEvent event) { config = new Configuration(event.getSuggestedConfigurationFile()); @@ -88,6 +94,9 @@ 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(); @@ -126,15 +135,25 @@ public static boolean overridesRecipe(IRecipe recipe) { 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) return true; + if (blockMade instanceof BlockButton) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } } if (UndergroundBiomes.stairsOn()) { - if (blockMade instanceof BlockStairs) {return true;} + if (blockMade instanceof BlockStairs) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } } if (UndergroundBiomes.wallsOn()) { - if (blockMade instanceof BlockWall) return true; + if (blockMade instanceof BlockWall) { + //logger.logger().log(Level.INFO, "suppressed"); + return true; + } } return false; } From cbf6c0a01a12e2350acc8e1e577086a34d3a3af2 Mon Sep 17 00:00:00 2001 From: Zeno410 Date: Wed, 4 Sep 2013 19:45:47 -0700 Subject: [PATCH 8/8] Fixed another source of wrong icons --- .../constructs/block/UBStairsBase.java | 10 ++++++++-- .../constructs/block/UBWallBase.java | 15 ++++++++++----- .../constructs/block/UndergroundBiomesButton.java | 9 +++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java index a6ba845..9f92ba7 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBStairsBase.java @@ -65,7 +65,7 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter */ - public final UndergroundBiomesTileEntity ubTileEntity(World world, int x, int y, int z) { + public final UndergroundBiomesTileEntity ubTileEntity(IBlockAccess world, int x, int y, int z) { UndergroundBiomesTileEntity result; result = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); return result; @@ -75,7 +75,7 @@ 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(World world, int x, int y, int z) { + 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); @@ -115,6 +115,12 @@ public Icon getIcon(int side, int metadata){ //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(); diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java index 5916bc6..c5cf7b5 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UBWallBase.java @@ -64,17 +64,17 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, * entity at this location. Args: world, x, y, z, blockID, EventID, event parameter */ - public final UndergroundBiomesTileEntity ubTileEntity(World world, int x, int y, int z) { + 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) { + 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(World world, int x, int y, int z) { + 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()); @@ -108,14 +108,19 @@ public void setIconKludge(Icon kludged) { public Icon getIcon(int side, int metadata){ hitCount--; if (hitCount == 0) { - iconKludgeFromHell= null; - throw new RuntimeException("no icon set up"); + //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); diff --git a/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java b/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java index aed4ebf..83bb9c6 100755 --- a/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java +++ b/src/exterminatorJeff/undergroundBiomes/constructs/block/UndergroundBiomesButton.java @@ -45,7 +45,7 @@ public TileEntity createNewTileEntity(World world) { @Override public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6){} - public final UndergroundBiomesTileEntity ubTileEntity(World world, int x, int y, int z) { + public final UndergroundBiomesTileEntity ubTileEntity(IBlockAccess world, int x, int y, int z) { UndergroundBiomesTileEntity result; result = (UndergroundBiomesTileEntity)(world.getBlockTileEntity(x, y, z)); return result; @@ -55,7 +55,7 @@ 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(World world, int x, int y, int z) { + 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()); @@ -92,6 +92,11 @@ public Icon getIcon(int side, int metadata){ //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();