Fixed coral suction, repacked sub biomes/tech biomes, fixed foliage being un-replacable

This commit is contained in:
Adubbz 2014-05-18 13:47:24 +10:00
parent 60f01c2191
commit 8596021766
22 changed files with 477 additions and 315 deletions

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.subbiomes;
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;

View file

@ -0,0 +1,127 @@
package biomesoplenty.common.biomes.overworld.sub;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase.Height;
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenShrub;
import biomesoplenty.api.BOPBlockHelper;
import biomesoplenty.common.biomes.BOPSubBiome;
import biomesoplenty.common.configuration.BOPConfigurationMisc;
import biomesoplenty.common.entities.EntityJungleSpider;
import biomesoplenty.common.world.features.WorldGenBOPDoubleFlora;
import biomesoplenty.common.world.features.WorldGenBOPFlora;
import biomesoplenty.common.world.features.WorldGenBOPTallGrass;
import biomesoplenty.common.world.features.trees.WorldGenPalmTree1;
import biomesoplenty.common.world.features.trees.WorldGenTropicsShrub;
public class BiomeGenTropics extends BOPSubBiome
{
private static final Height biomeHeight = new Height(0.0F, 0.4F);
public BiomeGenTropics(int id)
{
super(id);
this.zoom = 0.25D;
this.threshold = 0.25D;
//TODO: setHeight()
this.setHeight(biomeHeight);
//TODO: setColor()
this.setColor(2211330);
this.setTemperatureRainfall(2.0F, 2.0F);
this.spawnableCreatureList.clear();
this.spawnableMonsterList.add(new SpawnListEntry(EntityJungleSpider.class, 12, 6, 6));
this.theBiomeDecorator.treesPerChunk = 12;
this.theBiomeDecorator.grassPerChunk = 7;
this.theBiomeDecorator.flowersPerChunk = 10;
this.theBiomeDecorator.sandPerChunk = 50;
this.theBiomeDecorator.sandPerChunk2 = 50;
this.bopWorldFeatures.setFeature("bopFlowersPerChunk", 30);
this.bopWorldFeatures.setFeature("shrubsPerChunk", 4);
this.bopWorldFeatures.setFeature("leafPilesPerChunk", 10);
this.bopWorldFeatures.setFeature("seaweedPerChunk", 10);
this.bopWorldFeatures.setFeature("generatePumpkins", false);
this.bopWorldFeatures.setFeature("bopGrassPerChunk", 7);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPFlora(BOPBlockHelper.get("flowers"), 9), 8);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPFlora(BOPBlockHelper.get("flowers"), 5), 10);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPFlora(BOPBlockHelper.get("flowers2"), 0), 15);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPFlora(Blocks.red_flower, 1), 7);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPDoubleFlora(4, 5), 6);
this.bopWorldFeatures.weightedFlowerGen.put(new WorldGenBOPDoubleFlora(0, 3), 2);
this.bopWorldFeatures.weightedGrassGen.put(new WorldGenBOPTallGrass(BOPBlockHelper.get("foliage"), 10), 0.5D);
this.bopWorldFeatures.weightedGrassGen.put(new WorldGenBOPTallGrass(BOPBlockHelper.get("foliage"), 11), 0.5D);
this.bopWorldFeatures.weightedGrassGen.put(new WorldGenBOPTallGrass(Blocks.tallgrass, 1), 1D);
this.bopWorldFeatures.weightedGrassGen.put(new WorldGenBOPDoubleFlora(3), 0.25D);
}
@Override
//TODO: getRandomWorldGenForTrees()
public WorldGenAbstractTree func_150567_a(Random random)
{
return random.nextInt(2) == 0 ? new WorldGenPalmTree1() :
(random.nextInt(2) == 0 ? new WorldGenTropicsShrub() :
new WorldGenShrub(0, 0));
}
@Override
public void decorate(World world, Random random, int chunkX, int chunkZ)
{
super.decorate(world, random, chunkX, chunkZ);
int var5 = 12 + random.nextInt(6);
for (int var6 = 0; var6 < var5; ++var6)
{
int x = chunkX + random.nextInt(16);
int y = random.nextInt(28) + 4;
int z = chunkZ + random.nextInt(16);
//TODO: getBlock()
Block block = world.getBlock(x, y, z);
if (block != null && block.isReplaceableOreGen(world, x, y, z, Blocks.stone))
{
//TODO: setBlock()
world.setBlock(x, y, z, BOPBlockHelper.get("gemOre"), 6, 2);
}
}
}
@Override
public int getSkyColorByTemp(float par1)
{
if (BOPConfigurationMisc.skyColors) return 507391;
else return super.getSkyColorByTemp(par1);
}
/**
* Fog Color
*/
/*
@Override
public int getFogColour()
{
return 7724287;
}
*/
/*@Override
public float getFogCloseness()
{
// TODO Auto-generated method stub
return 1.0F;
}
*/
}

View file

@ -0,0 +1,45 @@
package biomesoplenty.common.biomes.overworld.sub;
import net.minecraft.world.biome.BiomeGenBase.Height;
import biomesoplenty.api.BOPBlockHelper;
import biomesoplenty.common.biomes.BOPSubBiome;
import biomesoplenty.common.configuration.BOPConfigurationMisc;
public class BiomeGenVolcano extends BOPSubBiome
{
private static final Height biomeHeight = new Height(5.0F, 0.025F);
public BiomeGenVolcano(int id)
{
super(id);
this.zoom = 0.25D;
this.threshold = 0.25D;
//TODO: setHeight()
this.setHeight(biomeHeight);
this.setDisableRain();
//TODO: setColor()
this.setColor(6645093);
this.setTemperatureRainfall(2.0F, 0.05F);
this.spawnableCreatureList.clear();
this.topBlock = BOPBlockHelper.get("ashStone");
this.fillerBlock = BOPBlockHelper.get("ashStone");
this.theBiomeDecorator.treesPerChunk = 0;
this.theBiomeDecorator.flowersPerChunk = -999;
this.theBiomeDecorator.grassPerChunk = -999;
this.bopWorldFeatures.setFeature("lavaLakesPerChunk", 20);
this.bopWorldFeatures.setFeature("lavaSpoutsPerChunk", 1);
this.bopWorldFeatures.setFeature("generateAsh", true);
}
@Override
public int getSkyColorByTemp(float par1)
{
if (BOPConfigurationMisc.skyColors) return 8026746;
else return super.getSkyColorByTemp(par1);
}
}

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.techbiomes;
package biomesoplenty.common.biomes.overworld.tech;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package biomesoplenty.common.biomes.overworld.techbiomes;
package biomesoplenty.common.biomes.overworld.tech;
import java.util.Random;

View file

@ -0,0 +1,66 @@
package biomesoplenty.common.blocks;
import java.util.Random;
import biomesoplenty.BiomesOPlenty;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public abstract class BOPBlock extends Block
{
protected BOPBlock(Material material)
{
super(material);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
this.checkAndDropBlock(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
this.checkAndDropBlock(world, x, y, z);
super.onNeighborBlockChange(world, x, y, z, block);
}
@Override
public boolean canReplace(World world, int x, int y, int z, int side, ItemStack itemStack)
{
return this.canBlockStay(world, x, y, z, itemStack.getItemDamage());
}
@Override
@Deprecated
public boolean canBlockStay(World world, int x, int y, int z)
{
return super.canBlockStay(world, x, y, z);
}
public boolean canBlockStay(World world, int x, int y, int z, int metadata)
{
return this.canBlockStay(world, x, y, z);
}
protected void checkAndDropBlock(World world, int x, int y, int z)
{
if (!this.canBlockStay(world, x, y, z, world.getBlockMetadata(x, y, z)))
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
@Override
public boolean renderAsNormalBlock()
{
return this.isOpaqueCube();
}
}

View file

@ -1,33 +1,56 @@
package biomesoplenty.common.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import net.minecraftforge.common.util.ForgeDirection;
import biomesoplenty.api.BOPBlockHelper;
import biomesoplenty.common.blocks.templates.BOPBlockWorldDecor;
import biomesoplenty.common.blocks.BlockBOPLog.LogCategory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPCoral extends BOPBlockWorldDecor
public class BlockBOPCoral extends BOPBlock
{
public static enum CoralCategory
{
CAT1, CAT2;
}
//coral1
//Kelp Bottom (8)
//Kelp Middle (9)
//Kelp Top (10)
//Kelp Single (11)
//Pink Coral (12)
//Orange Coral (13)
//Blue Coral (14)
//Glow Coral (15)
//coral2
//Algae (8)
private static final String[] coral = new String[] {"kelpbottom", "kelpmiddle", "kelptop", "kelpsingle", "pinkcoral", "orangecoral", "bluecoral", "glowcoral", "algae"};
private IIcon[] textures;
private final CoralCategory category;
public BlockBOPCoral()
public BlockBOPCoral(CoralCategory category)
{
super(Material.water);
this.category = category;
this.setHardness(0.0F);
this.setStepSound(Block.soundTypeGrass);
@ -35,134 +58,108 @@ public class BlockBOPCoral extends BOPBlockWorldDecor
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
textures = new IIcon[coral.length];
for (int i = 0; i < coral.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:" + coral[i]);
}
}
@Override
public IIcon getIcon(int side, int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
return textures[meta];
}
@Override
public int getRenderType()
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item block, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < coral.length; ++i)
{
if (i > 2)
{
list.add(new ItemStack(block, 1, i));
}
}
}
public boolean isValidPosition(World world, int x, int y, int z, int metadata)
{
Block block = world.getBlock(x, y - 1, z);
switch (metadata)
{
case 1: // Kelp Middle
return block == this;
case 2: // Kelp Top
return block == this;
default:
return block == Blocks.dirt || block == Blocks.sand|| block == Blocks.sponge || block == Blocks.stone || block == Blocks.clay || block == Blocks.gravel || block == Blocks.grass || block == BOPBlockHelper.get("mud");
}
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int silkTouch)
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
{
return meta < 8 ? meta + 8 : meta;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return null;
}
@Override
public boolean canReplace(World world, int x, int y, int z, int side, ItemStack itemStack)
{
return world.getBlock(x, y + 1, z) == Blocks.water && this.canBlockStay(world, x, y, z, itemStack.getItemDamage());
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock)
{
int meta = world.getBlockMetadata(x, y, z);
if (category == CoralCategory.CAT1)
{
if (world.getBlock(x, y - 1, z) != this)
{
if (world.getBlock(x, y + 1, z) != this) //Convert to single piece
{
world.setBlock(x, y, z, this, 11, 2);
}
else //Convert to bottom piece
{
world.setBlock(x, y, z, this, 8, 2);
}
}
else if (world.getBlock(x, y + 1, z) != this && world.getBlock(x, y - 1, z) == this) //Convert to top piece
{
world.setBlock(x, y, z, this, 10, 2);
}
else if (world.getBlock(x, y + 1, z) == this) //Convert to middle piece
{
world.setBlock(x, y, z, this, 9, 2);
}
}
super.onNeighborBlockChange(world, x, y, z, neighborBlock);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z, int metadata)
{
Block block = world.getBlock(x, y - 1, z);
if (category == CoralCategory.CAT1)
{
switch (metadata)
{
case 8:
return block == Blocks.dirt || block == Blocks.sand || block == Blocks.sponge || block == Blocks.stone || block == Blocks.clay || block == Blocks.gravel || block == Blocks.grass || block == BOPBlockHelper.get("mud");
case 9: // Kelp Middle
return block == this;
case 10: // Kelp Top
return block == this;
case 11:
return block == this || block == Blocks.dirt || block == Blocks.sand || block == Blocks.sponge || block == Blocks.stone || block == Blocks.clay || block == Blocks.gravel || block == Blocks.grass || block == BOPBlockHelper.get("mud");
}
}
return block == Blocks.dirt || block == Blocks.sand || block == Blocks.sponge || block == Blocks.stone || block == Blocks.clay || block == Blocks.gravel || block == Blocks.grass || block == BOPBlockHelper.get("mud");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (category == CoralCategory.CAT1 && meta == 15) return 10;
else return 0;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int silkTouch)
{
world.setBlock(x, y, z, Blocks.water);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock)
{
super.onNeighborBlockChange(world, x, y, z, neighborBlock);
if (world.getBlockMetadata(x, y, z) == 0 && world.getBlock(x, y + 1, z) != this)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (world.getBlockMetadata(x, y, z) == 1 && world.getBlock(x, y + 1, z) != this)
{
if (world.getBlock(x, y - 1, z) == this)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
}
if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 2)
{
for (int i = 1; world.getBlock(x, y + i, z) == this; i++)
{
if (!this.canBlockStay(world, x, y + i, z))
{
this.dropBlockAsItem(world, x, y + i, z, world.getBlockMetadata(x, y + i, z), 0);
world.setBlock(x, y + i, z, Blocks.water, 0, 2);
}
}
}
if (world.getBlock(x, y, z) != this)
{
world.setBlock(x, y, z, Blocks.water, 0, 2);
}
}
@Override
public int damageDropped(int meta)
{
if (meta < 3)
{
return 3;
}
return meta;
}
@Override
public int quantityDropped(int meta, int fortune, Random random)
{
return 1;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 7)
return 10;
else
return 0;
return category == CoralCategory.CAT1 && meta < 11 ? 11 : meta;
}
@Override
@ -170,19 +167,62 @@ public class BlockBOPCoral extends BOPBlockWorldDecor
{
int meta = world.getBlockMetadata(x, y, z);
if (meta < 3)
return category == CoralCategory.CAT1 && meta < 11 ? 11 : meta;
}
//Client Only
@Override
public void getSubBlocks(Item block, CreativeTabs creativeTabs, List list)
{
for (int i = 8; i < getCategorySize() + 8; ++i)
{
meta = 3;
if (category == CoralCategory.CAT1 ? i > 10 : true) list.add(new ItemStack(block, 1, i));
}
return meta;
}
@Override
public int getRenderType()
{
return 1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
textures = new IIcon[coral.length];
for (int i = 0; i < coral.length; ++i) textures[i] = iconRegister.registerIcon("biomesoplenty:" + coral[i]);
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
public IIcon getIcon(int side, int meta)
{
if (world.getBlockMetadata(x, y, z) == 10) return true;
if (meta < 8 || meta >= coral.length + 8) meta = 8;
return false;
return textures[getMetaIndex(meta)];
}
public String getCoralType(int meta)
{
if (meta < 8 || meta >= coral.length + 8) meta = 8;
return coral[getMetaIndex(meta)];
}
public int getMetaIndex(int meta)
{
return (meta - 8) + category.ordinal() * 8;
}
public int getCategorySize()
{
return category.ordinal() == category.values().length - 1 ? coral.length - category.ordinal() * 8 : 8;
}
}

View file

@ -291,6 +291,12 @@ public class BlockBOPFoliage extends BOPBlockWorldDecor implements IShearable
{
return null;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return true;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)

View file

@ -18,7 +18,6 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import biomesoplenty.api.BOPItemHelper;
import biomesoplenty.common.blocks.utils.BOPBlock;
public class BlockMud extends BOPBlock
{

View file

@ -1,29 +0,0 @@
package biomesoplenty.common.blocks.utils;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public abstract class BOPBlock extends Block
{
public BOPBlock(Material material)
{
super(material);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public int damageDropped(int meta)
{
return meta;
}
}

View file

@ -77,18 +77,18 @@ import biomesoplenty.common.biomes.overworld.BiomeGenTundra;
import biomesoplenty.common.biomes.overworld.BiomeGenWasteland;
import biomesoplenty.common.biomes.overworld.BiomeGenWetland;
import biomesoplenty.common.biomes.overworld.BiomeGenWoodland;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenAlpsForest;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenCanyonRavine;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenGlacier;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenMeadowForest;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenOasis;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenQuagmire;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenScrubland;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenSilkglades;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenTropics;
import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenVolcano;
import biomesoplenty.common.biomes.overworld.techbiomes.BiomeGenDryRiver;
import biomesoplenty.common.biomes.overworld.techbiomes.BiomeGenLushRiver;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenAlpsForest;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenCanyonRavine;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenGlacier;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenMeadowForest;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenOasis;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenQuagmire;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenScrubland;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenSilkglades;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenTropics;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenVolcano;
import biomesoplenty.common.biomes.overworld.tech.BiomeGenDryRiver;
import biomesoplenty.common.biomes.overworld.tech.BiomeGenLushRiver;
import biomesoplenty.common.configuration.BOPConfigurationBiomeGen;
import biomesoplenty.common.configuration.BOPConfigurationBiomeWeights;
import biomesoplenty.common.configuration.BOPConfigurationIDs;

View file

@ -11,6 +11,7 @@ import biomesoplenty.common.blocks.BlockBOPColorizedLeaves;
import biomesoplenty.common.blocks.BlockBOPColorizedLeaves.ColourizedLeafCategory;
import biomesoplenty.common.blocks.BlockBOPColorizedSapling;
import biomesoplenty.common.blocks.BlockBOPCoral;
import biomesoplenty.common.blocks.BlockBOPCoral.CoralCategory;
import biomesoplenty.common.blocks.BlockBOPFlower;
import biomesoplenty.common.blocks.BlockBOPFlower2;
import biomesoplenty.common.blocks.BlockBOPFoliage;
@ -101,17 +102,15 @@ public class BOPBlocks
registerBlock(new BlockBOPFlower2().setBlockName("flowers2"), ItemBlockFlower2.class);
registerBlock(new BlockStoneFormations().setBlockName("stoneFormations"), ItemBlockStoneFormations.class);
registerBlock(new BlockBOPMushroom().setBlockName("mushrooms"), ItemBlockMushroom.class);
registerBlock(new BlockBOPCoral().setBlockName("coral"), ItemBlockCoral.class);
registerBlock(new BlockWillow().setBlockName("willow"), ItemBlockWillow.class);
registerBlock(new BlockIvy().setBlockName("ivy"), ItemBlockIvy.class);
registerBlock(new BlockTreeMoss().setBlockName("treeMoss"));
registerBlock(new BlockFlowerVine().setBlockName("flowerVine"));
registerBlock(new BlockBOPLeaves(LeafCategory.CAT1).setBlockName("leaves1"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT2).setBlockName("leaves2"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT3).setBlockName("leaves3"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT4).setBlockName("leaves4"), ItemBlockLeaves.class);
registerBlock(new BlockBOPFoliage().setBlockName("foliage"), ItemBlockFoliage.class);
registerBlock(new BlockTurnip().setBlockName("turnip"));
registerBlock(new BlockBOPCoral(CoralCategory.CAT1).setBlockName("coral1"), ItemBlockCoral.class);
registerBlock(new BlockBOPCoral(CoralCategory.CAT2).setBlockName("coral2"), ItemBlockCoral.class);
registerBlock(new BlockBOPGeneric(Material.rock, BlockType.ASH_STONE).setBlockName("ashStone"));
registerBlock(new BlockBOPGeneric(Material.rock, BlockType.HARD_ICE).setBlockName("hardIce"));
@ -134,6 +133,11 @@ public class BOPBlocks
registerBlock(new BlockBOPLog(LogCategory.CAT3).setBlockName("logs3"), ItemBlockLog.class);
registerBlock(new BlockBOPLog(LogCategory.CAT4).setBlockName("logs4"), ItemBlockLog.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT1).setBlockName("leaves1"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT2).setBlockName("leaves2"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT3).setBlockName("leaves3"), ItemBlockLeaves.class);
registerBlock(new BlockBOPLeaves(LeafCategory.CAT4).setBlockName("leaves4"), ItemBlockLeaves.class);
registerBlock(new BlockBOPPetals().setBlockName("petals"), ItemBlockPetals.class);
registerBlock(new BlockBOPSapling().setBlockName("saplings"), ItemBlockSapling.class);

View file

@ -3,156 +3,60 @@ package biomesoplenty.common.itemblocks;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import biomesoplenty.api.BOPBlockHelper;
import biomesoplenty.common.blocks.BlockBOPCoral;
public class ItemBlockCoral extends ItemBlock
{
private static final String[] coral = new String[] {"kelpbottom", "kelpmiddle", "kelptop", "kelpsingle", "pinkcoral", "orangecoral", "bluecoral", "glowcoral", "algae"};
@SideOnly(Side.CLIENT)
private IIcon[] textures;
public ItemBlockCoral(Block block)
{
super(block);
setMaxDamage(0);
setHasSubtypes(true);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int meta)
{
return meta & 15;
return meta < 8 ? meta + 8 : meta;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (field_150939_a == BOPBlockHelper.get("coral1") && metadata > 8 && metadata < 12)
{
metadata = world.getBlock(x, y - 1, z) == field_150939_a ? 10 : 11;
}
return super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[1];
textures[0] = iconRegister.registerIcon("biomesoplenty:item_kelp");
}
@Override
public IIcon getIconFromDamage(int meta)
{
return field_150939_a.getIcon(0, meta);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= coral.length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + coral[meta];
}
@Override
public IIcon getIconFromDamage(int meta)
{
if (meta == 3)
return textures[0];
else
//TODO: block getIcon()
return field_150939_a.getIcon(0, meta);
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return null;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 20;
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
//TODO: getBlock()
Block block = world.getBlock(x, y, z);
if (block == Blocks.snow && (world.getBlockMetadata(x, y, z) & 7) < 1)
{
side = 1;
}
else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(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 (itemstack.stackSize == 0)
return false;
else if (!player.canPlayerEdit(x, y, z, side, itemstack))
return false;
//TODO: getBlockMaterial()
else if (y == 255 && block.getMaterial().isSolid())
return false;
//TODO: canPlaceEntityOnSide()?
else if (world.canPlaceEntityOnSide(block, x, y, z, false, side, player, itemstack))
{
//TODO: getBlock() getBlock()
if (world.getBlock(x, y + 1, z) == Blocks.water)
{
onItemUsePlaceBlock(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
return true;
}
}
return false;
}
public void onItemUsePlaceBlock(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ)
{
//TODO: block
Block block = field_150939_a;
int j1 = this.getMetadata(itemstack.getItemDamage());
//TODO: onBlockPlaced()
int k1 = block.onBlockPlaced(world, x, y, z, side, hitVecX, hitVecY, hitVecZ, j1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, hitVecX, hitVecY, hitVecZ, k1))
{
//TODO: stepSound.getPlaceSound() stepSound.getVolume() stepSound.getPitch()
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--itemstack.stackSize;
}
BlockBOPCoral block = (BlockBOPCoral)field_150939_a;
return super.getUnlocalizedName() + "." + block.getCoralType(itemStack.getItemDamage());
}
}

View file

@ -75,7 +75,7 @@ public class WorldGenFieldAssociation
associateFeature("desertSproutsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("plants"), 2));
associateFeature("bromeliadsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("flowers"), 12));
associateFeature("waterReedsPerChunk", new WorldGenWaterReeds());
associateFeature("seaweedPerChunk", new WorldGenBOPCoral(BOPBlockHelper.get("coral"), 8, 256));
associateFeature("seaweedPerChunk", new WorldGenBOPCoral(BOPBlockHelper.get("coral2"), 8, 256));
associateFeature("wildCarrotsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("plants"), 11));
associateFeature("poisonIvyPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("foliage"), 7));
associateFeature("berryBushesPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("foliage"), 8));

View file

@ -129,12 +129,12 @@ tile.overgrownNetherrack.name=Overgrown Netherrack
tile.treeMoss.name=Tree Moss
tile.flowerVine.name=Flowering Vines
tile.coral.kelpsingle.name=Kelp
tile.coral.pinkcoral.name=Pink Coral
tile.coral.orangecoral.name=Orange Coral
tile.coral.bluecoral.name=Blue Coral
tile.coral.glowcoral.name=Glowing Coral
tile.coral.algae.name=Algae
tile.coral1.kelpsingle.name=Kelp
tile.coral1.pinkcoral.name=Pink Coral
tile.coral1.orangecoral.name=Orange Coral
tile.coral1.bluecoral.name=Blue Coral
tile.coral1.glowcoral.name=Glowing Coral
tile.coral2.algae.name=Algae
tile.bopGrass.spectralmoss.name=Spectral Moss
tile.bopGrass.smolderinggrass.name=Smoldering Grass Block