Added the basics for the new dirt types. Farmland is yet to be added, and appropriate behaviours for sheep also need to be made

This commit is contained in:
Adubbz 2014-08-09 15:59:04 +10:00
parent 53bcc05c47
commit 819835662c
14 changed files with 331 additions and 28 deletions

View file

@ -41,7 +41,9 @@ public class BOPCBlocks
public static Block overgrownNetherrack; public static Block overgrownNetherrack;
public static Block bopGrass; public static Block bopGrass;
public static Block newBopGrass; public static Block newBopGrass;
public static Block newBopDirt;
public static Block logs1; public static Block logs1;
public static Block logs2; public static Block logs2;

View file

@ -5,11 +5,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import biomesoplenty.api.content.BOPCBlocks;
public class RenderUtils public class RenderUtils
{ {
public static int foliageModel = -1; public static int foliageModel = -1;
@ -21,38 +24,57 @@ public class RenderUtils
public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta)
{ {
boolean flag = block == BOPCBlocks.newBopGrass;
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F); tessellator.setNormal(0.0F, -1F, 0.0F);
//TODO: renderFaceYNeg getIcon()
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta)); renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
tessellator.draw(); tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F); if (flag && renderblocks.useInventoryTint)
//TODO: renderFaceYPos getIcon() {
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta)); int colour = 16777215;
tessellator.draw();
float f1 = (float)(colour >> 16 & 255) / 255.0F;
float f2 = (float)(colour >> 8 & 255) / 255.0F;
float f3 = (float)(colour & 255) / 255.0F;
GL11.glColor4f(f1, f2, f3, 1.0F);
}
if (!flag)
{
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
tessellator.draw();
}
GL11.glColor4f(1F, 1F, 1F, 1.0F);
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F); tessellator.setNormal(0.0F, 0.0F, -1F);
//TODO: renderFaceZNeg getIcon()
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta)); renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
tessellator.draw(); tessellator.draw();
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F); tessellator.setNormal(0.0F, 0.0F, 1.0F);
//TODO: renderFaceZPos getIcon()
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta)); renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
tessellator.draw(); tessellator.draw();
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F); tessellator.setNormal(-1F, 0.0F, 0.0F);
//TODO: renderFaceXNeg getIcon()
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta)); renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
tessellator.draw(); tessellator.draw();
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F); tessellator.setNormal(1.0F, 0.0F, 0.0F);
//TODO: renderFaceXPos getIcon()
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta)); renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
tessellator.draw(); tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glTranslatef(0.5F, 0.5F, 0.5F);
} }

View file

@ -1,10 +1,14 @@
package biomesoplenty.client.render.blocks; package biomesoplenty.client.render.blocks;
import biomesoplenty.client.render.RenderUtils; import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import biomesoplenty.api.content.BOPCBlocks;
import biomesoplenty.client.render.RenderUtils;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderNewGrass implements ISimpleBlockRenderingHandler public class RenderNewGrass implements ISimpleBlockRenderingHandler
@ -12,12 +16,27 @@ public class RenderNewGrass implements ISimpleBlockRenderingHandler
@Override @Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer)
{ {
float inset = 0.0001F;
renderer.setRenderBounds(inset, inset, inset, 1F - inset, 1F - inset, 1F - inset);
RenderUtils.renderStandardInvBlock(renderer, Blocks.grass, 0);
renderer.setRenderBounds(0F, 0F, 0F, 1F, 1F, 1F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
} }
@Override @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{ {
renderer.renderStandardBlock(Blocks.grass, x, y, z); if (renderer.hasOverrideBlockTexture())
{
renderer.renderBlockUsingTexture(Blocks.grass, x, y, z, renderer.overrideBlockTexture);
}
else
{
renderer.renderStandardBlock(Blocks.grass, x, y, z);
renderer.renderStandardBlock(block, x, y, z);
}
return true; return true;
} }

View file

@ -0,0 +1,97 @@
package biomesoplenty.common.blocks;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.common.utils.ISubLocalization;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockBOPNewDirt extends BlockDirt implements ISubLocalization
{
private static final String[] dirtTypes = new String[] { "loamy", "sandy", "silty" };
private static final IIcon[] dirtIcons = new IIcon[dirtTypes.length * 2];
public BlockBOPNewDirt()
{
this.setHardness(0.5F);
this.setHarvestLevel("shovel", 0);
this.setStepSound(soundTypeGravel);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public int damageDropped(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(String baseName, ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
return baseName + "." + (isCoarseDirt(meta) ? "coarse_dirt_" : "dirt_") + getBaseType(meta);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item block, CreativeTabs creativeTab, List blockList)
{
for (int i = 0; i < dirtTypes.length * 2; i++)
{
blockList.add(new ItemStack(block, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
for (int i = 0; i < dirtTypes.length; i++)
{
String dirtType = dirtTypes[i];
dirtIcons[i * 2 + 0] = iconRegister.registerIcon("biomesoplenty:dirt_" + dirtType);
dirtIcons[i * 2 + 1] = iconRegister.registerIcon("biomesoplenty:coarse_dirt_" + dirtType);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
return dirtIcons[meta];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
int meta = world.getBlockMetadata(x, y, z);
return this.getIcon(side, meta);
}
private boolean isCoarseDirt(int meta)
{
return (meta & 1) != 0;
}
private String getBaseType(int meta)
{
return dirtTypes[(meta - (meta & 1)) / 2];
}
}

View file

@ -1,17 +1,31 @@
package biomesoplenty.common.blocks; package biomesoplenty.common.blocks;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import biomesoplenty.BiomesOPlenty; import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.content.BOPCBlocks;
import biomesoplenty.client.render.RenderUtils; import biomesoplenty.client.render.RenderUtils;
import biomesoplenty.common.utils.ISubLocalization; import biomesoplenty.common.utils.ISubLocalization;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockGrass; import net.minecraft.block.BlockGrass;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization
{ {
@ -20,9 +34,145 @@ public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization
public BlockBOPNewGrass() public BlockBOPNewGrass()
{ {
this.setHardness(0.6F);
this.setHarvestLevel("shovel", 0);
this.setStepSound(soundTypeGrass);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
} }
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (!world.isRemote)
{
if (world.getBlockLightValue(x, y + 1, z) < 4 && world.getBlockLightOpacity(x, y + 1, z) > 2)
{
world.setBlock(x, y, z, BOPCBlocks.newBopDirt, world.getBlockMetadata(x, y, z) * 2, 2);
}
else if (world.getBlockLightValue(x, y + 1, z) >= 9)
{
for (int l = 0; l < 4; ++l)
{
int randX = x + random.nextInt(3) - 1;
int randY = y + random.nextInt(5) - 3;
int randZ = z + random.nextInt(3) - 1;
Block block = world.getBlock(randX, randY + 1, randZ);
if (world.getBlockLightValue(randX, randY + 1, randZ) >= 4 && world.getBlockLightOpacity(randX, randY + 1, randZ) <= 2)
{
if (world.getBlock(randX, randY, randZ) == Blocks.dirt && world.getBlockMetadata(randX, randY, randZ) == 0)
{
world.setBlock(randX, randY, randZ, Blocks.grass);
}
else if (world.getBlock(randX, randY, randZ) == BOPCBlocks.newBopDirt)
{
int dirtMeta = world.getBlockMetadata(randX, randY, randZ);
world.setBlock(randX, randY, randZ, BOPCBlocks.newBopGrass, (dirtMeta - (dirtMeta & 1)) / 2, 2);
}
}
}
}
}
}
@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
{
Block plant = plantable.getPlant(world, x, y + 1, z);
EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z);
switch (plantType)
{
case Cave: return isSideSolid(world, x, y, z, UP);
case Plains: return true;
case Beach:
boolean hasWater = (world.getBlock(x - 1, y, z ).getMaterial() == Material.water ||
world.getBlock(x + 1, y, z ).getMaterial() == Material.water ||
world.getBlock(x, y, z - 1).getMaterial() == Material.water ||
world.getBlock(x, y, z + 1).getMaterial() == Material.water);
return hasWater;
}
return super.canSustainPlant(world, x, y, z, direction, plantable);
}
@Override
// onApplyBonemeal - Dodgy Name
public void func_149853_b(World world, Random random, int x, int y, int z)
{
int l = 0;
while (l < 128)
{
int i1 = x;
int j1 = y + 1;
int k1 = z;
int l1 = 0;
while (true)
{
if (l1 < l / 16)
{
i1 += random.nextInt(3) - 1;
j1 += (random.nextInt(3) - 1) * random.nextInt(3) / 2;
k1 += random.nextInt(3) - 1;
if (world.getBlock(i1, j1 - 1, k1) == BOPCBlocks.newBopGrass && !world.getBlock(i1, j1, k1).isNormalCube())
{
++l1;
continue;
}
}
else if (world.getBlock(i1, j1, k1).getMaterial() == Material.air)
{
if (random.nextInt(8) != 0)
{
if (Blocks.tallgrass.canBlockStay(world, i1, j1, k1))
{
world.setBlock(i1, j1, k1, Blocks.tallgrass, 1, 3);
}
}
else
{
world.getBiomeGenForCoords(i1, k1).plantFlower(world, random, i1, j1, k1);
}
}
++l;
break;
}
}
}
@Override
public void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
{
world.setBlock(x, y, z, BOPCBlocks.newBopDirt, world.getBlockMetadata(x, y, z) * 2, 2);
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune)
{
return BOPCBlocks.newBopDirt.getItemDropped(metadata * 2, random, fortune);
}
@Override
public int damageDropped(int metadata)
{
return metadata * 2;
}
@Override
public String getUnlocalizedName(String baseName, ItemStack itemStack)
{
return baseName + "." + grassTypes[itemStack.getItemDamage()];
}
@Override @Override
public boolean renderAsNormalBlock() public boolean renderAsNormalBlock()
{ {
@ -35,12 +185,16 @@ public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization
return RenderUtils.newGrassModel; return RenderUtils.newGrassModel;
} }
@Override @Override
public String getUnlocalizedName(String baseName, ItemStack itemStack) @SideOnly(Side.CLIENT)
{ public void getSubBlocks(Item block, CreativeTabs creativeTab, List blockList)
return baseName + "." + grassTypes[itemStack.getItemDamage()]; {
} for (int i = 0; i < grassTypes.length; i++)
{
blockList.add(new ItemStack(block, 1, i));
}
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) public void registerBlockIcons(IIconRegister iconRegister)
@ -58,7 +212,7 @@ public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) public IIcon getIcon(int side, int meta)
{ {
return side == 1 ? Blocks.grass.getIcon(side, meta) : grassIcons[meta]; return side == 1 ? Blocks.grass.getIcon(side, meta) : side == 0 ? BOPCBlocks.newBopDirt.getIcon(side, meta * 2) : grassIcons[2 * meta];
} }
@Override @Override
@ -67,15 +221,18 @@ public class BlockBOPNewGrass extends BlockGrass implements ISubLocalization
{ {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if (side == 1) if (side == 0)
{
return BOPCBlocks.newBopDirt.getIcon(side, meta * 2);
}
else if (side == 1)
{ {
return Blocks.grass.getIcon(world, x, y, z, side); return Blocks.grass.getIcon(world, x, y, z, side);
} }
else else
{ {
Material material = world.getBlock(x, y + 1, z).getMaterial(); Material material = world.getBlock(x, y + 1, z).getMaterial();
return material != Material.snow && material != Material.craftedSnow ? grassIcons[meta] : grassIcons[meta + 1]; return material != Material.snow && material != Material.craftedSnow ? grassIcons[2 * meta] : grassIcons[2 * meta + 1];
} }
} }
} }

View file

@ -25,6 +25,7 @@ import biomesoplenty.common.blocks.BlockBOPLeaves.LeafCategory;
import biomesoplenty.common.blocks.BlockBOPLog; import biomesoplenty.common.blocks.BlockBOPLog;
import biomesoplenty.common.blocks.BlockBOPLog.LogCategory; import biomesoplenty.common.blocks.BlockBOPLog.LogCategory;
import biomesoplenty.common.blocks.BlockBOPMushroom; import biomesoplenty.common.blocks.BlockBOPMushroom;
import biomesoplenty.common.blocks.BlockBOPNewDirt;
import biomesoplenty.common.blocks.BlockBOPNewGrass; import biomesoplenty.common.blocks.BlockBOPNewGrass;
import biomesoplenty.common.blocks.BlockBOPPersimmonLeaves; import biomesoplenty.common.blocks.BlockBOPPersimmonLeaves;
import biomesoplenty.common.blocks.BlockBOPPetals; import biomesoplenty.common.blocks.BlockBOPPetals;
@ -135,7 +136,9 @@ public class BOPBlocks
overgrownNetherrack = registerBlock(new BlockOvergrownNetherrack().setBlockName("overgrownNetherrack")); overgrownNetherrack = registerBlock(new BlockOvergrownNetherrack().setBlockName("overgrownNetherrack"));
bopGrass = registerBlock(new BlockBOPGrass().setBlockName("bopGrass"), ItemBlockGrass.class); bopGrass = registerBlock(new BlockBOPGrass().setBlockName("bopGrass"), ItemBlockGrass.class);
newBopGrass = registerMetadataBlock(new BlockBOPNewGrass().setBlockName("newBopGrass")); newBopGrass = registerMetadataBlock(new BlockBOPNewGrass().setBlockName("newBopGrass"));
newBopDirt = registerMetadataBlock(new BlockBOPNewDirt().setBlockName("newBopDirt"));
logs1 = registerBlock(new BlockBOPLog(LogCategory.CAT1).setBlockName("logs1"), ItemBlockLog.class); logs1 = registerBlock(new BlockBOPLog(LogCategory.CAT1).setBlockName("logs1"), ItemBlockLog.class);
logs2 = registerBlock(new BlockBOPLog(LogCategory.CAT2).setBlockName("logs2"), ItemBlockLog.class); logs2 = registerBlock(new BlockBOPLog(LogCategory.CAT2).setBlockName("logs2"), ItemBlockLog.class);

View file

@ -137,12 +137,15 @@ tile.coral1.bluecoral.name=Blue Coral
tile.coral1.glowcoral.name=Glowing Coral tile.coral1.glowcoral.name=Glowing Coral
tile.coral2.algae.name=Algae tile.coral2.algae.name=Algae
tile.soil.grass_silty.name=Silty Grass Block tile.newBopGrass.silty.name=Silty Grass Block
tile.soil.grass_sandy.name=Sandy Grass Block tile.newBopGrass.sandy.name=Sandy Grass Block
tile.soil.grass_loamy.name=Loamy Grass Block tile.newBopGrass.loamy.name=Loamy Grass Block
tile.soil.dirt_silty.name=Silty Dirt tile.newBopDirt.dirt_silty.name=Silty Dirt
tile.soil.dirt_sandy.name=Sandy Dirt tile.newBopDirt.dirt_sandy.name=Sandy Dirt
tile.soil.dirt_loamy.name=Loamy Dirt tile.newBopDirt.dirt_loamy.name=Loamy Dirt
tile.newBopDirt.coarse_dirt_silty.name=Coarse Silty Dirt
tile.newBopDirt.coarse_dirt_sandy.name=Coarse Sandy Dirt
tile.newBopDirt.coarse_dirt_loamy.name=Coarse Loamy Dirt
tile.bopGrass.spectralmoss.name=Spectral Moss tile.bopGrass.spectralmoss.name=Spectral Moss
tile.bopGrass.smolderinggrass.name=Smoldering Grass Block tile.bopGrass.smolderinggrass.name=Smoldering Grass Block

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B