Jump to content

Changing blocks near a player.


Elrol_Arrowsend
 Share

Recommended Posts

Before this gets locked, last i checked this was a place to get help not forced to update to another version of minecraft. If I had wanted to update to a newer version I would have. But I enjoy using 1.7.10. So if you post anything that does not relate to helping me get some information on how to make this work for 1.7.10 then dont even bother posting.

 

Basically, I am attempting to, after a minecraft day, start replacing the top blocks around the player. i am wanting it to happen every second, not tick, my mod will be a Nuclear Apocalypse mod. and I am trying to get the world to decay from radiation. this is what i was trying but it keeps suspending.

 

ServerTickHandler:

Hidden

Code: [select]

@SubscribeEvent

  public void onServerTick(WorldTickEvent event){

      if(!event.world.isRemote){

        ticks++;

        if(ticks == 20){

            ticks = 0;

            if(event.world.getWorldTime()/24000 >= 1){

              for(int a = 0; a < event.world.playerEntities.size(); a++){

      EntityPlayer player = (EntityPlayer) event.world.playerEntities.get(a);

              int x = player.serverPosX -32 + rand.nextInt(64);

              int z = player.serverPosZ -32 + rand.nextInt(64);

              int y = event.world.getHeightValue(x, z);

              Block block = event.world.getBlock(x, y, z);

      player.addChatComponentMessage(new ChatComponentText("Block Changed at" + x + ", " + y + ", " + z));

      if(block == Blocks.grass){

                  event.world.setBlock(x, y, z, BlockRegistry.irradiatedDirt);

      }else if(block == Blocks.stone){

                  event.world.setBlock(x,y,z, Blocks.cobblestone);

      }else{

                  event.world.setBlockToAir(x,y,z);

              }

            }

        }

      }

  }

}

 

If I have missed something please let me know, and if there is a way for me to accomplish my task better then what I already have please explain to me how. Thanks in advance.

Link to comment
Share on other sites

Users posting privileges were removed for 24 hours to give him time to think about what he has done {recreating a locked thread} And to update his mod to 1.10.2.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

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