Cleaned up the code formatting

This commit is contained in:
Adubbz 2015-01-21 17:09:12 +11:00
parent 19180562fc
commit 8a5ef81dcd
54 changed files with 1809 additions and 1861 deletions

View file

@ -8,8 +8,7 @@
package biomesoplenty.api.biome; package biomesoplenty.api.biome;
public enum BiomeOwner public enum BiomeOwner
{ {
BIOMESOPLENTY, BIOMESOPLENTY, OTHER;
OTHER;
} }

View file

@ -10,7 +10,7 @@ package biomesoplenty.api.biome;
import java.util.Map; import java.util.Map;
public interface IExtendedBiome public interface IExtendedBiome
{ {
public BiomeOwner getBiomeOwner(); public BiomeOwner getBiomeOwner();
} }

View file

@ -10,9 +10,11 @@ package biomesoplenty.api.biome;
import java.util.Map; import java.util.Map;
public interface IExtendedDecorator public interface IExtendedDecorator
{ {
public void addGenerator(String key, IGenerator<?> generator); public void addGenerator(String key, IGenerator<?> generator);
public void configureGenerators(Map<String, IGenerator<?>> generatorMap);
public Map<String, IGenerator<?>> getGeneratorMap(); public void configureGenerators(Map<String, IGenerator<?>> generatorMap);
public Map<String, IGenerator<?>> getGeneratorMap();
} }

View file

@ -12,6 +12,7 @@ import com.google.gson.JsonElement;
public interface IGenerator<T> public interface IGenerator<T>
{ {
public JsonElement serialize(IGenerator<T> src); public JsonElement serialize(IGenerator<T> src);
public IGenerator<T> deserialize(JsonElement json);
public IGenerator<T> deserialize(JsonElement json);
} }

View file

@ -25,65 +25,65 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BOPBlock extends Block public abstract class BOPBlock extends Block
{ {
public ImmutableSet<IBlockState> presetStates; public ImmutableSet<IBlockState> presetStates;
protected BOPBlock(Material material) protected BOPBlock(Material material)
{ {
super(material); super(material);
this.setCreativeTab(CreativeTabBOP.instance);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list)
{
if (this.hasPresetProperties())
{
for (IBlockState state : presetStates)
{
list.add(new ItemStack(item, 1, this.getMetaFromState(state)));
}
}
else
{
list.add(new ItemStack(item, 1, 0));
}
}
this.setCreativeTab(CreativeTabBOP.instance);
@Override }
public int damageDropped(IBlockState state)
{ @Override
return this.getMetaFromState(state); @SideOnly(Side.CLIENT)
} public void getSubBlocks(Item item, CreativeTabs tab, List list)
{
public IProperty[] getPresetProperties() if (this.hasPresetProperties())
{ {
return null; for (IBlockState state : presetStates)
} {
list.add(new ItemStack(item, 1, this.getMetaFromState(state)));
public IProperty[] getHiddenProperties() }
{ }
return null; else
} {
list.add(new ItemStack(item, 1, 0));
public boolean hasPresetProperties() }
{ }
return getPresetProperties() != null;
} @Override
public int damageDropped(IBlockState state)
public boolean hasHiddenProperties() {
{ return this.getMetaFromState(state);
return getHiddenProperties() != null; }
}
public IProperty[] getPresetProperties()
public String getStateName(IBlockState state, boolean fullName) {
{ return null;
String unlocalizedName = state.getBlock().getUnlocalizedName(); }
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); public IProperty[] getHiddenProperties()
} {
return null;
}
public boolean hasPresetProperties()
{
return getPresetProperties() != null;
}
public boolean hasHiddenProperties()
{
return getHiddenProperties() != null;
}
public String getStateName(IBlockState state, boolean fullName)
{
String unlocalizedName = state.getBlock().getUnlocalizedName();
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
} }

View file

@ -12,20 +12,20 @@ import net.minecraft.block.Block;
public class BOPBlocks public class BOPBlocks
{ {
public static Block ash_block; public static Block ash_block;
public static Block bamboo; public static Block bamboo;
public static Block bone_segment; public static Block bone_segment;
public static Block coral; public static Block coral;
public static Block flower; public static Block flower;
public static Block flower2; public static Block flower2;
public static Block gem; public static Block gem;
public static Block gem_ore; public static Block gem_ore;
public static Block hive; public static Block hive;
public static Block log; public static Block log;
public static Block log2; public static Block log2;
public static Block log3; public static Block log3;
public static Block log4; public static Block log4;
public static Block mushroom; public static Block mushroom;
public static Block planks; public static Block planks;
public static Block stone; public static Block stone;
} }

View file

@ -28,32 +28,32 @@ public class BOPPlant extends BOPBlock
{ {
protected BOPPlant(Material material) protected BOPPlant(Material material)
{ {
super(material); super(material);
this.setTickRandomly(true); this.setTickRandomly(true);
this.setHardness(0.0F); this.setHardness(0.0F);
this.setStepSound(Block.soundTypeGrass); this.setStepSound(Block.soundTypeGrass);
} }
protected BOPPlant() protected BOPPlant()
{ {
this(Material.plants); this(Material.plants);
} }
@Override @Override
public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack) public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack)
{ {
return super.canPlaceBlockOnSide(world, pos, side) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata())); return super.canPlaceBlockOnSide(world, pos, side) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata()));
} }
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{ {
Block ground = world.getBlockState(pos.offsetDown()).getBlock(); Block ground = world.getBlockState(pos.offsetDown()).getBlock();
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland; return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
} }
@Override @Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
{ {
@ -100,11 +100,11 @@ public class BOPPlant extends BOPBlock
{ {
return EnumWorldBlockLayer.CUTOUT; return EnumWorldBlockLayer.CUTOUT;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType() public Block.EnumOffsetType getOffsetType()
{ {
return Block.EnumOffsetType.XZ; return Block.EnumOffsetType.XZ;
} }
} }

View file

@ -26,7 +26,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ModelHelper public class ModelHelper
{ {
public static void registerItem(Item item, int metadata, String itemName) public static void registerItem(Item item, int metadata, String itemName)
{ {
@ -47,14 +47,14 @@ public class ModelHelper
{ {
registerItem(item, 0, itemName); registerItem(item, 0, itemName);
} }
public static ItemModelMesher getItemModelMesher() public static ItemModelMesher getItemModelMesher()
{ {
return Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); return Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
} }
public static BlockModelShapes getBlockModelShapes() public static BlockModelShapes getBlockModelShapes()
{ {
return getItemModelMesher().getModelManager().getBlockModelShapes(); return getItemModelMesher().getModelManager().getBlockModelShapes();
} }
} }

View file

@ -21,36 +21,38 @@ import biomesoplenty.common.asm.transformers.BOPAccessTransformer;
@TransformerExclusions("biomesoplenty.common.asm") @TransformerExclusions("biomesoplenty.common.asm")
public class BOPLoadingPlugin implements IFMLLoadingPlugin public class BOPLoadingPlugin implements IFMLLoadingPlugin
{ {
public BOPLoadingPlugin() public BOPLoadingPlugin()
{ {
MixinBootstrap.init(); MixinBootstrap.init();
MixinEnvironment.getCurrentEnvironment().addConfiguration("mixins.biomesoplenty.json"); MixinEnvironment.getCurrentEnvironment().addConfiguration("mixins.biomesoplenty.json");
} }
@Override @Override
public String[] getASMTransformerClass() public String[] getASMTransformerClass()
{ {
return new String[] { MixinBootstrap.TRANSFORMER_CLASS }; return new String[] { MixinBootstrap.TRANSFORMER_CLASS };
} }
@Override @Override
public String getModContainerClass() public String getModContainerClass()
{ {
return null; return null;
} }
@Override @Override
public String getSetupClass() public String getSetupClass()
{ {
return null; return null;
} }
@Override @Override
public void injectData(Map<String, Object> data) {} public void injectData(Map<String, Object> data)
{
}
@Override @Override
public String getAccessTransformerClass() public String getAccessTransformerClass()
{ {
return BOPAccessTransformer.class.getName(); return BOPAccessTransformer.class.getName();
} }
} }

View file

@ -14,8 +14,8 @@ import net.minecraftforge.fml.common.asm.transformers.AccessTransformer;
public class BOPAccessTransformer extends AccessTransformer public class BOPAccessTransformer extends AccessTransformer
{ {
public BOPAccessTransformer() throws IOException public BOPAccessTransformer() throws IOException
{ {
super("biomesoplenty_at.cfg"); super("biomesoplenty_at.cfg");
} }
} }

View file

@ -29,73 +29,67 @@ public class BlockAsh extends BOPBlock
{ {
public BlockAsh() public BlockAsh()
{ {
super(Material.sand); super(Material.sand);
this.setHardness(0.4F); this.setHardness(0.4F);
//this.setHarvestLevel("shovel", 0); // this.setHarvestLevel("shovel", 0);
this.setStepSound(Block.soundTypeSand); this.setStepSound(Block.soundTypeSand);
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{ {
float heightOffset = 0.125F; float heightOffset = 0.125F;
return new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)((float)(pos.getY() + 1) - heightOffset), (double)(pos.getZ() + 1)); return new AxisAlignedBB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) ((float) (pos.getY() + 1) - heightOffset), (double) (pos.getZ() + 1));
} }
@Override @Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{ {
/*if (entity instanceof EntityPlayer) /*
{ * if (entity instanceof EntityPlayer) { InventoryPlayer inventory =
InventoryPlayer inventory = ((EntityPlayer)entity).inventory; * ((EntityPlayer)entity).inventory;
*
* if (inventory.armorInventory[0] != null &&
* inventory.armorInventory[0].getItem() == BOPCItems.wadingBoots) {
* return; } }
*/
if (inventory.armorInventory[0] != null && inventory.armorInventory[0].getItem() == BOPCItems.wadingBoots) entity.motionX *= 0.4D;
{ entity.motionZ *= 0.4D;
return; }
}
}*/
entity.motionX *= 0.4D; @Override
entity.motionZ *= 0.4D; public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
} {
if (side == EnumFacing.UP)
@Override {
public boolean isFireSource(World world, BlockPos pos, EnumFacing side) return true;
{ }
if (side == EnumFacing.UP) return false;
{ }
return true;
}
return false;
}
/*@Override
public Item getItemDropped(int metadata, Random random, int fortune)
{
return BOPCItems.misc;
}
@Override /*
public int damageDropped(int meta) * @Override public Item getItemDropped(int metadata, Random random, int
{ * fortune) { return BOPCItems.misc; }
return 1; *
}*/ * @Override public int damageDropped(int meta) { return 1; }
*/
@Override
public int quantityDropped(Random random)
{
return 4;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
{
if (random.nextInt(2) == 0)
{
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + random.nextFloat(), pos.getY() + 1.1F, pos.getZ() + random.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
@Override
public int quantityDropped(Random random)
{
return 4;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
{
if (random.nextInt(2) == 0)
{
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + random.nextFloat(), pos.getY() + 1.1F, pos.getZ() + random.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
} }

View file

@ -34,190 +34,181 @@ import biomesoplenty.common.block.BlockBOPLog.LogType;
public class BlockBOPFlower extends BOPPlant public class BlockBOPFlower extends BOPPlant
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class);
public BlockBOPFlower() public BlockBOPFlower()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.CLOVER)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.CLOVER));
} }
@Override @Override
public int getLightValue(IBlockAccess world, BlockPos pos) public int getLightValue(IBlockAccess world, BlockPos pos)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP); FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
switch (type) switch (type)
{ {
case GLOWFLOWER: case GLOWFLOWER:
return 9; return 9;
case ENDERLOTUS: case ENDERLOTUS:
return 5; return 5;
case BURNING_BLOSSOM: case BURNING_BLOSSOM:
return 9; return 9;
default: default:
return super.getLightValue(); return super.getLightValue();
} }
} }
//TODO: Make enderlotus require spectral moss // TODO: Make enderlotus require spectral moss
//TODO: Make bromeliads require hard dirt, hardened clay or sand // TODO: Make bromeliads require hard dirt, hardened clay or sand
//TODO: Make the burning blossom require netherrack or overgrown netherrack // TODO: Make the burning blossom require netherrack or overgrown netherrack
@Override @Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileentity) public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileentity)
{ {
super.harvestBlock(world, player, pos, state, tileentity); super.harvestBlock(world, player, pos, state, tileentity);
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP);
if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears)) FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
{
switch (type) if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears))
{ {
case DEATHBLOOM: switch (type)
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300)); {
break; case DEATHBLOOM:
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300));
case BURNING_BLOSSOM: break;
player.setFire(5);
break; case BURNING_BLOSSOM:
} player.setFire(5);
} break;
}
}
} }
@Override @Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{ {
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP); FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
if (type == FlowerType.BURNING_BLOSSOM)
{
entity.setFire(1);
}
else if (entity instanceof EntityLivingBase && type == FlowerType.DEATHBLOOM)
{
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
}
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]);
}
@Override if (type == FlowerType.BURNING_BLOSSOM)
public int getMetaFromState(IBlockState state) {
{ entity.setFire(1);
int meta = ((FlowerType)state.getValue(VARIANT_PROP)).ordinal(); }
else
if (entity instanceof EntityLivingBase && type == FlowerType.DEATHBLOOM)
{
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
}
}
return meta; @Override
} public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((FlowerType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty[] { VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((FlowerType)state.getValue(VARIANT_PROP)).getName(); return ((FlowerType) state.getValue(VARIANT_PROP)).getName();
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
switch ((FlowerType)state.getValue(VARIANT_PROP)) switch ((FlowerType) state.getValue(VARIANT_PROP))
{ {
case CLOVER: case CLOVER:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F);
break; break;
case ORANGE_COSMOS: case ORANGE_COSMOS:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F);
break; break;
case PINK_DAFFODIL: case PINK_DAFFODIL:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break; break;
case WHITE_ANEMONE: case WHITE_ANEMONE:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F);
break; break;
case DANDELION: case DANDELION:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break; break;
default: default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break; break;
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand) public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
{ {
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP); FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
if (type == FlowerType.DEATHBLOOM) if (type == FlowerType.DEATHBLOOM)
{ {
if (rand.nextInt(4) != 0) world.spawnParticle(EnumParticleTypes.TOWN_AURA, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); if (rand.nextInt(4) != 0)
if (rand.nextInt(4) == 0) world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); world.spawnParticle(EnumParticleTypes.TOWN_AURA, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
} if (rand.nextInt(4) == 0)
else if (type == FlowerType.BURNING_BLOSSOM) world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
{ }
if (rand.nextInt(2) == 0) world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); else
if (rand.nextInt(4) == 0) world.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); if (type == FlowerType.BURNING_BLOSSOM)
} {
if (rand.nextInt(2) == 0)
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
if (rand.nextInt(4) == 0)
world.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
}
} }
//TODO: Readd eyebulb in as a seperate block // TODO: Readd eyebulb in as a seperate block
//TODO: Readd dandelion blowing // TODO: Readd dandelion blowing
public static enum FlowerType implements IStringSerializable public static enum FlowerType implements IStringSerializable
{ {
CLOVER, CLOVER, SWAMPFLOWER, DEATHBLOOM, GLOWFLOWER, BLUE_HYDRANGEA, ORANGE_COSMOS, PINK_DAFFODIL, WILDFLOWER, VIOLET, WHITE_ANEMONE, ENDERLOTUS, BROMELIAD, DANDELION, PINK_HIBISCUS, LILY_OF_THE_VALLEY, BURNING_BLOSSOM;
SWAMPFLOWER,
DEATHBLOOM,
GLOWFLOWER,
BLUE_HYDRANGEA,
ORANGE_COSMOS,
PINK_DAFFODIL,
WILDFLOWER,
VIOLET,
WHITE_ANEMONE,
ENDERLOTUS,
BROMELIAD,
DANDELION,
PINK_HIBISCUS,
LILY_OF_THE_VALLEY,
BURNING_BLOSSOM;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -22,85 +22,80 @@ import net.minecraft.world.World;
public class BlockBOPFlower2 extends BOPPlant public class BlockBOPFlower2 extends BOPPlant
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class);
public BlockBOPFlower2() public BlockBOPFlower2()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.LAVENDER)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.LAVENDER));
} }
@Override @Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{ {
Block ground = world.getBlockState(pos.offsetDown()).getBlock(); Block ground = world.getBlockState(pos.offsetDown()).getBlock();
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP); FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
switch (type) switch (type)
{ {
case MINERS_DELIGHT: case MINERS_DELIGHT:
return ground == Blocks.stone; return ground == Blocks.stone;
default: default:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland; return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
} }
} }
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]);
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta)
{ {
int meta = ((FlowerType)state.getValue(VARIANT_PROP)).ordinal(); return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((FlowerType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
return meta;
}
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty[] { VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((FlowerType)state.getValue(VARIANT_PROP)).getName(); return ((FlowerType) state.getValue(VARIANT_PROP)).getName();
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{ {
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
} }
public static enum FlowerType implements IStringSerializable public static enum FlowerType implements IStringSerializable
{ {
LAVENDER, LAVENDER, GOLDENROD, BLUEBELLS, MINERS_DELIGHT, ICY_IRIS, ROSE;
GOLDENROD,
BLUEBELLS,
MINERS_DELIGHT,
ICY_IRIS,
ROSE;
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -17,72 +17,68 @@ import net.minecraft.util.IStringSerializable;
public class BlockBOPLog extends BlockBOPLogBase public class BlockBOPLog extends BlockBOPLogBase
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog() public BlockBOPLog()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.SACRED_OAK).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.SACRED_OAK).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
} }
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override
public IBlockState getStateFromMeta(int meta)
{
int axis = meta % 3;
int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); @Override
} public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta)
{ {
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal(); int axis = meta % 3;
int type = (meta - axis) / 3;
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal(); return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
} }
@Override
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal();
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
} }
public static enum LogType implements IStringSerializable public static enum LogType implements IStringSerializable
{ {
SACRED_OAK, SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL;
CHERRY,
DARK,
FIR,
ETHEREAL;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override @Override
public String toString() public String getName()
{ {
return getName(); return this.name().toLowerCase();
} }
}
@Override
public String toString()
{
return getName();
}
}
} }

View file

@ -17,72 +17,68 @@ import net.minecraft.util.IStringSerializable;
public class BlockBOPLog2 extends BlockBOPLogBase public class BlockBOPLog2 extends BlockBOPLogBase
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog2() public BlockBOPLog2()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAGIC).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAGIC).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
} }
@Override @Override
public int damageDropped(IBlockState state) public int damageDropped(IBlockState state)
{ {
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP))); return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
} }
@Override @Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta)
{ {
int axis = meta % 3; int axis = meta % 3;
int type = (meta - axis) / 3; int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
} }
@Override @Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state)
{ {
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal(); int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal(); return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal();
} }
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
} }
public static enum LogType implements IStringSerializable public static enum LogType implements IStringSerializable
{ {
MAGIC, MAGIC, MANGROVE, PALM, REDWOOD, WILLOW;
MANGROVE,
PALM,
REDWOOD,
WILLOW;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -17,74 +17,70 @@ import net.minecraft.util.IStringSerializable;
public class BlockBOPLog3 extends BlockBOPLogBase public class BlockBOPLog3 extends BlockBOPLogBase
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog3() public BlockBOPLog3()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.DEAD).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.DEAD).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
} }
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override @Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta)
{ {
int axis = meta % 3; int axis = meta % 3;
int type = (meta - axis) / 3; int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
} }
@Override @Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state)
{ {
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal(); int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal(); return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal();
} }
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
LogType type = (LogType)state.getValue(VARIANT_PROP); LogType type = (LogType) state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != LogType.GIANT_FLOWER_STEM ? "_log" : ""); return type.getName() + (fullName && type != LogType.GIANT_FLOWER_STEM ? "_log" : "");
} }
public static enum LogType implements IStringSerializable public static enum LogType implements IStringSerializable
{ {
DEAD, DEAD, GIANT_FLOWER_STEM, PINE, HELL_BARK, JACARANDA;
GIANT_FLOWER_STEM,
PINE,
HELL_BARK,
JACARANDA;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -18,68 +18,68 @@ import net.minecraft.util.IStringSerializable;
public class BlockBOPLog4 extends BlockBOPLogBase public class BlockBOPLog4 extends BlockBOPLogBase
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog4() public BlockBOPLog4()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAHOGANY).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAHOGANY).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
} }
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override @Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta)
{ {
int axis = meta % 3; int axis = meta % 3;
int type = (meta - axis) / 3; int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
} }
@Override @Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state)
{ {
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal(); int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal(); return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal();
} }
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
} }
public static enum LogType implements IStringSerializable public static enum LogType implements IStringSerializable
{ {
MAHOGANY; MAHOGANY;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -22,18 +22,18 @@ import biomesoplenty.common.util.inventory.CreativeTabBOP;
public abstract class BlockBOPLogBase extends BOPBlock public abstract class BlockBOPLogBase extends BOPBlock
{ {
public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class); public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class);
protected BlockBOPLogBase() protected BlockBOPLogBase()
{ {
super(Material.wood); super(Material.wood);
this.setHarvestLevel("axe", 0); this.setHarvestLevel("axe", 0);
this.setHardness(2.0F); this.setHardness(2.0F);
this.setResistance(5.0F); this.setResistance(5.0F);
this.setStepSound(Block.soundTypeWood); this.setStepSound(Block.soundTypeWood);
} }
@Override @Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int metadata, EntityLivingBase entity) public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int metadata, EntityLivingBase entity)
{ {

View file

@ -22,111 +22,107 @@ import net.minecraft.world.World;
public class BlockBOPMushroom extends BOPPlant public class BlockBOPMushroom extends BOPPlant
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", MushroomType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", MushroomType.class);
public BlockBOPMushroom() public BlockBOPMushroom()
{ {
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, MushroomType.TOADSTOOL)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, MushroomType.TOADSTOOL));
} }
@Override @Override
public int getLightValue(IBlockAccess world, BlockPos pos) public int getLightValue(IBlockAccess world, BlockPos pos)
{ {
IBlockState blockState = world.getBlockState(pos); IBlockState blockState = world.getBlockState(pos);
if ((MushroomType)blockState.getValue(VARIANT_PROP) == MushroomType.GLOWSHROOM) if ((MushroomType) blockState.getValue(VARIANT_PROP) == MushroomType.GLOWSHROOM)
{ {
return 6; return 6;
} }
return super.getLightValue(); return super.getLightValue();
} }
@Override @Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{ {
Block ground = world.getBlockState(pos.offsetDown()).getBlock(); Block ground = world.getBlockState(pos.offsetDown()).getBlock();
MushroomType type = (MushroomType)state.getValue(VARIANT_PROP); MushroomType type = (MushroomType) state.getValue(VARIANT_PROP);
switch (type)
{
//TODO: Make the toadstool, glowshroom, flat mushroom require overgrown netherrack
//TODO: Make flat mushroom, shadow shroom require bopgrass
case TOADSTOOL:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.grass;
case GLOWSHROOM:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.stone || ground == Blocks.netherrack;
case FLAT_MUSHROOM: switch (type)
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium; {
// TODO: Make the toadstool, glowshroom, flat mushroom require overgrown
case SHADOW_SHROOM: // netherrack
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.end_stone; // TODO: Make flat mushroom, shadow shroom require bopgrass
case TOADSTOOL:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.grass;
default: case GLOWSHROOM:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium; return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.stone || ground == Blocks.netherrack;
}
case FLAT_MUSHROOM:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium;
case SHADOW_SHROOM:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium || ground == Blocks.end_stone;
default:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium;
}
} }
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, MushroomType.values()[meta]);
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta)
{ {
int meta = ((MushroomType)state.getValue(VARIANT_PROP)).ordinal(); return this.getDefaultState().withProperty(VARIANT_PROP, MushroomType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((MushroomType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
return meta;
}
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty[] { VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((MushroomType)state.getValue(VARIANT_PROP)).getName(); return ((MushroomType) state.getValue(VARIANT_PROP)).getName();
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{ {
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.4F, 0.7F);
} }
public static enum MushroomType implements IStringSerializable public static enum MushroomType implements IStringSerializable
{ {
TOADSTOOL, TOADSTOOL, PORTOBELLO, BLUE_MILK_CAP, GLOWSHROOM, FLAT_MUSHROOM, SHADOW_SHROOM;
PORTOBELLO,
BLUE_MILK_CAP,
GLOWSHROOM,
FLAT_MUSHROOM,
SHADOW_SHROOM;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -19,82 +19,68 @@ import biomesoplenty.api.block.BOPBlock;
public class BlockBOPPlanks extends BOPBlock public class BlockBOPPlanks extends BOPBlock
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", PlankType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", PlankType.class);
public BlockBOPPlanks() public BlockBOPPlanks()
{ {
super(Material.wood); super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK));
this.setHarvestLevel("axe", 0); this.setHarvestLevel("axe", 0);
this.setHardness(2.0F); this.setHardness(2.0F);
this.setStepSound(Block.soundTypeWood); this.setStepSound(Block.soundTypeWood);
} }
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, PlankType.values()[meta]);
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta)
{ {
int meta = ((PlankType)state.getValue(VARIANT_PROP)).ordinal(); return this.getDefaultState().withProperty(VARIANT_PROP, PlankType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((PlankType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
return meta;
}
@Override @Override
protected BlockState createBlockState() protected BlockState createBlockState()
{ {
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty[] { VARIANT_PROP });
} }
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override
public String getStateName(IBlockState state, boolean fullName)
{
PlankType type = (PlankType)state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != PlankType.BAMBOO_THATCHING ? "_planks" : "");
}
public static enum PlankType implements IStringSerializable @Override
{ public String getStateName(IBlockState state, boolean fullName)
SACRED_OAK, {
CHERRY, PlankType type = (PlankType) state.getValue(VARIANT_PROP);
DARK,
FIR, return type.getName() + (fullName && type != PlankType.BAMBOO_THATCHING ? "_planks" : "");
ETHEREAL, }
MAGIC,
MANGROVE, public static enum PlankType implements IStringSerializable
PALM, {
REDWOOD, SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL, MAGIC, MANGROVE, PALM, REDWOOD, WILLOW, BAMBOO_THATCHING, PINE, HELL_BARK, JACARANDA, MAHOGANY;
WILLOW,
BAMBOO_THATCHING,
PINE,
HELL_BARK,
JACARANDA,
MAHOGANY;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -23,105 +23,105 @@ import net.minecraft.world.World;
public class BlockBOPStone extends BOPBlock public class BlockBOPStone extends BOPBlock
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", StoneType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", StoneType.class);
public static PropertyBool POLISHED_PROP = PropertyBool.create("polished"); public static PropertyBool POLISHED_PROP = PropertyBool.create("polished");
public BlockBOPStone() public BlockBOPStone()
{ {
super(Material.rock); super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, StoneType.LIMESTONE).withProperty(POLISHED_PROP, Boolean.valueOf(false))); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, StoneType.LIMESTONE).withProperty(POLISHED_PROP, Boolean.valueOf(false)));
this.setHarvestLevel("pickaxe", 1, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.LIMESTONE)); this.setHarvestLevel("pickaxe", 1, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.LIMESTONE));
this.setHarvestLevel("pickaxe", 2, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SILTSTONE)); this.setHarvestLevel("pickaxe", 2, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SILTSTONE));
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SHALE)); this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SHALE));
} }
@Override @Override
public float getBlockHardness(World world, BlockPos pos) public float getBlockHardness(World world, BlockPos pos)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this) if (state.getBlock() == this)
{ {
boolean polished = (Boolean)state.getValue(POLISHED_PROP); boolean polished = (Boolean) state.getValue(POLISHED_PROP);
if (polished) return 1.5F; if (polished)
return 3.0F; return 1.5F;
} return 3.0F;
}
return super.getBlockHardness(world, pos); return super.getBlockHardness(world, pos);
} }
@Override @Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this) if (state.getBlock() == this)
{ {
boolean polished = (Boolean)state.getValue(POLISHED_PROP); boolean polished = (Boolean) state.getValue(POLISHED_PROP);
if (polished) return 7.0F; if (polished)
return 5.0F; return 7.0F;
} return 5.0F;
}
return super.getExplosionResistance(world, pos, exploder, explosion); return super.getExplosionResistance(world, pos, exploder, explosion);
} }
@Override
public IBlockState getStateFromMeta(int meta)
{
boolean polished = (meta & 8) > 0;
int type = meta & 3;
return this.getDefaultState().withProperty(VARIANT_PROP, StoneType.values()[type]).withProperty(POLISHED_PROP, Boolean.valueOf(polished)); @Override
} public IBlockState getStateFromMeta(int meta)
{
boolean polished = (meta & 8) > 0;
int type = meta & 3;
@Override return this.getDefaultState().withProperty(VARIANT_PROP, StoneType.values()[type]).withProperty(POLISHED_PROP, Boolean.valueOf(polished));
public int getMetaFromState(IBlockState state) }
{
int baseMeta = ((StoneType)state.getValue(VARIANT_PROP)).ordinal(); @Override
boolean polished = (Boolean)state.getValue(POLISHED_PROP); public int getMetaFromState(IBlockState state)
{
return polished ? baseMeta | 8 : baseMeta; int baseMeta = ((StoneType) state.getValue(VARIANT_PROP)).ordinal();
} boolean polished = (Boolean) state.getValue(POLISHED_PROP);
return polished ? baseMeta | 8 : baseMeta;
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP, POLISHED_PROP });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP, POLISHED_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP, POLISHED_PROP }; return new IProperty[] { VARIANT_PROP, POLISHED_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
boolean polished = (Boolean)state.getValue(POLISHED_PROP); boolean polished = (Boolean) state.getValue(POLISHED_PROP);
return (fullName && polished ? "polished_" : "") + ((StoneType)state.getValue(VARIANT_PROP)).getName(); return (fullName && polished ? "polished_" : "") + ((StoneType) state.getValue(VARIANT_PROP)).getName();
} }
public static enum StoneType implements IStringSerializable public static enum StoneType implements IStringSerializable
{ {
LIMESTONE, LIMESTONE, SILTSTONE, SHALE;
SILTSTONE,
SHALE;
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -23,30 +23,30 @@ public class BlockBamboo extends BOPPlant
{ {
public BlockBamboo() public BlockBamboo()
{ {
this.setHardness(0.2F); this.setHardness(0.2F);
this.setStepSound(Block.soundTypeWood); this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 1.0F, 0.6875F); this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
} }
@Override @Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{ {
Block ground = world.getBlockState(pos.offsetDown()).getBlock(); Block ground = world.getBlockState(pos.offsetDown()).getBlock();
return ground == Blocks.grass || ground == Blocks.dirt || ground == this; return ground == Blocks.grass || ground == Blocks.dirt || ground == this;
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{ {
return new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ); return new AxisAlignedBB((double) pos.getX() + this.minX, (double) pos.getY() + this.minY, (double) pos.getZ() + this.minZ, (double) pos.getX() + this.maxX, (double) pos.getY() + this.maxY, (double) pos.getZ() + this.maxZ);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType() public Block.EnumOffsetType getOffsetType()
{ {
return Block.EnumOffsetType.NONE; return Block.EnumOffsetType.NONE;
} }
} }

View file

@ -27,67 +27,67 @@ import biomesoplenty.api.block.BOPBlock;
public class BlockBones extends BOPBlock public class BlockBones extends BOPBlock
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", BoneType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", BoneType.class);
public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class); public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class);
public BlockBones() public BlockBones()
{ {
super(Material.rock); super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, BoneType.SMALL).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, BoneType.SMALL).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
this.setHardness(3.0F); this.setHardness(3.0F);
this.setResistance(5.0F); this.setResistance(5.0F);
this.setStepSound(Block.soundTypeStone); this.setStepSound(Block.soundTypeStone);
} }
@Override @Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int metadata, EntityLivingBase entity) public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int metadata, EntityLivingBase entity)
{ {
return super.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, metadata, entity).withProperty(AXIS_PROP, side.getAxis()); return super.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, metadata, entity).withProperty(AXIS_PROP, side.getAxis());
} }
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override
public IBlockState getStateFromMeta(int meta)
{
int axis = meta % 3;
int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, BoneType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); @Override
} public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta)
{ {
int baseMeta = ((BoneType)state.getValue(VARIANT_PROP)).ordinal(); int axis = meta % 3;
int type = (meta - axis) / 3;
return this.getDefaultState().withProperty(VARIANT_PROP, BoneType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((BoneType) state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal();
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
}
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal();
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((BoneType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_bone_segment" : ""); return ((BoneType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_bone_segment" : "");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
@ -102,54 +102,55 @@ public class BlockBones extends BOPBlock
this.setBlockBoundsBasedOnState(worldIn, pos); this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state); return super.getCollisionBoundingBox(worldIn, pos, state);
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this) return; if (state.getBlock() != this)
return;
float width;
float width;
switch ((BoneType)state.getValue(VARIANT_PROP))
{ switch ((BoneType) state.getValue(VARIANT_PROP))
case SMALL: {
width = 0.25F; case SMALL:
break; width = 0.25F;
break;
case MEDIUM:
width = 0.625F; case MEDIUM:
break; width = 0.625F;
break;
case LARGE:
width = 1F; case LARGE:
break; width = 1F;
break;
default:
width = 1F; default:
break; width = 1F;
} break;
}
float min = (1.0F - width) / 2F;
float max = 1.0F - min; float min = (1.0F - width) / 2F;
float max = 1.0F - min;
switch ((EnumFacing.Axis)state.getValue(AXIS_PROP))
{ switch ((EnumFacing.Axis) state.getValue(AXIS_PROP))
case X: {
this.setBlockBounds(0F, min, min, 1.0F, max, max); case X:
break; this.setBlockBounds(0F, min, min, 1.0F, max, max);
break;
case Y:
this.setBlockBounds(min, 0F, min, max, 1.0F, max); case Y:
break; this.setBlockBounds(min, 0F, min, max, 1.0F, max);
break;
case Z:
this.setBlockBounds(min, min, 0F, max, max, 1.0F); case Z:
break; this.setBlockBounds(min, min, 0F, max, max, 1.0F);
} break;
}
} }
@Override @Override
public boolean isOpaqueCube() public boolean isOpaqueCube()
{ {
@ -161,23 +162,21 @@ public class BlockBones extends BOPBlock
{ {
return false; return false;
} }
public static enum BoneType implements IStringSerializable
{
SMALL,
MEDIUM,
LARGE;
@Override public static enum BoneType implements IStringSerializable
public String getName() {
{ SMALL, MEDIUM, LARGE;
return this.name().toLowerCase();
}
@Override @Override
public String toString() public String getName()
{ {
return getName(); return this.name().toLowerCase();
} }
}
@Override
public String toString()
{
return getName();
}
}
} }

View file

@ -25,101 +25,96 @@ import biomesoplenty.api.block.BOPPlant;
public class BlockCoral extends BOPPlant public class BlockCoral extends BOPPlant
{ {
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", CoralType.class); public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", CoralType.class);
public BlockCoral() public BlockCoral()
{ {
super(Material.water); super(Material.water);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, CoralType.PINK)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, CoralType.PINK));
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
} }
@Override @Override
public int getLightValue(IBlockAccess world, BlockPos pos) public int getLightValue(IBlockAccess world, BlockPos pos)
{ {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
if ((CoralType)state.getValue(VARIANT_PROP) == CoralType.GLOWING) if ((CoralType) state.getValue(VARIANT_PROP) == CoralType.GLOWING)
{ {
return 10; return 10;
} }
return super.getLightValue(); return super.getLightValue();
} }
@Override @Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{ {
Block ground = world.getBlockState(pos.offsetDown()).getBlock(); Block ground = world.getBlockState(pos.offsetDown()).getBlock();
Block cover = world.getBlockState(pos.offsetUp()).getBlock(); Block cover = world.getBlockState(pos.offsetUp()).getBlock();
boolean hasWater = cover == Blocks.water || cover == Blocks.flowing_water; boolean hasWater = cover == Blocks.water || cover == Blocks.flowing_water;
//TODO: Make all types depend on mud // TODO: Make all types depend on mud
return hasWater && return hasWater && (ground == Blocks.dirt || ground == Blocks.sand || ground == Blocks.sponge || ground == Blocks.stone || ground == Blocks.clay || ground == Blocks.gravel || ground == Blocks.grass);
(ground == Blocks.dirt || ground == Blocks.sand || ground == Blocks.sponge || ground == Blocks.stone || ground == Blocks.clay || ground == Blocks.gravel || ground == Blocks.grass);
} }
@Override @Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta)
{ {
return this.getDefaultState().withProperty(VARIANT_PROP, CoralType.values()[meta]).withProperty(LEVEL, 15); return this.getDefaultState().withProperty(VARIANT_PROP, CoralType.values()[meta]).withProperty(LEVEL, 15);
} }
@Override @Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state)
{ {
int meta = ((CoralType)state.getValue(VARIANT_PROP)).ordinal(); int meta = ((CoralType) state.getValue(VARIANT_PROP)).ordinal();
return meta; return meta;
} }
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP, LEVEL });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP, LEVEL });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public IProperty[] getHiddenProperties() public IProperty[] getHiddenProperties()
{ {
return new IProperty[] { LEVEL }; return new IProperty[] { LEVEL };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
CoralType type = (CoralType)state.getValue(VARIANT_PROP); CoralType type = (CoralType) state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != CoralType.ALGAE ? "_coral" : ""); return type.getName() + (fullName && type != CoralType.ALGAE ? "_coral" : "");
} }
//TODO: Readd kelp // TODO: Readd kelp
public static enum CoralType implements IStringSerializable public static enum CoralType implements IStringSerializable
{ {
PINK, PINK, ORANGE, BLUE, GLOWING, ALGAE;
ORANGE,
BLUE,
GLOWING,
ALGAE;
@Override @Override
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -21,80 +21,73 @@ import net.minecraft.util.IStringSerializable;
//TODO: Add gem ore drops, make gem item seperate //TODO: Add gem ore drops, make gem item seperate
public class BlockGem extends BOPBlock public class BlockGem extends BOPBlock
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", GemType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", GemType.class);
public BlockGem()
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
for (IBlockState state : presetStates)
{
this.setHarvestLevel("pickaxe", 2, state);
}
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.setHardness(5.0F);
this.setResistance(10.0F);
this.setStepSound(Block.soundTypeMetal);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, GemType.values()[meta]);
}
@Override public BlockGem()
public int getMetaFromState(IBlockState state) {
{ super(Material.rock);
int meta = ((GemType)state.getValue(VARIANT_PROP)).ordinal();
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
return meta;
} this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
for (IBlockState state : presetStates)
{
this.setHarvestLevel("pickaxe", 2, state);
}
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.setHardness(5.0F);
this.setResistance(10.0F);
this.setStepSound(Block.soundTypeMetal);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, GemType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((GemType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((GemType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_block" : ""); return ((GemType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_block" : "");
} }
public static enum GemType implements IStringSerializable public static enum GemType implements IStringSerializable
{ {
AMETHYST, AMETHYST, RUBY, PERIDOT, TOPAZ, TANZANITE, MALACHITE, SAPPHIRE, AMBER;
RUBY,
PERIDOT,
TOPAZ,
TANZANITE,
MALACHITE,
SAPPHIRE,
AMBER;
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -20,53 +20,53 @@ import net.minecraft.block.state.IBlockState;
public class BlockGemOre extends BOPBlock public class BlockGemOre extends BOPBlock
{ {
public BlockGemOre() public BlockGemOre()
{ {
super(Material.rock); super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
for (IBlockState state : presetStates)
{
this.setHarvestLevel("pickaxe", 2, state);
}
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypePiston);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, GemType.values()[meta]);
}
@Override this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
public int getMetaFromState(IBlockState state)
{ this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
int meta = ((GemType)state.getValue(VARIANT_PROP)).ordinal();
for (IBlockState state : presetStates)
return meta; {
} this.setHarvestLevel("pickaxe", 2, state);
}
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypePiston);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, GemType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((GemType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((GemType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_ore" : ""); return ((GemType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_ore" : "");
} }
} }

View file

@ -18,68 +18,65 @@ import net.minecraft.util.IStringSerializable;
import biomesoplenty.api.block.BOPBlock; import biomesoplenty.api.block.BOPBlock;
//TODO: Add wasp spawn on honeycomb breaking, add correct drops //TODO: Add wasp spawn on honeycomb breaking, add correct drops
public class BlockHive extends BOPBlock public class BlockHive extends BOPBlock
{ {
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", HiveType.class); public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", HiveType.class);
public BlockHive()
{
super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, HiveType.HIVE));
this.setHardness(0.5F);
this.setStepSound(Block.soundTypeGrass);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, HiveType.values()[meta]);
}
@Override public BlockHive()
public int getMetaFromState(IBlockState state) {
{ super(Material.wood);
int meta = ((HiveType)state.getValue(VARIANT_PROP)).ordinal();
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, HiveType.HIVE));
return meta;
} this.setHardness(0.5F);
this.setStepSound(Block.soundTypeGrass);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, HiveType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((HiveType) state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override @Override
public IProperty[] getPresetProperties() public IProperty[] getPresetProperties()
{ {
return new IProperty[] { VARIANT_PROP }; return new IProperty[] { VARIANT_PROP };
} }
@Override @Override
public String getStateName(IBlockState state, boolean fullName) public String getStateName(IBlockState state, boolean fullName)
{ {
return ((HiveType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_block" : ""); return ((HiveType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_block" : "");
} }
public static enum HiveType implements IStringSerializable public static enum HiveType implements IStringSerializable
{ {
HIVE, HIVE, HONEYCOMB, EMPTY_HONEYCOMB, FILLED_HONEYCOMB;
HONEYCOMB,
EMPTY_HONEYCOMB,
FILLED_HONEYCOMB;
public String getName() public String getName()
{ {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override @Override
public String toString() public String toString()
{ {
return getName(); return getName();
} }
} }
} }

View file

@ -8,6 +8,7 @@
package biomesoplenty.common.block; package biomesoplenty.common.block;
public class BlockSegmentedCoral { public class BlockSegmentedCoral
{
} }

View file

@ -28,139 +28,139 @@ import biomesoplenty.common.util.config.JsonEntitySpawn;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
public class BiomeConfigurationHandler public class BiomeConfigurationHandler
{ {
private static HashMap<BiomeGenBase, String> configFileMap = new HashMap(); private static HashMap<BiomeGenBase, String> configFileMap = new HashMap();
public static void init(File configDirectory) public static void init(File configDirectory)
{ {
registerConfigurableBiomes(); registerConfigurableBiomes();
load(configDirectory); load(configDirectory);
} }
private static void registerConfigurableBiomes() private static void registerConfigurableBiomes()
{ {
registerConfigurableBiome(BiomeGenBase.ocean, "ocean"); registerConfigurableBiome(BiomeGenBase.ocean, "ocean");
registerConfigurableBiome(BiomeGenBase.plains, "plains"); registerConfigurableBiome(BiomeGenBase.plains, "plains");
registerConfigurableBiome(BiomeGenBase.desert, "desert"); registerConfigurableBiome(BiomeGenBase.desert, "desert");
registerConfigurableBiome(BiomeGenBase.extremeHills, "extreme_hills"); registerConfigurableBiome(BiomeGenBase.extremeHills, "extreme_hills");
registerConfigurableBiome(BiomeGenBase.forest, "forest"); registerConfigurableBiome(BiomeGenBase.forest, "forest");
registerConfigurableBiome(BiomeGenBase.taiga, "taiga"); registerConfigurableBiome(BiomeGenBase.taiga, "taiga");
registerConfigurableBiome(BiomeGenBase.swampland, "swampland"); registerConfigurableBiome(BiomeGenBase.swampland, "swampland");
registerConfigurableBiome(BiomeGenBase.river, "river"); registerConfigurableBiome(BiomeGenBase.river, "river");
registerConfigurableBiome(BiomeGenBase.hell, "hell"); registerConfigurableBiome(BiomeGenBase.hell, "hell");
registerConfigurableBiome(BiomeGenBase.sky, "sky"); registerConfigurableBiome(BiomeGenBase.sky, "sky");
registerConfigurableBiome(BiomeGenBase.frozenOcean, "frozen_ocean"); registerConfigurableBiome(BiomeGenBase.frozenOcean, "frozen_ocean");
registerConfigurableBiome(BiomeGenBase.frozenRiver, "frozen_river"); registerConfigurableBiome(BiomeGenBase.frozenRiver, "frozen_river");
registerConfigurableBiome(BiomeGenBase.icePlains, "ice_plains"); registerConfigurableBiome(BiomeGenBase.icePlains, "ice_plains");
registerConfigurableBiome(BiomeGenBase.iceMountains, "ice_mountains"); registerConfigurableBiome(BiomeGenBase.iceMountains, "ice_mountains");
registerConfigurableBiome(BiomeGenBase.mushroomIsland, "mushroom_island"); registerConfigurableBiome(BiomeGenBase.mushroomIsland, "mushroom_island");
registerConfigurableBiome(BiomeGenBase.mushroomIslandShore, "mushroom_island_shore"); registerConfigurableBiome(BiomeGenBase.mushroomIslandShore, "mushroom_island_shore");
registerConfigurableBiome(BiomeGenBase.beach, "beach"); registerConfigurableBiome(BiomeGenBase.beach, "beach");
registerConfigurableBiome(BiomeGenBase.desertHills, "beach_hills"); registerConfigurableBiome(BiomeGenBase.desertHills, "beach_hills");
registerConfigurableBiome(BiomeGenBase.forestHills, "forest_hills"); registerConfigurableBiome(BiomeGenBase.forestHills, "forest_hills");
registerConfigurableBiome(BiomeGenBase.taigaHills, "taiga_hills"); registerConfigurableBiome(BiomeGenBase.taigaHills, "taiga_hills");
registerConfigurableBiome(BiomeGenBase.extremeHillsEdge, "extreme_hills_edge"); registerConfigurableBiome(BiomeGenBase.extremeHillsEdge, "extreme_hills_edge");
registerConfigurableBiome(BiomeGenBase.jungle, "jungle"); registerConfigurableBiome(BiomeGenBase.jungle, "jungle");
registerConfigurableBiome(BiomeGenBase.jungleHills, "jungle_hills"); registerConfigurableBiome(BiomeGenBase.jungleHills, "jungle_hills");
registerConfigurableBiome(BiomeGenBase.jungleEdge, "jungle_edge"); registerConfigurableBiome(BiomeGenBase.jungleEdge, "jungle_edge");
registerConfigurableBiome(BiomeGenBase.deepOcean, "deep_ocean"); registerConfigurableBiome(BiomeGenBase.deepOcean, "deep_ocean");
registerConfigurableBiome(BiomeGenBase.stoneBeach, "stone_beach"); registerConfigurableBiome(BiomeGenBase.stoneBeach, "stone_beach");
registerConfigurableBiome(BiomeGenBase.coldBeach, "cold_beach"); registerConfigurableBiome(BiomeGenBase.coldBeach, "cold_beach");
registerConfigurableBiome(BiomeGenBase.birchForest, "birch_forest"); registerConfigurableBiome(BiomeGenBase.birchForest, "birch_forest");
registerConfigurableBiome(BiomeGenBase.birchForestHills, "birch_forest_hills"); registerConfigurableBiome(BiomeGenBase.birchForestHills, "birch_forest_hills");
registerConfigurableBiome(BiomeGenBase.roofedForest, "roofed_forest"); registerConfigurableBiome(BiomeGenBase.roofedForest, "roofed_forest");
registerConfigurableBiome(BiomeGenBase.coldTaiga, "cold_taiga"); registerConfigurableBiome(BiomeGenBase.coldTaiga, "cold_taiga");
registerConfigurableBiome(BiomeGenBase.coldTaigaHills, "cold_taiga_hills"); registerConfigurableBiome(BiomeGenBase.coldTaigaHills, "cold_taiga_hills");
registerConfigurableBiome(BiomeGenBase.megaTaiga, "mega_taiga"); registerConfigurableBiome(BiomeGenBase.megaTaiga, "mega_taiga");
registerConfigurableBiome(BiomeGenBase.megaTaigaHills, "mega_taiga_hills"); registerConfigurableBiome(BiomeGenBase.megaTaigaHills, "mega_taiga_hills");
registerConfigurableBiome(BiomeGenBase.extremeHillsPlus, "extreme_hills_plus"); registerConfigurableBiome(BiomeGenBase.extremeHillsPlus, "extreme_hills_plus");
registerConfigurableBiome(BiomeGenBase.savanna, "savanna"); registerConfigurableBiome(BiomeGenBase.savanna, "savanna");
registerConfigurableBiome(BiomeGenBase.savannaPlateau, "savanna_plateau"); registerConfigurableBiome(BiomeGenBase.savannaPlateau, "savanna_plateau");
registerConfigurableBiome(BiomeGenBase.mesa, "mesa"); registerConfigurableBiome(BiomeGenBase.mesa, "mesa");
registerConfigurableBiome(BiomeGenBase.mesaPlateau_F, "mesa_plateau_f"); registerConfigurableBiome(BiomeGenBase.mesaPlateau_F, "mesa_plateau_f");
registerConfigurableBiome(BiomeGenBase.mesaPlateau, "mesa_plateau"); registerConfigurableBiome(BiomeGenBase.mesaPlateau, "mesa_plateau");
} }
private static void load(File configDirectory) private static void load(File configDirectory)
{ {
for (Entry<BiomeGenBase, String> entry : configFileMap.entrySet()) for (Entry<BiomeGenBase, String> entry : configFileMap.entrySet())
{ {
BiomeGenBase biome = entry.getKey(); BiomeGenBase biome = entry.getKey();
String configFileName = entry.getValue(); String configFileName = entry.getValue();
File configFile = new File(configDirectory, configFileName + ".json"); File configFile = new File(configDirectory, configFileName + ".json");
if (configFile.exists()) if (configFile.exists())
{ {
try try
{ {
JsonBiome jsonBiome = JsonBiome.serializer.fromJson(FileUtils.readFileToString(configFile), JsonBiome.class); JsonBiome jsonBiome = JsonBiome.serializer.fromJson(FileUtils.readFileToString(configFile), JsonBiome.class);
configureBiomeWithJson(biome, jsonBiome); configureBiomeWithJson(biome, jsonBiome);
} }
catch (JsonSyntaxException e) catch (JsonSyntaxException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
else else
{ {
try try
{ {
FileUtils.write(configFile, JsonBiome.serializer.toJson(JsonBiome.createFromBiomeGenBase(biome), JsonBiome.class)); FileUtils.write(configFile, JsonBiome.serializer.toJson(JsonBiome.createFromBiomeGenBase(biome), JsonBiome.class));
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
public static void registerConfigurableBiome(BiomeGenBase biome, String configFileName) public static void registerConfigurableBiome(BiomeGenBase biome, String configFileName)
{ {
translateVanillaValues(biome); translateVanillaValues(biome);
configFileMap.put(biome, configFileName); configFileMap.put(biome, configFileName);
} }
private static void translateVanillaValues(BiomeGenBase biome) private static void translateVanillaValues(BiomeGenBase biome)
{ {
IExtendedBiome extendedBiome = (IExtendedBiome)biome; IExtendedBiome extendedBiome = (IExtendedBiome) biome;
IExtendedDecorator extendedDecorator = (IExtendedDecorator)biome.theBiomeDecorator; IExtendedDecorator extendedDecorator = (IExtendedDecorator) biome.theBiomeDecorator;
if (extendedBiome.getBiomeOwner() == BiomeOwner.OTHER) if (extendedBiome.getBiomeOwner() == BiomeOwner.OTHER)
{ {
if (biome.theBiomeDecorator.cactiPerChunk > 0) if (biome.theBiomeDecorator.cactiPerChunk > 0)
{ {
WorldGenCactus cactusGen = new WorldGenCactus(); WorldGenCactus cactusGen = new WorldGenCactus();
IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen)cactusGen; IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen) cactusGen;
extendedCactusGen.setCactiPerChunk(biome.theBiomeDecorator.cactiPerChunk); extendedCactusGen.setCactiPerChunk(biome.theBiomeDecorator.cactiPerChunk);
extendedDecorator.addGenerator("cactus", extendedCactusGen); extendedDecorator.addGenerator("cactus", extendedCactusGen);
} }
} }
} }
private static void configureBiomeWithJson(BiomeGenBase biome, JsonBiome jsonBiome) private static void configureBiomeWithJson(BiomeGenBase biome, JsonBiome jsonBiome)
{ {
//TODO: Reflect and modify biome id biome.biomeId = jsonBiome.biomeID; // TODO: Reflect and modify biome id biome.biomeId = jsonBiome.biomeID;
biome.biomeName = jsonBiome.biomeName; biome.biomeName = jsonBiome.biomeName;
biome.topBlock = jsonBiome.topBlock; biome.topBlock = jsonBiome.topBlock;
biome.fillerBlock = jsonBiome.fillerBlock; biome.fillerBlock = jsonBiome.fillerBlock;
biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation)); biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation));
biome.temperature = jsonBiome.temperature; biome.temperature = jsonBiome.temperature;
biome.rainfall = jsonBiome.rainfall; biome.rainfall = jsonBiome.rainfall;
//TODO: Reflect and modify enableRain and enableSnow // TODO: Reflect and modify enableRain and enableSnow
biome.color = jsonBiome.color; biome.color = jsonBiome.color;
biome.waterColorMultiplier = jsonBiome.waterColorMultiplier; biome.waterColorMultiplier = jsonBiome.waterColorMultiplier;
JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome); JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome);
IExtendedDecorator extendedDecorator = (IExtendedDecorator)biome.theBiomeDecorator; IExtendedDecorator extendedDecorator = (IExtendedDecorator) biome.theBiomeDecorator;
extendedDecorator.configureGenerators(jsonBiome.decoration); extendedDecorator.configureGenerators(jsonBiome.decoration);
} }
} }

View file

@ -13,6 +13,7 @@ import biomesoplenty.api.biome.IGenerator;
public interface IExtendedCactusGen extends IGenerator<WorldGenCactus> public interface IExtendedCactusGen extends IGenerator<WorldGenCactus>
{ {
public void setCactiPerChunk(int amount); public void setCactiPerChunk(int amount);
public int getCactiPerChunk();
public int getCactiPerChunk();
} }

View file

@ -12,16 +12,16 @@ import net.minecraft.client.renderer.BlockModelShapes;
import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.Event;
/** /**
* Called upon the construction of BlockModelShapes after the registration * Called upon the construction of BlockModelShapes after the registration of
* of Vanilla blocks. This event should be used as an opportunity to register * Vanilla blocks. This event should be used as an opportunity to register any
* any custom state mappings for modded blocks. * custom state mappings for modded blocks.
*/ */
public class BlockModelRegisterEvent extends Event public class BlockModelRegisterEvent extends Event
{ {
public final BlockModelShapes modelShapes; public final BlockModelShapes modelShapes;
public BlockModelRegisterEvent(BlockModelShapes modelShapes) public BlockModelRegisterEvent(BlockModelShapes modelShapes)
{ {
this.modelShapes = modelShapes; this.modelShapes = modelShapes;
} }
} }

View file

@ -24,23 +24,23 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import biomesoplenty.api.block.BOPBlocks; import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.event.BlockModelRegisterEvent; import biomesoplenty.common.event.BlockModelRegisterEvent;
public class BlockModelRegisterEventHandler public class BlockModelRegisterEventHandler
{ {
private static Map<Block, Set<IProperty>> hiddenProperties = Maps.newHashMap(); private static Map<Block, Set<IProperty>> hiddenProperties = Maps.newHashMap();
@SubscribeEvent @SubscribeEvent
public void onBlockModelRegister(BlockModelRegisterEvent event) public void onBlockModelRegister(BlockModelRegisterEvent event)
{ {
BlockModelShapes modelShapes = event.modelShapes; BlockModelShapes modelShapes = event.modelShapes;
for (Entry<Block, Set<IProperty>> entry : hiddenProperties.entrySet()) for (Entry<Block, Set<IProperty>> entry : hiddenProperties.entrySet())
{ {
modelShapes.func_178121_a(entry.getKey(), (new StateMap.Builder()).func_178442_a(entry.getValue().toArray(new IProperty[] {})).build()); modelShapes.func_178121_a(entry.getKey(), (new StateMap.Builder()).func_178442_a(entry.getValue().toArray(new IProperty[] {})).build());
} }
} }
public static void addHiddenProperties(Block block, IProperty... properties) public static void addHiddenProperties(Block block, IProperty... properties)
{ {
hiddenProperties.put(block, Sets.newHashSet(properties)); hiddenProperties.put(block, Sets.newHashSet(properties));
} }
} }

View file

@ -20,33 +20,33 @@ import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class DrawScreenEventHandler public class DrawScreenEventHandler
{ {
public static int blockCount = 0; public static int blockCount = 0;
@SubscribeEvent @SubscribeEvent
public void onDrawScreen(DrawScreenEvent.Post event) public void onDrawScreen(DrawScreenEvent.Post event)
{ {
GuiScreen screenGui = event.gui; GuiScreen screenGui = event.gui;
if (screenGui instanceof GuiCreateWorld) if (screenGui instanceof GuiCreateWorld)
{ {
GuiCreateWorld createWorldGui = (GuiCreateWorld)screenGui; GuiCreateWorld createWorldGui = (GuiCreateWorld) screenGui;
GuiButton mapTypeButton = createWorldGui.field_146320_D; GuiButton mapTypeButton = createWorldGui.field_146320_D;
int worldTypeIndex = createWorldGui.field_146331_K; int worldTypeIndex = createWorldGui.field_146331_K;
if (mapTypeButton.isMouseOver() && WorldType.worldTypes[worldTypeIndex] == ModBiomes.worldTypeBOP) if (mapTypeButton.isMouseOver() && WorldType.worldTypes[worldTypeIndex] == ModBiomes.worldTypeBOP)
{ {
List text = new ArrayList<String>(); List text = new ArrayList<String>();
text.add("Progress:"); text.add("Progress:");
text.add("Blocks: " + blockCount); text.add("Blocks: " + blockCount);
text.add("Items: 0"); text.add("Items: 0");
text.add("Entities: 0"); text.add("Entities: 0");
text.add("Biomes: 0"); text.add("Biomes: 0");
createWorldGui.drawHoveringText(text, event.mouseX, event.mouseY); createWorldGui.drawHoveringText(text, event.mouseX, event.mouseY);
} }
} }
} }
} }

View file

@ -10,12 +10,12 @@ package biomesoplenty.common.init;
import biomesoplenty.common.world.WorldTypeBOP; import biomesoplenty.common.world.WorldTypeBOP;
public class ModBiomes public class ModBiomes
{ {
public static WorldTypeBOP worldTypeBOP; public static WorldTypeBOP worldTypeBOP;
public static void init() public static void init()
{ {
worldTypeBOP = new WorldTypeBOP(); worldTypeBOP = new WorldTypeBOP();
} }
} }

View file

@ -42,58 +42,60 @@ import biomesoplenty.core.BiomesOPlenty;
public class ModBlocks public class ModBlocks
{ {
public static void init() public static void init()
{ {
ash_block = registerBlock(new BlockAsh(), "ash_block"); ash_block = registerBlock(new BlockAsh(), "ash_block");
bamboo = registerBlock(new BlockBamboo(), "bamboo"); bamboo = registerBlock(new BlockBamboo(), "bamboo");
bone_segment = registerBlock(new BlockBones(), "bone_segment"); bone_segment = registerBlock(new BlockBones(), "bone_segment");
coral = registerBlock(new BlockCoral(), "coral"); coral = registerBlock(new BlockCoral(), "coral");
flower = registerBlock(new BlockBOPFlower(), "flower"); flower = registerBlock(new BlockBOPFlower(), "flower");
flower2 = registerBlock(new BlockBOPFlower2(), "flower2"); flower2 = registerBlock(new BlockBOPFlower2(), "flower2");
gem = registerBlock(new BlockGem(), "gem"); gem = registerBlock(new BlockGem(), "gem");
gem_ore = registerBlock(new BlockGemOre(), "gem_ore"); gem_ore = registerBlock(new BlockGemOre(), "gem_ore");
hive = registerBlock(new BlockHive(), "hive"); hive = registerBlock(new BlockHive(), "hive");
log = registerBlock(new BlockBOPLog(), "log"); log = registerBlock(new BlockBOPLog(), "log");
log2 = registerBlock(new BlockBOPLog2(), "log2"); log2 = registerBlock(new BlockBOPLog2(), "log2");
log3 = registerBlock(new BlockBOPLog3(), "log3"); log3 = registerBlock(new BlockBOPLog3(), "log3");
log4 = registerBlock(new BlockBOPLog4(), "log4"); log4 = registerBlock(new BlockBOPLog4(), "log4");
mushroom = registerBlock(new BlockBOPMushroom(), "mushroom"); mushroom = registerBlock(new BlockBOPMushroom(), "mushroom");
planks = registerBlock(new BlockBOPPlanks(), "planks"); planks = registerBlock(new BlockBOPPlanks(), "planks");
stone = registerBlock(new BlockBOPStone(), "stone"); stone = registerBlock(new BlockBOPStone(), "stone");
} }
private static Block registerBlock(BOPBlock block, String name)
{
if (block.presetStates == null) block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties());
block.setUnlocalizedName(name);
if (block.hasPresetProperties()) private static Block registerBlock(BOPBlock block, String name)
{ {
GameRegistry.registerBlock(block, ItemBlockWithVariants.class, name); if (block.presetStates == null)
block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties());
for (IBlockState state : block.presetStates)
{
String stateName = block.getStateName(state, true);
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + stateName);
BiomesOPlenty.proxy.registerBlockForMeshing(block, block.getMetaFromState(state), stateName);
DrawScreenEventHandler.blockCount++;
}
}
else
{
GameRegistry.registerBlock(block, name);
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + name); block.setUnlocalizedName(name);
BiomesOPlenty.proxy.registerBlockForMeshing(block, 0, name);
if (block.hasPresetProperties())
DrawScreenEventHandler.blockCount++; {
} GameRegistry.registerBlock(block, ItemBlockWithVariants.class, name);
if (block.hasHiddenProperties()) BlockModelRegisterEventHandler.addHiddenProperties(block, block.getHiddenProperties()); for (IBlockState state : block.presetStates)
{
return block; String stateName = block.getStateName(state, true);
}
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + stateName);
BiomesOPlenty.proxy.registerBlockForMeshing(block, block.getMetaFromState(state), stateName);
DrawScreenEventHandler.blockCount++;
}
}
else
{
GameRegistry.registerBlock(block, name);
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + name);
BiomesOPlenty.proxy.registerBlockForMeshing(block, 0, name);
DrawScreenEventHandler.blockCount++;
}
if (block.hasHiddenProperties())
BlockModelRegisterEventHandler.addHiddenProperties(block, block.getHiddenProperties());
return block;
}
} }

View file

@ -12,10 +12,10 @@ import java.io.File;
import biomesoplenty.common.config.BiomeConfigurationHandler; import biomesoplenty.common.config.BiomeConfigurationHandler;
public class ModConfiguration public class ModConfiguration
{ {
public static void init(File configDirectory) public static void init(File configDirectory)
{ {
BiomeConfigurationHandler.init(new File(configDirectory, "biomes")); BiomeConfigurationHandler.init(new File(configDirectory, "biomes"));
} }
} }

View file

@ -12,11 +12,11 @@ import biomesoplenty.common.handler.BlockModelRegisterEventHandler;
import biomesoplenty.common.handler.DrawScreenEventHandler; import biomesoplenty.common.handler.DrawScreenEventHandler;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
public class ModHandlers public class ModHandlers
{ {
public static void init() public static void init()
{ {
MinecraftForge.EVENT_BUS.register(new BlockModelRegisterEventHandler()); MinecraftForge.EVENT_BUS.register(new BlockModelRegisterEventHandler());
MinecraftForge.EVENT_BUS.register(new DrawScreenEventHandler()); MinecraftForge.EVENT_BUS.register(new DrawScreenEventHandler());
} }
} }

View file

@ -10,8 +10,8 @@ package biomesoplenty.common.init;
public class ModItems public class ModItems
{ {
public static void init() public static void init()
{ {
} }
} }

View file

@ -17,8 +17,8 @@ public class ItemBlockWithVariants extends ItemBlock
{ {
public ItemBlockWithVariants(Block block) public ItemBlockWithVariants(Block block)
{ {
super(block); super(block);
this.setMaxDamage(0); this.setMaxDamage(0);
this.setHasSubtypes(true); this.setHasSubtypes(true);
} }
@ -28,17 +28,18 @@ public class ItemBlockWithVariants extends ItemBlock
{ {
return metadata; return metadata;
} }
@Override @Override
public String getUnlocalizedName(ItemStack stack) public String getUnlocalizedName(ItemStack stack)
{ {
BOPBlock block = (BOPBlock)this.block; BOPBlock block = (BOPBlock) this.block;
if (block.hasPresetProperties()) if (block.hasPresetProperties())
{ {
return super.getUnlocalizedName() + "." + block.getStateName(block.getStateFromMeta(stack.getMetadata()), false); return super.getUnlocalizedName() + "." + block.getStateName(block.getStateFromMeta(stack.getMetadata()), false);
} }
else return super.getUnlocalizedName(); else
return super.getUnlocalizedName();
} }
} }

View file

@ -25,31 +25,29 @@ import biomesoplenty.api.biome.IGenerator;
@Mixin(BiomeDecorator.class) @Mixin(BiomeDecorator.class)
public class MixinBiomeDecorator implements IExtendedDecorator public class MixinBiomeDecorator implements IExtendedDecorator
{ {
private Map<String, IGenerator<?>> generatorMap; private Map<String, IGenerator<?>> generatorMap;
@Inject(method = "<init>", at = @At("RETURN")) @Inject(method = "<init>", at = @At("RETURN"))
private void onConstructed(CallbackInfo callbackInfo) private void onConstructed(CallbackInfo callbackInfo)
{ {
this.generatorMap = new HashMap(); this.generatorMap = new HashMap();
}
@Override
public void addGenerator(String key, IGenerator<?> generator)
{
this.generatorMap.put(key, generator);
}
@Override
public void configureGenerators(Map<String, IGenerator<?>> generatorMap)
{
this.generatorMap.putAll(generatorMap);
}
@Override
public Map<String, IGenerator<?>> getGeneratorMap()
{
return Collections.unmodifiableMap(this.generatorMap);
} }
@Override
public void addGenerator(String key, IGenerator<?> generator)
{
this.generatorMap.put(key, generator);
}
@Override
public void configureGenerators(Map<String, IGenerator<?>> generatorMap)
{
this.generatorMap.putAll(generatorMap);
}
@Override
public Map<String, IGenerator<?>> getGeneratorMap()
{
return Collections.unmodifiableMap(this.generatorMap);
}
} }

View file

@ -21,17 +21,17 @@ import biomesoplenty.api.biome.IExtendedBiome;
@Mixin(BiomeGenBase.class) @Mixin(BiomeGenBase.class)
public abstract class MixinBiomeGenBase implements IExtendedBiome public abstract class MixinBiomeGenBase implements IExtendedBiome
{ {
private BiomeOwner biomeOwner; private BiomeOwner biomeOwner;
@Inject(method = "<init>(IZ)V", at = @At("RETURN")) @Inject(method = "<init>(IZ)V", at = @At("RETURN"))
private void onConstructed(int biomeId, boolean register, CallbackInfo callbackInfo) private void onConstructed(int biomeId, boolean register, CallbackInfo callbackInfo)
{ {
this.biomeOwner = BiomeOwner.OTHER; this.biomeOwner = BiomeOwner.OTHER;
}
@Override
public BiomeOwner getBiomeOwner()
{
return biomeOwner;
} }
@Override
public BiomeOwner getBiomeOwner()
{
return biomeOwner;
}
} }

View file

@ -22,39 +22,39 @@ import com.google.gson.JsonObject;
@Mixin(WorldGenCactus.class) @Mixin(WorldGenCactus.class)
public abstract class MixinWorldGenCactus extends WorldGenerator implements IExtendedCactusGen public abstract class MixinWorldGenCactus extends WorldGenerator implements IExtendedCactusGen
{ {
private int cactiPerChunk; private int cactiPerChunk;
@Override
public void setCactiPerChunk(int amount)
{
this.cactiPerChunk = amount;
}
@Override
public int getCactiPerChunk()
{
return this.cactiPerChunk;
}
@Override @Override
public JsonElement serialize(IGenerator<WorldGenCactus> src) public void setCactiPerChunk(int amount)
{ {
JsonObject jsonCactusGen = new JsonObject(); this.cactiPerChunk = amount;
}
jsonCactusGen.addProperty("cacti_per_chunk", ((IExtendedCactusGen)src).getCactiPerChunk()); @Override
public int getCactiPerChunk()
{
return this.cactiPerChunk;
}
return jsonCactusGen; @Override
} public JsonElement serialize(IGenerator<WorldGenCactus> src)
{
JsonObject jsonCactusGen = new JsonObject();
@Override jsonCactusGen.addProperty("cacti_per_chunk", ((IExtendedCactusGen) src).getCactiPerChunk());
public IGenerator<WorldGenCactus> deserialize(JsonElement json)
{ return jsonCactusGen;
JsonObject jsonCactusGen = json.getAsJsonObject(); }
WorldGenCactus cactusGen = new WorldGenCactus();
IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen)cactusGen; @Override
public IGenerator<WorldGenCactus> deserialize(JsonElement json)
extendedCactusGen.setCactiPerChunk(jsonCactusGen.get("cacti_per_chunk").getAsInt()); {
JsonObject jsonCactusGen = json.getAsJsonObject();
return (IGenerator<WorldGenCactus>)new WorldGenCactus(); WorldGenCactus cactusGen = new WorldGenCactus();
} IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen) cactusGen;
extendedCactusGen.setCactiPerChunk(jsonCactusGen.get("cacti_per_chunk").getAsInt());
return (IGenerator<WorldGenCactus>) new WorldGenCactus();
}
} }

View file

@ -22,11 +22,11 @@ import biomesoplenty.common.event.BlockModelRegisterEvent;
@Mixin(BlockModelShapes.class) @Mixin(BlockModelShapes.class)
public abstract class MixinBlockModelShapes public abstract class MixinBlockModelShapes
{ {
@Inject(method = "<init>", at = @At("RETURN")) @Inject(method = "<init>", at = @At("RETURN"))
private void onConstructed(ModelManager modelManager, CallbackInfo callbackInfo) private void onConstructed(ModelManager modelManager, CallbackInfo callbackInfo)
{ {
Object obj = (Object)this; Object obj = (Object) this;
MinecraftForge.EVENT_BUS.post(new BlockModelRegisterEvent((BlockModelShapes)obj)); MinecraftForge.EVENT_BUS.post(new BlockModelRegisterEvent((BlockModelShapes) obj));
} }
} }

View file

@ -10,5 +10,6 @@ package biomesoplenty.common.util;
public class ReflectionHelper public class ReflectionHelper
{ {
//Various fields used in Reflection. These should be checked with every update. // Various fields used in Reflection. These should be checked with every
// update.
} }

View file

@ -21,157 +21,163 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
public class BlockStateUtils public class BlockStateUtils
{ {
public static IProperty getPropertyByName(IBlockState blockState, String propertyName) public static IProperty getPropertyByName(IBlockState blockState, String propertyName)
{ {
for (IProperty property : (ImmutableSet<IProperty>)blockState.getProperties().keySet()) for (IProperty property : (ImmutableSet<IProperty>) blockState.getProperties().keySet())
{ {
if (property.getName().equals(propertyName)) return property; if (property.getName().equals(propertyName))
} return property;
}
return null;
} return null;
}
public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
{ public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
return getPropertyByName(blockState, propertyName) != null; {
} return getPropertyByName(blockState, propertyName) != null;
}
public static Comparable getPropertyValueByName(IBlockState blockState, IProperty property, String valueName)
{ public static Comparable getPropertyValueByName(IBlockState blockState, IProperty property, String valueName)
for (Comparable value : (ImmutableSet<Comparable>)property.getAllowedValues()) {
{ for (Comparable value : (ImmutableSet<Comparable>) property.getAllowedValues())
if (value.toString().equals(valueName)) return value; {
} if (value.toString().equals(valueName))
return value;
return null; }
}
return null;
public static ImmutableSet<IBlockState> getValidStatesForProperties(IBlockState baseState, IProperty... properties) }
{
if (properties == null) return null; public static ImmutableSet<IBlockState> getValidStatesForProperties(IBlockState baseState, IProperty... properties)
{
Set<IBlockState> validStates = Sets.newHashSet(); if (properties == null)
PropertyIndexer propertyIndexer = new PropertyIndexer(properties); return null;
do Set<IBlockState> validStates = Sets.newHashSet();
{ PropertyIndexer propertyIndexer = new PropertyIndexer(properties);
IBlockState currentState = baseState;
do
for (IProperty property : properties) {
{ IBlockState currentState = baseState;
IndexedProperty indexedProperty = propertyIndexer.getIndexedProperty(property);
for (IProperty property : properties)
currentState = currentState.withProperty(property, indexedProperty.getCurrentValue()); {
} IndexedProperty indexedProperty = propertyIndexer.getIndexedProperty(property);
validStates.add(currentState); currentState = currentState.withProperty(property, indexedProperty.getCurrentValue());
} }
while (propertyIndexer.increment());
validStates.add(currentState);
return ImmutableSet.copyOf(validStates); }
} while (propertyIndexer.increment());
private static class PropertyIndexer return ImmutableSet.copyOf(validStates);
{ }
private HashMap<IProperty, IndexedProperty> indexedProperties = new HashMap();
private static class PropertyIndexer
private IProperty finalProperty; {
private HashMap<IProperty, IndexedProperty> indexedProperties = new HashMap();
private PropertyIndexer(IProperty... properties)
{ private IProperty finalProperty;
finalProperty = properties[properties.length - 1];
private PropertyIndexer(IProperty... properties)
IndexedProperty previousIndexedProperty = null; {
finalProperty = properties[properties.length - 1];
for (IProperty property : properties)
{ IndexedProperty previousIndexedProperty = null;
IndexedProperty indexedProperty = new IndexedProperty(property);
for (IProperty property : properties)
if (previousIndexedProperty != null) {
{ IndexedProperty indexedProperty = new IndexedProperty(property);
indexedProperty.parent = previousIndexedProperty;
previousIndexedProperty.child = indexedProperty; if (previousIndexedProperty != null)
} {
indexedProperty.parent = previousIndexedProperty;
indexedProperties.put(property, indexedProperty); previousIndexedProperty.child = indexedProperty;
previousIndexedProperty = indexedProperty; }
}
} indexedProperties.put(property, indexedProperty);
previousIndexedProperty = indexedProperty;
public boolean increment() }
{ }
return indexedProperties.get(finalProperty).increment();
} public boolean increment()
{
public IndexedProperty getIndexedProperty(IProperty property) return indexedProperties.get(finalProperty).increment();
{ }
return indexedProperties.get(property);
} public IndexedProperty getIndexedProperty(IProperty property)
} {
return indexedProperties.get(property);
private static class IndexedProperty }
{ }
private ArrayList<Comparable> validValues = new ArrayList();
private static class IndexedProperty
private int maxCount; {
private int counter; private ArrayList<Comparable> validValues = new ArrayList();
private IndexedProperty parent; private int maxCount;
private IndexedProperty child; private int counter;
private IndexedProperty(IProperty property) private IndexedProperty parent;
{ private IndexedProperty child;
this.validValues.addAll(property.getAllowedValues());
this.maxCount = this.validValues.size() - 1; private IndexedProperty(IProperty property)
} {
this.validValues.addAll(property.getAllowedValues());
public boolean increment() this.maxCount = this.validValues.size() - 1;
{ }
if (counter < maxCount) counter++;
else public boolean increment()
{ {
if (hasParent()) if (counter < maxCount)
{ counter++;
resetSelfAndChildren(); else
return this.parent.increment(); {
} if (hasParent())
else return false; {
} resetSelfAndChildren();
return this.parent.increment();
return true; }
} else
return false;
public void resetSelfAndChildren() }
{
counter = 0; return true;
if (this.hasChild()) this.child.resetSelfAndChildren(); }
}
public void resetSelfAndChildren()
public boolean hasParent() {
{ counter = 0;
return parent != null; if (this.hasChild())
} this.child.resetSelfAndChildren();
}
public boolean hasChild()
{ public boolean hasParent()
return child != null; {
} return parent != null;
}
public int getCounter()
{ public boolean hasChild()
return counter; {
} return child != null;
}
public int getMaxCount()
{ public int getCounter()
return maxCount; {
} return counter;
}
public Comparable getCurrentValue()
{ public int getMaxCount()
return validValues.get(counter); {
} return maxCount;
} }
public Comparable getCurrentValue()
{
return validValues.get(counter);
}
}
} }

View file

@ -22,40 +22,40 @@ import com.google.gson.JsonSerializer;
public class GeneratorTypeAdaptor implements JsonSerializer<IGenerator<?>>, JsonDeserializer<IGenerator<?>> public class GeneratorTypeAdaptor implements JsonSerializer<IGenerator<?>>, JsonDeserializer<IGenerator<?>>
{ {
@Override @Override
public JsonElement serialize(IGenerator<?> src, Type typeOfSrc, JsonSerializationContext context) public JsonElement serialize(IGenerator<?> src, Type typeOfSrc, JsonSerializationContext context)
{ {
JsonObject jsonObject = src.serialize((IGenerator)src).getAsJsonObject(); JsonObject jsonObject = src.serialize((IGenerator) src).getAsJsonObject();
jsonObject.addProperty("class", src.getClass().getCanonicalName()); jsonObject.addProperty("class", src.getClass().getCanonicalName());
return jsonObject; return jsonObject;
} }
@Override @Override
public IGenerator<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException public IGenerator<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{ {
JsonObject jsonObject = json.getAsJsonObject(); JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has("class")) if (jsonObject.has("class"))
{ {
try try
{ {
Class generatorClass = Class.forName(jsonObject.get("class").getAsString()); Class generatorClass = Class.forName(jsonObject.get("class").getAsString());
if (IGenerator.class.isAssignableFrom(generatorClass)) if (IGenerator.class.isAssignableFrom(generatorClass))
{ {
IGenerator<?> generator = (IGenerator<?>)generatorClass.newInstance(); IGenerator<?> generator = (IGenerator<?>) generatorClass.newInstance();
return generator.deserialize(json); return generator.deserialize(json);
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
return null; return null;
} }
} }

View file

@ -20,47 +20,43 @@ import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
public class JsonBiome public class JsonBiome
{ {
public static final Gson serializer = new GsonBuilder() public static final Gson serializer = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).registerTypeAdapter(IBlockState.class, new JsonBlockState()).registerTypeAdapter(IGenerator.class, new GeneratorTypeAdaptor()).create();
.setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.registerTypeAdapter(IBlockState.class, new JsonBlockState()) public String biomeName;
.registerTypeAdapter(IGenerator.class, new GeneratorTypeAdaptor()) public int biomeId;
.create(); public IBlockState topBlock;
public IBlockState fillerBlock;
public String biomeName; public float rootHeight;
public int biomeId; public float rootVariation;
public IBlockState topBlock; public float temperature;
public IBlockState fillerBlock; public float rainfall;
public float rootHeight; public int color;
public float rootVariation; public int waterColorMultiplier;
public float temperature; public ArrayList<JsonEntitySpawn> entities;
public float rainfall; public Map<String, IGenerator<?>> decoration;
public int color;
public int waterColorMultiplier; public static JsonBiome createFromBiomeGenBase(BiomeGenBase baseBiome)
public ArrayList<JsonEntitySpawn> entities; {
public Map<String, IGenerator<?>> decoration; JsonBiome biome = new JsonBiome();
public static JsonBiome createFromBiomeGenBase(BiomeGenBase baseBiome) biome.biomeId = baseBiome.biomeID;
{ biome.biomeName = baseBiome.biomeName;
JsonBiome biome = new JsonBiome(); biome.topBlock = baseBiome.topBlock;
biome.fillerBlock = baseBiome.fillerBlock;
biome.biomeId = baseBiome.biomeID; biome.rootHeight = baseBiome.minHeight;
biome.biomeName = baseBiome.biomeName; biome.rootVariation = baseBiome.maxHeight;
biome.topBlock = baseBiome.topBlock; biome.temperature = baseBiome.temperature;
biome.fillerBlock = baseBiome.fillerBlock; biome.rainfall = baseBiome.rainfall;
biome.rootHeight = baseBiome.minHeight; biome.color = baseBiome.color;
biome.rootVariation = baseBiome.maxHeight; biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
biome.temperature = baseBiome.temperature; biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome);
biome.rainfall = baseBiome.rainfall;
biome.color = baseBiome.color; IExtendedDecorator extendedDecorator = (IExtendedDecorator) baseBiome.theBiomeDecorator;
biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome); biome.decoration = extendedDecorator.getGeneratorMap();
IExtendedDecorator extendedDecorator = (IExtendedDecorator)baseBiome.theBiomeDecorator; return biome;
}
biome.decoration = extendedDecorator.getGeneratorMap();
return biome;
}
} }

View file

@ -31,72 +31,72 @@ import com.google.gson.JsonSyntaxException;
public class JsonBlockState implements JsonDeserializer<IBlockState>, JsonSerializer<IBlockState> public class JsonBlockState implements JsonDeserializer<IBlockState>, JsonSerializer<IBlockState>
{ {
@Override @Override
public JsonElement serialize(IBlockState blockState, Type typeOfSrc, JsonSerializationContext context) public JsonElement serialize(IBlockState blockState, Type typeOfSrc, JsonSerializationContext context)
{ {
JsonObject jsonBlockState = new JsonObject(); JsonObject jsonBlockState = new JsonObject();
JsonObject jsonStateProperties = new JsonObject(); JsonObject jsonStateProperties = new JsonObject();
jsonBlockState.addProperty("block", GameRegistry.findUniqueIdentifierFor(blockState.getBlock()).toString()); jsonBlockState.addProperty("block", GameRegistry.findUniqueIdentifierFor(blockState.getBlock()).toString());
for (Entry<IProperty, Comparable> entry : (ImmutableSet<Entry<IProperty, Comparable>>)blockState.getProperties().entrySet())
{
IProperty property = entry.getKey();
Comparable value = entry.getValue();
jsonStateProperties.addProperty(property.getName(), value.toString());
}
jsonBlockState.add("properties", jsonStateProperties);
return jsonBlockState;
}
@Override for (Entry<IProperty, Comparable> entry : (ImmutableSet<Entry<IProperty, Comparable>>) blockState.getProperties().entrySet())
public IBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
{ IProperty property = entry.getKey();
JsonObject jsonBlockState = json.getAsJsonObject(); Comparable value = entry.getValue();
if (jsonBlockState.has("block"))
{
Block block = Block.getBlockFromName(jsonBlockState.get("block").getAsString());
if (block != null)
{
IBlockState blockState = block.getDefaultState();
if (jsonBlockState.has("properties"))
{
JsonObject jsonProperties = jsonBlockState.getAsJsonObject("properties");
for (Entry<String, JsonElement> entry : jsonProperties.entrySet())
{
IProperty property = BlockStateUtils.getPropertyByName(blockState, entry.getKey());
if (property != null) jsonStateProperties.addProperty(property.getName(), value.toString());
{ }
Comparable propertyValue = BlockStateUtils.getPropertyValueByName(blockState, property, entry.getValue().getAsString());
if (propertyValue != null) jsonBlockState.add("properties", jsonStateProperties);
{
blockState = blockState.withProperty(property, propertyValue); return jsonBlockState;
} }
else
{ @Override
throw new JsonParseException("Invalid value " + entry.getValue().getAsString() + " for property " + entry.getKey()); public IBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
} {
} JsonObject jsonBlockState = json.getAsJsonObject();
else
{ if (jsonBlockState.has("block"))
throw new JsonParseException("Invalid property name: " + entry.getKey()); {
} Block block = Block.getBlockFromName(jsonBlockState.get("block").getAsString());
}
} if (block != null)
{
return blockState; IBlockState blockState = block.getDefaultState();
}
} if (jsonBlockState.has("properties"))
{
throw new JsonParseException("Invalid block state: " + json.toString()); JsonObject jsonProperties = jsonBlockState.getAsJsonObject("properties");
}
for (Entry<String, JsonElement> entry : jsonProperties.entrySet())
{
IProperty property = BlockStateUtils.getPropertyByName(blockState, entry.getKey());
if (property != null)
{
Comparable propertyValue = BlockStateUtils.getPropertyValueByName(blockState, property, entry.getValue().getAsString());
if (propertyValue != null)
{
blockState = blockState.withProperty(property, propertyValue);
}
else
{
throw new JsonParseException("Invalid value " + entry.getValue().getAsString() + " for property " + entry.getKey());
}
}
else
{
throw new JsonParseException("Invalid property name: " + entry.getKey());
}
}
}
return blockState;
}
}
throw new JsonParseException("Invalid block state: " + json.toString());
}
} }

View file

@ -15,59 +15,59 @@ import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
public class JsonEntitySpawn public class JsonEntitySpawn
{ {
public String entityType; public String entityType;
public String entityClass; public String entityClass;
public int weight; public int weight;
public int minGroupCount; public int minGroupCount;
public int maxGroupCount; public int maxGroupCount;
public static ArrayList<JsonEntitySpawn> getBiomeEntitySpawns(BiomeGenBase biome) public static ArrayList<JsonEntitySpawn> getBiomeEntitySpawns(BiomeGenBase biome)
{ {
ArrayList<JsonEntitySpawn> entitySpawns = new ArrayList(); ArrayList<JsonEntitySpawn> entitySpawns = new ArrayList();
for (EnumCreatureType creatureType : EnumCreatureType.values()) for (EnumCreatureType creatureType : EnumCreatureType.values())
{ {
List<SpawnListEntry> spawnableList = biome.getSpawnableList(creatureType); List<SpawnListEntry> spawnableList = biome.getSpawnableList(creatureType);
for (SpawnListEntry spawnListEntry : spawnableList) for (SpawnListEntry spawnListEntry : spawnableList)
{ {
JsonEntitySpawn entitySpawn = new JsonEntitySpawn(); JsonEntitySpawn entitySpawn = new JsonEntitySpawn();
entitySpawn.entityType = creatureType.toString().toLowerCase(); entitySpawn.entityType = creatureType.toString().toLowerCase();
entitySpawn.entityClass = spawnListEntry.entityClass.getCanonicalName(); entitySpawn.entityClass = spawnListEntry.entityClass.getCanonicalName();
entitySpawn.weight = spawnListEntry.itemWeight; entitySpawn.weight = spawnListEntry.itemWeight;
entitySpawn.minGroupCount = spawnListEntry.minGroupCount; entitySpawn.minGroupCount = spawnListEntry.minGroupCount;
entitySpawn.maxGroupCount = spawnListEntry.maxGroupCount; entitySpawn.maxGroupCount = spawnListEntry.maxGroupCount;
entitySpawns.add(entitySpawn); entitySpawns.add(entitySpawn);
} }
} }
return entitySpawns; return entitySpawns;
} }
public static void addBiomeEntitySpawns(BiomeGenBase biome, JsonBiome jsonBiome) public static void addBiomeEntitySpawns(BiomeGenBase biome, JsonBiome jsonBiome)
{ {
for (EnumCreatureType creatureType : EnumCreatureType.values()) for (EnumCreatureType creatureType : EnumCreatureType.values())
{ {
biome.getSpawnableList(creatureType).clear(); biome.getSpawnableList(creatureType).clear();
} }
for (JsonEntitySpawn entitySpawn : jsonBiome.entities) for (JsonEntitySpawn entitySpawn : jsonBiome.entities)
{ {
try try
{ {
EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase()); EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase());
Class entityClass = Class.forName(entitySpawn.entityClass); Class entityClass = Class.forName(entitySpawn.entityClass);
biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount)); biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount));
} }
catch (ClassNotFoundException e) catch (ClassNotFoundException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }

View file

@ -15,16 +15,16 @@ import net.minecraft.item.Item;
//TODO: Fix icon //TODO: Fix icon
public class CreativeTabBOP extends CreativeTabs public class CreativeTabBOP extends CreativeTabs
{ {
public static final CreativeTabs instance = new CreativeTabBOP(CreativeTabs.getNextID(), "tabBiomesOPlenty"); public static final CreativeTabs instance = new CreativeTabBOP(CreativeTabs.getNextID(), "tabBiomesOPlenty");
private CreativeTabBOP(int index, String label)
{
super(index, label);
}
@Override private CreativeTabBOP(int index, String label)
public Item getTabIconItem() {
{ super(index, label);
return Item.getItemFromBlock(Blocks.sapling); }
}
@Override
public Item getTabIconItem()
{
return Item.getItemFromBlock(Blocks.sapling);
}
} }

View file

@ -12,10 +12,10 @@ import net.minecraft.world.WorldType;
public class WorldTypeBOP extends WorldType public class WorldTypeBOP extends WorldType
{ {
public WorldTypeBOP() public WorldTypeBOP()
{ {
super("BIOMESOP"); super("BIOMESOP");
this.setNotificationData(); this.setNotificationData();
} }
} }

View file

@ -26,43 +26,43 @@ import biomesoplenty.common.init.ModItems;
@Mod(modid = BiomesOPlenty.MOD_ID, name = BiomesOPlenty.MOD_NAME) @Mod(modid = BiomesOPlenty.MOD_ID, name = BiomesOPlenty.MOD_NAME)
public class BiomesOPlenty public class BiomesOPlenty
{ {
public static final String MOD_NAME = "Biomes O' Plenty"; public static final String MOD_NAME = "Biomes O' Plenty";
public static final String MOD_ID = "BiomesOPlenty"; public static final String MOD_ID = "BiomesOPlenty";
@Instance(MOD_ID) @Instance(MOD_ID)
public static BiomesOPlenty instance; public static BiomesOPlenty instance;
@SidedProxy(clientSide = "biomesoplenty.core.ClientProxy", serverSide = "biomesoplenty.core.CommonProxy") @SidedProxy(clientSide = "biomesoplenty.core.ClientProxy", serverSide = "biomesoplenty.core.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
private File configDirectory; private File configDirectory;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent event)
{ {
configDirectory = new File(event.getModConfigurationDirectory(), "biomesoplenty"); configDirectory = new File(event.getModConfigurationDirectory(), "biomesoplenty");
ModConfiguration.init(configDirectory); ModConfiguration.init(configDirectory);
ModItems.init(); ModItems.init();
ModBlocks.init(); ModBlocks.init();
ModBiomes.init(); ModBiomes.init();
ModHandlers.init(); ModHandlers.init();
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent event) public void init(FMLInitializationEvent event)
{ {
proxy.registerRenderers(); proxy.registerRenderers();
} }
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event) public void postInit(FMLPostInitializationEvent event)
{ {
} }
public File getConfigDirectory() public File getConfigDirectory()
{ {
return configDirectory; return configDirectory;
} }
} }

View file

@ -17,34 +17,34 @@ import biomesoplenty.client.util.ModelHelper;
public class ClientProxy extends CommonProxy public class ClientProxy extends CommonProxy
{ {
private static ArrayList<ModelEntry> blocksToRegister = new ArrayList(); private static ArrayList<ModelEntry> blocksToRegister = new ArrayList();
@Override @Override
public void registerRenderers() public void registerRenderers()
{ {
for (ModelEntry modelEntry : blocksToRegister) for (ModelEntry modelEntry : blocksToRegister)
{ {
ModelHelper.registerBlock(modelEntry.block, modelEntry.metadata, BiomesOPlenty.MOD_ID + ":" + modelEntry.name); ModelHelper.registerBlock(modelEntry.block, modelEntry.metadata, BiomesOPlenty.MOD_ID + ":" + modelEntry.name);
} }
} }
@Override @Override
public void registerBlockForMeshing(BOPBlock block, int metadata, String name) public void registerBlockForMeshing(BOPBlock block, int metadata, String name)
{ {
blocksToRegister.add(new ModelEntry(block, metadata, name)); blocksToRegister.add(new ModelEntry(block, metadata, name));
} }
private static class ModelEntry private static class ModelEntry
{ {
public BOPBlock block; public BOPBlock block;
public int metadata; public int metadata;
public String name; public String name;
public ModelEntry(BOPBlock block, int metadata, String name) public ModelEntry(BOPBlock block, int metadata, String name)
{ {
this.block = block; this.block = block;
this.metadata = metadata; this.metadata = metadata;
this.name = name; this.name = name;
} }
} }
} }

View file

@ -14,7 +14,11 @@ import net.minecraft.item.Item;
public class CommonProxy public class CommonProxy
{ {
public void registerRenderers() {} public void registerRenderers()
{
public void registerBlockForMeshing(BOPBlock block, int metadata, String name) {} }
public void registerBlockForMeshing(BOPBlock block, int metadata, String name)
{
}
} }