I have a single player mod that simply adds a clone of sugar cane, renamed to cocaine. It has 2 main classes:
mod_cocaine.java
package net.minecraft.src;
import java.util.Random;
public class mod_cocaine extends BaseMod {
//Item / Block inits
public static Block cocaPlant = (new BlockCocaPlant(200, ModLoader.addOverride("/terrain.png", "/winDev/CocaPlant.png"))).setHardness(0.0F).setResistance(0.0F).setBlockName("Coca Plant");
public static final Item cocaLeaves = new Item(415).setItemName("Coca Leaves");
public static final Item cocaPaste = new Item(416).setItemName("Coca Paste");
public static final Item cocainePack = new ItemFood(417, 4, 0F, false).setPotionEffect(Potion.moveSpeed.id, 60, 0, 10F).setItemName("Cocaine Pack");
static Achievement openInventory = AchievementList.openInventory;
public static final Achievement cocainePackCraft = new Achievement(5000, "Drug Trafficker", 4, 9, mod_cocaine.cocainePack, openInventory).registerAchievement();
public mod_cocaine()
{
//Coca Plant (Block)
ModLoader.registerBlock(cocaPlant);
ModLoader.addName(cocaPlant, "Coca Plant");
ModLoader.addRecipe(new ItemStack(mod_cocaine.cocaPlant, 3), new Object[] {"#", Character.valueOf('#'), Block.dirt});
cocaLeaves.iconIndex = ModLoader.addOverride("/gui/items.png", "/winDev/cocaLeaves.png");
ModLoader.addName(cocaLeaves, "cocaLeaves");
ModLoader.addShapelessRecipe(new ItemStack(mod_cocaine.cocaLeaves, 4), new Object[] {new ItemStack(mod_cocaine.cocaPlant)});
cocaPaste.iconIndex = ModLoader.addOverride("/gui/items.png", "/winDev/cocaPaste.png");
ModLoader.addName(cocaPaste, "Coca Paste");
ModLoader.addShapelessRecipe(new ItemStack(mod_cocaine.cocaPaste, 1), new Object[] {new ItemStack(mod_cocaine.cocaLeaves), new ItemStack(Item.bucketWater), new ItemStack(Item.bowlEmpty)});
cocainePack.iconIndex = ModLoader.addOverride("/gui/items.png", "/winDev/cocainePack.png");
ModLoader.addName(cocainePack, "Cocaine Pack");
ModLoader.addRecipe(new ItemStack(mod_cocaine.cocainePack, 1), new Object[] {
"###", "#@#", "###", Character.valueOf('#'), Item.paper, Character.valueOf('@'), mod_cocaine.cocaPaste
});
ModLoader.addAchievementDesc(cocainePackCraft, "Drug Trafficker", "Create a Cocaine Pack.");
}
public void GenerateSurface(World world, Random random, int i, int j)
{
if(random.nextInt(20) == 0)
{
for(int k = 0; k < 16; k++)
{
for(int l = 0; l < 16; l++)
{
int i1 = random.nextInt(200);
if(world.getBlockId(i + l, i1, j + k) != Block.grass.blockID || !world.isAirBlock(i + l, i1 + 1, j + k))
{
continue;
}
int j1 = random.nextInt(2);
if(j1 == 0)
{
world.setBlock(i + l, i1 + 1, j + k, cocaPlant.blockID);
}
if(j1 == 1)
{
world.setBlock(i + l, i1 + 1, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 2, j + k, cocaPlant.blockID);
}
if(j1 == 2)
{
world.setBlock(i + l, i1 + 1, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 2, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 3, j + k, cocaPlant.blockID);
}
if(j1 == 3)
{
world.setBlock(i + l, i1 + 1, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 2, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 3, j + k, cocaPlant.blockID);
world.setBlock(i + l, i1 + 4, j + k, cocaPlant.blockID);
}
}
}
}
}
public void takenFromCrafting(EntityPlayer entityplayer, ItemStack itemstack, IInventory iinventory)
{
if(itemstack.itemID == mod_cocaine.cocainePack.shiftedIndex)
{
entityplayer.addStat(cocainePackCraft, 1);
}
}
@Override
public String getVersion() {
// TODO Auto-generated method stub
return null;
}
@Override
public void load() {
// TODO Auto-generated method stub
}
}
and BlockCocaPlant.java
package net.minecraft.src;
import java.util.Random;
public class BlockCocaPlant extends Block
{
protected BlockCocaPlant(int par1, int par2)
{
super(par1, Material.grass);
this.blockIndexInTexture = par2;
float var3 = 0.375F;
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 1.0F, 0.5F + var3);
this.setTickRandomly(true);
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (par1World.isAirBlock(par2, par3 + 1, par4))
{
int var6;
for (var6 = 1; par1World.getBlockId(par2, par3 - var6, par4) == this.blockID; ++var6)
{
;
}
if (var6 < 3)
{
int var7 = par1World.getBlockMetadata(par2, par3, par4);
if (var7 == 15)
{
par1World.setBlockWithNotify(par2, par3 + 1, par4, this.blockID);
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 + 1);
}
}
}
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
return var5 == this.blockID ? true : (var5 != Block.grass.blockID && var5 != Block.dirt.blockID && var5 != Block.sand.blockID ? false : (par1World.getBlockMaterial(par2 - 1, par3 - 1, par4) == Material.water ? true : (par1World.getBlockMaterial(par2 + 1, par3 - 1, par4) == Material.water ? true : (par1World.getBlockMaterial(par2, par3 - 1, par4 - 1) == Material.water ? true : par1World.getBlockMaterial(par2, par3 - 1, par4 + 1) == Material.water))));
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
this.checkBlockCoordValid(par1World, par2, par3, par4);
}
/**
* Checks if current block pos is valid, if not, breaks the block as dropable item. Used for cocaPlant and cactus.
*/
protected final void checkBlockCoordValid(World par1World, int par2, int par3, int par4)
{
if (!this.canBlockStay(par1World, par2, par3, par4))
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
/**
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
*/
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
return this.canPlaceBlockAt(par1World, par2, par3, par4);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_cocaine.cocaPlant.blockID;
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 1;
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
public int idPicked(World par1World, int par2, int par3, int par4)
{
return mod_cocaine.cocaPlant.blockID;
}
}
I should also mention that I have almost no experience with SMP modding.
I want to make a new crop that acts like sugar cane but has different crop growing graphics and names. Does anyone have advice on how I would go about doing this or can point me to some resources?
Thanks!
Hi, I'm not sure if this is in the right section, but I need some help setting up my server.
I have two groups: A and B. I don't want Group A to be able to go into the Group B zone and vice versa. How would I be able to block the groups from certain areas in the map?
I am using Essentials Groupmanager for the groups and I also have WorldEdit and WorldGuard. How can I perform this?
I just have a few recipes for a toolset, and when I attempt to run Minecraft from Eclipse it crashes with this:
java.lang.NullPointerException
at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:398)
at net.minecraft.src.ModLoader.addRecipe(ModLoader.java:412)
at net.minecraft.src.mod_sappheiros.load(mod_sappheiros.java:39)
at net.minecraft.src.ModLoader.init(ModLoader.java:856)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:157)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:424)
at net.minecraft.client.Minecraft.run(Minecraft.java:786)
at java.lang.Thread.run(Thread.java:680)
--- END ERROR REPORT 7597cdac ----------
And here is my actual code:
package net.minecraft.src;
import java.util.Random;
public class mod_sappheiros extends BaseMod {
public static final Block sapphireOre = new BlockSapphireOre(160, 0).setBlockName("Sapphire Ore").setHardness(1F).setResistance(2F);
public static final Item sapphireGem = new ItemSapphireGem(5000).setItemName("Sapphire");
public static final Item SapphirePickaxe = new ItemPickaxe(2001, EnumToolMaterial.SAPPHIRE).setItemName("Sapphire Pickaxe");
public static final Item SapphireSpade = new ItemSpade(2002, EnumToolMaterial.SAPPHIRE).setItemName("Sapphire Spade");
public static final Item SapphireAxe = new ItemAxe(2003, EnumToolMaterial.SAPPHIRE).setItemName("Sapphire Axe");
public static final Item SapphireHoe = new ItemHoe(2004, EnumToolMaterial.SAPPHIRE).setItemName("Sapphire Hoe");
public static final Item SapphireSword = new ItemSword(2005, EnumToolMaterial.SAPPHIRE).setItemName("Sapphire Sword");
public void load()
{
sapphireOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/ffkm/sapphireOre.png");
ModLoader.registerBlock(sapphireOre);
ModLoader.addName(sapphireOre, "Sapphire Ore");
sapphireGem.iconIndex = ModLoader.addOverride("/gui/items.png", "/ffkm/sapphireGem.png");
ModLoader.addName(sapphireGem, "Sapphire");
SapphirePickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/SapphirePickaxe.png");
SapphireSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/SapphireSpade.png");
SapphireAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/SapphireAxe.png");
SapphireHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/SapphireHoe.png");
SapphireSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/SapphireSword.png");
ModLoader.addName(SapphirePickaxe, "Sapphire Pickaxe");
ModLoader.addName(SapphireSpade, "Sapphire Shovel");
ModLoader.addName(SapphireAxe, "Sapphire Axe");
ModLoader.addName(SapphireHoe, "Sapphire Hoe");
ModLoader.addName(SapphireSword, "Sapphire Sword");
ModLoader.addRecipe(new ItemStack(SapphirePickaxe, 1), new Object[] {"***", " @ ", " @ ", Character.valueOf('*'), mod_sappheiros.sapphireGem.shiftedIndex, Character.valueOf('@'), Item.stick});
ModLoader.addRecipe(new ItemStack(SapphireSpade, 1), new Object[] {"** ", "*@ ", " @ ", Character.valueOf('*'), mod_sappheiros.sapphireGem.shiftedIndex, Character.valueOf('@'), Item.stick});
ModLoader.addRecipe(new ItemStack(SapphireAxe, 1), new Object[] {" * ", " @ ", " @ ", Character.valueOf('*'), mod_sappheiros.sapphireGem.shiftedIndex, Character.valueOf('@'), Item.stick});
ModLoader.addRecipe(new ItemStack(SapphireHoe, 1), new Object[] {"** ", " @ ", " @ ", Character.valueOf('*'), mod_sappheiros.sapphireGem.shiftedIndex, Character.valueOf('@'), Item.stick});
ModLoader.addRecipe(new ItemStack(SapphireSword, 1), new Object[] {" * ", " * ", " @ ", Character.valueOf('*'), mod_sappheiros.sapphireGem.shiftedIndex, Character.valueOf('@'), Item.stick});
}
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < 25; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(64);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_sappheiros.sapphireOre.blockID, 50)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
public String getVersion()
{
return "1.2.5";
}
}
P.S. This seems to happen any time I have more than one recipe. Am I doing something wrong?
Thanks in advance!
EDIT: I should have also included the work I did to the EnumToolMaterial File:
package net.minecraft.src;
public enum EnumToolMaterial
{
WOOD(0, 59, 2.0F, 0, 15),
STONE(1, 131, 4F, 1, 5),
IRON(2, 250, 6F, 2, 14),
EMERALD(3, 1561, 8F, 3, 10),
GOLD(0, 32, 12F, 0, 22),
SAPPHIRE(2, 475, 9F, 2, 16);
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
private final int harvestLevel;
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
private final int maxUses;
/**
* The strength of this tool material against blocks which it is effective against.
*/
private final float efficiencyOnProperMaterial;
/** Damage versus entities. */
private final int damageVsEntity;
/** Defines the natural enchantability factor of the material. */
private final int enchantability;
private EnumToolMaterial(int par3, int par4, float par5, int par6, int par7)
{
harvestLevel = par3;
maxUses = par4;
efficiencyOnProperMaterial = par5;
damageVsEntity = par6;
enchantability = par7;
}
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
public int getMaxUses()
{
return maxUses;
}
/**
* The strength of this tool material against blocks which it is effective against.
*/
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
/**
* Damage versus entities.
*/
public int getDamageVsEntity()
{
return damageVsEntity;
}
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
public int getHarvestLevel()
{
return harvestLevel;
}
/**
* Return the natural enchantability factor of the material.
*/
public int getEnchantability()
{
return enchantability;
}
}
Since some random time yesterday, my client has been acting very odd. When I click on anything when the game is resized from the original size (the size of the launcher), it either lags for around 2 seconds before registering my click, or it doesn't register at all (It's usually the latter). I have tried deleting my minecraft folder twice now. Also, I am on a Mac with a 23-inch monitor attached. It seems to lag even when the monitor is not plugged in though.
Is there anything I can do to fix this, and is this a known problem? All I can find is the double block placing glitch.
0
I know it's possible, I just want to know the basics of how to do it.
0
0
mod_cocaine.java
and BlockCocaPlant.java
I should also mention that I have almost no experience with SMP modding.
0
Thanks!
1
I have two groups: A and B. I don't want Group A to be able to go into the Group B zone and vice versa. How would I be able to block the groups from certain areas in the map?
I am using Essentials Groupmanager for the groups and I also have WorldEdit and WorldGuard. How can I perform this?
Thanks!
0
0
0
GRAMMAR NAZI, AWAY!
0
And here is my actual code:
P.S. This seems to happen any time I have more than one recipe. Am I doing something wrong?
Thanks in advance!
EDIT: I should have also included the work I did to the EnumToolMaterial File:
0
0
Is there anything I can do to fix this, and is this a known problem? All I can find is the double block placing glitch.
0
Thanks. I will try that ASAP and get back to you!
0
And, my mod_Hog:
The error Eclipse is giving is "The constructor RenderPig(ModelPig, float) is undefined".
0