This is the code for Xporbs I got from net.minecraft.src using MCP, JDK, and Eclipse.
I have looked all through this code and cannot find anything to indicate an editable color code.
I have found no hex or numeric color codes.
package net.minecraft.src;
public class EntityXPOrb extends Entity
{
/**
* A constantly increasing value that RenderXPOrb uses to control the colour shifting (Green / yellow)
*/
public int xpColor;
/** The age of the XP orb in ticks. */
public int xpOrbAge = 0;
public int field_70532_c;
/** The health of this XP orb. */
private int xpOrbHealth = 5;
/** This is how much XP this orb has. */
private int xpValue;
/** The closest EntityPlayer to this orb. */
private EntityPlayer closestPlayer;
/** Threshold color for tracking players */
private int xpTargetColor;
public EntityXPOrb(World par1World, double par2, double par4, double par6, int par8)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.yOffset = this.height / 2.0F;
this.setPosition(par2, par4, par6);
this.rotationYaw = (float)(Math.random() * 360.0D);
this.motionX = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F);
this.motionY = (double)((float)(Math.random() * 0.2D) * 2.0F);
this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F);
this.xpValue = par8;
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
public EntityXPOrb(World par1World)
{
super(par1World);
this.setSize(0.25F, 0.25F);
this.yOffset = this.height / 2.0F;
}
protected void entityInit() {}
public int getBrightnessForRender(float par1)
{
float var2 = 0.5F;
if (var2 < 0.0F)
{
var2 = 0.0F;
}
if (var2 > 1.0F)
{
var2 = 1.0F;
}
int var3 = super.getBrightnessForRender(par1);
int var4 = var3 & 255;
int var5 = var3 >> 16 & 255;
var4 += (int)(var2 * 15.0F * 16.0F);
if (var4 > 240)
{
var4 = 240;
}
return var4 | var5 << 16;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.field_70532_c > 0)
{
--this.field_70532_c;
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.029999999329447746D;
if (this.worldObj.getBlockMaterial(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) == Material.lava)
{
this.motionY = 0.20000000298023224D;
this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
}
this.pushOutOfBlocks(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
double var1 = 8.0D;
if (this.xpTargetColor < this.xpColor - 20 + this.entityId % 100)
{
if (this.closestPlayer == null || this.closestPlayer.getDistanceSqToEntity(this) > var1 * var1)
{
this.closestPlayer = this.worldObj.getClosestPlayerToEntity(this, var1);
}
this.xpTargetColor = this.xpColor;
}
if (this.closestPlayer != null)
{
double var3 = (this.closestPlayer.posX - this.posX) / var1;
double var5 = (this.closestPlayer.posY + (double)this.closestPlayer.getEyeHeight() - this.posY) / var1;
double var7 = (this.closestPlayer.posZ - this.posZ) / var1;
double var9 = Math.sqrt(var3 * var3 + var5 * var5 + var7 * var7);
double var11 = 1.0D - var9;
if (var11 > 0.0D)
{
var11 *= var11;
this.motionX += var3 / var9 * var11 * 0.1D;
this.motionY += var5 / var9 * var11 * 0.1D;
this.motionZ += var7 / var9 * var11 * 0.1D;
}
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
float var13 = 0.98F;
if (this.onGround)
{
var13 = 0.58800006F;
int var4 = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (var4 > 0)
{
var13 = Block.blocksList[var4].slipperiness * 0.98F;
}
}
this.motionX *= (double)var13;
this.motionY *= 0.9800000190734863D;
this.motionZ *= (double)var13;
if (this.onGround)
{
this.motionY *= -0.8999999761581421D;
}
++this.xpColor;
++this.xpOrbAge;
if (this.xpOrbAge >= 6000)
{
this.setDead();
}
}
/**
* Returns if this entity is in water and will end up adding the waters velocity to the entity
*/
public boolean handleWaterMovement()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
/**
* Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args:
* amountDamage
*/
protected void dealFireDamage(int par1)
{
this.attackEntityFrom(DamageSource.inFire, par1);
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
if (this.isEntityInvulnerable())
{
return false;
}
else
{
this.setBeenAttacked();
this.xpOrbHealth -= par2;
if (this.xpOrbHealth <= 0)
{
this.setDead();
}
return false;
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("Health", (short)((byte)this.xpOrbHealth));
par1NBTTagCompound.setShort("Age", (short)this.xpOrbAge);
par1NBTTagCompound.setShort("Value", (short)this.xpValue);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
this.xpOrbHealth = par1NBTTagCompound.getShort("Health") & 255;
this.xpOrbAge = par1NBTTagCompound.getShort("Age");
this.xpValue = par1NBTTagCompound.getShort("Value");
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote)
{
if (this.field_70532_c == 0 && par1EntityPlayer.xpCooldown == 0)
{
par1EntityPlayer.xpCooldown = 2;
this.playSound("random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
par1EntityPlayer.onItemPickup(this, 1);
par1EntityPlayer.addExperience(this.xpValue);
this.setDead();
}
}
}
/**
* Returns the XP value of this XP orb.
*/
public int getXpValue()
{
return this.xpValue;
}
/**
* Returns a number from 1 to 10 based on how much XP this orb is worth. This is used by RenderXPOrb to determine
* what texture to use.
*/
public int getTextureByXP()
{
return this.xpValue >= 2477 ? 10 : (this.xpValue >= 1237 ? 9 : (this.xpValue >= 617 ? 8 : (this.xpValue >= 307 ? 7 : (this.xpValue >= 149 ? 6 : (this.xpValue >= 73 ? 5 : (this.xpValue >= 37 ? 4 : (this.xpValue >= 17 ? 3 : (this.xpValue >= 7 ? 2 : (this.xpValue >= 3 ? 1 : 0)))))))));
}
/**
* Get xp split rate (Is called until the xp drop code in EntityLiving.onEntityUpdate is complete)
*/
public static int getXPSplit(int par0)
{
return par0 >= 2477 ? 2477 : (par0 >= 1237 ? 1237 : (par0 >= 617 ? 617 : (par0 >= 307 ? 307 : (par0 >= 149 ? 149 : (par0 >= 73 ? 73 : (par0 >= 37 ? 37 : (par0 >= 17 ? 17 : (par0 >= 7 ? 7 : (par0 >= 3 ? 3 : 1)))))))));
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return false;
}
}
I made an account just to ask this !
i tried to make my first block. i did everything right but when i hit recompile it says:
"!! Can not find server sources, try decompiling !!"
I decompiled. Said i should try cleanup
Cleanupped. Remade all of my codes but the problem persists.
What to do?
Cannot find server source... I think (THINK) that this isn´t a problem. You tried your mod in Minecraft SP?
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.minecraft.src.TextureWaterFX.<init>(TextureWaterFX.java:20)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:248)
at net.minecraft.src.MinecraftAppletImpl.<init>(MinecraftAppletImpl.java:16)
at net.minecraft.client.MinecraftApplet.init(MinecraftApplet.java:25)
at net.minecraft.client.Minecraft.main(Minecraft.java:2276)
at Start.main(Start.java:22)
Caused by: java.lang.IllegalArgumentException: Slot 92 is already occupied by net.minecraft.src.BlockExample@12af08b when adding net.minecraft.src.BlockCake@164feb
at net.minecraft.src.Block.<init>(Block.java:283)
at net.minecraft.src.Block.<init>(Block.java:315)
at net.minecraft.src.BlockCake.<init>(BlockCake.java:9)
at net.minecraft.src.Block.<clinit>(Block.java:147)
... 6 more
Someone is closing me!
After i set up a BlockExample.java and run minecraft.. I got this error.
How can I fix it?
Ok, how do I make a block similar to NiftyCraft's removed Water/Lava Storage Block? I wanted a toggleable source of water or lava, but Niftycraft's owner removed it and caarg98's mod is currently not working due to it complaining about ctm.class and ctm.png not being present.
Rollback Post to RevisionRollBack
I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.minecraft.src.TextureWaterFX.<init>(TextureWaterFX.java:20)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:248)
at net.minecraft.src.MinecraftAppletImpl.<init>(MinecraftAppletImpl.java:16)
at net.minecraft.client.MinecraftApplet.init(MinecraftApplet.java:25)
at net.minecraft.client.Minecraft.main(Minecraft.java:2276)
at Start.main(Start.java:22)
Caused by: java.lang.IllegalArgumentException: Slot 92 is already occupied by net.minecraft.src.BlockExample@12af08b when adding net.minecraft.src.BlockCake@164feb
at net.minecraft.src.Block.<init>(Block.java:283)
at net.minecraft.src.Block.<init>(Block.java:315)
at net.minecraft.src.BlockCake.<init>(BlockCake.java:9)
at net.minecraft.src.Block.<clinit>(Block.java:147)
... 6 more
Someone is closing me!
After i set up a BlockExample.java and run minecraft.. I got this error.
How can I fix it?
If you read the error it says, Caused by:
Caused by: java.lang.IllegalArgumentException: Slot 92 is already occupied by net.minecraft.src.BlockExample@12af08b when adding net.minecraft.src.BlockCake@164feb
This is basically saying that the id is already taken. I ran into this problem while following this tut. Look at the id of the very last recipe and set your id to one after that. Have a good day!
src\minecraft\net\minecraft\src\Block.java:206: cannot find symbol
symbol : constructor BlockDyedCobblestone(int)
location: class net.minecraft.src.BlockDyedCobblestone
public static final Block dyedCobblestone = (new BlockDyedCobblestone(146)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("dyedCobblestone");
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
My code is
package net.minecraft.src;
import java.util.List;
public class BlockDyedCobblestone extends Block
{
public BlockDyedCobblestone()
{
super(35, 64, Material.cloth);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
if (par2 == 0)
{
return this.blockIndexInTexture;
}
else
{
par2 = ~(par2 & 15);
return 113 + ((par2 & 8) >> 3) + (par2 & 7) * 16;
}
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int par1)
{
return par1;
}
/**
* Takes a dye damage value and returns the block damage value to match
*/
public static int getBlockFromDye(int par0)
{
return ~par0 & 15;
}
/**
* Takes a block damage value and returns the dye damage value to match
*/
public static int getDyeFromBlock(int par0)
{
return ~par0 & 15;
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int var4 = 0; var4 < 16; ++var4)
{
par3List.add(new ItemStack(par1, 1, var4));
}
}
}
public static final Block dyedCobblestone = (new BlockDyedCobblestone(146)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("dyedCobblestone");
I am trying to make a dye-able cobblestone mod where you can make different color cobblestone.
Ok, how do I make a block similar to NiftyCraft's removed Water/Lava Storage Block? I wanted a toggleable source of water or lava, but Niftycraft's owner removed it and caarg98's mod is currently not working due to it complaining about ctm.class and ctm.png not being present.
Excuse me, I need a bit of help here. I want to be able to make a block that does this:
1. User places lever next to block
2. User activates lever.
3. ??????
4. PROFIT!(In other words, creates a block of lava or water in front of it)
Rollback Post to RevisionRollBack
I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
Excuse me, I need a bit of help here. I want to be able to make a block that does this:
1. User places lever next to block
2. User activates lever.
3. ??????
4. PROFIT!(In other words, creates a block of lava or water in front of it)
Well, Ice creates an entity (water) when being broken so I wonder if you copy the ice code, change its texture, add redstone activation and decide if you are wanting it to make lava or water then its done, I cant really explain how to do it in detail as I havent done it myself yet but thats a theory.
You should also try asking for the source, if he doesent use it, im sure he wont mind giving it to you to update and continue it.
1. Setup the minecraft coder pack (MCP)
1.1 Extract the ZIP to a directory on your computer, for this example; C:/MCP
1.2 Copy the whole .minecraft/bin and .minecraft/resources directories to C:/MCP/jars/
1.3 Run decompile.bat
When I run decompile.bat i get this:
"Java JDK is not installed! Please install Java JDK from http://java.oracle.com"
Any help?
Thanks, BTW: I have found everything else helpful so far
***EDIT***
As You can see in the third Picture I am hovering over the item and it is not giving me the name either.
Help with that as well would be great, thanks.
***END_EDIT***
--------------------------------------------------
Ok, you start of with your mod_**** file
Now Define the item in your mod_**** file.
EXAMPLE: Public static final ItemDagger = (new ItemDagger(100)). *Extra Features of your Item go here*
----------------------------------------------
If it was ItemDagger it would be
package net.minecraft.src;
public class ItemDagger extends Item
public ItemDagger(int i)
{
super(i);
-------------------------------
At public ItemDagger(int i) why is there the (int i)?
Because the interface will be defined as i, allowing super(i); Function to work
------------------------------
Now add your flashy epic features of flashy epic
maxStackSize = 1; MAX STACK SIZE
maxDamage = 3124; HOW DURABLE IT IS, IN THIS CASE 3124 USES
field_22047_d = 20; THE AMOUNT OF DAMAGE, 20 HEALTH OR 10 HEARTS.
Finish with a }
----------------------------------
Now we wana get the item to take damage
soo below all we added we should also add
public void hitEntity(ItemStack itemstack, EntityLiving entityliving)
{
itemstack.damageItem(1);
}
public void hitBlock(ItemStack itemstack, int i, int j, int k, int l)
{
itemstack.damageItem(2);
}
this code refers to that when the item hits a entity, it takes 1 damage, and when destroys a block, it takes 2, Mess around with that if you want
---------------------------------
Now we have to vertify function field_22047_d;
Add this below what you have added
public int getDamageVsEntity(Entity entity)
{
return field_22047_d;
}
public boolean isFull3D()
{
return true;
}
Finally finish off with this
private int field_22047_d;
}
So were done, recompile and test your weapon!
if your getting errors, use this base structure !
---------------------------------------------
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
public class ItemDagger extends Item
{
public ItemDagger(int i)
{
super(i);
maxStackSize = 1;
maxDamage = 500;
field_22047_d = 5;
}
public void hitEntity(ItemStack itemstack, EntityLiving entityliving)
{
itemstack.damageItem(1);
}
public void hitBlock(ItemStack itemstack, int i, int j, int k, int l)
{
itemstack.damageItem(2);
}
public int getDamageVsEntity(Entity entity)
{
return field_22047_d;
}
public boolean isFull3D()
{
return true;
}
private int field_22047_d;
}
In this tutorial I will explain how to create a new block in Minecraft and how to make it craftable. This tutorial makes a standard block like stone.
Creating a new block
1. You need to make a new file called BlockExample.java in the src directory.
2. The basic structure of this file is this:
package net.minecraft.src;
import java.util.Random;
public class BlockExample extends Block
{
public BlockExample(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return 0;
}
}
3. You now need to add this block to minecraft so that it knows about it. To do this open up Block.java
4. You should see a whole bunch of variable declarations towards the bottom of the file, add a new one:
public static final Block example;
5. Below the declarations you should see initialisation of these instance variables, initialise your block.
example = (new BlockExample(92, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep);
Like mentioned before this example block is creating a new 'stone' block.
new BlockExample(92, 1) creates the new block, the first number is the block id - THIS HAS TO BE UNIQUE, the second number is the graphic of the block, in this case the same as stone.
setHardness(1.5F) is the same as stone, this is how long it takes to destroy a block.
setResistance(10F) is the same as stone, this is how strong the block is against explosions.
setStepSound(soundStoneFootstep) is the same as stone, this is the sound it makes when you walk on it.
You have now successfully created a new block class. To use this block you need to generate it, this can be done using the Single Player Commands mod using this command: "/give 92".
Continue on reading if you want to add a recipe to the crafting table to make this block.
Creating a new recipe
1. Open up CraftingManager.java
2. You should immediately see the constructor for the class and within it recipes being added using the addRecipe function.
3. Scroll to the bottom of this list of recipes and add in a new one:
addRecipe(new ItemStack(Block.example, 1), new Object[] {"##", "##", Character.valueOf('#'), Block.dirt});
This will add a recipe in which when you craft four dirt is a square share will give you your new block.
new ItemStack(Block.example, 1) - this specifies what item is going to be generated and the quantity.
new Object[] {"##", "##", Character.valueOf('#'), Block.dirt} - this specifies how it is created.
This should allow you to now craft a very basic new block using four dirt like so:
Hello my friend. I've tried your new block and item and it seems it will not work. I get a crash error. I don't know if I didn't compile it correctly or something? But I also get an error with that source code.
ex:
"super(i, j, Material.rock);"
It says I have to remove "j" or something and I do and It dont work.
Could you possibly tell me what is wrong? Thank you for your time.
Can you give me an example of what I would do to add this?
I have looked all through this code and cannot find anything to indicate an editable color code.
I have found no hex or numeric color codes.
Cannot find server source... I think (THINK) that this isn´t a problem. You tried your mod in Minecraft SP?
at net.minecraft.src.TextureWaterFX.<init>(TextureWaterFX.java:20)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:248)
at net.minecraft.src.MinecraftAppletImpl.<init>(MinecraftAppletImpl.java:16)
at net.minecraft.client.MinecraftApplet.init(MinecraftApplet.java:25)
at net.minecraft.client.Minecraft.main(Minecraft.java:2276)
at Start.main(Start.java:22)
Caused by: java.lang.IllegalArgumentException: Slot 92 is already occupied by net.minecraft.src.BlockExample@12af08b when adding net.minecraft.src.BlockCake@164feb
at net.minecraft.src.Block.<init>(Block.java:283)
at net.minecraft.src.Block.<init>(Block.java:315)
at net.minecraft.src.BlockCake.<init>(BlockCake.java:9)
at net.minecraft.src.Block.<clinit>(Block.java:147)
... 6 more
Someone is closing me!
After i set up a BlockExample.java and run minecraft.. I got this error.
How can I fix it?
I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
To take the test, check out
https://minecraftnoobtest.com/test.php
Don't click this link, HE is haunting it...
If you read the error it says, Caused by: This is basically saying that the id is already taken. I ran into this problem while following this tut. Look at the id of the very last recipe and set your id to one after that. Have a good day!
My code is
I am trying to make a dye-able cobblestone mod where you can make different color cobblestone.
Excuse me, I need a bit of help here. I want to be able to make a block that does this:
1. User places lever next to block
2. User activates lever.
3. ??????
4. PROFIT!(In other words, creates a block of lava or water in front of it)
I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
To take the test, check out
https://minecraftnoobtest.com/test.php
Don't click this link, HE is haunting it...
Well, Ice creates an entity (water) when being broken so I wonder if you copy the ice code, change its texture, add redstone activation and decide if you are wanting it to make lava or water then its done, I cant really explain how to do it in detail as I havent done it myself yet but thats a theory.
You should also try asking for the source, if he doesent use it, im sure he wont mind giving it to you to update and continue it.
When I run decompile.bat i get this:
"Java JDK is not installed! Please install Java JDK from http://java.oracle.com"
Any help?
Thanks, BTW: I have found everything else helpful so far
Thanks.
--
It is dangerous to go alone, Take this:
The links take you to pictures that tell the story except I can't get the block to have a texture. Any help would be great, thanks.
---https://photos-3.dro...4?size=1280x960
---https://photos-5.dro...E?size=1280x960
---https://photos-5.dro...s?size=1280x960
---https://photos-6.dro...E?size=1280x960
---https://photos-3.dro...s?size=1280x960
---https://photos-4.dro...I?size=1280x960
---https://photos-1.dro...A?size=1280x960
Thanks again
- Krcoon
***EDIT***
As You can see in the third Picture I am hovering over the item and it is not giving me the name either.
Help with that as well would be great, thanks.
***END_EDIT***
Hello my friend. I've tried your new block and item and it seems it will not work. I get a crash error. I don't know if I didn't compile it correctly or something? But I also get an error with that source code.
ex:
"super(i, j, Material.rock);"
It says I have to remove "j" or something and I do and It dont work.
Could you possibly tell me what is wrong? Thank you for your time.