Jump to content

How to know if a block is natural generated or not


zerozhou

Recommended Posts

Vanilla doesn't care for most blocks, except leaves, which use metadata to determine if they were natural or player-placed.

So without rewriting a huge chunk of vanilla (as either base class edits or through Reflections/ASM) you probably won't ever be able to tell.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

So it seems I have to replace all block when they are generated with my own block which act like the original ones to do this.

By the way, would this make the server very very slow?

 

No and Yes.

If you do it as an IWorldGenerator, yes, but only at chunk generation.

If you make new blocks and shove them into the blocksList at the old block's ID (essentially getting around the conflicting ID problem) you can cheat, but keep in mind that this may cause compatibility issues with other mods.*  But you won't have any extra chunk generation lag.

 

*As an example I used Block.furnaceIdle to get the furnace texture to use on one of my blocks, but someone paired my mod with a mod that replaced the vanilla furnace in the above manner, leaving the vanilla furnace to never register its textures, thus making a null pointer error in my mod.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Replace vanilla stone block in the blockList with your own stone block that adds that drop.

Remove the recipe for smelting cobble into stone.

Add a new stone block which is the same as the vanilla stone block.

Add a new smelting recipe where cobble smelts into the new stone block.

 

Wouldn't that suffice?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Silk Touch would get you "natural" stone, but there's no ability to "cheat" resources there, as once its broken by not-silk-touch it drops the resource and not the stone.  So it's still one-for-one.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yes it seems ok.

But while I'm checking the code, I found that there is a "public static final Block stone" in the class Block, and many other code reffer this. which may cause some strange things? Should I change that too?

 

And I'm thinking if there is a event that hook when the player break a block(it seems there is not). If so, I would not need to change the vanilla stone which may have many many issues.

Link to comment
Share on other sites

And I try to replace all stone into a new block while generating the map, and I found that the speed is acceptable. But what it confused me is that some stones are replaced but some are not in different chunk.

I think that it's the generate algorithm that run my own generator firstly then the original one, dont know if that's right. If so, how to make my generator run last?

Link to comment
Share on other sites

Actually I havent used xray to know how it works. And my idea is base on that even the server dont know where the ore is. If I simply give the new block the texture of stone, maybe xray could filter all the real stone, make them transparent and knowing that where the real ore is.

Link to comment
Share on other sites

...You might want to actually get the various xray cheats and check....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I think what are u tring to do is exacly same thing I did. Note I did this on 1.6.2 (I know some guy before me said something close to this)

Stone - vanillia stone, My - referes to anything thats mod-made.

*Create MyStone1 and MyStone2 //They will both use SAME textures as Stone

MyStone1 will be used as a ,,general" stone and MyStone2 as a ,,touched" stone

*Replace Stone with MyStone1 - now the world will generate it as a normal Stone which will drop CobbleStone

*When you try to smelt CobbleStone into Stone you will get MyStone:0 (and we don't want that) you need to remove all recipes that use Stone (including buttons/slabs and other stuff - they will also use MyStone1 which is not for players to have)

*Now you need to re-add all the recipes with small change: Everywhere there needs to be MyStone2.

Note: what we have now is a MyStone1 which will drop some stuff and then if you try to craft other stone you'll get MyStone2 which DOESN'T have any special loot properties.

 

Finally:

*Add custom drops to MyStone1 - here is the fun stuff :D

There are two fun methods you'll wanna use:

//Called right before loots are set and dropped. (moment of breaking)
onBlockDestroyedByPlayer(World world, int x, int y, int z, int m)
or
//Called when player click it (when he start to hit it or inspect it/right-click - well am not sure if right-click works here)
onBlockClicked(World world, int x, int y, int z, EntityPlayer player)

Now you must decide which you wanna use: If you want super Anti-X-Ray you will wanna use onBlockDestroyedByPlayer - block will always stay the same, and only will change if you actually destroy him (and by change i mean - switch its drops). If you want to be more Realistic you will use onBlockClicked - well, by that you could travel across the tunnels and click on walls to inspect them, and if you get lucky random the block will change into ore :)

I am using both - why? Well why not... it's not like it is lagging server (only called whe you actually interact with block).

I'm just gonna write pseudo-code xD

 

//using this once-clicked block will be saved and ALWAYS give you same result since it will become other block ;p
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
random x(1000); //100.0% chances.
if (0<=x<=100) {set x/y/z MyStone1 to IronOre}
else if (101<=x<=666) {set x/y/z MyStone1 to SatanOre}
else {set x/y/z MyStone1 to MyStone2} //which again does nothing but drops cobble (standard vanillia-like-stone used in recipes)}
}

 

 

//Super-anti-x-ray - everything is invisible and happens inside code *_*
int GlobalID; //u need it to save your randomly-got ID
public void onBlockDestroyedByPlayer(World par1World, int x, int y, int z, int m)
{
int GlobalID = CobbleStone; //U need to set this before every roll to reset GlobalID int (and no - maybe it is ont int for whole server, but no player can get int randomed for you).
random x(1000); //100.0% chances.
if (0<=x<=100) {GlobalID == IronOre}
else if (101<=x<=666) {GlobalID == SatanOre}
}
public int idDropped (int par1, Random random, int par2)
{
return this.GlobalID; //well if it didn't changed in previous function it will just drop CObbleStone?
}

 

Combine those two and BOOM!!! You are god ;O

See also:

 

this.blockHardness; //You can actually set hardness right before mining ANY block 
Item item = player.getCurrentEquippedItem().getItem(); //Make some pickaxes add more % chances for particular drops 
You can actually do ANYTHING - get bomes, get height and change drops, change hardness (told before), check if block is in mountains, also if there is other block around it - possibilities = INFINITY <flies away> 

 

 

Hope I covered everything you could actually think of when making a mining system :)

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

this.blockHardness; //You can actually set hardness right before mining ANY block :D

That would only work with one player. And I doubt you have one alone player on your server.

 

Actually I havent used xray to know how it works.

I'd suggest you study them thoroughly, checking code and such.

There may be more simple and obvious ways than making a mod with incompatibilities and such.

Link to comment
Share on other sites

I dont know what MyStone2 do. Why not just let Mystone1 to drop cobblestone and smelt the cobblestone to a Stone? If so, all recpie can stay still.

 

And about x-ray, I'll check it sometime, but maybe not now. I think the theory is strong enough that unless the client can cheat the server to change the server's behavior or make the server to spawn something. And that maybe not the problem I can handle.

Link to comment
Share on other sites

X-ray that's not a texture pack uses block IDs but that type is not comparable with forge.

So the textural pack one makes all block but ores and water and pave clear with a outline so make it use the atucal texture of stone (get the stone texture from the stone block and use it.)

Link to comment
Share on other sites

Well if you are still "bothering with this shit" - MyStone1 is created by generator and stays that way. MyStone2 is a MyStone1 clicked by player but not changed to Ore.

Example (depending on which one of described by me ways are you using):

*Player starts mining MyStone1.

*Random % is rolled and hits 5405 which is a empty result (MyStone1 doesn't change into Ore)

*Well - that way you could hit it till it changes?

And when you have MyStone2 you simply set that if MyStone1 will roll % which is not an Ore, it will change into MyStone2 - which is standard stone - that way you cannot click on block and wait till it's changed.

 

MyStone1 with MyStone2 option was described only if you are setting block (chaging it from stone to ores) right before mining (onBlockClicked).

If you are using option that set random loot before braking (onBlockDestroyedByPlayer) you won't need two stones.

 

Also: most of X-rays base on Block IDs or resource data (what block.png is the block using). Its obvious that since all changes are called ONLY when player clicks/breaks a block it cannot be just found by ANY mod (including X-Rays).

 

(WRONG) And about GotoLink thesis: Nope, I don't think so. Data travels through CPU (or other shit) in order, so if you reset and change hardness everytime its called it will be changed only for this certain block - you can call it everytime player starts to hit it and change it. And if you don't belive that data is sent in queues - well, this work's for me - no bugs/multi-loots/not-precised loots/other shit.

 

Also little note about X-Ray: When I say "//Super-anti-x-ray - everything is invisible and happens inside code *_*" I mean it - there is NO program that can detect it.

 

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

And about GotoLink thesis: Nope, I don't think so. Data travels through CPU (or other shit) in order, so if you reset and change hardness everytime its called it will be changed only for this certain block - you can call it everytime player starts to hit it and change it. And if you don't belive that data is sent in queues - well, this work's for me - no bugs/multi-loots/not-precised loots/other shit.

 

It's called a Race Condition.  If you change the block hardness, that effects ALL players.  What the hardness is would depend on the last player to start mining the block.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

But... but... that means my mod is broken (so hard) :C

Actually I was worried about it - but doesn't that mean that when I am setting Hardness like this: (pseudo)

onBlockClicked() //y is coord - so obvious?
{
    if (y<64}
        Hardness = 50.0F;
    else
        Hardness = 10.0F;
}

And one player starts mining one block on y<64 (50.F), almost finishes it and right before it breaks (half a second to break), second player starts mining other block which is y>=64 : shouldn't that reset the 1st player's block hardness to 10.0F? If you are right it should (or maybe it would auto-break it since time player 1 is mining his block is greater that time needed to mine block that player 2 is mining) - BUT it doesn't - either it is a glitch (and may cause problems) or I am missing something important.

 

Also: sorry for offtop. ;p

& also: thanks for reminder - my Ground block was written months ago and I forgot to make more tests.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

And one player starts mining one block on y<64 (50.F), almost finishes it and right before it breaks (half a second to break), second player starts mining other block which is y>=64 : shouldn't that reset the 1st player's block hardness to 10.0F? If you are right it should (or maybe it would auto-break it since time player 1 is mining his block is greater that time needed to mine block that player 2 is mining) - BUT it doesn't - either it is a glitch (and may cause problems) or I am missing something important.

It does happen. Of course, we are talking about breaking time of a block, which no player can actually measure precisely.

But consider this issue is more general than the block hardness only, all Block data (except stored in a TileEntity) is subject to this effect, thus your idea is really flawed.

Don't be worried though, Forge provides hooks to effectively achieve what you want. (BreakSpeedEvent, in this case)

 

I think the original topic is done anyway. Answers have been given, and the OP issue with xray should be discussed elsewhere too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.