Added hive sub-blocks, tweaked hive generation

This commit is contained in:
Matt Caughey 2013-10-29 16:52:51 -04:00
parent f370a1291d
commit a6d06c97b3
10 changed files with 159 additions and 31 deletions

View file

@ -1,30 +1,92 @@
package biomesoplenty.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockHive extends Block
{
private static final String[] hiveTypes = new String[] {"honeycomb", "honeycombspawner", "hive", "hivespawner"};
private Icon[] textures;
public BlockHive(int par1)
{
super(par1, Material.wood);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World par1World)
{
return new TileEntityMobSpawner();
}
@Override
public void registerIcons(IconRegister par1IconRegister)
public void registerIcons(IconRegister iconRegister)
{
blockIcon = par1IconRegister.registerIcon("biomesoplenty:hive");
textures = new Icon[hiveTypes.length];
for (int i = 0; i < hiveTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+hiveTypes[i]);
}
}
@Override
public Icon getIcon(int side, int meta)
{
return textures[meta];
}
@Override
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < hiveTypes.length; ++i) {
list.add(new ItemStack(blockID, 1, i));
}
}
@Override
public int damageDropped(int meta)
{
if (meta == 1) {
meta = 0;
}
if (meta == 3) {
meta = 2;
}
return meta;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
super.setBurnProperties(blockID, 2, 4);
return blockFlammability[blockID];
}
@Override
public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face)
{
return blockFireSpreadSpeed[blockID];
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return getFlammability(world, x, y, z, metadata, face) > 0;
}
}

View file

@ -64,6 +64,7 @@ import biomesoplenty.itemblocks.ItemBlockFoliage;
import biomesoplenty.itemblocks.ItemBlockGlass;
import biomesoplenty.itemblocks.ItemBlockGrass;
import biomesoplenty.itemblocks.ItemBlockGrave;
import biomesoplenty.itemblocks.ItemBlockHive;
import biomesoplenty.itemblocks.ItemBlockLeaves;
import biomesoplenty.itemblocks.ItemBlockLog;
import biomesoplenty.itemblocks.ItemBlockMoss;
@ -264,7 +265,7 @@ public class BOPBlocks
GameRegistry.registerBlock(Blocks.moss.get(), ItemBlockMoss.class, "bop.moss");
GameRegistry.registerBlock(Blocks.cragRock.get(), "bop.cragRock");
GameRegistry.registerBlock(Blocks.cloud.get(), "bop.cloud");
GameRegistry.registerBlock(Blocks.hive.get(), "bop.hive");
GameRegistry.registerBlock(Blocks.hive.get(), ItemBlockHive.class, "bop.hive");
GameRegistry.registerBlock(Blocks.bones.get(), ItemBlockBones.class, "bop.bones");
GameRegistry.registerBlock(Blocks.glass.get(), ItemBlockGlass.class, "bop.glass");

View file

@ -0,0 +1,35 @@
package biomesoplenty.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBlockHive extends ItemBlock
{
private static final String[] types = new String[] {"honeycomb", "honeycombspawner", "hive", "hivespawner"};
public ItemBlockHive(int par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
int meta = itemstack.getItemDamage();
if (meta < 0 || meta >= types.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
}

View file

@ -24,41 +24,50 @@ public class WorldGenHive extends WorldGenerator
return false;
}
for (int cubeno = 0; cubeno < 3; cubeno++)
for (int cubeno = 0; cubeno < 4; cubeno++)
{
float chance = 0.0F;
int meta = 0;
switch (cubeno)
{
case 0:
chance = 0.25F;
meta = 0;
break;
case 1:
chance = 1.0F;
meta = 0;
break;
case 2:
chance = 1.0F;
meta = 2;
break;
case 3:
chance = 0.5F;
meta = 2;
break;
}
int honeychance = rand.nextInt(2);
//Top
generateHiveCubeSmall(world, x, y + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance);
generateHiveCubeSmall(world, x, y + cubeno, z, (baseHeight - 11) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance, meta);
//Middle
generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance, honeychance);
generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance, honeychance, meta);
//Bottom
generateHiveCubeSmall(world, x, (y - (baseHeight + 4)) + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance);
generateHiveCubeSmall(world, x, (y - (baseHeight + 6)) + cubeno, z, (baseHeight - 10) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance, meta);
//Bottom 2
generateHiveCubeSmall(world, x, (y - (baseHeight + 5)) + cubeno, z, (baseHeight - 7) + (cubeno * 2), (baseWidth - 2) + cubeno, cubeno, chance);
generateHiveCubeSmall(world, x, (y - (baseHeight + 7)) + cubeno, z, (baseHeight - 9) + (cubeno * 2), (baseWidth - 2) + cubeno, cubeno, chance, meta);
//Bottom 3
generateHiveCubeSmall(world, x, (y - (baseHeight + 7)) + cubeno, z, (baseHeight - 7) + (cubeno * 2), (baseWidth - 4) + cubeno, cubeno, chance);
generateHiveCubeSmall(world, x, (y - (baseHeight + 9)) + cubeno, z, (baseHeight - 9) + (cubeno * 2), (baseWidth - 4) + cubeno, cubeno, chance, meta);
spawnWasps(world, rand, x, y, z, 15);
}
@ -66,7 +75,7 @@ public class WorldGenHive extends WorldGenerator
return true;
}
public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int honeychance)
public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int honeychance, int meta)
{
for (int hLayer = 0; hLayer < height; hLayer++)
{
@ -74,30 +83,33 @@ public class WorldGenHive extends WorldGenerator
{
for (int j = -width; j < width; j++)
{
if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID);
else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID);
if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2);
else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2);
if (hLayer > (height / 2))
{
if (honeychance == 0)
{
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlock(origx + i, origy - hLayer, origz + j, Fluids.honey.get().blockID);
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlock(origx + i, origy - hLayer, origz + j, Fluids.honey.get().blockID);
}
else
{
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j);
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlockToAir(origx + i, origy - hLayer, origz + j);
}
}
else
{
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j);
if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlockToAir(origx + i, origy - hLayer, origz + j);
}
}
}
}
}
public void generateHiveCubeSmall(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance)
public void generateHiveCubeSmall(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int meta)
{
for (int hLayer = 0; hLayer < height; hLayer++)
{
@ -105,8 +117,8 @@ public class WorldGenHive extends WorldGenerator
{
for (int j = -width; j < width; j++)
{
if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID);
else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID);
if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2);
else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2);
}
}
}
@ -122,14 +134,29 @@ public class WorldGenHive extends WorldGenerator
if (world.getBlockId(spawnx, spawny, spawnz) == Blocks.hive.get().blockID)
{
world.setBlock(spawnx, spawny, spawnz, Block.mobSpawner.blockID);
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz);
if (tileentitymobspawner != null)
{
tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp");
}
if (world.getBlockMetadata(spawnx, spawny, spawnz) == 0)
{
world.setBlock(spawnx, spawny, spawnz, Blocks.hive.get().blockID, 1, 0);
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz);
if (tileentitymobspawner != null)
{
tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp");
}
}
if (world.getBlockMetadata(spawnx, spawny, spawnz) == 2)
{
world.setBlock(spawnx, spawny, spawnz, Blocks.hive.get().blockID, 3, 0);
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz);
if (tileentitymobspawner != null)
{
tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp");
}
}
}
}
}

View file

@ -157,7 +157,10 @@ tile.bop.moss.name=Moss
tile.bop.cloud.name=Cloud Block
tile.bop.hive.name=Hive
tile.bop.hive.honeycomb.name=Honeycomb Block
tile.bop.hive.honeycombspawner.name=Honeycomb Wasp Spawner
tile.bop.hive.hive.name=Hive Block
tile.bop.hive.hivespawner.name=Hive Wasp Spawner
tile.bop.bones.bones_small.name=Small Bone Segment
tile.bop.bones.bones_medium.name=Medium Bone Segment

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

View file

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B