Any one got any Ideas as to how I would make a block be dangerous to mobs but not item entities? Much like a cactus but something that only attacks Living entities not item entities etc.
I've tried
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity entity)
{
entity.attackEntityFrom(DamageSource.inFire, 4);
}
but that's not quite what I want.. Help is appreciated. :]
I also can't get my ores to spawn! I even set the generation to try 500,000,000 times to spawn veins up to 100 of my ore on EVERY layer... I know at this point it's human error, but I, for the life of me, can't figure out what I coded wrong. After all, the game runs! I know that doesn't necessarily mean NO errors, but I'm still new at this whole thing. ;n_n
again help is appreciated! =D
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity entity)
{
if(entity instanceof EntityLiving)
{
entity.attackEntityFrom(DamageSource.inFire, 4);
}
}
Also I have to see the code for the other problem to tell you what's wrong.
I have an already existing generateSuface statment(public void generateSurface(World world1, Random random, int i, int j) for ore generating) and when i add the new generateSurface i tells me to rename it to generateSurface1. And then nothing genrates! HELP!
That's the problem.
Take the original method and change it to what I used, then change all of the names in your code accordingly. The important bit you're missing here is that the ChunkX and ChunkZ variables are the X and Z coordinates of the chunk the block is going to be generated in.
This is an example of a working piece of WorldGen code from my own files:
public void generateSurface(World world, Random random, int ChunkX, int ChunkZ)
{
for (int i = 0; i < 10; i++)
{
int randPosX = ChunkX + random.nextInt(16);
int randPosY = random.nextInt(60);
int randPosZ = ChunkZ + random.nextInt(16);
new WorldGenMinable(blockSomeBlock.blockID, 7).generate(world, random, randPosX, randPosY, randPosZ);
}
}
randPosX is a random position within the chunk returned, this is why it's the value of ChunkX plus a random number between 0 and 16 (the size of a chunk)
randPosZ has the same behavior as randPosX
randPosY is what you're actually wanting to change (and move it below both randPosX and randPosZ for trees)
randPosY should be where you use your "world.getHeight()" method, as so:
int randPosY = world.getHeightValue(randPosX, randPosZ);
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(BaseX, BaseZ);
WorldGenLightTree tree = new WorldGenLightTree();
if(biome instanceof BiomeGenForest)
{
for(int x = 0; x < 1; x++)
{
int Xcoord = BaseX + random.nextInt(16);
int Zcoord = BaseZ + random.nextInt(16);
int i = world.getHeightValue(Xcoord, Zcoord);
tree.generate(world, random, Xcoord, i, Zcoord);
}
}
It says "BaseX cannot be resolved to a variable" on line 1 and 7 and the same about "BaseZ" on lines 1 and 8...And that "random cannot be resolved" on lines 7 and 8 and "random cannot be resolved to a variable" on line 10. And finally on line 2 it says "Syntax error on token ";", { expected after this token"
I know i don't understand what it's saying but hopefully you'll get it. And i know you will.
Thanks
- Dr O
You left out the
public void generateSurface(World world, Random random, int ChunkX, int ChunkZ){}
method that that piece of code actually belongs in.
Is there any way to remove recipes without modifying base classes?
Use a copy of the exact recipe but replace actual blocks and items with something like the air block (block id of 0)
This will probably override the old recipe with one that's "blank" since air can't be interacted with like other blocks, since it's designed to technically not "exist"
Actually, tell me if this works too. I'm too lazy to test it myself.
EVERYBODY DANCE! New tutorials are out and on the thread!
I'm doing a explosive tut right now
Doing a tut on that right now
Explosive blocks are fun...I made one a while ago and today I decided to make it more interesting. It now has a different explosion radius depending on what biome it's detonated in.
could you show us how to make a new tnt block with a large blast radius?
I won't tell you how to make a new TNT block, but this is the line of code used by entities (emphasis here -- used by ENTITIES, see EntityTNTPrimed) to create an explosion
The fields posX, posY, and posZ all need to refer to the Entity's position in the world, generally you would use "this.posX, this.posY, this.posZ within a file subclassed to Entity.
The number 1 is a Float used to set the blast radius. The game's TNT entity creates an explosion with a blast radius of 4.
You could get really technical and make a new block class that uses a new spirite sheet..... but i would imagine that would be very hard XD
Yeah so you could do it the hard way, or just get an API that's hugely useful and allows you to avoid editing numerous base classes, without losing out on functionality, on top of custom personal spritesheets.
Also you're more likely to run out of items anyway >.>
Remember me? I hung out here all the time before the adventure update made minecraft unusable for me on my old laptop. But now I have a new machine and I'm playing minecraft again!
Your pack was one of the first things I downloaded, since I can't play minecraft without having a bunch of texture packs to choose from.
I started out in a Jungle biome on my first SSP game. I'm suddenly super-afraid of the monsters like I'm a noob. It's been so long.
Anyway, I'll probably start hanging out here again. So glad to see you finally got that mod position!
Until you get used to it the new AI makes mobs horrifying to fight, but it was a very nice improvement overall.
Well this is the problem I cant find the code that makes the player move, its harder than it looks to make what I said,
Maybe not that hard for you
I would appreciate if you can show it to me, my final goal is to make the "Pig(example)" rotate as the player rotates, like following his rotation
I'll go look for it, I might want it myself someday. After all, being able to ride a huge ass spider that shoots balls of web on command would be rather entertaining, no?
Edit:
MovementInput and MovementInputFromOptions contain the fields used and the values being incremented or decremented based on key input that are used somewhere else. I don't know where these are actually used, but these numbers are what you want your movement to be based from.
== MCP 5.6 (data: 5.6, client: 1.1, server: 1.1) ==
> Recompiling client...
'"C:\Program Files (x86)\Java\jdk1.6.0_25\bin\javac.exe" -g -source 1.6 -target
1.6 -classpath "lib;lib\*;jars\bin\minecraft.jar;jars\bin\jinput.jar;jars\bin\lw
jgl.jar;jars\bin\lwjgl_util.jar" -sourcepath src\minecraft -d bin\minecraft src\
minecraft\net\minecraft\client\*.java src\minecraft\net\minecraft\isom\*.java sr
c\minecraft\net\minecraft\src\*.java conf\patches\ga.java conf\patches\Start.jav
a' failed : 1
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\EntitySpaceZombie.java:32: invalid method declar
ation; return type required
public isAIEnabled()
^
src\minecraft\net\minecraft\src\EntitySpaceZombie.java:53: ';' expected
public void writeEnityToNBT(NBTTagCompound par1NBTTagCompound)ToNBT(par1
NBTTagCompound);
^
src\minecraft\net\minecraft\src\EntitySpaceZombie.java:58: ')' expected
public void readEntityFromNBT (NBTTagCompund par 1NBTTagCompound)
^
src\minecraft\net\minecraft\src\EntitySpaceZombie.java:58: <identifier> expected
public void readEntityFromNBT (NBTTagCompund par 1NBTTagCompound)
^
src\minecraft\net\minecraft\src\mod_Dirty.java:544: illegal start of expression
public void addRenderer(Map map);
^
src\minecraft\net\minecraft\src\mod_Dirty.java:544: illegal start of expression
public void addRenderer(Map map);
^
src\minecraft\net\minecraft\src\mod_Dirty.java:544: ';' expected
public void addRenderer(Map map);
^
src\minecraft\net\minecraft\src\mod_Dirty.java:544: ';' expected
public void addRenderer(Map map);
^
8 errors
==================
FATAL ERROR
Traceback (most recent call last):
File "runtime\recompile.py", line 31, in recompile
commands.recompile(CLIENT)
File "C:\Users\Gebruiker\Desktop\modding minecraft\mcp\mcp\runtime\commands.py
", line 736, in recompile
self.runcmd(forkcmd)
File "C:\Users\Gebruiker\Desktop\modding minecraft\mcp\mcp\runtime\commands.py
", line 779, in runcmd
raise CalledProcessError(returncode, forkcmd, output)
CalledProcessError: Command '"C:\Program Files (x86)\Java\jdk1.6.0_25\bin\javac.
exe" -g -source 1.6 -target 1.6 -classpath "lib;lib\*;jars\bin\minecraft.jar;jar
s\bin\jinput.jar;jars\bin\lwjgl.jar;jars\bin\lwjgl_util.jar" -sourcepath src\min
ecraft -d bin\minecraft src\minecraft\net\minecraft\client\*.java src\minecraft\
net\minecraft\isom\*.java src\minecraft\net\minecraft\src\*.java conf\patches\ga
.java conf\patches\Start.java' returned non-zero exit status 1
Druk op een toets om door te gaan. . .
could you help me please?
A poorly formatted compile error that's difficult to read, combined with a lack of the actual offending code to look at, makes it rather difficult to do so, I hope you realize.
I just want to thank CowedOffACliff for doing everything I should be doing. He has helped me with hours of modding. Thanks for making my job easier, I appreciate it
Well I like solving computer problems, and helping others solve the same sorts of problems that I've already faced myself benefits all parties (reinforces learning), so I may as well stick to my moral values and pass on all valuable knowledge, eh?
Also I've got two requests for you:
1. A tutorial on using metadata to create things similar to the popular log and wool examples where all of the blocks reside in the same ID -- Looking at the code for these blocks hasn't helped me figure this out particularly much, and I don't feel like using 12 classfiles when I should be able to do it in something more like 4. (Two BlockSoAndSo files and two ItemSoAndSo files)
2. You should add an explanation of how ModLoader texture overriding actually works so that people won't suffer from the daunting problem of running out of sprites. If you don't know this exactly for yourself, what ModLoader does is takes the texture and "overrides" it into a free slot in the respective sprite sheet. The texture is not physically added to the sheet, but all of the pointers such as texture ids that would normally come with its location are applied, thus if you run out of slots in the sheet, well...you're out of sprites. When this happens the game will crash if you try to load more sprites onto the sheet (The command line output from ModLoader will say something like "blah blah blah overriding...blah blah....something of something 42, 0 remaining" then crash on the next override) , and the only way I know of to get beyond this it to get Forge API and learn to use the extra spritesheet capabilities it provides.
Both of these are important to know about and not necessarily well-documented outside of the personal experience of a select few.
Hey I would REALLY appreciate it if you could make a tutorial on how to add like poision effects to weapons such as swords. I want to know because i have a mod and It "Toxic" so i want to add a poision effect to the toxic sword. Thanks a bunch if you can!!!!
If I ever figure out how to do this slightly differently (I need to detect things like a fire-related mob vs. an ice-related mob so that I can give damage benefits to specific individual weapons for those monsters) I'll come back here and help you. It shouldn't be that much different.
@CowedOffACliff about your mob attracked to block AI... when they get into a range of the block (know how to do that) is it possible to clear a task of the list? such as um..... ah creeper comes to a block it is 5 blocks away then it doesn't aggro anymore like in creative. You seem to be good at AI and i am still trying to figure them out a bit
Also can you help me with a custom lamp:
code:
public static Block neonLampIdle = (new BlockRedstoneLight(170, false)).setHardness(0.3F).setBlockName("redstoneLight2"),
neonLampActive = (new BlockRedstoneLight(171, true)).setHardness(0.3F).setBlockName("redstoneLight2");
public void load()
{
ModLoader.registerBlock(neonLampIdle);
ModLoader.registerBlock(neonLampActive);
ModLoader.addName(neonLampIdle, "Neon Lamp");
}
(mod_file)
then i coiped the redstone lamp and changed it to my block
java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:286)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1278)
at net.minecraft.src.ModLoader.init(ModLoader.java:848)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:156)
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:422)
at net.minecraft.client.Minecraft.run(Minecraft.java:783)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT c0c092f5 ----------
(minecraft)
You can use this somehow to make the mob stop attacking the player. Have it check some variable that will cause this method to return null when true. (The spider uses this method for light level checking)
Here's something you can use for checking the ID of a block within given minimum and maximum coordinates.
int hostPosX = (int) (this.posX);
int hostPosY = (int) (this.posY);
int hostPosZ = (int) (this.posZ);
for (int posY1 = hostPosY + viewRangeYMin ; posY1 <= hostPosY + viewRangeYMax; posY1++)
for (int posX1 = hostPosX + viewRangeXMin; posX1 <= hostPosX + viewRangeXMax; posX1++)
for (int posZ1 = hostPosZ + viewRangeZMin; posZ1 <= hostPosZ + viewRangeZMax; posZ1++)
{
if (((posY1 <= 256) && (posY1 > 0)))
{
blockPosX = posX1;
blockPosY = posY1;
blockPosZ = posZ1;
if(worldObj.getBlockId(blockPosX, blockPosY, blockPosZ) == blockIDHere)
{
do something here
}
}
}
Put the for() loop inside the onUpdate() of whatever you want to use it in.
(Oh and blockPosX/Y/Z are fields within the file from the example I used)
0
Armor is so annoying that I've been too lazy to even colorize it...
...I've needed to do so for over a month...
0
Also I have to see the code for the other problem to tell you what's wrong.
0
That's the problem.
Take the original method and change it to what I used, then change all of the names in your code accordingly. The important bit you're missing here is that the ChunkX and ChunkZ variables are the X and Z coordinates of the chunk the block is going to be generated in.
This is an example of a working piece of WorldGen code from my own files:
randPosX is a random position within the chunk returned, this is why it's the value of ChunkX plus a random number between 0 and 16 (the size of a chunk)
randPosZ has the same behavior as randPosX
randPosY is what you're actually wanting to change (and move it below both randPosX and randPosZ for trees)
randPosY should be where you use your "world.getHeight()" method, as so:
0
You left out the method that that piece of code actually belongs in.
0
Use a copy of the exact recipe but replace actual blocks and items with something like the air block (block id of 0)
This will probably override the old recipe with one that's "blank" since air can't be interacted with like other blocks, since it's designed to technically not "exist"
Actually, tell me if this works too. I'm too lazy to test it myself.
0
Explosive blocks are fun...I made one a while ago and today I decided to make it more interesting. It now has a different explosion radius depending on what biome it's detonated in.
0
I won't tell you how to make a new TNT block, but this is the line of code used by entities (emphasis here -- used by ENTITIES, see EntityTNTPrimed) to create an explosion
[code
worldObj.createExplosion(null, posX, posY, posZ, 1);
[/code]
The fields posX, posY, and posZ all need to refer to the Entity's position in the world, generally you would use "this.posX, this.posY, this.posZ within a file subclassed to Entity.
The number 1 is a Float used to set the blast radius. The game's TNT entity creates an explosion with a blast radius of 4.
0
Yeah so you could do it the hard way, or just get an API that's hugely useful and allows you to avoid editing numerous base classes, without losing out on functionality, on top of custom personal spritesheets.
Also you're more likely to run out of items anyway >.>
0
Until you get used to it the new AI makes mobs horrifying to fight, but it was a very nice improvement overall.
0
I'll go look for it, I might want it myself someday. After all, being able to ride a huge ass spider that shoots balls of web on command would be rather entertaining, no?
Edit:
MovementInput and MovementInputFromOptions contain the fields used and the values being incremented or decremented based on key input that are used somewhere else. I don't know where these are actually used, but these numbers are what you want your movement to be based from.
0
Find the code for the player that lets you move and modify the pig file to use that code for movement when it's ridden by an EntityPlayer
I imagine it can't be that difficult to cobble the player movement code onto a mob
0
A poorly formatted compile error that's difficult to read, combined with a lack of the actual offending code to look at, makes it rather difficult to do so, I hope you realize.
0
Well I like solving computer problems, and helping others solve the same sorts of problems that I've already faced myself benefits all parties (reinforces learning), so I may as well stick to my moral values and pass on all valuable knowledge, eh?
Also I've got two requests for you:
1. A tutorial on using metadata to create things similar to the popular log and wool examples where all of the blocks reside in the same ID -- Looking at the code for these blocks hasn't helped me figure this out particularly much, and I don't feel like using 12 classfiles when I should be able to do it in something more like 4. (Two BlockSoAndSo files and two ItemSoAndSo files)
2. You should add an explanation of how ModLoader texture overriding actually works so that people won't suffer from the daunting problem of running out of sprites. If you don't know this exactly for yourself, what ModLoader does is takes the texture and "overrides" it into a free slot in the respective sprite sheet. The texture is not physically added to the sheet, but all of the pointers such as texture ids that would normally come with its location are applied, thus if you run out of slots in the sheet, well...you're out of sprites. When this happens the game will crash if you try to load more sprites onto the sheet (The command line output from ModLoader will say something like "blah blah blah overriding...blah blah....something of something 42, 0 remaining" then crash on the next override) , and the only way I know of to get beyond this it to get Forge API and learn to use the extra spritesheet capabilities it provides.
Both of these are important to know about and not necessarily well-documented outside of the personal experience of a select few.
0
If I ever figure out how to do this slightly differently (I need to detect things like a fire-related mob vs. an ice-related mob so that I can give damage benefits to specific individual weapons for those monsters) I'll come back here and help you. It shouldn't be that much different.
0
You can use this somehow to make the mob stop attacking the player. Have it check some variable that will cause this method to return null when true. (The spider uses this method for light level checking)
Here's something you can use for checking the ID of a block within given minimum and maximum coordinates.
Put the for() loop inside the onUpdate() of whatever you want to use it in.
(Oh and blockPosX/Y/Z are fields within the file from the example I used)