== MCP v4.1 ==
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\MyBlock.java:9: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
^
src\minecraft\net\minecraft\src\MyBlock.java:9: cannot find symbol
symbol : variable j
location: class net.minecraft.src.MyBlock
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
^
src\minecraft\net\minecraft\src\MyBlock.java:9: cannot find symbol
symbol : variable k
location: class net.minecraft.src.MyBlock
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
^
src\minecraft\net\minecraft\src\MyBlock.java:9: cannot find symbol
symbol : variable world
location: class net.minecraft.src.MyBlock
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
^
src\minecraft\net\minecraft\src\MyBlock.java:12: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posX > i - range && player.posX < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:12: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posX > i - range && player.posX < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:12: operator < cannot be a
pplied to double,<nulltype>
if(player.posX > i - range && player.posX < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:14: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posY > i - range && player.posY < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:14: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posY > i - range && player.posY < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:14: operator < cannot be a
pplied to double,<nulltype>
if(player.posY > i - range && player.posY < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:16: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posZ > i - range && player.posZ < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:16: cannot find symbol
symbol : variable i
location: class net.minecraft.src.MyBlock
if(player.posZ > i - range && player.posZ < i + range)
^
src\minecraft\net\minecraft\src\MyBlock.java:16: operator < cannot be a
pplied to double,<nulltype>
if(player.posZ > i - range && player.posZ < i + range)
^
13 errors
==================
you are currently using onInGameTick() correct?? as you can see, it requires no arguments, and thus provides no variables. I also see that you are putting that function inside a Block file. It belongs in your Mod_ file.
now, to fix what you are doing...
put this in your Block file
public void updateTick(World world, int i, int j, int k, Random random)
{
// as you can see, this provides the variables world, random, i, j, and k
// the i, j, and k are the coordinates of the current block.
// now that you have coordinates, you can use those to get the player closest to those coordinates
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
}
after that, you can do whatever you want with that data.
you are currently using onInGameTick() correct?? as you can see, it requires no arguments, and thus provides no variables. I also see that you are putting that function inside a Block file. It belongs in your Mod_ file.
now, to fix what you are doing...
put this in your Block file
public void updateTick(World world, int i, int j, int k, Random random)
{
// as you can see, this provides the variables world, random, i, j, and k
// the i, j, and k are the coordinates of the current block.
// now that you have coordinates, you can use those to get the player closest to those coordinates
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
}
after that, you can do whatever you want with that data.
REMEMBER, THIS BELONGS IN BlockYourBlockHere.java
I'm sorry, what goes in my mod_ file?
This is what BlockMyBlock looks like:
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
}
}
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
}
}
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
int range = 5;
if(player.posX > i - range && player.posX < i + range)
{
if(player.posY > i - range && player.posY < i + range)
{
if(player.posZ > i - range && player.posZ < i + range)
{
player.heal(1);
}
}
}
}
}
...But I don't gain health when I am around the block. What am I doing wrong?
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
int range = 5;
if(player.posX > i - range && player.posX < i + range)
{
if(player.posY > i - range && player.posY < i + range)
{
if(player.posZ > i - range && player.posZ < i + range)
{
player.heal(1);
}
}
}
}
}
...But I don't gain health when I am around the block. What am I doing wrong?
your iff statements are only going to evaluate for true if the player is simulteously on one side of the black and on the other. use || instead of &&.
your iff statements are only going to evaluate for true if the player is simulteously on one side of the black and on the other. use || instead of &&.
I see what you mean, but I still don't heal when I am around the block.
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
int range = 5;
if(player.posX > i - range || player.posX < i + range)
{
if(player.posY > i - range || player.posY < i + range)
{
if(player.posZ > i - range || player.posZ < i + range)
{
player.heal(1);
}
}
}
}
}
Thank you for your patience with me, I truly appreciate it.
I'm not sure what the problem is with your code, but whether or not updateTick is being called, you should use System.out.println() statements to see how far it's getting. If you're unsure if updateTick is being called, insert this at the very front of your function:
System.out.println("Calling updateTick");
If it works, the console screen that MCP uses when running Minecraft should output A TON of those lines. Once you're sure that the function is being called, you can put similar lines inside the if statements to make sure that those are working properly.
On another note, I disagree with what AbrarSyed said about using || instead of &&. Let's evaluate your first if statement. Suppose the block is located at 0 and the player is located at 200 on the X axis. Your if statement would appear as so:
if(200 > 0 - 5 || 200 < 0 + 5)
200 is greater than -5, and since only one of those needs to be true, the statement will return true, even though 200 is WAY out of range. On the other hand, if the player was at -200, that would be less than 0 + 5, so that would return true as well. I think this is how your if statements should be set up:
if(player.posX > i - range && player.posX < i + range)
Using this code, although 200 is greater than -5, it is NOT less than 5, so the player is not within range.
Nope, updateTick doen't seem to be running. This is what BlockMyBlock looks like:
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
System.out.println("running update tick");
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
int range = 5;
if(player.posX > i - range || player.posX < i + range)
{
if(player.posY > i - range || player.posY < i + range)
{
if(player.posZ > i - range || player.posZ < i + range)
{
System.out.println("Do this");
}
}
}
}
}
And this is what mod_MyMod looks like:
package net.minecraft.src;
import java.util.Random;
public class mod_MyMod extends BaseMod{
public static final Block MyBlock = new BlockMyBlock(98, 0) .setHardness(2.0F) .setResistance(10F) .setLightValue(0.9F) .setBlockName("My Block");
public mod_MyMod(){
ModLoader.RegisterBlock(MyBlock);
MyBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/MyBlock.png");
ModLoader.AddName(MyBlock, "My Block");
ModLoader.AddRecipe(new ItemStack(MyBlock, 10), new Object[] {
"##", "##", Character.valueOf('#'), Item.stick,
});
}
public String Version() {
return "1.6.6";
}
}
I'm just grasping at straws now. Your updateTick function looks great from where I'm sitting. There's one thing that puzzles me though, and this is about Minecraft, not your mod. A couple blocks, like BlockTorch and BlockFluid, use super.updateTick in their updateTick functions, even though they extend Block and Block's updateTick function doesn't do anything. I don't know if calling super.updateTick would fix your problem or not. Most blocks that use updateTick don't need it, but maybe for some reason yours does? Like I said, I'm grasping at straws now.
package net.minecraft.src;
import java.util.Random;
public class BlockMyBlock extends Block {
protected BlockMyBlock(int i, int j) {
super(i, j, Material.rock);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
super.updateTick(world, i, j, k, random);
System.out.println("running update tick");
EntityPlayer player = world.getClosestPlayer(i, j, k, 0);
int range = 5;
if(player.posX > i - range && player.posX < i + range)
{
if(player.posY > i - range && player.posY < i + range)
{
if(player.posZ > i - range && player.posZ < i + range)
{
System.out.println("Do this");
}
}
}
}
Nope, still nothing.
Maybe one of you guys could try doing this yourselves? If it's not too much trouble; I just really want to solve this mystery now.
So... can't anyone help me with this?
What do you suggest?
now, to fix what you are doing...
put this in your Block file
after that, you can do whatever you want with that data.
REMEMBER, THIS BELONGS IN BlockYourBlockHere.java
I'm sorry, what goes in my mod_ file?
This is what BlockMyBlock looks like:
exactly... NOTHING goes in your mod file.
it should work perfectly.
Alright, It recompiled without a problem:
...But I don't gain health when I am around the block. What am I doing wrong?
your iff statements are only going to evaluate for true if the player is simulteously on one side of the black and on the other. use || instead of &&.
I see what you mean, but I still don't heal when I am around the block.
Thank you for your patience with me, I truly appreciate it.
If it works, the console screen that MCP uses when running Minecraft should output A TON of those lines. Once you're sure that the function is being called, you can put similar lines inside the if statements to make sure that those are working properly.
On another note, I disagree with what AbrarSyed said about using || instead of &&. Let's evaluate your first if statement. Suppose the block is located at 0 and the player is located at 200 on the X axis. Your if statement would appear as so:
200 is greater than -5, and since only one of those needs to be true, the statement will return true, even though 200 is WAY out of range. On the other hand, if the player was at -200, that would be less than 0 + 5, so that would return true as well. I think this is how your if statements should be set up:
Using this code, although 200 is greater than -5, it is NOT less than 5, so the player is not within range.
And this is what mod_MyMod looks like:
Any ideas?
Anyways, you MUST use an AND. Otherwise it will be triggered all the time.
What you should do instead of making system outprints, is to give chat messages to the player. Use this:
Nope, still nothing.
Maybe one of you guys could try doing this yourselves? If it's not too much trouble; I just really want to solve this mystery now.