So in a attempted to make something look cool, I ran into a small bug. When I spawn a Item entity into the world, spawns two into the world. One of them works fine but the other just becomes a phantom, It's there but you can't interact with it. Any help and/or suggestions would be amazing!
The code!
The TileEntity
package magic.entitys;
import java.util.Random;
import net.minecraft.client.Minecraft;
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.tileentity.TileEntity;
import net.minecraft.util.Timer;
public class TileEntityWandAltar extends TileEntity {
public ItemStack itemStack;
private Timer timer;
private float time = 10;
private float curTime = 0;
private Random rand = new Random();
public TileEntityWandAltar() {
super();
timer = new Timer(20);
}
@Override
public void updateEntity() {
if (itemStack == null) return;
timer.updateTimer();
if (curTime < time) curTime = curTime + 2f * timer.elapsedTicks;
if (curTime >= time) {
GivePlayerItem(Minecraft.getMinecraft().thePlayer);
}
System.out.println(curTime);
}
private boolean GivePlayerItem(EntityPlayer player) {
EntityItem entity = new EntityItem(worldObj, xCoord, yCoord, zCoord, itemStack);
worldObj.spawnEntityInWorld(entity);
itemStack = null;
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
}
}
The Block
package magic.block;
import magic.entitys.TileEntityWandAltar;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockWandAltar extends BlockMagic implements ITileEntityProvider{
protected BlockWandAltar() {
super("wandAltar", Material.wood);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
ItemStack item = player.inventory.getCurrentItem();
if (item != null) {
TileEntityWandAltar tileEntity = (TileEntityWandAltar) world.getTileEntity(x, y, z);
if (item.getItem() == Items.stick && tileEntity != null && tileEntity.itemStack == null) {
tileEntity.itemStack = new ItemStack(Items.stick);
if (!player.capabilities.isCreativeMode) item.stackSize--;
}
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int var2) {
return new TileEntityWandAltar();
}
}
So in a attempted to make something look cool, I ran into a small bug. When I spawn a Item entity into the world, spawns two into the world. One of them works fine but the other just becomes a phantom, It's there but you can't interact with it. Any help and suggestions would be amazing!
The code!
package magic.entitys;
import java.util.Random;
import net.minecraft.client.Minecraft;
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.tileentity.TileEntity;
import net.minecraft.util.Timer;
public class TileEntityWandAltar extends TileEntity {
public ItemStack itemStack;
private Timer timer;
private float time = 10;
private float curTime = 0;
private Random rand = new Random();
public TileEntityWandAltar() {
super();
timer = new Timer(20);
}
@Override
public void updateEntity() {
if (itemStack == null) return;
timer.updateTimer();
if (curTime < time) curTime = curTime + 2f * timer.elapsedTicks;
if (curTime >= time) {
GivePlayerItem(Minecraft.getMinecraft().thePlayer);
}
System.out.println(curTime);
}
private boolean GivePlayerItem(EntityPlayer player) {
EntityItem entity = new EntityItem(worldObj, xCoord, yCoord, zCoord, itemStack);
worldObj.spawnEntityInWorld(entity);
itemStack = null;
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
}
}
Hello McCricket, This is a very interesting idea, and I would love to be apart of it. now I do have work and family so I don't always have free time but I do have four years of coding experience, I don't have any mods out to the public but I have been working with forge for a good few months and I think I can help.
Hello,
this looks very interesting. But before I sigh up for anything I would like to know a little about the project I'll be working on. And how will you be contribute to the project.
Hmm, looks like your going to haveing alot of missing file errors. This is esay to fix just re-setup your mcp folder and you should be fine
-Roda1265, 1Love
hello everyone,
im currently working on a mod, but i need a varabile saved, now i have tryed this and for some reason it's refusing to save, i'v tryed everything i could possibly think of so any help would be greatly appreciated.
This is the code i am using... package
mod.magic;
import
net.minecraft.src.NBTTagCompound;
public
class ManaStats {
privateintmana;
privatefinalintmaxMana = 100;
publicvoid addMana(int hm) {
mana = getMana() + hm; System. out.println(getMana()); }
publicvoid takeMana(int hm) {
mana -= 0;
if (mana < 0) {
mana = 0; } System. out.println(getMana()); }
publicint getMana() {
returnmana; }
publicint getMaxMana() {
returnmaxMana; }
publicvoid readFromNBT(NBTTagCompound nbt) {
mana = nbt.getInteger("Mana"); System. out.println(getMana()); }
NullPointerExecption means that something equals null when it's called, no take a look at the error meassage, the first line is an error in ModLoader.addName, at line 436, and because that was not a line you made that's not the problem, move on. Same with the next line, but when we look at the third line, its you mod class. So we can see what line is has the error. So the line is "ModLoader.addName(Cutter, "Cutter");", now that we know what line is errored we can fix it. We now its a that something equals null, and only one object is being used, Cutter, now with all this it's simple you have Cutter initalized to far in the method your going to need to move it into farther up so it can get called before ModLoader.addName,
Sorry if this was bit of a handfull, i think it's best to help you throught it then just telling you where and how to fix it.
-Roda1265, OneLove
Hello my fellower Minecrafters,
Me and a friend, had a amazing idea. Why not space in Minecraft? So a I took a look into it, and of course some other people have already done the same thing, but all of them have them as a new type as Dimension... That to me do not seem like space (not to hate on them, all of the, look really good.) So I wanted to mod thats more like an expansion.
I already have a few ideas, seemless planet travel, atmosphere, spaceships. These are just a few ideas... but i need the communtiys input, because i will HAVE to override some base files.
As if skyrim's mods weren't enough to keep me staring at a screen, theres a skyrim MINECRAFT mod!
Question:
Do swords swing faster than axes and axes faster than maces? And do maces do the most damage where as swords do the least?
If not, then it should be like that :tongue.gif:
0
The code!
The TileEntity
The Block
Thanks!
0
The code!
0
This is a very interesting idea, and I would love to be apart of it. now I do have work and family so I don't always have free time but I do have four years of coding experience, I don't have any mods out to the public but I have been working with forge for a good few months and I think I can help.
0
this looks very interesting. But before I sigh up for anything I would like to know a little about the project I'll be working on. And how will you be contribute to the project.
0
-Roda1265, 1Love
0
A really great tut for all the new things with forge!
-Roda1265, 1Love
0
-Roda1265, 1Love
0
im currently working on a mod, but i need a varabile saved, now i have tryed this and for some reason it's refusing to save, i'v tryed everything i could possibly think of so any help would be greatly appreciated.
This is the code i am using...
package
mod.magic;
import
net.minecraft.src.NBTTagCompound;
public
class ManaStats {
private int mana;
private final int maxMana = 100;
public void addMana(int hm) {
mana = getMana() + hm;
System.
out.println(getMana());
}
public void takeMana(int hm) {
mana -= 0;
if (mana < 0) {
mana = 0;
}
System.
out.println(getMana());
}
public int getMana() {
return mana;
}
public int getMaxMana() {
return maxMana;
}
public void readFromNBT(NBTTagCompound nbt) {
mana = nbt.getInteger("Mana");
System.
out.println(getMana());
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setInteger(
"Mana", mana);
System.
out.println(getMana());
}
}
1
Sorry if this was bit of a handfull, i think it's best to help you throught it then just telling you where and how to fix it.
-Roda1265, OneLove
0
0
Me and a friend, had a amazing idea. Why not space in Minecraft? So a I took a look into it, and of course some other people have already done the same thing, but all of them have them as a new type as Dimension... That to me do not seem like space (not to hate on them, all of the, look really good.) So I wanted to mod thats more like an expansion.
I already have a few ideas, seemless planet travel, atmosphere, spaceships. These are just a few ideas... but i need the communtiys input, because i will HAVE to override some base files.
All input is greatly appreciated.
-Roda1265
0
Age: 16
Link: http://www.minecraft...t&f=45&t=335188
BetterCraft, BetterAnarchy or Both?: BetterCraft!
Why BetterVerse?: I'v been hunting for a nice server, and out of all the one's I have seen your's is the best.
How did you find us?: Recomend by a family member.
Did anyone assist you with your application/understanding the process?: Nope.
Anything else you want to say: I'v been with Minecraft since it first came out... (Those where the days!)
0
0
i will look into that thanks!
What do you mean?
1
No but thats a great idea thanks!