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;
public enum BiomeOwner
public enum BiomeOwner
{
BIOMESOPLENTY,
OTHER;
BIOMESOPLENTY, OTHER;
}

View file

@ -10,7 +10,7 @@ package biomesoplenty.api.biome;
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;
public interface IExtendedDecorator
public interface IExtendedDecorator
{
public void addGenerator(String key, IGenerator<?> generator);
public void configureGenerators(Map<String, IGenerator<?>> generatorMap);
public Map<String, IGenerator<?>> getGeneratorMap();
public void addGenerator(String key, IGenerator<?> generator);
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 JsonElement serialize(IGenerator<T> src);
public IGenerator<T> deserialize(JsonElement json);
public JsonElement serialize(IGenerator<T> src);
public IGenerator<T> deserialize(JsonElement json);
}

View file

@ -25,65 +25,65 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BOPBlock extends Block
{
public ImmutableSet<IBlockState> presetStates;
public ImmutableSet<IBlockState> presetStates;
protected BOPBlock(Material 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));
}
}
super(material);
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(state);
}
public IProperty[] getPresetProperties()
{
return null;
}
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);
}
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));
}
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(state);
}
public IProperty[] getPresetProperties()
{
return null;
}
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 static Block ash_block;
public static Block bamboo;
public static Block bone_segment;
public static Block coral;
public static Block flower;
public static Block flower2;
public static Block gem;
public static Block gem_ore;
public static Block hive;
public static Block log;
public static Block log2;
public static Block log3;
public static Block log4;
public static Block mushroom;
public static Block planks;
public static Block stone;
public static Block ash_block;
public static Block bamboo;
public static Block bone_segment;
public static Block coral;
public static Block flower;
public static Block flower2;
public static Block gem;
public static Block gem_ore;
public static Block hive;
public static Block log;
public static Block log2;
public static Block log3;
public static Block log4;
public static Block mushroom;
public static Block planks;
public static Block stone;
}

View file

@ -28,32 +28,32 @@ public class BOPPlant extends BOPBlock
{
protected BOPPlant(Material material)
{
super(material);
this.setTickRandomly(true);
this.setHardness(0.0F);
this.setStepSound(Block.soundTypeGrass);
super(material);
this.setTickRandomly(true);
this.setHardness(0.0F);
this.setStepSound(Block.soundTypeGrass);
}
protected BOPPlant()
{
this(Material.plants);
this(Material.plants);
}
@Override
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()));
}
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;
}
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
{
@ -100,11 +100,11 @@ public class BOPPlant extends BOPBlock
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
@SideOnly(Side.CLIENT)
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;
@SideOnly(Side.CLIENT)
public class ModelHelper
public class ModelHelper
{
public static void registerItem(Item item, int metadata, String itemName)
{
@ -47,14 +47,14 @@ public class ModelHelper
{
registerItem(item, 0, itemName);
}
public static ItemModelMesher getItemModelMesher()
{
return Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
return Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
}
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")
public class BOPLoadingPlugin implements IFMLLoadingPlugin
{
public BOPLoadingPlugin()
{
MixinBootstrap.init();
MixinEnvironment.getCurrentEnvironment().addConfiguration("mixins.biomesoplenty.json");
}
public BOPLoadingPlugin()
{
MixinBootstrap.init();
MixinEnvironment.getCurrentEnvironment().addConfiguration("mixins.biomesoplenty.json");
}
@Override
public String[] getASMTransformerClass()
{
return new String[] { MixinBootstrap.TRANSFORMER_CLASS };
return new String[] { MixinBootstrap.TRANSFORMER_CLASS };
}
@Override
public String getModContainerClass()
{
return null;
return null;
}
@Override
public String getSetupClass()
{
return null;
return null;
}
@Override
public void injectData(Map<String, Object> data) {}
public void injectData(Map<String, Object> data)
{
}
@Override
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 BOPAccessTransformer() throws IOException
{
super("biomesoplenty_at.cfg");
}
public BOPAccessTransformer() throws IOException
{
super("biomesoplenty_at.cfg");
}
}

View file

@ -29,73 +29,67 @@ public class BlockAsh extends BOPBlock
{
public BlockAsh()
{
super(Material.sand);
this.setHardness(0.4F);
//this.setHarvestLevel("shovel", 0);
this.setStepSound(Block.soundTypeSand);
super(Material.sand);
this.setHardness(0.4F);
// this.setHarvestLevel("shovel", 0);
this.setStepSound(Block.soundTypeSand);
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{
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
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
/*if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
/*
* if (entity instanceof EntityPlayer) { InventoryPlayer 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)
{
return;
}
}*/
entity.motionX *= 0.4D;
entity.motionZ *= 0.4D;
}
entity.motionX *= 0.4D;
entity.motionZ *= 0.4D;
}
@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
if (side == EnumFacing.UP)
{
return true;
}
return false;
}
/*@Override
public Item getItemDropped(int metadata, Random random, int fortune)
{
return BOPCItems.misc;
}
@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
if (side == EnumFacing.UP)
{
return true;
}
return false;
}
@Override
public int damageDropped(int meta)
{
return 1;
}*/
/*
* @Override public Item getItemDropped(int metadata, Random random, int
* fortune) { return BOPCItems.misc; }
*
* @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 static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class);
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class);
public BlockBOPFlower()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.CLOVER));
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.CLOVER));
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP);
switch (type)
{
case GLOWFLOWER:
return 9;
case ENDERLOTUS:
return 5;
case BURNING_BLOSSOM:
return 9;
default:
return super.getLightValue();
}
IBlockState state = world.getBlockState(pos);
FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
switch (type)
{
case GLOWFLOWER:
return 9;
case ENDERLOTUS:
return 5;
case BURNING_BLOSSOM:
return 9;
default:
return super.getLightValue();
}
}
//TODO: Make enderlotus require spectral moss
//TODO: Make bromeliads require hard dirt, hardened clay or sand
//TODO: Make the burning blossom require netherrack or overgrown netherrack
// TODO: Make enderlotus require spectral moss
// TODO: Make bromeliads require hard dirt, hardened clay or sand
// TODO: Make the burning blossom require netherrack or overgrown netherrack
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileentity)
{
super.harvestBlock(world, player, pos, state, tileentity);
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP);
super.harvestBlock(world, player, pos, state, tileentity);
if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears))
{
switch (type)
{
case DEATHBLOOM:
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300));
break;
case BURNING_BLOSSOM:
player.setFire(5);
break;
}
}
FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears))
{
switch (type)
{
case DEATHBLOOM:
player.addPotionEffect(new PotionEffect(Potion.wither.id, 300));
break;
case BURNING_BLOSSOM:
player.setFire(5);
break;
}
}
}
@Override
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
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]);
}
{
FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((FlowerType)state.getValue(VARIANT_PROP)).ordinal();
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));
}
}
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
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((FlowerType)state.getValue(VARIANT_PROP)).getName();
}
public String getStateName(IBlockState state, boolean fullName)
{
return ((FlowerType) state.getValue(VARIANT_PROP)).getName();
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
switch ((FlowerType)state.getValue(VARIANT_PROP))
{
case CLOVER:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F);
break;
case ORANGE_COSMOS:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F);
break;
case PINK_DAFFODIL:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
case WHITE_ANEMONE:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F);
break;
case DANDELION:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
IBlockState state = world.getBlockState(pos);
switch ((FlowerType) state.getValue(VARIANT_PROP))
{
case CLOVER:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F);
break;
case ORANGE_COSMOS:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F);
break;
case PINK_DAFFODIL:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
case WHITE_ANEMONE:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F);
break;
case DANDELION:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
{
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP);
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) 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 (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]);
}
FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
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)
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 (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 dandelion blowing
public static enum FlowerType implements IStringSerializable
{
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;
// TODO: Readd eyebulb in as a seperate block
// TODO: Readd dandelion blowing
public static enum FlowerType implements IStringSerializable
{
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;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -22,85 +22,80 @@ import net.minecraft.world.World;
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()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.LAVENDER));
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.LAVENDER));
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
FlowerType type = (FlowerType)state.getValue(VARIANT_PROP);
switch (type)
{
case MINERS_DELIGHT:
return ground == Blocks.stone;
default:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
}
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
FlowerType type = (FlowerType) state.getValue(VARIANT_PROP);
switch (type)
{
case MINERS_DELIGHT:
return ground == Blocks.stone;
default:
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
public int getMetaFromState(IBlockState state)
{
int meta = ((FlowerType)state.getValue(VARIANT_PROP)).ordinal();
@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;
}
return meta;
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((FlowerType)state.getValue(VARIANT_PROP)).getName();
}
public String getStateName(IBlockState state, boolean fullName)
{
return ((FlowerType) state.getValue(VARIANT_PROP)).getName();
}
@Override
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
{
LAVENDER,
GOLDENROD,
BLUEBELLS,
MINERS_DELIGHT,
ICY_IRIS,
ROSE;
public static enum FlowerType implements IStringSerializable
{
LAVENDER, GOLDENROD, BLUEBELLS, MINERS_DELIGHT, ICY_IRIS, ROSE;
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -17,72 +17,68 @@ import net.minecraft.util.IStringSerializable;
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()
{
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;
public BlockBOPLog()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.SACRED_OAK).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
}
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
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal();
@Override
public IBlockState getStateFromMeta(int meta)
{
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
SACRED_OAK,
CHERRY,
DARK,
FIR,
ETHEREAL;
@Override
public String getName()
{
return this.name().toLowerCase();
}
public static enum LogType implements IStringSerializable
{
SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL;
@Override
public String toString()
{
return getName();
}
}
@Override
public String 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 static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog2()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAGIC).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP)));
}
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class);
public BlockBOPLog2()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAGIC).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;
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 getMetaFromState(IBlockState state)
{
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal();
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
MAGIC,
MANGROVE,
PALM,
REDWOOD,
WILLOW;
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
MAGIC, MANGROVE, PALM, REDWOOD, WILLOW;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
return getName();
}
}
}
}

View file

@ -17,74 +17,70 @@ import net.minecraft.util.IStringSerializable;
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()
{
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
public IBlockState getStateFromMeta(int meta)
{
int axis = meta % 3;
int type = (meta - axis) / 3;
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 getMetaFromState(IBlockState state)
{
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal();
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
LogType type = (LogType)state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != LogType.GIANT_FLOWER_STEM ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
DEAD,
GIANT_FLOWER_STEM,
PINE,
HELL_BARK,
JACARANDA;
public String getStateName(IBlockState state, boolean fullName)
{
LogType type = (LogType) state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != LogType.GIANT_FLOWER_STEM ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
DEAD, GIANT_FLOWER_STEM, PINE, HELL_BARK, JACARANDA;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
return getName();
}
}
}
}

View file

@ -18,68 +18,68 @@ import net.minecraft.util.IStringSerializable;
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()
{
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
public IBlockState getStateFromMeta(int meta)
{
int axis = meta % 3;
int type = (meta - axis) / 3;
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 getMetaFromState(IBlockState state)
{
int baseMeta = ((LogType)state.getValue(VARIANT_PROP)).ordinal();
return baseMeta * 3 + ((EnumFacing.Axis)state.getValue(AXIS_PROP)).ordinal();
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
MAHOGANY;
public String getStateName(IBlockState state, boolean fullName)
{
return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : "");
}
public static enum LogType implements IStringSerializable
{
MAHOGANY;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
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 static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class);
protected BlockBOPLogBase()
{
super(Material.wood);
this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeWood);
super(Material.wood);
this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeWood);
}
@Override
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 static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", MushroomType.class);
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", MushroomType.class);
public BlockBOPMushroom()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, MushroomType.TOADSTOOL));
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, MushroomType.TOADSTOOL));
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos)
{
IBlockState blockState = world.getBlockState(pos);
if ((MushroomType)blockState.getValue(VARIANT_PROP) == MushroomType.GLOWSHROOM)
{
return 6;
}
return super.getLightValue();
IBlockState blockState = world.getBlockState(pos);
if ((MushroomType) blockState.getValue(VARIANT_PROP) == MushroomType.GLOWSHROOM)
{
return 6;
}
return super.getLightValue();
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
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;
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
MushroomType type = (MushroomType) state.getValue(VARIANT_PROP);
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;
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;
default:
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.mycelium;
}
case GLOWSHROOM:
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
public int getMetaFromState(IBlockState state)
{
int meta = ((MushroomType)state.getValue(VARIANT_PROP)).ordinal();
@Override
public IBlockState getStateFromMeta(int meta)
{
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
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((MushroomType)state.getValue(VARIANT_PROP)).getName();
}
public String getStateName(IBlockState state, boolean fullName)
{
return ((MushroomType) state.getValue(VARIANT_PROP)).getName();
}
@Override
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
{
TOADSTOOL,
PORTOBELLO,
BLUE_MILK_CAP,
GLOWSHROOM,
FLAT_MUSHROOM,
SHADOW_SHROOM;
public static enum MushroomType implements IStringSerializable
{
TOADSTOOL, PORTOBELLO, BLUE_MILK_CAP, GLOWSHROOM, FLAT_MUSHROOM, SHADOW_SHROOM;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -19,82 +19,68 @@ import biomesoplenty.api.block.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()
{
super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK));
this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setStepSound(Block.soundTypeWood);
super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK));
this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setStepSound(Block.soundTypeWood);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, PlankType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((PlankType)state.getValue(VARIANT_PROP)).ordinal();
@Override
public IBlockState getStateFromMeta(int meta)
{
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
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@Override
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
{
SACRED_OAK,
CHERRY,
DARK,
FIR,
ETHEREAL,
MAGIC,
MANGROVE,
PALM,
REDWOOD,
WILLOW,
BAMBOO_THATCHING,
PINE,
HELL_BARK,
JACARANDA,
MAHOGANY;
@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
{
SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL, MAGIC, MANGROVE, PALM, REDWOOD, WILLOW, BAMBOO_THATCHING, PINE, HELL_BARK, JACARANDA, MAHOGANY;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
return getName();
}
}
}
}

View file

@ -23,105 +23,105 @@ import net.minecraft.world.World;
public class BlockBOPStone extends BOPBlock
{
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", StoneType.class);
public static PropertyBool POLISHED_PROP = PropertyBool.create("polished");
public BlockBOPStone()
{
super(Material.rock);
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", 2, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SILTSTONE));
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SHALE));
}
@Override
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", StoneType.class);
public static PropertyBool POLISHED_PROP = PropertyBool.create("polished");
public BlockBOPStone()
{
super(Material.rock);
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", 2, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SILTSTONE));
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT_PROP, StoneType.SHALE));
}
@Override
public float getBlockHardness(World world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this)
{
boolean polished = (Boolean)state.getValue(POLISHED_PROP);
if (state.getBlock() == this)
{
boolean polished = (Boolean) state.getValue(POLISHED_PROP);
if (polished) return 1.5F;
return 3.0F;
}
if (polished)
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)
{
IBlockState state = world.getBlockState(pos);
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this)
{
boolean polished = (Boolean)state.getValue(POLISHED_PROP);
if (state.getBlock() == this)
{
boolean polished = (Boolean) state.getValue(POLISHED_PROP);
if (polished) return 7.0F;
return 5.0F;
}
if (polished)
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
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((StoneType)state.getValue(VARIANT_PROP)).ordinal();
boolean polished = (Boolean)state.getValue(POLISHED_PROP);
return polished ? baseMeta | 8 : baseMeta;
}
return this.getDefaultState().withProperty(VARIANT_PROP, StoneType.values()[type]).withProperty(POLISHED_PROP, Boolean.valueOf(polished));
}
@Override
public int getMetaFromState(IBlockState state)
{
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP, POLISHED_PROP };
return new IProperty[] { VARIANT_PROP, POLISHED_PROP };
}
@Override
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
{
LIMESTONE,
SILTSTONE,
SHALE;
public static enum StoneType implements IStringSerializable
{
LIMESTONE, SILTSTONE, SHALE;
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -23,30 +23,30 @@ public class BlockBamboo extends BOPPlant
{
public BlockBamboo()
{
this.setHardness(0.2F);
this.setStepSound(Block.soundTypeWood);
this.setHardness(0.2F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
}
@Override
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;
}
@Override
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
@SideOnly(Side.CLIENT)
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 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 BlockBones()
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, BoneType.SMALL).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeStone);
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, BoneType.SMALL).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeStone);
}
@Override
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());
}
@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
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((BoneType)state.getValue(VARIANT_PROP)).ordinal();
@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 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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
return ((BoneType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_bone_segment" : "");
}
public String getStateName(IBlockState state, boolean fullName)
{
return ((BoneType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_bone_segment" : "");
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
@ -102,54 +102,55 @@ public class BlockBones extends BOPBlock
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this) return;
float width;
switch ((BoneType)state.getValue(VARIANT_PROP))
{
case SMALL:
width = 0.25F;
break;
case MEDIUM:
width = 0.625F;
break;
case LARGE:
width = 1F;
break;
default:
width = 1F;
break;
}
float min = (1.0F - width) / 2F;
float max = 1.0F - min;
switch ((EnumFacing.Axis)state.getValue(AXIS_PROP))
{
case X:
this.setBlockBounds(0F, min, min, 1.0F, max, max);
break;
case Y:
this.setBlockBounds(min, 0F, min, max, 1.0F, max);
break;
case Z:
this.setBlockBounds(min, min, 0F, max, max, 1.0F);
break;
}
IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this)
return;
float width;
switch ((BoneType) state.getValue(VARIANT_PROP))
{
case SMALL:
width = 0.25F;
break;
case MEDIUM:
width = 0.625F;
break;
case LARGE:
width = 1F;
break;
default:
width = 1F;
break;
}
float min = (1.0F - width) / 2F;
float max = 1.0F - min;
switch ((EnumFacing.Axis) state.getValue(AXIS_PROP))
{
case X:
this.setBlockBounds(0F, min, min, 1.0F, max, max);
break;
case Y:
this.setBlockBounds(min, 0F, min, max, 1.0F, max);
break;
case Z:
this.setBlockBounds(min, min, 0F, max, max, 1.0F);
break;
}
}
@Override
public boolean isOpaqueCube()
{
@ -161,23 +162,21 @@ public class BlockBones extends BOPBlock
{
return false;
}
public static enum BoneType implements IStringSerializable
{
SMALL,
MEDIUM,
LARGE;
@Override
public String getName()
{
return this.name().toLowerCase();
}
public static enum BoneType implements IStringSerializable
{
SMALL, MEDIUM, LARGE;
@Override
public String toString()
{
return getName();
}
}
@Override
public String 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 static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", CoralType.class);
public BlockCoral()
{
super(Material.water);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, CoralType.PINK));
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
}
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", CoralType.class);
public BlockCoral()
{
super(Material.water);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, CoralType.PINK));
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
if ((CoralType)state.getValue(VARIANT_PROP) == CoralType.GLOWING)
{
return 10;
}
return super.getLightValue();
IBlockState state = world.getBlockState(pos);
if ((CoralType) state.getValue(VARIANT_PROP) == CoralType.GLOWING)
{
return 10;
}
return super.getLightValue();
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
Block cover = world.getBlockState(pos.offsetUp()).getBlock();
boolean hasWater = cover == Blocks.water || cover == Blocks.flowing_water;
//TODO: Make all types depend on mud
return hasWater &&
(ground == Blocks.dirt || ground == Blocks.sand || ground == Blocks.sponge || ground == Blocks.stone || ground == Blocks.clay || ground == Blocks.gravel || ground == Blocks.grass);
Block ground = world.getBlockState(pos.offsetDown()).getBlock();
Block cover = world.getBlockState(pos.offsetUp()).getBlock();
boolean hasWater = cover == Blocks.water || cover == Blocks.flowing_water;
// TODO: Make all types depend on mud
return hasWater && (ground == Blocks.dirt || ground == Blocks.sand || ground == Blocks.sponge || ground == Blocks.stone || ground == Blocks.clay || ground == Blocks.gravel || ground == Blocks.grass);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, CoralType.values()[meta]).withProperty(LEVEL, 15);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, CoralType.values()[meta]).withProperty(LEVEL, 15);
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((CoralType)state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((CoralType) state.getValue(VARIANT_PROP)).ordinal();
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
public IProperty[] getHiddenProperties()
{
return new IProperty[] { LEVEL };
return new IProperty[] { LEVEL };
}
@Override
public String getStateName(IBlockState state, boolean fullName)
{
CoralType type = (CoralType)state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != CoralType.ALGAE ? "_coral" : "");
}
//TODO: Readd kelp
public static enum CoralType implements IStringSerializable
{
PINK,
ORANGE,
BLUE,
GLOWING,
ALGAE;
public String getStateName(IBlockState state, boolean fullName)
{
CoralType type = (CoralType) state.getValue(VARIANT_PROP);
return type.getName() + (fullName && type != CoralType.ALGAE ? "_coral" : "");
}
// TODO: Readd kelp
public static enum CoralType implements IStringSerializable
{
PINK, ORANGE, BLUE, GLOWING, ALGAE;
@Override
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -21,80 +21,73 @@ import net.minecraft.util.IStringSerializable;
//TODO: Add gem ore drops, make gem item seperate
public class BlockGem extends BOPBlock
{
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]);
}
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", GemType.class);
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((GemType)state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
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 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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
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
{
AMETHYST,
RUBY,
PERIDOT,
TOPAZ,
TANZANITE,
MALACHITE,
SAPPHIRE,
AMBER;
public static enum GemType implements IStringSerializable
{
AMETHYST, RUBY, PERIDOT, TOPAZ, TANZANITE, MALACHITE, SAPPHIRE, AMBER;
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -20,53 +20,53 @@ import net.minecraft.block.state.IBlockState;
public class BlockGemOre extends BOPBlock
{
public BlockGemOre()
{
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]);
}
public BlockGemOre()
{
super(Material.rock);
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((GemType)state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
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
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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
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;
//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 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]);
}
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", HiveType.class);
@Override
public int getMetaFromState(IBlockState state)
{
int meta = ((HiveType)state.getValue(VARIANT_PROP)).ordinal();
return meta;
}
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 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
public IProperty[] getPresetProperties()
{
return new IProperty[] { VARIANT_PROP };
return new IProperty[] { VARIANT_PROP };
}
@Override
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
{
HIVE,
HONEYCOMB,
EMPTY_HONEYCOMB,
FILLED_HONEYCOMB;
public static enum HiveType implements IStringSerializable
{
HIVE, HONEYCOMB, EMPTY_HONEYCOMB, FILLED_HONEYCOMB;
public String getName()
{
return this.name().toLowerCase();
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
@Override
public String toString()
{
return getName();
}
}
}

View file

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

View file

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

View file

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

View file

@ -24,23 +24,23 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.event.BlockModelRegisterEvent;
public class BlockModelRegisterEventHandler
public class BlockModelRegisterEventHandler
{
private static Map<Block, Set<IProperty>> hiddenProperties = Maps.newHashMap();
@SubscribeEvent
public void onBlockModelRegister(BlockModelRegisterEvent event)
{
BlockModelShapes modelShapes = event.modelShapes;
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());
}
}
public static void addHiddenProperties(Block block, IProperty... properties)
{
hiddenProperties.put(block, Sets.newHashSet(properties));
}
private static Map<Block, Set<IProperty>> hiddenProperties = Maps.newHashMap();
@SubscribeEvent
public void onBlockModelRegister(BlockModelRegisterEvent event)
{
BlockModelShapes modelShapes = event.modelShapes;
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());
}
}
public static void addHiddenProperties(Block block, IProperty... 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.eventhandler.SubscribeEvent;
public class DrawScreenEventHandler
public class DrawScreenEventHandler
{
public static int blockCount = 0;
@SubscribeEvent
public void onDrawScreen(DrawScreenEvent.Post event)
{
GuiScreen screenGui = event.gui;
if (screenGui instanceof GuiCreateWorld)
{
GuiCreateWorld createWorldGui = (GuiCreateWorld)screenGui;
GuiButton mapTypeButton = createWorldGui.field_146320_D;
int worldTypeIndex = createWorldGui.field_146331_K;
if (mapTypeButton.isMouseOver() && WorldType.worldTypes[worldTypeIndex] == ModBiomes.worldTypeBOP)
{
List text = new ArrayList<String>();
text.add("Progress:");
text.add("Blocks: " + blockCount);
text.add("Items: 0");
text.add("Entities: 0");
text.add("Biomes: 0");
createWorldGui.drawHoveringText(text, event.mouseX, event.mouseY);
}
}
}
public static int blockCount = 0;
@SubscribeEvent
public void onDrawScreen(DrawScreenEvent.Post event)
{
GuiScreen screenGui = event.gui;
if (screenGui instanceof GuiCreateWorld)
{
GuiCreateWorld createWorldGui = (GuiCreateWorld) screenGui;
GuiButton mapTypeButton = createWorldGui.field_146320_D;
int worldTypeIndex = createWorldGui.field_146331_K;
if (mapTypeButton.isMouseOver() && WorldType.worldTypes[worldTypeIndex] == ModBiomes.worldTypeBOP)
{
List text = new ArrayList<String>();
text.add("Progress:");
text.add("Blocks: " + blockCount);
text.add("Items: 0");
text.add("Entities: 0");
text.add("Biomes: 0");
createWorldGui.drawHoveringText(text, event.mouseX, event.mouseY);
}
}
}
}

View file

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

View file

@ -42,58 +42,60 @@ import biomesoplenty.core.BiomesOPlenty;
public class ModBlocks
{
public static void init()
{
ash_block = registerBlock(new BlockAsh(), "ash_block");
bamboo = registerBlock(new BlockBamboo(), "bamboo");
bone_segment = registerBlock(new BlockBones(), "bone_segment");
coral = registerBlock(new BlockCoral(), "coral");
flower = registerBlock(new BlockBOPFlower(), "flower");
flower2 = registerBlock(new BlockBOPFlower2(), "flower2");
gem = registerBlock(new BlockGem(), "gem");
gem_ore = registerBlock(new BlockGemOre(), "gem_ore");
hive = registerBlock(new BlockHive(), "hive");
log = registerBlock(new BlockBOPLog(), "log");
log2 = registerBlock(new BlockBOPLog2(), "log2");
log3 = registerBlock(new BlockBOPLog3(), "log3");
log4 = registerBlock(new BlockBOPLog4(), "log4");
mushroom = registerBlock(new BlockBOPMushroom(), "mushroom");
planks = registerBlock(new BlockBOPPlanks(), "planks");
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);
public static void init()
{
ash_block = registerBlock(new BlockAsh(), "ash_block");
bamboo = registerBlock(new BlockBamboo(), "bamboo");
bone_segment = registerBlock(new BlockBones(), "bone_segment");
coral = registerBlock(new BlockCoral(), "coral");
flower = registerBlock(new BlockBOPFlower(), "flower");
flower2 = registerBlock(new BlockBOPFlower2(), "flower2");
gem = registerBlock(new BlockGem(), "gem");
gem_ore = registerBlock(new BlockGemOre(), "gem_ore");
hive = registerBlock(new BlockHive(), "hive");
log = registerBlock(new BlockBOPLog(), "log");
log2 = registerBlock(new BlockBOPLog2(), "log2");
log3 = registerBlock(new BlockBOPLog3(), "log3");
log4 = registerBlock(new BlockBOPLog4(), "log4");
mushroom = registerBlock(new BlockBOPMushroom(), "mushroom");
planks = registerBlock(new BlockBOPPlanks(), "planks");
stone = registerBlock(new BlockBOPStone(), "stone");
}
if (block.hasPresetProperties())
{
GameRegistry.registerBlock(block, ItemBlockWithVariants.class, name);
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);
private static Block registerBlock(BOPBlock block, String name)
{
if (block.presetStates == null)
block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties());
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;
}
block.setUnlocalizedName(name);
if (block.hasPresetProperties())
{
GameRegistry.registerBlock(block, ItemBlockWithVariants.class, name);
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);
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;
public class ModConfiguration
public class ModConfiguration
{
public static void init(File configDirectory)
{
BiomeConfigurationHandler.init(new File(configDirectory, "biomes"));
}
public static void init(File configDirectory)
{
BiomeConfigurationHandler.init(new File(configDirectory, "biomes"));
}
}

View file

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

View file

@ -10,8 +10,8 @@ package biomesoplenty.common.init;
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)
{
super(block);
super(block);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@ -28,17 +28,18 @@ public class ItemBlockWithVariants extends ItemBlock
{
return metadata;
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
BOPBlock block = (BOPBlock)this.block;
if (block.hasPresetProperties())
{
return super.getUnlocalizedName() + "." + block.getStateName(block.getStateFromMeta(stack.getMetadata()), false);
}
else return super.getUnlocalizedName();
BOPBlock block = (BOPBlock) this.block;
if (block.hasPresetProperties())
{
return super.getUnlocalizedName() + "." + block.getStateName(block.getStateFromMeta(stack.getMetadata()), false);
}
else
return super.getUnlocalizedName();
}
}

View file

@ -25,31 +25,29 @@ import biomesoplenty.api.biome.IGenerator;
@Mixin(BiomeDecorator.class)
public class MixinBiomeDecorator implements IExtendedDecorator
{
private Map<String, IGenerator<?>> generatorMap;
@Inject(method = "<init>", at = @At("RETURN"))
private void onConstructed(CallbackInfo callbackInfo)
private Map<String, IGenerator<?>> generatorMap;
@Inject(method = "<init>", at = @At("RETURN"))
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)
public abstract class MixinBiomeGenBase implements IExtendedBiome
{
private BiomeOwner biomeOwner;
@Inject(method = "<init>(IZ)V", at = @At("RETURN"))
private void onConstructed(int biomeId, boolean register, CallbackInfo callbackInfo)
private BiomeOwner biomeOwner;
@Inject(method = "<init>(IZ)V", at = @At("RETURN"))
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)
public abstract class MixinWorldGenCactus extends WorldGenerator implements IExtendedCactusGen
{
private int cactiPerChunk;
@Override
public void setCactiPerChunk(int amount)
{
this.cactiPerChunk = amount;
}
@Override
public int getCactiPerChunk()
{
return this.cactiPerChunk;
}
private int cactiPerChunk;
@Override
public JsonElement serialize(IGenerator<WorldGenCactus> src)
{
JsonObject jsonCactusGen = new JsonObject();
@Override
public void setCactiPerChunk(int amount)
{
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
public IGenerator<WorldGenCactus> deserialize(JsonElement json)
{
JsonObject jsonCactusGen = json.getAsJsonObject();
WorldGenCactus cactusGen = new WorldGenCactus();
IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen)cactusGen;
extendedCactusGen.setCactiPerChunk(jsonCactusGen.get("cacti_per_chunk").getAsInt());
return (IGenerator<WorldGenCactus>)new WorldGenCactus();
}
jsonCactusGen.addProperty("cacti_per_chunk", ((IExtendedCactusGen) src).getCactiPerChunk());
return jsonCactusGen;
}
@Override
public IGenerator<WorldGenCactus> deserialize(JsonElement json)
{
JsonObject jsonCactusGen = json.getAsJsonObject();
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)
public abstract class MixinBlockModelShapes
{
@Inject(method = "<init>", at = @At("RETURN"))
private void onConstructed(ModelManager modelManager, CallbackInfo callbackInfo)
@Inject(method = "<init>", at = @At("RETURN"))
private void onConstructed(ModelManager modelManager, CallbackInfo callbackInfo)
{
Object obj = (Object)this;
MinecraftForge.EVENT_BUS.post(new BlockModelRegisterEvent((BlockModelShapes)obj));
Object obj = (Object) this;
MinecraftForge.EVENT_BUS.post(new BlockModelRegisterEvent((BlockModelShapes) obj));
}
}

View file

@ -10,5 +10,6 @@ package biomesoplenty.common.util;
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.Sets;
public class BlockStateUtils
public class BlockStateUtils
{
public static IProperty getPropertyByName(IBlockState blockState, String propertyName)
{
for (IProperty property : (ImmutableSet<IProperty>)blockState.getProperties().keySet())
{
if (property.getName().equals(propertyName)) return property;
}
return null;
}
public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
{
return getPropertyByName(blockState, propertyName) != null;
}
public static Comparable getPropertyValueByName(IBlockState blockState, IProperty property, String valueName)
{
for (Comparable value : (ImmutableSet<Comparable>)property.getAllowedValues())
{
if (value.toString().equals(valueName)) return value;
}
return null;
}
public static ImmutableSet<IBlockState> getValidStatesForProperties(IBlockState baseState, IProperty... properties)
{
if (properties == null) return null;
Set<IBlockState> validStates = Sets.newHashSet();
PropertyIndexer propertyIndexer = new PropertyIndexer(properties);
do
{
IBlockState currentState = baseState;
for (IProperty property : properties)
{
IndexedProperty indexedProperty = propertyIndexer.getIndexedProperty(property);
currentState = currentState.withProperty(property, indexedProperty.getCurrentValue());
}
validStates.add(currentState);
}
while (propertyIndexer.increment());
return ImmutableSet.copyOf(validStates);
}
private static class PropertyIndexer
{
private HashMap<IProperty, IndexedProperty> indexedProperties = new HashMap();
private IProperty finalProperty;
private PropertyIndexer(IProperty... properties)
{
finalProperty = properties[properties.length - 1];
IndexedProperty previousIndexedProperty = null;
for (IProperty property : properties)
{
IndexedProperty indexedProperty = new IndexedProperty(property);
if (previousIndexedProperty != null)
{
indexedProperty.parent = previousIndexedProperty;
previousIndexedProperty.child = indexedProperty;
}
indexedProperties.put(property, indexedProperty);
previousIndexedProperty = indexedProperty;
}
}
public boolean increment()
{
return indexedProperties.get(finalProperty).increment();
}
public IndexedProperty getIndexedProperty(IProperty property)
{
return indexedProperties.get(property);
}
}
private static class IndexedProperty
{
private ArrayList<Comparable> validValues = new ArrayList();
private int maxCount;
private int counter;
private IndexedProperty parent;
private IndexedProperty child;
private IndexedProperty(IProperty property)
{
this.validValues.addAll(property.getAllowedValues());
this.maxCount = this.validValues.size() - 1;
}
public boolean increment()
{
if (counter < maxCount) counter++;
else
{
if (hasParent())
{
resetSelfAndChildren();
return this.parent.increment();
}
else return false;
}
return true;
}
public void resetSelfAndChildren()
{
counter = 0;
if (this.hasChild()) this.child.resetSelfAndChildren();
}
public boolean hasParent()
{
return parent != null;
}
public boolean hasChild()
{
return child != null;
}
public int getCounter()
{
return counter;
}
public int getMaxCount()
{
return maxCount;
}
public Comparable getCurrentValue()
{
return validValues.get(counter);
}
}
public static IProperty getPropertyByName(IBlockState blockState, String propertyName)
{
for (IProperty property : (ImmutableSet<IProperty>) blockState.getProperties().keySet())
{
if (property.getName().equals(propertyName))
return property;
}
return null;
}
public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
{
return getPropertyByName(blockState, propertyName) != null;
}
public static Comparable getPropertyValueByName(IBlockState blockState, IProperty property, String valueName)
{
for (Comparable value : (ImmutableSet<Comparable>) property.getAllowedValues())
{
if (value.toString().equals(valueName))
return value;
}
return null;
}
public static ImmutableSet<IBlockState> getValidStatesForProperties(IBlockState baseState, IProperty... properties)
{
if (properties == null)
return null;
Set<IBlockState> validStates = Sets.newHashSet();
PropertyIndexer propertyIndexer = new PropertyIndexer(properties);
do
{
IBlockState currentState = baseState;
for (IProperty property : properties)
{
IndexedProperty indexedProperty = propertyIndexer.getIndexedProperty(property);
currentState = currentState.withProperty(property, indexedProperty.getCurrentValue());
}
validStates.add(currentState);
}
while (propertyIndexer.increment());
return ImmutableSet.copyOf(validStates);
}
private static class PropertyIndexer
{
private HashMap<IProperty, IndexedProperty> indexedProperties = new HashMap();
private IProperty finalProperty;
private PropertyIndexer(IProperty... properties)
{
finalProperty = properties[properties.length - 1];
IndexedProperty previousIndexedProperty = null;
for (IProperty property : properties)
{
IndexedProperty indexedProperty = new IndexedProperty(property);
if (previousIndexedProperty != null)
{
indexedProperty.parent = previousIndexedProperty;
previousIndexedProperty.child = indexedProperty;
}
indexedProperties.put(property, indexedProperty);
previousIndexedProperty = indexedProperty;
}
}
public boolean increment()
{
return indexedProperties.get(finalProperty).increment();
}
public IndexedProperty getIndexedProperty(IProperty property)
{
return indexedProperties.get(property);
}
}
private static class IndexedProperty
{
private ArrayList<Comparable> validValues = new ArrayList();
private int maxCount;
private int counter;
private IndexedProperty parent;
private IndexedProperty child;
private IndexedProperty(IProperty property)
{
this.validValues.addAll(property.getAllowedValues());
this.maxCount = this.validValues.size() - 1;
}
public boolean increment()
{
if (counter < maxCount)
counter++;
else
{
if (hasParent())
{
resetSelfAndChildren();
return this.parent.increment();
}
else
return false;
}
return true;
}
public void resetSelfAndChildren()
{
counter = 0;
if (this.hasChild())
this.child.resetSelfAndChildren();
}
public boolean hasParent()
{
return parent != null;
}
public boolean hasChild()
{
return child != null;
}
public int getCounter()
{
return counter;
}
public int getMaxCount()
{
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<?>>
{
@Override
public JsonElement serialize(IGenerator<?> src, Type typeOfSrc, JsonSerializationContext context)
{
JsonObject jsonObject = src.serialize((IGenerator)src).getAsJsonObject();
jsonObject.addProperty("class", src.getClass().getCanonicalName());
return jsonObject;
}
@Override
public IGenerator<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has("class"))
{
try
{
Class generatorClass = Class.forName(jsonObject.get("class").getAsString());
if (IGenerator.class.isAssignableFrom(generatorClass))
{
IGenerator<?> generator = (IGenerator<?>)generatorClass.newInstance();
return generator.deserialize(json);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return null;
}
@Override
public JsonElement serialize(IGenerator<?> src, Type typeOfSrc, JsonSerializationContext context)
{
JsonObject jsonObject = src.serialize((IGenerator) src).getAsJsonObject();
jsonObject.addProperty("class", src.getClass().getCanonicalName());
return jsonObject;
}
@Override
public IGenerator<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has("class"))
{
try
{
Class generatorClass = Class.forName(jsonObject.get("class").getAsString());
if (IGenerator.class.isAssignableFrom(generatorClass))
{
IGenerator<?> generator = (IGenerator<?>) generatorClass.newInstance();
return generator.deserialize(json);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return null;
}
}

View file

@ -20,47 +20,43 @@ import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class JsonBiome
public class JsonBiome
{
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();
public String biomeName;
public int biomeId;
public IBlockState topBlock;
public IBlockState fillerBlock;
public float rootHeight;
public float rootVariation;
public float temperature;
public float rainfall;
public int color;
public int waterColorMultiplier;
public ArrayList<JsonEntitySpawn> entities;
public Map<String, IGenerator<?>> decoration;
public static JsonBiome createFromBiomeGenBase(BiomeGenBase baseBiome)
{
JsonBiome biome = new JsonBiome();
biome.biomeId = baseBiome.biomeID;
biome.biomeName = baseBiome.biomeName;
biome.topBlock = baseBiome.topBlock;
biome.fillerBlock = baseBiome.fillerBlock;
biome.rootHeight = baseBiome.minHeight;
biome.rootVariation = baseBiome.maxHeight;
biome.temperature = baseBiome.temperature;
biome.rainfall = baseBiome.rainfall;
biome.color = baseBiome.color;
biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome);
IExtendedDecorator extendedDecorator = (IExtendedDecorator)baseBiome.theBiomeDecorator;
biome.decoration = extendedDecorator.getGeneratorMap();
return biome;
}
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();
public String biomeName;
public int biomeId;
public IBlockState topBlock;
public IBlockState fillerBlock;
public float rootHeight;
public float rootVariation;
public float temperature;
public float rainfall;
public int color;
public int waterColorMultiplier;
public ArrayList<JsonEntitySpawn> entities;
public Map<String, IGenerator<?>> decoration;
public static JsonBiome createFromBiomeGenBase(BiomeGenBase baseBiome)
{
JsonBiome biome = new JsonBiome();
biome.biomeId = baseBiome.biomeID;
biome.biomeName = baseBiome.biomeName;
biome.topBlock = baseBiome.topBlock;
biome.fillerBlock = baseBiome.fillerBlock;
biome.rootHeight = baseBiome.minHeight;
biome.rootVariation = baseBiome.maxHeight;
biome.temperature = baseBiome.temperature;
biome.rainfall = baseBiome.rainfall;
biome.color = baseBiome.color;
biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome);
IExtendedDecorator extendedDecorator = (IExtendedDecorator) baseBiome.theBiomeDecorator;
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>
{
@Override
public JsonElement serialize(IBlockState blockState, Type typeOfSrc, JsonSerializationContext context)
{
JsonObject jsonBlockState = new JsonObject();
JsonObject jsonStateProperties = new JsonObject();
@Override
public JsonElement serialize(IBlockState blockState, Type typeOfSrc, JsonSerializationContext context)
{
JsonObject jsonBlockState = new JsonObject();
JsonObject jsonStateProperties = new JsonObject();
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;
}
jsonBlockState.addProperty("block", GameRegistry.findUniqueIdentifierFor(blockState.getBlock()).toString());
@Override
public IBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
JsonObject jsonBlockState = json.getAsJsonObject();
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());
for (Entry<IProperty, Comparable> entry : (ImmutableSet<Entry<IProperty, Comparable>>) blockState.getProperties().entrySet())
{
IProperty property = entry.getKey();
Comparable value = entry.getValue();
if (property != null)
{
Comparable propertyValue = BlockStateUtils.getPropertyValueByName(blockState, property, entry.getValue().getAsString());
jsonStateProperties.addProperty(property.getName(), value.toString());
}
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());
}
jsonBlockState.add("properties", jsonStateProperties);
return jsonBlockState;
}
@Override
public IBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
JsonObject jsonBlockState = json.getAsJsonObject();
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)
{
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.SpawnListEntry;
public class JsonEntitySpawn
public class JsonEntitySpawn
{
public String entityType;
public String entityClass;
public int weight;
public int minGroupCount;
public int maxGroupCount;
public static ArrayList<JsonEntitySpawn> getBiomeEntitySpawns(BiomeGenBase biome)
{
ArrayList<JsonEntitySpawn> entitySpawns = new ArrayList();
for (EnumCreatureType creatureType : EnumCreatureType.values())
{
List<SpawnListEntry> spawnableList = biome.getSpawnableList(creatureType);
for (SpawnListEntry spawnListEntry : spawnableList)
{
JsonEntitySpawn entitySpawn = new JsonEntitySpawn();
entitySpawn.entityType = creatureType.toString().toLowerCase();
entitySpawn.entityClass = spawnListEntry.entityClass.getCanonicalName();
entitySpawn.weight = spawnListEntry.itemWeight;
entitySpawn.minGroupCount = spawnListEntry.minGroupCount;
entitySpawn.maxGroupCount = spawnListEntry.maxGroupCount;
entitySpawns.add(entitySpawn);
}
}
return entitySpawns;
}
public static void addBiomeEntitySpawns(BiomeGenBase biome, JsonBiome jsonBiome)
{
for (EnumCreatureType creatureType : EnumCreatureType.values())
{
biome.getSpawnableList(creatureType).clear();
}
for (JsonEntitySpawn entitySpawn : jsonBiome.entities)
{
try
{
EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase());
Class entityClass = Class.forName(entitySpawn.entityClass);
biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount));
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
}
public String entityType;
public String entityClass;
public int weight;
public int minGroupCount;
public int maxGroupCount;
public static ArrayList<JsonEntitySpawn> getBiomeEntitySpawns(BiomeGenBase biome)
{
ArrayList<JsonEntitySpawn> entitySpawns = new ArrayList();
for (EnumCreatureType creatureType : EnumCreatureType.values())
{
List<SpawnListEntry> spawnableList = biome.getSpawnableList(creatureType);
for (SpawnListEntry spawnListEntry : spawnableList)
{
JsonEntitySpawn entitySpawn = new JsonEntitySpawn();
entitySpawn.entityType = creatureType.toString().toLowerCase();
entitySpawn.entityClass = spawnListEntry.entityClass.getCanonicalName();
entitySpawn.weight = spawnListEntry.itemWeight;
entitySpawn.minGroupCount = spawnListEntry.minGroupCount;
entitySpawn.maxGroupCount = spawnListEntry.maxGroupCount;
entitySpawns.add(entitySpawn);
}
}
return entitySpawns;
}
public static void addBiomeEntitySpawns(BiomeGenBase biome, JsonBiome jsonBiome)
{
for (EnumCreatureType creatureType : EnumCreatureType.values())
{
biome.getSpawnableList(creatureType).clear();
}
for (JsonEntitySpawn entitySpawn : jsonBiome.entities)
{
try
{
EnumCreatureType creatureType = EnumCreatureType.valueOf(entitySpawn.entityType.toUpperCase());
Class entityClass = Class.forName(entitySpawn.entityClass);
biome.getSpawnableList(creatureType).add(new BiomeGenBase.SpawnListEntry(entityClass, entitySpawn.weight, entitySpawn.minGroupCount, entitySpawn.maxGroupCount));
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
}
}

View file

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

View file

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

View file

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

View file

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