Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Code to set wall to air

Comments in 'Plugin Development' started by Kabluinc, Jul 8, 2016.

  1. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Oh, I don't care about that. I will never reach as high as @PEMapModder anyway ;)
    It is 4:19 a.m. here, and I got too bored. Right, I guess I should just write it on GitHub Gist and stop posting here, since it is really off-topic :)
    But! But! Java is really much more beautiful! The syntax! The generalization! The simplicity! The beauty! The anonymity! The lambdas! (Wait, did I use lambdas anywhere in this thread?)
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    It looks pretty handsome in german Java too.


    PHP:
    finales Plugin plugin;hauptteilAuftrag verwalter neuer HauptteilAuftragVerwalter();
    server.bekommePlaner().planWiederholungsAufgabe(neue FortschrittsAufgabe(neue WeltBearbeitungsKunst.WeltBearbeitungsKunst(), VerwalterTürschwelle){
    öffentlicher HauptteilAuftrag richtigmachen(){
    dashier.gehörer plugin;
    ausgeben dashier;
    }
    }.
    richtigmachen(), 1);

    Fläche quaderFläche neue QuaderFläche(Weltneuer dreidimensionalerVektor(x0y0z0), neuer dreidimensionalerVektor(x1y1z1));BlockKonstantedInformationErhalten
    blockKonstantesInformationErhalten quaderFläche.bekommeSolideBlockKonstantesInformationErhalten();
    WiegendeBlockListe liste = new WiegendeBlockListe().hinzufüge(WiegendeBlockEigenschaften.bauer()
    .
    Gewicht(1.0f)
    .
    BlockNummer(0).Wert(0)
    .
    bauen());
    BlockVeränderer blockVeränderer neuer GewichtsListenBlockVeränderer(Liste);
    Finale Kassette kassette neue Kassette(blockKonstanteInformationErhaltungblockVeränderer);
    HauptteilAuftrag hauptteilAuftrag neuer HauptteilAuftrag(){

    öffentlicher JaOderNein hatMehr(){
    gebeaus kassette.nächste() != garnichts;
    }
    öffentlicher Abgrund machEinmal(){Block[] blöcke Kassette.zurzeitige();
    blöcke[0].bekommeWelt().setzeBlock(blöcke[0], blöcke[1]);
    }
    }.
    richtigmachen(plugin);
    verwalter.hinzufüge(hauptteilAuftrag);
    Survingo likes this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    C++ is still best! :p
    Just one word to get rekt:
    Speed.

    Anyways a joke?

    Ok here you go:

    Knock, knock!
    Who is there?
    Long Pause...
    - Java

    Knock, Knock!
    Who is there?
    - C++

    Knock, Knock!
    - Assembly
  4. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    Sorry to keep bothering you. the coordinates for the minx, miny etc are:

    minY= 52 maxY=56 maxZ= 131 minzZ= 166 maxX= -116 minX= -81

    so how would the code you gave me earlier look like now

    again sorry for bothering and many thanks
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PHP:
    $minX = -116;
    $maxX =  -81;
    $minY 52;
    $maxY 56;
    $maxZ 166;
    $minZ 131;

    $wallz floor($maxZ $minZ 2) + $minZ;

    $wallx $minX floor($maxX $minX 2);

    // $wallx and $wallz are the x and z coordinates of each wall, you can just find them out or calculate them since they are in the middle point of the wall

    for($x $minX$x <= $maxX$x++){
    for(
    $y $minY$y <= $maxY$y++){$level->setBlock(new Vector3($x$y$wallz), new Air());
    }}

    for(
    $z $minZ$z $maxZ$z++){
    for(
    $y $minY$y $maxY$y++){
    $level->setBlock(new Vector3($wallx$y$z), new Air());
    }}
  6. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    This is not really true. Performance of Java is now comparable to C++.

    Also, the main reason I love Java is that Java code looks more elegant than C++. C++ is good with memory management, but all the standard libraries are simply a big mess, and we still haven't counted Microsoft messing around with some of the functions (support for Visual C++).
    Off-topic alert.
    Last edited: Jul 11, 2016
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    But what do your customers like more? A very fast app or a slow app with cleaned up and "elegant" code that the customers will never see anyways? That's why C++ is better and still faster.
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    And the function names of Java are very long, to long. Can you remember as I told you about the file content getting between Java and PHP? That's with the slower general speed one of the main reasons why I would never want to learn Java. But I don't want to "destroy" you, Java is still one of the most used languages, so you can learn it.
  9. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    For fair comparison, proper error handling should be done in this comparison:
    PHP:
    // PHP
    try{
      
    $file file_get_contents("file.txt");
    }catch(\
    RuntimeException $e){
      
    // TODO handle
    }

    // Java
    try{
      
    byte[] bytes Files.readAllBytes(Paths.get("file.txt"));
      
    // note the difference between byte[] and String, which are mixed together in PHP
    }catch(IOException e){
      
    // TODO handle
      // oh we even have a convenient e.printStackTrace() and a graceful IO API to choose where to print the stack trace!
    }
    This is bad anyway. You really shouldn't read the whole file in a single command call. Unless you need to manipulate it as a whole, you should start at the beginning, and read it byte by byte, or pipe it into another InputStream for reading, such as an InputStreamReader for a JsonReader (I'm talking about android.util.JsonReader).
    Most importantly, Java already has the best library management system around.
    That is not true. The performance of Java nowadays is comparable to C++. Moreover, I don't have any customers anyway. Programming code is written for communication between humans, not to be compiled (for me only). And the app running faster doesn't mean you will code it faster. Unless you are running something really CPU-intensive (e.g. graphics, bitcoin mining), there isn't really much notable difference.
    Off-topic alert. We were actually talking about setting a wall.
    Last edited: Jul 11, 2016
  10. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    I don't see any significance that German has given to the structure of the program. Using a type-strict language like Java can increase the readability of the code, but I doubt if German and English make any difference to any native readers. (Also, I saw that you translated "new" to "neuer", "new" and "neue". I don't know German, but I am sure this definitely doesn't properly reflect the meaning of the "new" keyword, from the meaning of "instantiation of object" in PHP to the meaning of "allocate more memory and show me the memory address" in C++.
  11. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Dude, that was sarcasm...
  12. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    If sarcasm doesn't correct reflect the background of the subject of sarcasm, it is a bad one.
  13. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Dude, understand the context, I wrote that non-sense code, because you wrote that useless Java code. It's so embarassing to understand the subject of the joke...

Share This Page

Advertisement