Copyright © 2015 Curt Hill Java for Minecraft Those things you should know.

Slides:



Advertisements
Similar presentations
Object Oriented Programming with Java
Advertisements

Web Application Development Slides Credit Umair Javed LUMS.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
Chapter 16 Templates. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives  Function Templates  Syntax, defining 
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
CS102--Object Oriented Programming Review 1: Chapter 1 – Chapter 7 Copyright © 2008 Xiaoyan Li.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
OOP Languages: Java vs C++
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
Programming Languages and Paradigms Object-Oriented Programming.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Page: 1 การโปรแกรมเชิงวัตถุด้วยภาษา JAVA บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 15 มิถุนายน 2552 Keyword & Data Type มหาวิทยาลัยเนชั่น.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Copyright Curt Hill Variables What are they? Why do we need them?
Copyright © Curt Hill Inheritance in C++ How to do it.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 5 Introduction to Defining Classes
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Copyright © Curt Hill Error Handling in Java Throwing and catching exceptions.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
UnrealScript An Introduction Copyright © 2015 Curt Hill.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 3 is due Sunday, the 8 th at 7pm. Problems with assn 3? Discuss at your team meeting tonight.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
ISBN Chapter 12 Support for Object-Oriented Programming.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Copyright © 2015 – Curt Hill Your First Mod Creating an Item and Block in Eclipse using Forge Annotations! Inheritance! Proxies! Oh my!
C++ Lesson 1.
Inheritance in C++ How to do it Copyright © Curt Hill
Modern Programming Tools And Techniques-I
CIS 200 Test 01 Review.
Inheritance and Polymorphism
Java Primer 1: Types, Classes and Operators
Java Programming Language
C# In many ways, C# looks similar to Java
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
Chapter 3 Introduction to Classes, Objects Methods and Strings
Java Programming Language
The Java Alternative to Multiple Inheritance
Object Oriented Programming in java
Web Design & Development Lecture 4
Introduction to Programming
Classes in Java Specifics for Java Copyright Curt Hill.
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Copyright © 2015 Curt Hill Java for Minecraft Those things you should know

Introduction As you know Minecraft is written in Java In order to create mods for Minecraft there are parts of the language that you may not know and should This presentation should start to cover much of this –Well that is the hope anyway Copyright © 2015 Curt Hill

Topics General Pointers Final Visibility Annotations Class definition Inheritance and polymorphism Copyright © 2015 Curt Hill

General C++ and Java have much in common There is virtually no difference in: –Declarations and types –If –For –While –Do/while –Method calls Copyright © 2015 Curt Hill

Exceptions Java uses boolean instead of bool The conditional in if/for/while must be a Boolean The C/C++ scheme of zero is false, everything else is true is not allowed Copyright © 2015 Curt Hill

Visibility C++ sets its visibility in sections Java immediately prefixes any declaration with the visibility: protected class helper{…} Any item without a visibility has “friendly” visibility –This makes it public to anything in the same file and private to anything not in that file Every public class must be in a file of the same name Copyright © 2015 Curt Hill

Preprocessor Java has no preprocessor Thus it uses import instead of include Java also uses the package statement instead of namespaces Java has a larger role for final than C++ does const Copyright © 2015 Curt Hill

Final Java uses final instead of const Thus a constant variable uses the final declaration: final String VERSION = “1.1.4”; The final keyword may also be used in a class declaration: public final class some{…} –This indicates that no derivation may be made of class some Copyright © 2015 Curt Hill

Heap and Stack C/C++ allows any type to be on either the heap or stack Java only allows primitives and handles on the stack All objects must be on the heap and created with new Java only allows dots and not the -> Java does not allow delete, garbage collection is the only way to claim unused heap memory Copyright © 2015 Curt Hill

Pointers Java claims to have no pointers, it calls them handles instead –A handle is a restricted pointer Copyright © 2015 Curt Hill

Annotations Java annotations are a feature not present in C/C++ Annotations given hints to the compiler or run-time system An annotation starts with followed by a word which determines the type of annotation An annotation may be followed by a parenthesized list of parameters There are some standard Java annotations and some particular to Minecraft Copyright © 2015 Curt Hill

@EventHandler Annotations are not terminated by a semicolon Copyright © 2015 Curt Hill

@Override Standard Java annotation Tells the compiler that the method that follows overrides a method in the ancestral class If there is no method that this overrides a compile error occurs Usually this is a misspelled the name or made a mistake on the signature The compile error prevents a run-time or logic error Copyright © 2015 Curt Hill

@Mod Indicates to forge that this is the Base of a Mod class Three parameters: modid – a unique ID for the mod name – people readable name version – the version All three are strings Copyright © 2015 Curt Hill

@Instance The instantiation of the mod class What follows is usually a static instance of the mod class See the following example Copyright © 2015 Curt Hill

Example Here is some sample = “CurtModID”,, name = “CurtMod”, version = “1.0.2”) public class CurtMod { public static CurtMod instance = new CurtMod(); Copyright © 2015 Curt Hill

@SidedMod Announces which proxy is to be loaded depending on whether a client or server is running –Precedes the declaration Two parameters: –clientProxy –serverProxy May not use anything but a literal string See next slide for example Copyright © 2015 Curt Hill

Example Annotation and "edu.vscu.ServerProxy", clientSide= "edu.vscu.ClientProxy") public static CommonProxy proxy; CommonProxy was the ancestor of both ServerProxy and ClientProxy in this example Copyright © 2015 Curt Hill

@EventHandler Indicates that the method that follows will be an event handler Recall that event handlers are typically not called directly by code in the same file Instead called unpredictably by system code –In Minecraft’s case usually by the Forge or Minecraft itself Copyright © 2015 Curt Hill

Classes The class definition is slightly different than C++ Inheritance and polymorphism are as well These we will cover in their own presentation Copyright © 2015 Curt Hill

Finally It is possible, even likely, that despite this presentation you will find features in mod code that are confusing Ask! Copyright © 2015 Curt Hill