Fixed placing of mangrove and holy saplings.

This commit is contained in:
Amnet 2013-05-01 10:59:00 +02:00
parent 3696e24901
commit 86cde9b500
2 changed files with 41 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
@ -12,6 +13,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.worldgen.WorldGenAcacia;
import biomesoplenty.worldgen.WorldGenMangrove;
import biomesoplenty.worldgen.WorldGenPalmTree1;
@ -62,6 +64,25 @@ public class BlockBOPColorizedSapling extends BlockSapling
list.add(new ItemStack(blockID, 1, i));
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == this.blockID)
switch (meta)
{
case 1: // Mangrove
return id == Block.sand.blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
}
else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{

View file

@ -12,6 +12,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.worldgen.WorldGenApple;
import biomesoplenty.worldgen.WorldGenAutumn;
import biomesoplenty.worldgen.WorldGenAutumn2;
@ -68,6 +69,25 @@ public class BlockBOPSapling extends BlockSapling
list.add(new ItemStack(blockID, 1, i));
}
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack)
{
int id = world.getBlockId(x, y - 1, z);
int meta = itemStack.getItemDamage();
if (itemStack.itemID == this.blockID)
switch (meta)
{
case 7: // Holy
return id == Blocks.holyGrass.get().blockID;
default:
return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID;
}
else
return this.canPlaceBlockOnSide(world, x, y, z, side);
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{