Add biome essence and biome block
This commit is contained in:
parent
fd81cb9029
commit
c32a624f92
|
@ -69,4 +69,10 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
||||||
{
|
{
|
||||||
this.weightMap.clear();
|
this.weightMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// whether or not a biome essence item corresponding to this biome should be able to drop from biome blocks
|
||||||
|
public boolean hasBiomeEssence()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class BOPBlocks
|
||||||
public static Block hive;
|
public static Block hive;
|
||||||
public static Block mushroom;
|
public static Block mushroom;
|
||||||
public static Block stone;
|
public static Block stone;
|
||||||
|
public static Block biome_block;
|
||||||
|
|
||||||
public static Block log_0;
|
public static Block log_0;
|
||||||
public static Block log_1;
|
public static Block log_1;
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class BOPItems
|
||||||
public static Item amethyst_scythe;
|
public static Item amethyst_scythe;
|
||||||
|
|
||||||
public static Item biome_finder;
|
public static Item biome_finder;
|
||||||
|
public static Item biome_essence;
|
||||||
public static Item enderporter;
|
public static Item enderporter;
|
||||||
public static Item jar_empty;
|
public static Item jar_empty;
|
||||||
public static Item jar_filled;
|
public static Item jar_filled;
|
||||||
|
|
|
@ -5,11 +5,15 @@
|
||||||
*
|
*
|
||||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
/*
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import biomesoplenty.api.biome.BOPBiomes;
|
import java.util.ArrayList;
|
||||||
import biomesoplenty.api.block.BOPBlock;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import biomesoplenty.api.biome.BOPBiome;
|
||||||
import biomesoplenty.api.item.BOPItems;
|
import biomesoplenty.api.item.BOPItems;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -17,42 +21,83 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
public class BlockBiomeBlock extends BOPBlock
|
public class BlockBiomeBlock extends BlockBOPGeneric
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockBiomeBlock() {
|
public BlockBiomeBlock() {
|
||||||
super(Material.glass);
|
super(Material.glass);
|
||||||
this.setHardness(0.6F);
|
this.setHardness(0.6F);
|
||||||
this.setStepSound(Block.soundTypeGlass);
|
this.setStepSound(Block.soundTypeGlass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't understand this method at all.
|
// list of biomes which have an associated essence (possible drops when this block is broken)
|
||||||
@Override
|
private static List<BiomeGenBase> biomesWithEssence;
|
||||||
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
|
|
||||||
|
// generate the list of biomes which have an associated essence
|
||||||
|
public List<BiomeGenBase> getBiomesWithEssence()
|
||||||
{
|
{
|
||||||
if (!worldIn.isRemote && !worldIn.restoringBlockSnapshots) // do not drop items while restoring blockstates, prevents item dupe
|
if (biomesWithEssence != null) {return biomesWithEssence;}
|
||||||
|
|
||||||
|
biomesWithEssence = new ArrayList<BiomeGenBase>();
|
||||||
|
|
||||||
|
List<BiomeGenBase> vanillaBiomesToExclude = Arrays.asList(
|
||||||
|
new BiomeGenBase[] {
|
||||||
|
BiomeGenBase.sky,
|
||||||
|
BiomeGenBase.hell,
|
||||||
|
BiomeGenBase.beach,
|
||||||
|
BiomeGenBase.coldBeach,
|
||||||
|
BiomeGenBase.stoneBeach,
|
||||||
|
BiomeGenBase.ocean,
|
||||||
|
BiomeGenBase.frozenOcean,
|
||||||
|
BiomeGenBase.deepOcean,
|
||||||
|
BiomeGenBase.river,
|
||||||
|
BiomeGenBase.frozenRiver
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
|
||||||
{
|
{
|
||||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
|
if (biome == null) {continue;}
|
||||||
|
if (biome instanceof BOPBiome)
|
||||||
{
|
{
|
||||||
if (biome == null) {continue;}
|
if (((BOPBiome)biome).hasBiomeEssence()) {biomesWithEssence.add(biome);}
|
||||||
|
}
|
||||||
// TODO: add the other biomes
|
else
|
||||||
// TODO: add areBiomesEqual function for comparing these
|
{
|
||||||
if ( biome.biomeID == BOPBiomes.alps.biomeID )
|
if (!vanillaBiomesToExclude.contains(biome)) {biomesWithEssence.add(biome);}
|
||||||
{
|
|
||||||
if (worldIn.rand.nextInt(75) == 0)
|
|
||||||
{
|
|
||||||
ItemStack biome_essence = new ItemStack(BOPItems.biome_essence);
|
|
||||||
biome_essence.setTagCompound(new NBTTagCompound());
|
|
||||||
biome_essence.getTagCompound().setInteger("biomeID", biome.biomeID);
|
|
||||||
spawnAsEntity(worldIn, pos, biome_essence);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return biomesWithEssence;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// drops biome essence items for random biomes
|
||||||
*/
|
@Override
|
||||||
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
|
||||||
|
{
|
||||||
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||||
|
Random rand = world instanceof World ? ((World)world).rand : RANDOM;
|
||||||
|
|
||||||
|
List<BiomeGenBase> biomes = this.getBiomesWithEssence();
|
||||||
|
int numToDrop = rand.nextInt(fortune + 2) + 1;
|
||||||
|
int numChoices = biomes.size();
|
||||||
|
BiomeGenBase biome;
|
||||||
|
|
||||||
|
for (int i = 0; i < numToDrop; i++)
|
||||||
|
{
|
||||||
|
biome = biomes.get(rand.nextInt(numChoices));
|
||||||
|
ItemStack biome_essence = new ItemStack(BOPItems.biome_essence);
|
||||||
|
biome_essence.setTagCompound(new NBTTagCompound());
|
||||||
|
biome_essence.getTagCompound().setInteger("biomeID", biome.biomeID);
|
||||||
|
ret.add(biome_essence);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -66,6 +66,7 @@ public class ModBlocks
|
||||||
stone_formations = registerBlock( new BlockStoneFormations(), "stone_formations" );
|
stone_formations = registerBlock( new BlockStoneFormations(), "stone_formations" );
|
||||||
fruit_block = registerBlock( new BlockFruit(), "fruit_block" /*, creativeTab(null) */); // TODO: once the mechanism for farming fruit is established: remove creative tab
|
fruit_block = registerBlock( new BlockFruit(), "fruit_block" /*, creativeTab(null) */); // TODO: once the mechanism for farming fruit is established: remove creative tab
|
||||||
crystal = registerBlock( new BlockCrystal(), "crystal" );
|
crystal = registerBlock( new BlockCrystal(), "crystal" );
|
||||||
|
biome_block = registerBlock( new BlockBiomeBlock(), "biome_block" );
|
||||||
|
|
||||||
// generics
|
// generics
|
||||||
ash_stone = registerBlock( new BlockBOPGeneric(), "ash_stone" );
|
ash_stone = registerBlock( new BlockBOPGeneric(), "ash_stone" );
|
||||||
|
|
|
@ -174,6 +174,7 @@ public class ModItems
|
||||||
|
|
||||||
|
|
||||||
biome_finder = registerItem(new ItemBiomeFinder(), "biome_finder");
|
biome_finder = registerItem(new ItemBiomeFinder(), "biome_finder");
|
||||||
|
biome_essence = registerItem(new ItemBiomeEssence(), "biome_essence");
|
||||||
enderporter = registerItem(new ItemEnderporter(), "enderporter");
|
enderporter = registerItem(new ItemEnderporter(), "enderporter");
|
||||||
jar_empty = registerItem(new ItemJarEmpty(), "jar_empty");
|
jar_empty = registerItem(new ItemJarEmpty(), "jar_empty");
|
||||||
jar_filled = registerItem(new ItemJarFilled(), "jar_filled");
|
jar_filled = registerItem(new ItemJarFilled(), "jar_filled");
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
// TODO: This is probably all kinds of wrong
|
|
||||||
public class ItemBiomeEssence extends Item
|
public class ItemBiomeEssence extends Item
|
||||||
{
|
{
|
||||||
public ItemBiomeEssence() {}
|
public ItemBiomeEssence() {}
|
||||||
|
@ -28,49 +27,46 @@ public class ItemBiomeEssence extends Item
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: wtf?
|
// TODO: really? this looks well dodgy.
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getContainerItem(ItemStack itemStack)
|
public ItemStack getContainerItem(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BiomeGenBase getBiome(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("biomeID"))
|
||||||
|
{
|
||||||
|
int biomeId = itemStack.getTagCompound().getInteger("biomeID");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return BiomeGenBase.getBiomeGenArray()[biomeId];
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List infoList, boolean advancedItemTooltips)
|
public void addInformation(ItemStack itemStack, EntityPlayer player, List infoList, boolean advancedItemTooltips)
|
||||||
{
|
{
|
||||||
if (itemStack.hasTagCompound())
|
BiomeGenBase biome = this.getBiome(itemStack);
|
||||||
|
if (biome != null)
|
||||||
{
|
{
|
||||||
if (itemStack.getTagCompound().hasKey("biomeID"))
|
infoList.add(biome.biomeName);
|
||||||
{
|
|
||||||
BiomeGenBase biome = BiomeGenBase.getBiomeGenArray()[itemStack.getTagCompound().getInteger("biomeID")];
|
|
||||||
|
|
||||||
if (biome != null)
|
|
||||||
{
|
|
||||||
infoList.add(biome.biomeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public int getColorFromItemStack(ItemStack itemStack, int par2)
|
public int getColorFromItemStack(ItemStack itemStack, int tintIndex)
|
||||||
{
|
{
|
||||||
if (itemStack.hasTagCompound())
|
BiomeGenBase biome = this.getBiome(itemStack);
|
||||||
{
|
return biome == null ? 0xFFFFFF : biome.color;
|
||||||
if (itemStack.getTagCompound().hasKey("biomeID"))
|
|
||||||
{
|
|
||||||
BiomeGenBase biome = BiomeGenBase.getBiomeGenArray()[itemStack.getTagCompound().getInteger("biomeID")];
|
|
||||||
|
|
||||||
if (biome != null)
|
|
||||||
{
|
|
||||||
return biome.color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 16777215;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"normal": { "model": "biomesoplenty:biome_block" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "biomesoplenty:blocks/biome_block"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent": "biomesoplenty:block/biome_block",
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 10, -45, 170 ],
|
||||||
|
"translation": [ 0, 1.5, -2.75 ],
|
||||||
|
"scale": [ 0.375, 0.375, 0.375 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "biomesoplenty:items/biome_essence"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ -90, 0, 0 ],
|
||||||
|
"translation": [ 0, 1, -3 ],
|
||||||
|
"scale": [ 0.55, 0.55, 0.55 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 811 B |
Binary file not shown.
After Width: | Height: | Size: 339 B |
Loading…
Reference in New Issue