Whelp I'm back here again, lol, I have been seeing a lot of people not really understanding some of the changes in 1.6, so I decided that I would shed some light on it. Considering I was also going to start some tutorials again since I have been wanting to, and have the time now that school is out, I figured that this would be the perfect time to abuse this. This time I will keep it going and have plans to keep it on a scheduled basis, I will be adding new tutorials every Monday, Wednesday, Friday. On Saturday I will also do a tutorial but I will do something a little different, I will pick a tutorial out of some suggestions that you offer, and will do that. Please, and I beg, don't spam the comments with suggestions instead PM me with them, I prefer to keep the comments full of solutions to peoples problems, or comments. I will also have a poll of things I would like to do at the top that you can vote on to see, and it will go to the top of my list of things to do. I also ask if you do read these tutorials, and are really determined to mod, make sure you follow the golden rule: "Learn java first before attempting to mod", it literally will save you a lot of time. Other rules suggestions will be below the tutorials. Bear in mind if something that has a slot but nothing in it, it means it is coming just give it time. I am working on my mod, as well as these tutorials, and my language.
Nice to see you getting back into the tutorials Leah
And as I said in IRC, I will always be there for you no matter what, tis what friends do.
Good luck on the tutorials, some of these might help me with updating
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
Whole section on items, mobs, blocks and entities.
oh hell yeah, i need blocks and i can't seem to find a tut that works...
Once i know custom shaped block, my mod will have soooo many more blocks....i really need that tut...
Let me know if you like the format of the tutorials I figured GIthub Gists are good for this, if not I could always switch it around. These first few tutorials will probably be in multiples but later on it will start to dwindle down as they will get more complex and I don't have the time for them. But for now enjoy :D.
Thank you for taking you're time to write tutorials again, there's a huge need for good quality tutorials and over saturation of crappy ones so it's great to you back! In my experience rendering tutorials are popularly requested. Also a general TileEntity tutorial could probably do as well, since many people seem to struggle with understanding them for some reason.
Beyond that getting a real tutorial to Core mods would be nice, although I considered figuring core mods out to be a nice bar for when you know programming so good that you can play with ASM and core mods
So, I'm trying to get my Weee! Flowers mod using tile entities for the sixteen flower crops.
I've managed to do everything except the crops don't show their textures and when broken, they drop nothing.
Any help you could give me with this would be fantastic. So many people are waiting for me to update! >.<
BlockPamFlowerCrop
package assets.pamweeeflowers;
import java.util.ArrayList;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class BlockPamFlowerCrop extends BlockFlower
{
@SideOnly(Side.CLIENT)
public Icon[][] iconArray;
public String[] cropName = { "white", "orange", "magenta", "lightblue", "lime", "pink", "darkgrey", "lightgrey", "cyan", "purple", "blue", "brown", "black", "yellow", "red" };
protected BlockPamFlowerCrop(int par1)
{
super(par1);
this.setTickRandomly(true);
float f = 0.5F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
this.setCreativeTab((CreativeTabs)null);
this.setHardness(0.0F);
this.setStepSound(soundGrassFootstep);
this.disableStats();
}
public int idDropped(int i, Random random, int j)
{
//We will use our own drop function
return 0;
}
protected boolean canThisPlantGrowOnThisBlockID(int i)
{
return i == Block.tilledField.blockID;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public int getRenderType()
{
//set our RenderID
//return PamWeeeFlowers.FlowerCropRenderID;
return 6;
}
public boolean renderAsNormalBlock()
{
//use custom renderID
return false;
}
public boolean isOpaqueCube()
{
//Xray sides appear on the sides of the block while this is true;
return false;
}
public TileEntity getBlockEntity()
{
//get a TileEntity.
return new TileEntityPamFlowerCrop();
}
public static TileEntityPamFlowerCrop getFlowerCrop(World world, int i, int j, int k)
{
TileEntityPamFlowerCrop crop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(i, j, k);
return crop;
//This will do all the casting and checking we need
}
/**
* Apply bonemeal to the crops.
*/
public void fertilize(World world, int i, int j, int k, EntityPlayer entityplayer)
{
//Primative bonemeal function
ItemStack helditem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem); //get selected slot
TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k);
if (crop != null && helditem != null)
{
if (helditem.itemID == Item.dyePowder.itemID && helditem.getItemDamage() == 15) /* If it is white dye */
{
crop.applyBonemeal();
entityplayer.inventory.decrStackSize(entityplayer.inventory.currentItem, 1); //decrease current item id slot by 1. Remove 1 bonemeal.
}
}
return;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
super.updateTick(world, i, j, k, random);
if (world.getBlockLightValue(i, j + 1, k) >= 9)
{
//Removed a bunch of stuff involving metadata. addGrowthStage() will do it all.
float f = getGrowthRate(world, i, j, k);
if (random.nextInt((int)(260F / f)) == 0)
{
TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k);
if (crop != null) /* still need to make sure we have a tileentity */
{
crop.addGrowthStage(); //right click grows it one stage
}
}
}
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float f = 1.0F;
int l = par1World.getBlockId(par2, par3, par4 - 1);
int i1 = par1World.getBlockId(par2, par3, par4 + 1);
int j1 = par1World.getBlockId(par2 - 1, par3, par4);
int k1 = par1World.getBlockId(par2 + 1, par3, par4);
int l1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int i2 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int j2 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int k2 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean flag = j1 == this.blockID || k1 == this.blockID;
boolean flag1 = l == this.blockID || i1 == this.blockID;
boolean flag2 = l1 == this.blockID || i2 == this.blockID || j2 == this.blockID || k2 == this.blockID;
for (int l2 = par2 - 1; l2 <= par2 + 1; ++l2)
{
for (int i3 = par4 - 1; i3 <= par4 + 1; ++i3)
{
int j3 = par1World.getBlockId(l2, par3 - 1, i3);
float f1 = 0.0F;
if (blocksList[j3] != null && blocksList[j3].canSustainPlant(par1World, l2, par3 - 1, i3, ForgeDirection.UP, this))
{
f1 = 1.0F;
if (blocksList[j3].isFertile(par1World, l2, par3 - 1, i3))
{
f1 = 3.0F;
}
}
if (l2 != par2 || i3 != par4)
{
f1 /= 4.0F;
}
f += f1;
}
}
if (flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
@SideOnly(Side.CLIENT)
public Icon getIcon(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int cropID = 0;
int stage = 0;
TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
if (tileentitypamflowercrop != null)
{
cropID = tileentitypamflowercrop.getFlowerCropID();
stage = tileentitypamflowercrop.getGrowthStage();
}
return this.iconArray[cropID][stage];
}
@SideOnly(Side.CLIENT)
public void registerIcon(IconRegister ir)
{
this.iconArray = new Icon[15][2];
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 2; j++)
{
this.iconArray[i][j] = ir.registerIcon("pamweeeflowers:" + this.cropName[i] + (j));
}
}
}
}
ClientProxyPamWeeeFlowers
package assets.pamweeeflowers;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxyPamWeeeFlowers extends CommonProxyPamWeeeFlowers
{
@Override
public void registerRenderThings()
{
RenderingRegistry.registerBlockHandler(new PamFlowerCropRenderHandler());
RenderingRegistry.registerBlockHandler(PamWeeeFlowers.FlowerCropRenderID, new PamFlowerCropRenderHandler());
}
}
PamFlowerCropRenderHandler
package assets.pamweeeflowers;
import javax.swing.Renderer;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class PamFlowerCropRenderHandler
implements ISimpleBlockRenderingHandler
{
public PamFlowerCropRenderHandler()
{
PamWeeeFlowers.FlowerCropRenderID = RenderingRegistry.getNextAvailableRenderId();
}
public int getRenderId()
{
return PamWeeeFlowers.FlowerCropRenderID;
}
public boolean shouldRender3DInInventory()
{
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
if (modelId == PamWeeeFlowers.FlowerCropRenderID)
{
TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(x, y, z);
if (tileentitypamflowercrop == null)
{
return false;
}
int cropID = tileentitypamflowercrop.getFlowerCropID();
int stage = tileentitypamflowercrop.getGrowthStage();
if ((block != null) && ((block instanceof BlockPamFlowerCrop)))
{
BlockPamFlowerCrop pamflowerCrop = (BlockPamFlowerCrop)block;
renderer.setOverrideBlockTexture(pamflowerCrop.iconArray[cropID][stage]);
renderer.renderBlockCrops(block, x, y, z);
renderer.hasOverrideBlockTexture();
return true;
}
return false;
}
return false;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID,
RenderBlocks renderer) {
// TODO Auto-generated method stub
}
}
TileEntityPamFlowerCrop
package assets.pamweeeflowers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
public class TileEntityPamFlowerCrop extends TileEntity
{
public TileEntityPamFlowerCrop()
{
}
public void readFromNBT(NBTTagCompound nbttagcompound)
{
//Load the data
super.readFromNBT(nbttagcompound);
FlowerCropID = nbttagcompound.getShort("FlowerCropID");
GrowthStage = nbttagcompound.getShort("GrowthStage");
}
public void writeToNBT(NBTTagCompound nbttagcompound)
{
//Save the data
super.writeToNBT(nbttagcompound);
nbttagcompound.setShort("FlowerCropID", (short) FlowerCropID);
nbttagcompound.setShort("GrowthStage", (short) GrowthStage);
}
public void invalidate()
{
super.invalidate();
int i = GrowthStageCount[FlowerCropID] - 1;
int j = 0;
int k = 0;
if (worldObj.rand.nextInt(1) == 0)
{
j++;
}
if (GrowthStage > 0 && worldObj.rand.nextInt(2) == 0)
{
j++;
}
if (GrowthStage == i)
{
if (j < 1)
{
j = 1;
}
j += worldObj.rand.nextInt(2);
k = 1;
}
/// Added Here
if (GrowthStage == -1)
{
j = 0;
k = 0;
}
///
if (FlowerCropID < SeedDrops.length && j > 0)
{
DropItem(SeedDrops[FlowerCropID], j);
}
if (FlowerCropID < HarvestDrops.length && k > 0)
{
DropItem(HarvestDrops[FlowerCropID], k);
}
}
public void DropItem(int Item, int Count)
{
float f = 0.7F;
double d = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d2 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
if (FlowerCropID > 13)
{
EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, 0));
entityitem.delayBeforeCanPickup = 10;
worldObj.spawnEntityInWorld(entityitem);
}
else
{
EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, FlowerCropID));
entityitem.delayBeforeCanPickup = 10;
worldObj.spawnEntityInWorld(entityitem);
}
return;
}
public void setFlowerCropID(int ID)
{
FlowerCropID = ID;//used by the seed item
}
public int getFlowerCropID()
{
//Base value for fetching other values
return FlowerCropID;
}
public void addGrowthStage()
{
//Run this instead of metadata functions
if (FlowerCropID < GrowthStageCount.length) /* Check if the CropID is in range to avoid a crash */
{
if (GrowthStage < GrowthStageCount[FlowerCropID] - 1) /* If it hasn't hit the max for that CropID, add a stage. Subtract one because the start stage was already used. */
{
GrowthStage++;
}
}
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); //Updates the block so it displays properly
}
public void setGrowthStage(int Stage)
{
//In case you need an override
if (FlowerCropID < GrowthStageCount.length)
{
int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max
if (Stage > MaxStage)
{
GrowthStage = MaxStage;
}
else
{
GrowthStage = Stage;
}
}
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
}
public int getGrowthStage()
{
//In case you need to check the stage
return GrowthStage;
}
public void applyBonemeal()
{
//Set it to the Max Stage
if (FlowerCropID < GrowthStageCount.length)
{
int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max
System.out.println("I'm Growing");
GrowthStage = MaxStage;
}
worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
}
private int FlowerCropID = 0; //This will be set in a custom seed item during placement
private int GrowthStage = 0; //should always start at 0
private int[] GrowthStageCount = {3,//White
3,//Orange
3,//Magenta
3,//Lightblue
3,//Lime
3,//Pink
3,//Grey
3,//Lightgrey
3,//Cyan
3,//Purple
3,//Blue
3,//Brown
3,//Green
3,//Black
3,//Yellow
3};//Red
//There are 8 default wheat stages. We will put 8 for CropID 3 so we can go through all stages.
private int[] SeedDrops = {PamWeeeFlowers.pamFlower.blockID,//White
PamWeeeFlowers.pamFlower.blockID,//Orange
PamWeeeFlowers.pamFlower.blockID,//Magenta
PamWeeeFlowers.pamFlower.blockID,//Lightblue
PamWeeeFlowers.pamFlower.blockID,//Lime
PamWeeeFlowers.pamFlower.blockID,//Pink
PamWeeeFlowers.pamFlower.blockID,//Grey
PamWeeeFlowers.pamFlower.blockID,//Lightgrey
PamWeeeFlowers.pamFlower.blockID,//Cyan
PamWeeeFlowers.pamFlower.blockID,//Purple
PamWeeeFlowers.pamFlower.blockID,//Blue
PamWeeeFlowers.pamFlower.blockID,//Brown
PamWeeeFlowers.pamFlower.blockID,//Green
PamWeeeFlowers.pamFlower.blockID,//Black
Block.plantYellow.blockID,//Yellow
Block.plantRed.blockID};//Red
//These are seed drops in the same array format. Just fill it with Item/Block IDs.
private int[] HarvestDrops = {PamWeeeFlowers.pamFlower.blockID,//White
PamWeeeFlowers.pamFlower.blockID,//Orange
PamWeeeFlowers.pamFlower.blockID,//Magenta
PamWeeeFlowers.pamFlower.blockID,//Lightblue
PamWeeeFlowers.pamFlower.blockID,//Lime
PamWeeeFlowers.pamFlower.blockID,//Pink
PamWeeeFlowers.pamFlower.blockID,//Grey
PamWeeeFlowers.pamFlower.blockID,//Lightgrey
PamWeeeFlowers.pamFlower.blockID,//Cyan
PamWeeeFlowers.pamFlower.blockID,//Purple
PamWeeeFlowers.pamFlower.blockID,//Blue
PamWeeeFlowers.pamFlower.blockID,//Brown
PamWeeeFlowers.pamFlower.blockID,//Green
PamWeeeFlowers.pamFlower.blockID,//Black
Block.plantYellow.blockID,//Yellow
Block.plantRed.blockID};//Red
}
Excellent tutorials! I'm currently working on writing the underpinnings of my new mod, and this helped clear up some of the 1.6 differences. Pam, have you posted that on your thread? I'm sure that if you asked for update help there, one of your users could help. I of course understand why you wouldn't want to do that, but it's always an option.
Excellent tutorials! I'm currently working on writing the underpinnings of my new mod, and this helped clear up some of the 1.6 differences. Pam, have you posted that on your thread? I'm sure that if you asked for update help there, one of your users could help. I of course understand why you wouldn't want to do that, but it's always an option.
I've posted it several places and e-mailed some coders who are waaay better than me. Hopefully I'll get an answer soon so flowers can once again spawn in Minecraftia. xD
So, I'm trying to get my Weee! Flowers mod using tile entities for the sixteen flower crops.
I've managed to do everything except the crops don't show their textures and when broken, they drop nothing.
Any help you could give me with this would be fantastic. So many people are waiting for me to update! >.<
BlockPamFlowerCrop
package assets.pamweeeflowers;
import java.util.ArrayList;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class BlockPamFlowerCrop extends BlockFlower
{
@SideOnly(Side.CLIENT)
public Icon[][] iconArray;
public String[] cropName = { "white", "orange", "magenta", "lightblue", "lime", "pink", "darkgrey", "lightgrey", "cyan", "purple", "blue", "brown", "black", "yellow", "red" };
protected BlockPamFlowerCrop(int par1)
{
super(par1);
this.setTickRandomly(true);
float f = 0.5F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
this.setCreativeTab((CreativeTabs)null);
this.setHardness(0.0F);
this.setStepSound(soundGrassFootstep);
this.disableStats();
}
public int idDropped(int i, Random random, int j)
{
//We will use our own drop function
return 0;
}
protected boolean canThisPlantGrowOnThisBlockID(int i)
{
return i == Block.tilledField.blockID;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public int getRenderType()
{
//set our RenderID
//return PamWeeeFlowers.FlowerCropRenderID;
return 6;
}
public boolean renderAsNormalBlock()
{
//use custom renderID
return false;
}
public boolean isOpaqueCube()
{
//Xray sides appear on the sides of the block while this is true;
return false;
}
public TileEntity getBlockEntity()
{
//get a TileEntity.
return new TileEntityPamFlowerCrop();
}
public static TileEntityPamFlowerCrop getFlowerCrop(World world, int i, int j, int k)
{
TileEntityPamFlowerCrop crop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(i, j, k);
return crop;
//This will do all the casting and checking we need
}
/**
* Apply bonemeal to the crops.
*/
public void fertilize(World world, int i, int j, int k, EntityPlayer entityplayer)
{
//Primative bonemeal function
ItemStack helditem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem); //get selected slot
TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k);
if (crop != null && helditem != null)
{
if (helditem.itemID == Item.dyePowder.itemID && helditem.getItemDamage() == 15) /* If it is white dye */
{
crop.applyBonemeal();
entityplayer.inventory.decrStackSize(entityplayer.inventory.currentItem, 1); //decrease current item id slot by 1. Remove 1 bonemeal.
}
}
return;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
super.updateTick(world, i, j, k, random);
if (world.getBlockLightValue(i, j + 1, k) >= 9)
{
//Removed a bunch of stuff involving metadata. addGrowthStage() will do it all.
float f = getGrowthRate(world, i, j, k);
if (random.nextInt((int)(260F / f)) == 0)
{
TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k);
if (crop != null) /* still need to make sure we have a tileentity */
{
crop.addGrowthStage(); //right click grows it one stage
}
}
}
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float f = 1.0F;
int l = par1World.getBlockId(par2, par3, par4 - 1);
int i1 = par1World.getBlockId(par2, par3, par4 + 1);
int j1 = par1World.getBlockId(par2 - 1, par3, par4);
int k1 = par1World.getBlockId(par2 + 1, par3, par4);
int l1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int i2 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int j2 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int k2 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean flag = j1 == this.blockID || k1 == this.blockID;
boolean flag1 = l == this.blockID || i1 == this.blockID;
boolean flag2 = l1 == this.blockID || i2 == this.blockID || j2 == this.blockID || k2 == this.blockID;
for (int l2 = par2 - 1; l2 <= par2 + 1; ++l2)
{
for (int i3 = par4 - 1; i3 <= par4 + 1; ++i3)
{
int j3 = par1World.getBlockId(l2, par3 - 1, i3);
float f1 = 0.0F;
if (blocksList[j3] != null && blocksList[j3].canSustainPlant(par1World, l2, par3 - 1, i3, ForgeDirection.UP, this))
{
f1 = 1.0F;
if (blocksList[j3].isFertile(par1World, l2, par3 - 1, i3))
{
f1 = 3.0F;
}
}
if (l2 != par2 || i3 != par4)
{
f1 /= 4.0F;
}
f += f1;
}
}
if (flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
@SideOnly(Side.CLIENT)
public Icon getIcon(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int cropID = 0;
int stage = 0;
TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
if (tileentitypamflowercrop != null)
{
cropID = tileentitypamflowercrop.getFlowerCropID();
stage = tileentitypamflowercrop.getGrowthStage();
}
return this.iconArray[cropID][stage];
}
@SideOnly(Side.CLIENT)
public void registerIcon(IconRegister ir)
{
this.iconArray = new Icon[15][2];
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 2; j++)
{
this.iconArray[i][j] = ir.registerIcon("pamweeeflowers:" + this.cropName[i] + (j));
}
}
}
}
ClientProxyPamWeeeFlowers
package assets.pamweeeflowers;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxyPamWeeeFlowers extends CommonProxyPamWeeeFlowers
{
@Override
public void registerRenderThings()
{
RenderingRegistry.registerBlockHandler(new PamFlowerCropRenderHandler());
RenderingRegistry.registerBlockHandler(PamWeeeFlowers.FlowerCropRenderID, new PamFlowerCropRenderHandler());
}
}
PamFlowerCropRenderHandler
package assets.pamweeeflowers;
import javax.swing.Renderer;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class PamFlowerCropRenderHandler
implements ISimpleBlockRenderingHandler
{
public PamFlowerCropRenderHandler()
{
PamWeeeFlowers.FlowerCropRenderID = RenderingRegistry.getNextAvailableRenderId();
}
public int getRenderId()
{
return PamWeeeFlowers.FlowerCropRenderID;
}
public boolean shouldRender3DInInventory()
{
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
if (modelId == PamWeeeFlowers.FlowerCropRenderID)
{
TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(x, y, z);
if (tileentitypamflowercrop == null)
{
return false;
}
int cropID = tileentitypamflowercrop.getFlowerCropID();
int stage = tileentitypamflowercrop.getGrowthStage();
if ((block != null) && ((block instanceof BlockPamFlowerCrop)))
{
BlockPamFlowerCrop pamflowerCrop = (BlockPamFlowerCrop)block;
renderer.setOverrideBlockTexture(pamflowerCrop.iconArray[cropID][stage]);
renderer.renderBlockCrops(block, x, y, z);
renderer.hasOverrideBlockTexture();
return true;
}
return false;
}
return false;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID,
RenderBlocks renderer) {
// TODO Auto-generated method stub
}
}
TileEntityPamFlowerCrop
package assets.pamweeeflowers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
public class TileEntityPamFlowerCrop extends TileEntity
{
public TileEntityPamFlowerCrop()
{
}
public void readFromNBT(NBTTagCompound nbttagcompound)
{
//Load the data
super.readFromNBT(nbttagcompound);
FlowerCropID = nbttagcompound.getShort("FlowerCropID");
GrowthStage = nbttagcompound.getShort("GrowthStage");
}
public void writeToNBT(NBTTagCompound nbttagcompound)
{
//Save the data
super.writeToNBT(nbttagcompound);
nbttagcompound.setShort("FlowerCropID", (short) FlowerCropID);
nbttagcompound.setShort("GrowthStage", (short) GrowthStage);
}
public void invalidate()
{
super.invalidate();
int i = GrowthStageCount[FlowerCropID] - 1;
int j = 0;
int k = 0;
if (worldObj.rand.nextInt(1) == 0)
{
j++;
}
if (GrowthStage > 0 && worldObj.rand.nextInt(2) == 0)
{
j++;
}
if (GrowthStage == i)
{
if (j < 1)
{
j = 1;
}
j += worldObj.rand.nextInt(2);
k = 1;
}
/// Added Here
if (GrowthStage == -1)
{
j = 0;
k = 0;
}
///
if (FlowerCropID < SeedDrops.length && j > 0)
{
DropItem(SeedDrops[FlowerCropID], j);
}
if (FlowerCropID < HarvestDrops.length && k > 0)
{
DropItem(HarvestDrops[FlowerCropID], k);
}
}
public void DropItem(int Item, int Count)
{
float f = 0.7F;
double d = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d2 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
if (FlowerCropID > 13)
{
EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, 0));
entityitem.delayBeforeCanPickup = 10;
worldObj.spawnEntityInWorld(entityitem);
}
else
{
EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, FlowerCropID));
entityitem.delayBeforeCanPickup = 10;
worldObj.spawnEntityInWorld(entityitem);
}
return;
}
public void setFlowerCropID(int ID)
{
FlowerCropID = ID;//used by the seed item
}
public int getFlowerCropID()
{
//Base value for fetching other values
return FlowerCropID;
}
public void addGrowthStage()
{
//Run this instead of metadata functions
if (FlowerCropID < GrowthStageCount.length) /* Check if the CropID is in range to avoid a crash */
{
if (GrowthStage < GrowthStageCount[FlowerCropID] - 1) /* If it hasn't hit the max for that CropID, add a stage. Subtract one because the start stage was already used. */
{
GrowthStage++;
}
}
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); //Updates the block so it displays properly
}
public void setGrowthStage(int Stage)
{
//In case you need an override
if (FlowerCropID < GrowthStageCount.length)
{
int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max
if (Stage > MaxStage)
{
GrowthStage = MaxStage;
}
else
{
GrowthStage = Stage;
}
}
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
}
public int getGrowthStage()
{
//In case you need to check the stage
return GrowthStage;
}
public void applyBonemeal()
{
//Set it to the Max Stage
if (FlowerCropID < GrowthStageCount.length)
{
int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max
System.out.println("I'm Growing");
GrowthStage = MaxStage;
}
worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
}
private int FlowerCropID = 0; //This will be set in a custom seed item during placement
private int GrowthStage = 0; //should always start at 0
private int[] GrowthStageCount = {3,//White
3,//Orange
3,//Magenta
3,//Lightblue
3,//Lime
3,//Pink
3,//Grey
3,//Lightgrey
3,//Cyan
3,//Purple
3,//Blue
3,//Brown
3,//Green
3,//Black
3,//Yellow
3};//Red
//There are 8 default wheat stages. We will put 8 for CropID 3 so we can go through all stages.
private int[] SeedDrops = {PamWeeeFlowers.pamFlower.blockID,//White
PamWeeeFlowers.pamFlower.blockID,//Orange
PamWeeeFlowers.pamFlower.blockID,//Magenta
PamWeeeFlowers.pamFlower.blockID,//Lightblue
PamWeeeFlowers.pamFlower.blockID,//Lime
PamWeeeFlowers.pamFlower.blockID,//Pink
PamWeeeFlowers.pamFlower.blockID,//Grey
PamWeeeFlowers.pamFlower.blockID,//Lightgrey
PamWeeeFlowers.pamFlower.blockID,//Cyan
PamWeeeFlowers.pamFlower.blockID,//Purple
PamWeeeFlowers.pamFlower.blockID,//Blue
PamWeeeFlowers.pamFlower.blockID,//Brown
PamWeeeFlowers.pamFlower.blockID,//Green
PamWeeeFlowers.pamFlower.blockID,//Black
Block.plantYellow.blockID,//Yellow
Block.plantRed.blockID};//Red
//These are seed drops in the same array format. Just fill it with Item/Block IDs.
private int[] HarvestDrops = {PamWeeeFlowers.pamFlower.blockID,//White
PamWeeeFlowers.pamFlower.blockID,//Orange
PamWeeeFlowers.pamFlower.blockID,//Magenta
PamWeeeFlowers.pamFlower.blockID,//Lightblue
PamWeeeFlowers.pamFlower.blockID,//Lime
PamWeeeFlowers.pamFlower.blockID,//Pink
PamWeeeFlowers.pamFlower.blockID,//Grey
PamWeeeFlowers.pamFlower.blockID,//Lightgrey
PamWeeeFlowers.pamFlower.blockID,//Cyan
PamWeeeFlowers.pamFlower.blockID,//Purple
PamWeeeFlowers.pamFlower.blockID,//Blue
PamWeeeFlowers.pamFlower.blockID,//Brown
PamWeeeFlowers.pamFlower.blockID,//Green
PamWeeeFlowers.pamFlower.blockID,//Black
Block.plantYellow.blockID,//Yellow
Block.plantRed.blockID};//Red
}
Try going to my github I have a mod there that is for 1.6.1 that has crops in it.
Excellent tutorials! I'm currently working on writing the underpinnings of my new mod, and this helped clear up some of the 1.6 differences. Pam, have you posted that on your thread? I'm sure that if you asked for update help there, one of your users could help. I of course understand why you wouldn't want to do that, but it's always an option.
I've posted it several places and e-mailed some coders who are waaay better than me. Hopefully I'll get an answer soon so flowers can once again spawn in Minecraftia. xD
Here is your reply ;PWhat should I do for wednesday anyone have any comments?
I am sorry if this is a very stupid question but what exactly do I do with the code in the tutorials. Where am I supposed to save the file or paste the code to?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
rulessuggestions will be below the tutorials. Bear in mind if something that has a slot but nothing in it, it means it is coming just give it time. I am working on my mod, as well as these tutorials, and my language.Simple Mod Base:
Here is a link to the tutorial: https://gist.github....fde532c03299d63
Simple Block:
This uses the Simple Mod Base tutorial so please make sure you follow that one first.
Here is a link to the tutorial: https://gist.github....b20e3d1bfb7a38d
Simple Item:
This uses the Simple Mod Base tutorial so please make sure you follow that one first.
Here is a link to the tutorial: https://gist.github....e81d5e03771ce70
Creative Tab:
Basic Custom Block Rendering (TESR / IIR):
This uses the Simple Mod Base tutorial so please make sure you follow that one first.
Here is a link to the tutorial: https://gist.github.com/Asyncronous/28d0951ea0b2b3f32091
Rules:
Misc:
My github: https://www.github.com/Asyncronous
Credits:
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHelp modders out by contributing to the Forge Ore Dictionary List! http://mce626.wix.com/odnlist
And as I said in IRC, I will always be there for you no matter what, tis what friends do.
Good luck on the tutorials, some of these might help me with updating
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Whole section on items, mobs, blocks and entities.
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumoh hell yeah, i need blocks and i can't seem to find a tut that works...
Once i know custom shaped block, my mod will have soooo many more blocks....i really need that tut...
Help modders out by contributing to the Forge Ore Dictionary List! http://mce626.wix.com/odnlist
- Simple Mod Base
- Simple Block
- Simple Item
Let me know if you like the format of the tutorials I figured GIthub Gists are good for this, if not I could always switch it around. These first few tutorials will probably be in multiples but later on it will start to dwindle down as they will get more complex and I don't have the time for them. But for now enjoy :D.Beyond that getting a real tutorial to Core mods would be nice, although I considered figuring core mods out to be a nice bar for when you know programming so good that you can play with ASM and core mods
Anyways, welcome back!
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI've managed to do everything except the crops don't show their textures and when broken, they drop nothing.
Any help you could give me with this would be fantastic. So many people are waiting for me to update! >.<
BlockPamFlowerCrop
package assets.pamweeeflowers; import java.util.ArrayList; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; public class BlockPamFlowerCrop extends BlockFlower { @SideOnly(Side.CLIENT) public Icon[][] iconArray; public String[] cropName = { "white", "orange", "magenta", "lightblue", "lime", "pink", "darkgrey", "lightgrey", "cyan", "purple", "blue", "brown", "black", "yellow", "red" }; protected BlockPamFlowerCrop(int par1) { super(par1); this.setTickRandomly(true); float f = 0.5F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); this.setCreativeTab((CreativeTabs)null); this.setHardness(0.0F); this.setStepSound(soundGrassFootstep); this.disableStats(); } public int idDropped(int i, Random random, int j) { //We will use our own drop function return 0; } protected boolean canThisPlantGrowOnThisBlockID(int i) { return i == Block.tilledField.blockID; } public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { return null; } public int getRenderType() { //set our RenderID //return PamWeeeFlowers.FlowerCropRenderID; return 6; } public boolean renderAsNormalBlock() { //use custom renderID return false; } public boolean isOpaqueCube() { //Xray sides appear on the sides of the block while this is true; return false; } public TileEntity getBlockEntity() { //get a TileEntity. return new TileEntityPamFlowerCrop(); } public static TileEntityPamFlowerCrop getFlowerCrop(World world, int i, int j, int k) { TileEntityPamFlowerCrop crop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(i, j, k); return crop; //This will do all the casting and checking we need } /** * Apply bonemeal to the crops. */ public void fertilize(World world, int i, int j, int k, EntityPlayer entityplayer) { //Primative bonemeal function ItemStack helditem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem); //get selected slot TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k); if (crop != null && helditem != null) { if (helditem.itemID == Item.dyePowder.itemID && helditem.getItemDamage() == 15) /* If it is white dye */ { crop.applyBonemeal(); entityplayer.inventory.decrStackSize(entityplayer.inventory.currentItem, 1); //decrease current item id slot by 1. Remove 1 bonemeal. } } return; } public void updateTick(World world, int i, int j, int k, Random random) { super.updateTick(world, i, j, k, random); if (world.getBlockLightValue(i, j + 1, k) >= 9) { //Removed a bunch of stuff involving metadata. addGrowthStage() will do it all. float f = getGrowthRate(world, i, j, k); if (random.nextInt((int)(260F / f)) == 0) { TileEntityPamFlowerCrop crop = getFlowerCrop(world, i, j, k); if (crop != null) /* still need to make sure we have a tileentity */ { crop.addGrowthStage(); //right click grows it one stage } } } } /** * Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on * different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below * this one). Args: x, y, z */ private float getGrowthRate(World par1World, int par2, int par3, int par4) { float f = 1.0F; int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); int l1 = par1World.getBlockId(par2 - 1, par3, par4 - 1); int i2 = par1World.getBlockId(par2 + 1, par3, par4 - 1); int j2 = par1World.getBlockId(par2 + 1, par3, par4 + 1); int k2 = par1World.getBlockId(par2 - 1, par3, par4 + 1); boolean flag = j1 == this.blockID || k1 == this.blockID; boolean flag1 = l == this.blockID || i1 == this.blockID; boolean flag2 = l1 == this.blockID || i2 == this.blockID || j2 == this.blockID || k2 == this.blockID; for (int l2 = par2 - 1; l2 <= par2 + 1; ++l2) { for (int i3 = par4 - 1; i3 <= par4 + 1; ++i3) { int j3 = par1World.getBlockId(l2, par3 - 1, i3); float f1 = 0.0F; if (blocksList[j3] != null && blocksList[j3].canSustainPlant(par1World, l2, par3 - 1, i3, ForgeDirection.UP, this)) { f1 = 1.0F; if (blocksList[j3].isFertile(par1World, l2, par3 - 1, i3)) { f1 = 3.0F; } } if (l2 != par2 || i3 != par4) { f1 /= 4.0F; } f += f1; } } if (flag2 || flag && flag1) { f /= 2.0F; } return f; } @SideOnly(Side.CLIENT) public Icon getIcon(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int cropID = 0; int stage = 0; TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)par1IBlockAccess.getBlockTileEntity(par2, par3, par4); if (tileentitypamflowercrop != null) { cropID = tileentitypamflowercrop.getFlowerCropID(); stage = tileentitypamflowercrop.getGrowthStage(); } return this.iconArray[cropID][stage]; } @SideOnly(Side.CLIENT) public void registerIcon(IconRegister ir) { this.iconArray = new Icon[15][2]; for (int i = 0; i < 15; i++) { for (int j = 0; j < 2; j++) { this.iconArray[i][j] = ir.registerIcon("pamweeeflowers:" + this.cropName[i] + (j)); } } } }ClientProxyPamWeeeFlowers
package assets.pamweeeflowers; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyPamWeeeFlowers extends CommonProxyPamWeeeFlowers { @Override public void registerRenderThings() { RenderingRegistry.registerBlockHandler(new PamFlowerCropRenderHandler()); RenderingRegistry.registerBlockHandler(PamWeeeFlowers.FlowerCropRenderID, new PamFlowerCropRenderHandler()); } }PamFlowerCropRenderHandler
package assets.pamweeeflowers; import javax.swing.Renderer; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; public class PamFlowerCropRenderHandler implements ISimpleBlockRenderingHandler { public PamFlowerCropRenderHandler() { PamWeeeFlowers.FlowerCropRenderID = RenderingRegistry.getNextAvailableRenderId(); } public int getRenderId() { return PamWeeeFlowers.FlowerCropRenderID; } public boolean shouldRender3DInInventory() { return false; } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (modelId == PamWeeeFlowers.FlowerCropRenderID) { TileEntityPamFlowerCrop tileentitypamflowercrop = (TileEntityPamFlowerCrop)world.getBlockTileEntity(x, y, z); if (tileentitypamflowercrop == null) { return false; } int cropID = tileentitypamflowercrop.getFlowerCropID(); int stage = tileentitypamflowercrop.getGrowthStage(); if ((block != null) && ((block instanceof BlockPamFlowerCrop))) { BlockPamFlowerCrop pamflowerCrop = (BlockPamFlowerCrop)block; renderer.setOverrideBlockTexture(pamflowerCrop.iconArray[cropID][stage]); renderer.renderBlockCrops(block, x, y, z); renderer.hasOverrideBlockTexture(); return true; } return false; } return false; } @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { // TODO Auto-generated method stub } }TileEntityPamFlowerCrop
package assets.pamweeeflowers; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; public class TileEntityPamFlowerCrop extends TileEntity { public TileEntityPamFlowerCrop() { } public void readFromNBT(NBTTagCompound nbttagcompound) { //Load the data super.readFromNBT(nbttagcompound); FlowerCropID = nbttagcompound.getShort("FlowerCropID"); GrowthStage = nbttagcompound.getShort("GrowthStage"); } public void writeToNBT(NBTTagCompound nbttagcompound) { //Save the data super.writeToNBT(nbttagcompound); nbttagcompound.setShort("FlowerCropID", (short) FlowerCropID); nbttagcompound.setShort("GrowthStage", (short) GrowthStage); } public void invalidate() { super.invalidate(); int i = GrowthStageCount[FlowerCropID] - 1; int j = 0; int k = 0; if (worldObj.rand.nextInt(1) == 0) { j++; } if (GrowthStage > 0 && worldObj.rand.nextInt(2) == 0) { j++; } if (GrowthStage == i) { if (j < 1) { j = 1; } j += worldObj.rand.nextInt(2); k = 1; } /// Added Here if (GrowthStage == -1) { j = 0; k = 0; } /// if (FlowerCropID < SeedDrops.length && j > 0) { DropItem(SeedDrops[FlowerCropID], j); } if (FlowerCropID < HarvestDrops.length && k > 0) { DropItem(HarvestDrops[FlowerCropID], k); } } public void DropItem(int Item, int Count) { float f = 0.7F; double d = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d2 = (double)(worldObj.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; if (FlowerCropID > 13) { EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, 0)); entityitem.delayBeforeCanPickup = 10; worldObj.spawnEntityInWorld(entityitem); } else { EntityItem entityitem = new EntityItem(worldObj, (double)xCoord + d, (double)yCoord + d1, (double)zCoord + d2, new ItemStack(Item, Count, FlowerCropID)); entityitem.delayBeforeCanPickup = 10; worldObj.spawnEntityInWorld(entityitem); } return; } public void setFlowerCropID(int ID) { FlowerCropID = ID;//used by the seed item } public int getFlowerCropID() { //Base value for fetching other values return FlowerCropID; } public void addGrowthStage() { //Run this instead of metadata functions if (FlowerCropID < GrowthStageCount.length) /* Check if the CropID is in range to avoid a crash */ { if (GrowthStage < GrowthStageCount[FlowerCropID] - 1) /* If it hasn't hit the max for that CropID, add a stage. Subtract one because the start stage was already used. */ { GrowthStage++; } } worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); //Updates the block so it displays properly } public void setGrowthStage(int Stage) { //In case you need an override if (FlowerCropID < GrowthStageCount.length) { int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max if (Stage > MaxStage) { GrowthStage = MaxStage; } else { GrowthStage = Stage; } } worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); } public int getGrowthStage() { //In case you need to check the stage return GrowthStage; } public void applyBonemeal() { //Set it to the Max Stage if (FlowerCropID < GrowthStageCount.length) { int MaxStage = GrowthStageCount[FlowerCropID] - 1; //Make sure we don't get above max System.out.println("I'm Growing"); GrowthStage = MaxStage; } worldObj.setBlock(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); } private int FlowerCropID = 0; //This will be set in a custom seed item during placement private int GrowthStage = 0; //should always start at 0 private int[] GrowthStageCount = {3,//White 3,//Orange 3,//Magenta 3,//Lightblue 3,//Lime 3,//Pink 3,//Grey 3,//Lightgrey 3,//Cyan 3,//Purple 3,//Blue 3,//Brown 3,//Green 3,//Black 3,//Yellow 3};//Red //There are 8 default wheat stages. We will put 8 for CropID 3 so we can go through all stages. private int[] SeedDrops = {PamWeeeFlowers.pamFlower.blockID,//White PamWeeeFlowers.pamFlower.blockID,//Orange PamWeeeFlowers.pamFlower.blockID,//Magenta PamWeeeFlowers.pamFlower.blockID,//Lightblue PamWeeeFlowers.pamFlower.blockID,//Lime PamWeeeFlowers.pamFlower.blockID,//Pink PamWeeeFlowers.pamFlower.blockID,//Grey PamWeeeFlowers.pamFlower.blockID,//Lightgrey PamWeeeFlowers.pamFlower.blockID,//Cyan PamWeeeFlowers.pamFlower.blockID,//Purple PamWeeeFlowers.pamFlower.blockID,//Blue PamWeeeFlowers.pamFlower.blockID,//Brown PamWeeeFlowers.pamFlower.blockID,//Green PamWeeeFlowers.pamFlower.blockID,//Black Block.plantYellow.blockID,//Yellow Block.plantRed.blockID};//Red //These are seed drops in the same array format. Just fill it with Item/Block IDs. private int[] HarvestDrops = {PamWeeeFlowers.pamFlower.blockID,//White PamWeeeFlowers.pamFlower.blockID,//Orange PamWeeeFlowers.pamFlower.blockID,//Magenta PamWeeeFlowers.pamFlower.blockID,//Lightblue PamWeeeFlowers.pamFlower.blockID,//Lime PamWeeeFlowers.pamFlower.blockID,//Pink PamWeeeFlowers.pamFlower.blockID,//Grey PamWeeeFlowers.pamFlower.blockID,//Lightgrey PamWeeeFlowers.pamFlower.blockID,//Cyan PamWeeeFlowers.pamFlower.blockID,//Purple PamWeeeFlowers.pamFlower.blockID,//Blue PamWeeeFlowers.pamFlower.blockID,//Brown PamWeeeFlowers.pamFlower.blockID,//Green PamWeeeFlowers.pamFlower.blockID,//Black Block.plantYellow.blockID,//Yellow Block.plantRed.blockID};//Red }-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI've posted it several places and e-mailed some coders who are waaay better than me. Hopefully I'll get an answer soon so flowers can once again spawn in Minecraftia. xD
Try going to my github I have a mod there that is for 1.6.1 that has crops in it.
Thanks
Here is your reply ;PWhat should I do for wednesday anyone have any comments?
Yes I mean TE's
-
View User Profile
-
View Posts
-
Send Message
ModeratorMapping and Modding rules | Global rules | MCFStaff Youtube channel
Follow @I_Mod_Minecraft
Alright I will add that to my list this saturday
I presume so...yes