The Meaning of Life, the Universe, and Everything.
Join Date:
2/17/2012
Posts:
49
Minecraft:
Pyroglyph
Member Details
Okay so my mod adds lots of candy to the game. What I want is a block which you can right-click and you get some candy canes. After a while the candy canes will grow back. I think I need a TileEntity (because I need 2 different textures kinda like a furnace) but I have never worked with them before.
I've made the block and the textures so all I need is some guidance!
Hope you can help, and if you do thank you
BlockCandyBush.java:
package com.cydial.candyland.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.world.IBlockAccess;
import com.cydial.candyland.Main;
public class BlockCandyBush extends Block
{
public BlockCandyBush(Material material)
{
super(material);
this.setHardness(0.1F);
this.setBlockTextureName(Main.MODID + ":candyBush");
this.setBlockName("BlockCandyBush");
this.setCreativeTab(CreativeTabs.tabBlock);
this.setStepSound(Block.soundTypeGrass);
this.opaque = false;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune)
{
return com.cydial.candyland.Main.ItemCandyCane;
}
@Override
public int quantityDropped(Random random)
{
return 4;
}
public boolean isOpaqueCube()
{
return false;
}
}
I think you probably want to consider this a "crop".
I've already had a look and I think they only cover what block it can be placed on (might be handy) and to get the candycanes from it requires you to destroy it. Which I don't want. I want the bush to stay there, but with a different texture (a bush without the candy) that's why I suggested TileEntity.
I've already had a look and I think they only cover what block it can be placed on (might be handy) and to get the candycanes from it requires you to destroy it. Which I don't want. I want the bush to stay there, but with a different texture (a bush without the candy) that's why I suggested TileEntity.
Just to add onto it, since you mentioned that you've never dealt with TileEntities before, you'd want to just... make a tile entity class extending "TileEntity." Not sure what other methods are required for crops, but in "public void updateEntity()" should be a randomized timer (look at other crop Tile Entities) that eventually changes the metadata, or the "stage" of the crop (In reality, it's just another variation of a block).
Okay I had a look at that and played round with it a bit, but now I'm stuck at this:
spawnItemAtPlayer(player, new ItemStack(ItemCandyCane));
Apparently ItemCandyCane "can't be resolved to a variable" even though it's a class and it's not supposed to be a variable. I have tried importing 'com.cydial.candyland.items.*' and 'com.cydial.candyland.items.ItemCandyCane' but none of these work. I also tried to do this:
spawnItemAtPlayer(player, new ItemStack(com.cydial.candyland.items.ItemCandyCane));
which didn't work either. Any help?
I've already had a look and I think they only cover what block it can be placed on (might be handy) and to get the candycanes from it requires you to destroy it. Which I don't want. I want the bush to stay there, but with a different texture (a bush without the candy) that's why I suggested TileEntity.
Actually, you can just cancel the BlockEvent.BreakEvent if you want. Basically you'd handle the block break event, check if the block is your custom type, output the harvest, and reset the damage for the block (so that it will take a while to get the harvest out again) and cancel the event.
Okay I had a look at that and played round with it a bit, but now I'm stuck at this:
spawnItemAtPlayer(player, new ItemStack(ItemCandyCane));
Apparently ItemCandyCane "can't be resolved to a variable" even though it's a class and it's not supposed to be a variable. I have tried importing 'com.cydial.candyland.items.*' and 'com.cydial.candyland.items.ItemCandyCane' but none of these work. I also tried to do this:
spawnItemAtPlayer(player, new ItemStack(com.cydial.candyland.items.ItemCandyCane));
which didn't work either. Any help?
You should have made your item static in the main class where you registered it. Not the actual item class file. :\
You should have made your item static in the main class where you registered it. Not the actual item class file. :\
It is static... And anyways I fixed it by importing my main class and not the Item class itself (becasue I registered the item in the Main class) but now is the problem of making the berries grow. I have already tested the rightclick thing and it works, now to make it grow and change texture.
Okay so now I have my candy bush (w/ candy) which changes to the empty bush (no candy) when right-clicked (you also get a candy cane) but do I use tickUpdate or something with a for loop to decide when to make the candy canes grow back? Also, when you right-click a full bush, it doesn't change texture unless there is a block update nearby. Any way to fix this without using a TileEntity? (becuase those are difficult)
I've made the block and the textures so all I need is some guidance!
Hope you can help, and if you do thank you
BlockCandyBush.java:
No, my computer is not too slow.
[email protected], GALAX GTX 980Ti HOF 6GB, Seagate 1TB 7200RPM HDD, Crucial MX100 256GB SSD, 2x Kingston 8GB@1866MHz, EVGA NEX750G PSU
I've already had a look and I think they only cover what block it can be placed on (might be handy) and to get the candycanes from it requires you to destroy it. Which I don't want. I want the bush to stay there, but with a different texture (a bush without the candy) that's why I suggested TileEntity.
No, my computer is not too slow.
[email protected], GALAX GTX 980Ti HOF 6GB, Seagate 1TB 7200RPM HDD, Crucial MX100 256GB SSD, 2x Kingston 8GB@1866MHz, EVGA NEX750G PSU
You should really look before questioning.
https://github.com/SlimeKnights/TinkersConstruct/blob/1.6.4/src/main/java/tconstruct/blocks/OreberryBush.java
Just to add onto it, since you mentioned that you've never dealt with TileEntities before, you'd want to just... make a tile entity class extending "TileEntity." Not sure what other methods are required for crops, but in "public void updateEntity()" should be a randomized timer (look at other crop Tile Entities) that eventually changes the metadata, or the "stage" of the crop (In reality, it's just another variation of a block).
:3
Okay I had a look at that and played round with it a bit, but now I'm stuck at this:
Apparently ItemCandyCane "can't be resolved to a variable" even though it's a class and it's not supposed to be a variable. I have tried importing 'com.cydial.candyland.items.*' and 'com.cydial.candyland.items.ItemCandyCane' but none of these work. I also tried to do this:
spawnItemAtPlayer(player, new ItemStack(com.cydial.candyland.items.ItemCandyCane));
which didn't work either. Any help?
No, my computer is not too slow.
[email protected], GALAX GTX 980Ti HOF 6GB, Seagate 1TB 7200RPM HDD, Crucial MX100 256GB SSD, 2x Kingston 8GB@1866MHz, EVGA NEX750G PSU
Actually, you can just cancel the BlockEvent.BreakEvent if you want. Basically you'd handle the block break event, check if the block is your custom type, output the harvest, and reset the damage for the block (so that it will take a while to get the harvest out again) and cancel the event.
You should have made your item static in the main class where you registered it. Not the actual item class file. :\
It is static... And anyways I fixed it by importing my main class and not the Item class itself (becasue I registered the item in the Main class) but now is the problem of making the berries grow. I have already tested the rightclick thing and it works, now to make it grow and change texture.
No, my computer is not too slow.
[email protected], GALAX GTX 980Ti HOF 6GB, Seagate 1TB 7200RPM HDD, Crucial MX100 256GB SSD, 2x Kingston 8GB@1866MHz, EVGA NEX750G PSU
Okay so now I have my candy bush (w/ candy) which changes to the empty bush (no candy) when right-clicked (you also get a candy cane) but do I use tickUpdate or something with a for loop to decide when to make the candy canes grow back? Also, when you right-click a full bush, it doesn't change texture unless there is a block update nearby. Any way to fix this without using a TileEntity? (becuase those are difficult)
No, my computer is not too slow.
[email protected], GALAX GTX 980Ti HOF 6GB, Seagate 1TB 7200RPM HDD, Crucial MX100 256GB SSD, 2x Kingston 8GB@1866MHz, EVGA NEX750G PSU