repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32;
protected Handler handler;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/items/Item.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256];
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/items/Item.java import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256];
public static Item woodItem = new Item(Assets.wood, "Wood", 0);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/items/Item.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/items/Item.java import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32;
protected Handler handler;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/Animation.java // public class Animation { // // private int speed, index; // private long lastTime, timer; // private BufferedImage[] frames; // // public Animation(int speed, BufferedImage[] frames){ // this.speed = speed; // this.frames = frames; // index = 0; // timer = 0; // lastTime = System.currentTimeMillis(); // } // // public void tick(){ // timer += System.currentTimeMillis() - lastTime; // lastTime = System.currentTimeMillis(); // // if(timer > speed){ // index++; // timer = 0; // if(index >= frames.length) // index = 0; // } // } // // public BufferedImage getCurrentFrame(){ // return frames[index]; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Animation; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.entities.creatures; public class Player extends Creature { //Animations private Animation animDown, animUp, animLeft, animRight;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/Animation.java // public class Animation { // // private int speed, index; // private long lastTime, timer; // private BufferedImage[] frames; // // public Animation(int speed, BufferedImage[] frames){ // this.speed = speed; // this.frames = frames; // index = 0; // timer = 0; // lastTime = System.currentTimeMillis(); // } // // public void tick(){ // timer += System.currentTimeMillis() - lastTime; // lastTime = System.currentTimeMillis(); // // if(timer > speed){ // index++; // timer = 0; // if(index >= frames.length) // index = 0; // } // } // // public BufferedImage getCurrentFrame(){ // return frames[index]; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Animation; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.entities.creatures; public class Player extends Creature { //Animations private Animation animDown, animUp, animLeft, animRight;
public Player(Handler handler, float x, float y) {
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/Animation.java // public class Animation { // // private int speed, index; // private long lastTime, timer; // private BufferedImage[] frames; // // public Animation(int speed, BufferedImage[] frames){ // this.speed = speed; // this.frames = frames; // index = 0; // timer = 0; // lastTime = System.currentTimeMillis(); // } // // public void tick(){ // timer += System.currentTimeMillis() - lastTime; // lastTime = System.currentTimeMillis(); // // if(timer > speed){ // index++; // timer = 0; // if(index >= frames.length) // index = 0; // } // } // // public BufferedImage getCurrentFrame(){ // return frames[index]; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Animation; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.entities.creatures; public class Player extends Creature { //Animations private Animation animDown, animUp, animLeft, animRight; public Player(Handler handler, float x, float y) { super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH, Creature.DEFAULT_CREATURE_HEIGHT); bounds.x = 22; bounds.y = 44; bounds.width = 19; bounds.height = 19; //Animatons
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/Animation.java // public class Animation { // // private int speed, index; // private long lastTime, timer; // private BufferedImage[] frames; // // public Animation(int speed, BufferedImage[] frames){ // this.speed = speed; // this.frames = frames; // index = 0; // timer = 0; // lastTime = System.currentTimeMillis(); // } // // public void tick(){ // timer += System.currentTimeMillis() - lastTime; // lastTime = System.currentTimeMillis(); // // if(timer > speed){ // index++; // timer = 0; // if(index >= frames.length) // index = 0; // } // } // // public BufferedImage getCurrentFrame(){ // return frames[index]; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Player.java import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Animation; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.entities.creatures; public class Player extends Creature { //Animations private Animation animDown, animUp, animLeft, animRight; public Player(Handler handler, float x, float y) { super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH, Creature.DEFAULT_CREATURE_HEIGHT); bounds.x = 22; bounds.y = 44; bounds.width = 19; bounds.height = 19; //Animatons
animDown = new Animation(500, Assets.player_down);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 31/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // }
import java.awt.Graphics; import java.awt.Rectangle; import dev.codenmore.tilegame.Handler;
package dev.codenmore.tilegame.entities; public abstract class Entity { public static final int DEFAULT_HEALTH = 10;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // Path: Episode 31/TileGame/src/dev/codenmore/tilegame/entities/Entity.java import java.awt.Graphics; import java.awt.Rectangle; import dev.codenmore.tilegame.Handler; package dev.codenmore.tilegame.entities; public abstract class Entity { public static final int DEFAULT_HEALTH = 10;
protected Handler handler;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/DirtTile.java
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.tiles; public class DirtTile extends Tile { public DirtTile(int id) {
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/DirtTile.java import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.tiles; public class DirtTile extends Tile { public DirtTile(int id) {
super(Assets.dirt, id);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics; public class Tree extends StaticEntity { public Tree(Handler handler, float x, float y) {
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.entities.statics; public class Tree extends StaticEntity { public Tree(Handler handler, float x, float y) {
super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.statics; public class Tree extends StaticEntity { public Tree(Handler handler, float x, float y) { super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2); bounds.x = 10; bounds.y = (int) (height / 1.5f); bounds.width = width - 20; bounds.height = (int) (height - height / 1.5f); } @Override public void tick() { } @Override public void render(Graphics g) {
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/statics/Tree.java import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.entities.statics; public class Tree extends StaticEntity { public Tree(Handler handler, float x, float y) { super(handler, x, y, Tile.TILEWIDTH, Tile.TILEHEIGHT * 2); bounds.x = 10; bounds.y = (int) (height / 1.5f); bounds.width = width - 20; bounds.height = (int) (height - height / 1.5f); } @Override public void tick() { } @Override public void render(Graphics g) {
g.drawImage(Assets.tree, (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset()), width, height, null);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 32/TileGame/src/dev/codenmore/tilegame/items/Item.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256];
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 32/TileGame/src/dev/codenmore/tilegame/items/Item.java import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256];
public static Item woodItem = new Item(Assets.wood, "Wood", 0);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 32/TileGame/src/dev/codenmore/tilegame/items/Item.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32, PICKED_UP = -1;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 32/TileGame/src/dev/codenmore/tilegame/items/Item.java import java.awt.Graphics; import java.awt.image.BufferedImage; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.items; public class Item { // Handler public static Item[] items = new Item[256]; public static Item woodItem = new Item(Assets.wood, "Wood", 0); public static Item rockItem = new Item(Assets.rock, "Rock", 1); // Class public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32, PICKED_UP = -1;
protected Handler handler;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/entities/Entity.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // }
import java.awt.Graphics; import java.awt.Rectangle; import dev.codenmore.tilegame.Handler;
package dev.codenmore.tilegame.entities; public abstract class Entity { public static final int DEFAULT_HEALTH = 3;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/entities/Entity.java import java.awt.Graphics; import java.awt.Rectangle; import dev.codenmore.tilegame.Handler; package dev.codenmore.tilegame.entities; public abstract class Entity { public static final int DEFAULT_HEALTH = 3;
protected Handler handler;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/states/GameState.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 32/TileGame/src/dev/codenmore/tilegame/worlds/World.java // public class World { // // private Handler handler; // private int width, height; // private int spawnX, spawnY; // private int[][] tiles; // //Entities // private EntityManager entityManager; // // Item // private ItemManager itemManager; // // public World(Handler handler, String path){ // this.handler = handler; // entityManager = new EntityManager(handler, new Player(handler, 100, 100)); // itemManager = new ItemManager(handler); // // Temporary entity code! // entityManager.addEntity(new Tree(handler, 100, 250)); // entityManager.addEntity(new Rock(handler, 100, 450)); // // loadWorld(path); // // entityManager.getPlayer().setX(spawnX); // entityManager.getPlayer().setY(spawnY); // } // // public void tick(){ // itemManager.tick(); // entityManager.tick(); // } // // public void render(Graphics g){ // int xStart = (int) Math.max(0, handler.getGameCamera().getxOffset() / Tile.TILEWIDTH); // int xEnd = (int) Math.min(width, (handler.getGameCamera().getxOffset() + handler.getWidth()) / Tile.TILEWIDTH + 1); // int yStart = (int) Math.max(0, handler.getGameCamera().getyOffset() / Tile.TILEHEIGHT); // int yEnd = (int) Math.min(height, (handler.getGameCamera().getyOffset() + handler.getHeight()) / Tile.TILEHEIGHT + 1); // // for(int y = yStart;y < yEnd;y++){ // for(int x = xStart;x < xEnd;x++){ // getTile(x, y).render(g, (int) (x * Tile.TILEWIDTH - handler.getGameCamera().getxOffset()), // (int) (y * Tile.TILEHEIGHT - handler.getGameCamera().getyOffset())); // } // } // // Items // itemManager.render(g); // //Entities // entityManager.render(g); // } // // public Tile getTile(int x, int y){ // if(x < 0 || y < 0 || x >= width || y >= height) // return Tile.grassTile; // // Tile t = Tile.tiles[tiles[x][y]]; // if(t == null) // return Tile.dirtTile; // return t; // } // // private void loadWorld(String path){ // String file = Utils.loadFileAsString(path); // String[] tokens = file.split("\\s+"); // width = Utils.parseInt(tokens[0]); // height = Utils.parseInt(tokens[1]); // spawnX = Utils.parseInt(tokens[2]); // spawnY = Utils.parseInt(tokens[3]); // // tiles = new int[width][height]; // for(int y = 0;y < height;y++){ // for(int x = 0;x < width;x++){ // tiles[x][y] = Utils.parseInt(tokens[(x + y * width) + 4]); // } // } // } // // public int getWidth(){ // return width; // } // // public int getHeight(){ // return height; // } // // public EntityManager getEntityManager() { // return entityManager; // } // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public ItemManager getItemManager() { // return itemManager; // } // // public void setItemManager(ItemManager itemManager) { // this.itemManager = itemManager; // } // // }
import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.worlds.World;
package dev.codenmore.tilegame.states; public class GameState extends State { private World world;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 32/TileGame/src/dev/codenmore/tilegame/worlds/World.java // public class World { // // private Handler handler; // private int width, height; // private int spawnX, spawnY; // private int[][] tiles; // //Entities // private EntityManager entityManager; // // Item // private ItemManager itemManager; // // public World(Handler handler, String path){ // this.handler = handler; // entityManager = new EntityManager(handler, new Player(handler, 100, 100)); // itemManager = new ItemManager(handler); // // Temporary entity code! // entityManager.addEntity(new Tree(handler, 100, 250)); // entityManager.addEntity(new Rock(handler, 100, 450)); // // loadWorld(path); // // entityManager.getPlayer().setX(spawnX); // entityManager.getPlayer().setY(spawnY); // } // // public void tick(){ // itemManager.tick(); // entityManager.tick(); // } // // public void render(Graphics g){ // int xStart = (int) Math.max(0, handler.getGameCamera().getxOffset() / Tile.TILEWIDTH); // int xEnd = (int) Math.min(width, (handler.getGameCamera().getxOffset() + handler.getWidth()) / Tile.TILEWIDTH + 1); // int yStart = (int) Math.max(0, handler.getGameCamera().getyOffset() / Tile.TILEHEIGHT); // int yEnd = (int) Math.min(height, (handler.getGameCamera().getyOffset() + handler.getHeight()) / Tile.TILEHEIGHT + 1); // // for(int y = yStart;y < yEnd;y++){ // for(int x = xStart;x < xEnd;x++){ // getTile(x, y).render(g, (int) (x * Tile.TILEWIDTH - handler.getGameCamera().getxOffset()), // (int) (y * Tile.TILEHEIGHT - handler.getGameCamera().getyOffset())); // } // } // // Items // itemManager.render(g); // //Entities // entityManager.render(g); // } // // public Tile getTile(int x, int y){ // if(x < 0 || y < 0 || x >= width || y >= height) // return Tile.grassTile; // // Tile t = Tile.tiles[tiles[x][y]]; // if(t == null) // return Tile.dirtTile; // return t; // } // // private void loadWorld(String path){ // String file = Utils.loadFileAsString(path); // String[] tokens = file.split("\\s+"); // width = Utils.parseInt(tokens[0]); // height = Utils.parseInt(tokens[1]); // spawnX = Utils.parseInt(tokens[2]); // spawnY = Utils.parseInt(tokens[3]); // // tiles = new int[width][height]; // for(int y = 0;y < height;y++){ // for(int x = 0;x < width;x++){ // tiles[x][y] = Utils.parseInt(tokens[(x + y * width) + 4]); // } // } // } // // public int getWidth(){ // return width; // } // // public int getHeight(){ // return height; // } // // public EntityManager getEntityManager() { // return entityManager; // } // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public ItemManager getItemManager() { // return itemManager; // } // // public void setItemManager(ItemManager itemManager) { // this.itemManager = itemManager; // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/states/GameState.java import java.awt.Graphics; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.worlds.World; package dev.codenmore.tilegame.states; public class GameState extends State { private World world;
public GameState(Handler handler){
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/GameCamera.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.gfx; public class GameCamera { private Handler handler; private float xOffset, yOffset; public GameCamera(Handler handler, float xOffset, float yOffset){ this.handler = handler; this.xOffset = xOffset; this.yOffset = yOffset; } public void checkBlankSpace(){ if(xOffset < 0){ xOffset = 0;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/GameCamera.java import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.gfx; public class GameCamera { private Handler handler; private float xOffset, yOffset; public GameCamera(Handler handler, float xOffset, float yOffset){ this.handler = handler; this.xOffset = xOffset; this.yOffset = yOffset; } public void checkBlankSpace(){ if(xOffset < 0){ xOffset = 0;
}else if(xOffset > handler.getWorld().getWidth() * Tile.TILEWIDTH - handler.getWidth()){
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/GameCamera.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.gfx; public class GameCamera { private Handler handler; private float xOffset, yOffset; public GameCamera(Handler handler, float xOffset, float yOffset){ this.handler = handler; this.xOffset = xOffset; this.yOffset = yOffset; } public void checkBlankSpace(){ if(xOffset < 0){ xOffset = 0; }else if(xOffset > handler.getWorld().getWidth() * Tile.TILEWIDTH - handler.getWidth()){ xOffset = handler.getWorld().getWidth() * Tile.TILEWIDTH - handler.getWidth(); } if(yOffset < 0){ yOffset = 0; }else if(yOffset > handler.getWorld().getHeight() * Tile.TILEHEIGHT - handler.getHeight()){ yOffset = handler.getWorld().getHeight() * Tile.TILEHEIGHT - handler.getHeight(); } }
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/gfx/GameCamera.java import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.gfx; public class GameCamera { private Handler handler; private float xOffset, yOffset; public GameCamera(Handler handler, float xOffset, float yOffset){ this.handler = handler; this.xOffset = xOffset; this.yOffset = yOffset; } public void checkBlankSpace(){ if(xOffset < 0){ xOffset = 0; }else if(xOffset > handler.getWorld().getWidth() * Tile.TILEWIDTH - handler.getWidth()){ xOffset = handler.getWorld().getWidth() * Tile.TILEWIDTH - handler.getWidth(); } if(yOffset < 0){ yOffset = 0; }else if(yOffset > handler.getWorld().getHeight() * Tile.TILEHEIGHT - handler.getHeight()){ yOffset = handler.getWorld().getHeight() * Tile.TILEHEIGHT - handler.getHeight(); } }
public void centerOnEntity(Entity e){
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/RockTile.java
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.tiles; public class RockTile extends Tile { public RockTile(int id) {
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/RockTile.java import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.tiles; public class RockTile extends Tile { public RockTile(int id) {
super(Assets.stone, id);
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/input/MouseManager.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/ui/UIManager.java // public class UIManager { // // private Handler handler; // private ArrayList<UIObject> objects; // // public UIManager(Handler handler){ // this.handler = handler; // objects = new ArrayList<UIObject>(); // } // // public void tick(){ // for(UIObject o : objects) // o.tick(); // } // // public void render(Graphics g){ // for(UIObject o : objects) // o.render(g); // } // // public void onMouseMove(MouseEvent e){ // for(UIObject o : objects) // o.onMouseMove(e); // } // // public void onMouseRelease(MouseEvent e){ // for(UIObject o : objects) // o.onMouseRelease(e); // } // // public void addObject(UIObject o){ // objects.add(o); // } // // public void removeObject(UIObject o){ // objects.remove(o); // } // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public ArrayList<UIObject> getObjects() { // return objects; // } // // public void setObjects(ArrayList<UIObject> objects) { // this.objects = objects; // } // // }
import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import dev.codenmore.tilegame.ui.UIManager;
package dev.codenmore.tilegame.input; public class MouseManager implements MouseListener, MouseMotionListener { private boolean leftPressed, rightPressed; private int mouseX, mouseY;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/ui/UIManager.java // public class UIManager { // // private Handler handler; // private ArrayList<UIObject> objects; // // public UIManager(Handler handler){ // this.handler = handler; // objects = new ArrayList<UIObject>(); // } // // public void tick(){ // for(UIObject o : objects) // o.tick(); // } // // public void render(Graphics g){ // for(UIObject o : objects) // o.render(g); // } // // public void onMouseMove(MouseEvent e){ // for(UIObject o : objects) // o.onMouseMove(e); // } // // public void onMouseRelease(MouseEvent e){ // for(UIObject o : objects) // o.onMouseRelease(e); // } // // public void addObject(UIObject o){ // objects.add(o); // } // // public void removeObject(UIObject o){ // objects.remove(o); // } // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public ArrayList<UIObject> getObjects() { // return objects; // } // // public void setObjects(ArrayList<UIObject> objects) { // this.objects = objects; // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/input/MouseManager.java import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import dev.codenmore.tilegame.ui.UIManager; package dev.codenmore.tilegame.input; public class MouseManager implements MouseListener, MouseMotionListener { private boolean leftPressed, rightPressed; private int mouseX, mouseY;
private UIManager uiManager;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 33/TileGame/src/dev/codenmore/tilegame/inventory/Inventory.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java // public class Item { // // // Handler // // public static Item[] items = new Item[256]; // public static Item woodItem = new Item(Assets.wood, "Wood", 0); // public static Item rockItem = new Item(Assets.rock, "Rock", 1); // // // Class // // public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32; // // protected Handler handler; // protected BufferedImage texture; // protected String name; // protected final int id; // // protected Rectangle bounds; // // protected int x, y, count; // protected boolean pickedUp = false; // // public Item(BufferedImage texture, String name, int id){ // this.texture = texture; // this.name = name; // this.id = id; // count = 1; // // bounds = new Rectangle(x, y, ITEMWIDTH, ITEMHEIGHT); // // items[id] = this; // } // // public void tick(){ // if(handler.getWorld().getEntityManager().getPlayer().getCollisionBounds(0f, 0f).intersects(bounds)){ // pickedUp = true; // handler.getWorld().getEntityManager().getPlayer().getInventory().addItem(this); // } // } // // public void render(Graphics g){ // if(handler == null) // return; // render(g, (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset())); // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, ITEMWIDTH, ITEMHEIGHT, null); // } // // public Item createNew(int x, int y){ // Item i = new Item(texture, name, id); // i.setPosition(x, y); // return i; // } // // public void setPosition(int x, int y){ // this.x = x; // this.y = y; // bounds.x = x; // bounds.y = y; // } // // // Getters and Setters // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public BufferedImage getTexture() { // return texture; // } // // public void setTexture(BufferedImage texture) { // this.texture = texture; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getX() { // return x; // } // // public void setX(int x) { // this.x = x; // } // // public int getY() { // return y; // } // // public void setY(int y) { // this.y = y; // } // // public int getCount() { // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public int getId() { // return id; // } // // public boolean isPickedUp() { // return pickedUp; // } // // }
import java.awt.Graphics; import java.awt.event.KeyEvent; import java.util.ArrayList; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.items.Item;
package dev.codenmore.tilegame.inventory; public class Inventory { private Handler handler; private boolean active = false;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 33/TileGame/src/dev/codenmore/tilegame/items/Item.java // public class Item { // // // Handler // // public static Item[] items = new Item[256]; // public static Item woodItem = new Item(Assets.wood, "Wood", 0); // public static Item rockItem = new Item(Assets.rock, "Rock", 1); // // // Class // // public static final int ITEMWIDTH = 32, ITEMHEIGHT = 32; // // protected Handler handler; // protected BufferedImage texture; // protected String name; // protected final int id; // // protected Rectangle bounds; // // protected int x, y, count; // protected boolean pickedUp = false; // // public Item(BufferedImage texture, String name, int id){ // this.texture = texture; // this.name = name; // this.id = id; // count = 1; // // bounds = new Rectangle(x, y, ITEMWIDTH, ITEMHEIGHT); // // items[id] = this; // } // // public void tick(){ // if(handler.getWorld().getEntityManager().getPlayer().getCollisionBounds(0f, 0f).intersects(bounds)){ // pickedUp = true; // handler.getWorld().getEntityManager().getPlayer().getInventory().addItem(this); // } // } // // public void render(Graphics g){ // if(handler == null) // return; // render(g, (int) (x - handler.getGameCamera().getxOffset()), (int) (y - handler.getGameCamera().getyOffset())); // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, ITEMWIDTH, ITEMHEIGHT, null); // } // // public Item createNew(int x, int y){ // Item i = new Item(texture, name, id); // i.setPosition(x, y); // return i; // } // // public void setPosition(int x, int y){ // this.x = x; // this.y = y; // bounds.x = x; // bounds.y = y; // } // // // Getters and Setters // // public Handler getHandler() { // return handler; // } // // public void setHandler(Handler handler) { // this.handler = handler; // } // // public BufferedImage getTexture() { // return texture; // } // // public void setTexture(BufferedImage texture) { // this.texture = texture; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getX() { // return x; // } // // public void setX(int x) { // this.x = x; // } // // public int getY() { // return y; // } // // public void setY(int y) { // this.y = y; // } // // public int getCount() { // return count; // } // // public void setCount(int count) { // this.count = count; // } // // public int getId() { // return id; // } // // public boolean isPickedUp() { // return pickedUp; // } // // } // Path: Episode 33/TileGame/src/dev/codenmore/tilegame/inventory/Inventory.java import java.awt.Graphics; import java.awt.event.KeyEvent; import java.util.ArrayList; import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.items.Item; package dev.codenmore.tilegame.inventory; public class Inventory { private Handler handler; private boolean active = false;
private ArrayList<Item> inventoryItems;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.creatures; public abstract class Creature extends Entity { public static final int DEFAULT_HEALTH = 10; public static final float DEFAULT_SPEED = 3.0f; public static final int DEFAULT_CREATURE_WIDTH = 64, DEFAULT_CREATURE_HEIGHT = 64; protected int health; protected float speed; protected float xMove, yMove;
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.entities.creatures; public abstract class Creature extends Entity { public static final int DEFAULT_HEALTH = 10; public static final float DEFAULT_SPEED = 3.0f; public static final int DEFAULT_CREATURE_WIDTH = 64, DEFAULT_CREATURE_HEIGHT = 64; protected int health; protected float speed; protected float xMove, yMove;
public Creature(Handler handler, float x, float y, int width, int height) {
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // }
import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile;
package dev.codenmore.tilegame.entities.creatures; public abstract class Creature extends Entity { public static final int DEFAULT_HEALTH = 10; public static final float DEFAULT_SPEED = 3.0f; public static final int DEFAULT_CREATURE_WIDTH = 64, DEFAULT_CREATURE_HEIGHT = 64; protected int health; protected float speed; protected float xMove, yMove; public Creature(Handler handler, float x, float y, int width, int height) { super(handler, x, y, width, height); health = DEFAULT_HEALTH; speed = DEFAULT_SPEED; xMove = 0; yMove = 0; } public void move(){ if(!checkEntityCollisions(xMove, 0f)) moveX(); if(!checkEntityCollisions(0f, yMove)) moveY(); } public void moveX(){ if(xMove > 0){//Moving right
// Path: Episode 34/TileGame/src/dev/codenmore/tilegame/Handler.java // public class Handler { // // private Game game; // private World world; // // public Handler(Game game){ // this.game = game; // } // // public GameCamera getGameCamera(){ // return game.getGameCamera(); // } // // public KeyManager getKeyManager(){ // return game.getKeyManager(); // } // // public MouseManager getMouseManager(){ // return game.getMouseManager(); // } // // public int getWidth(){ // return game.getWidth(); // } // // public int getHeight(){ // return game.getHeight(); // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // // public World getWorld() { // return world; // } // // public void setWorld(World world) { // this.world = world; // } // // } // // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/Entity.java // public abstract class Entity { // // protected Handler handler; // protected float x, y; // protected int width, height; // protected Rectangle bounds; // // public Entity(Handler handler, float x, float y, int width, int height){ // this.handler = handler; // this.x = x; // this.y = y; // this.width = width; // this.height = height; // // bounds = new Rectangle(0, 0, width, height); // } // // public abstract void tick(); // // public abstract void render(Graphics g); // // public boolean checkEntityCollisions(float xOffset, float yOffset){ // for(Entity e : handler.getWorld().getEntityManager().getEntities()){ // if(e.equals(this)) // continue; // if(e.getCollisionBounds(0f, 0f).intersects(getCollisionBounds(xOffset, yOffset))) // return true; // } // return false; // } // // public Rectangle getCollisionBounds(float xOffset, float yOffset){ // return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width, bounds.height); // } // // public float getX() { // return x; // } // // public void setX(float x) { // this.x = x; // } // // public float getY() { // return y; // } // // public void setY(float y) { // this.y = y; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // } // // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/Tile.java // public class Tile { // // //STATIC STUFF HERE // // public static Tile[] tiles = new Tile[256]; // public static Tile grassTile = new GrassTile(0); // public static Tile dirtTile = new DirtTile(1); // public static Tile rockTile = new RockTile(2); // // //CLASS // // public static final int TILEWIDTH = 64, TILEHEIGHT = 64; // // protected BufferedImage texture; // protected final int id; // // public Tile(BufferedImage texture, int id){ // this.texture = texture; // this.id = id; // // tiles[id] = this; // } // // public void tick(){ // // } // // public void render(Graphics g, int x, int y){ // g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null); // } // // public boolean isSolid(){ // return false; // } // // public int getId(){ // return id; // } // // } // Path: Episode 30/TileGame/src/dev/codenmore/tilegame/entities/creatures/Creature.java import dev.codenmore.tilegame.Handler; import dev.codenmore.tilegame.entities.Entity; import dev.codenmore.tilegame.tiles.Tile; package dev.codenmore.tilegame.entities.creatures; public abstract class Creature extends Entity { public static final int DEFAULT_HEALTH = 10; public static final float DEFAULT_SPEED = 3.0f; public static final int DEFAULT_CREATURE_WIDTH = 64, DEFAULT_CREATURE_HEIGHT = 64; protected int health; protected float speed; protected float xMove, yMove; public Creature(Handler handler, float x, float y, int width, int height) { super(handler, x, y, width, height); health = DEFAULT_HEALTH; speed = DEFAULT_SPEED; xMove = 0; yMove = 0; } public void move(){ if(!checkEntityCollisions(xMove, 0f)) moveX(); if(!checkEntityCollisions(0f, yMove)) moveY(); } public void moveX(){ if(xMove > 0){//Moving right
int tx = (int) (x + xMove + bounds.x + bounds.width) / Tile.TILEWIDTH;
CodeNMore/New-Beginner-Java-Game-Programming-Src
Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/GrassTile.java
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // }
import dev.codenmore.tilegame.gfx.Assets;
package dev.codenmore.tilegame.tiles; public class GrassTile extends Tile { public GrassTile(int id) {
// Path: Episode 29/TileGame/src/dev/codenmore/tilegame/gfx/Assets.java // public class Assets { // // private static final int width = 32, height = 32; // // public static BufferedImage dirt, grass, stone, tree, rock; // public static BufferedImage[] player_down, player_up, player_left, player_right; // public static BufferedImage[] zombie_down, zombie_up, zombie_left, zombie_right; // // public static void init(){ // SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png")); // // player_down = new BufferedImage[2]; // player_up = new BufferedImage[2]; // player_left = new BufferedImage[2]; // player_right = new BufferedImage[2]; // // player_down[0] = sheet.crop(width * 4, 0, width, height); // player_down[1] = sheet.crop(width * 5, 0, width, height); // player_up[0] = sheet.crop(width * 6, 0, width, height); // player_up[1] = sheet.crop(width * 7, 0, width, height); // player_right[0] = sheet.crop(width * 4, height, width, height); // player_right[1] = sheet.crop(width * 5, height, width, height); // player_left[0] = sheet.crop(width * 6, height, width, height); // player_left[1] = sheet.crop(width * 7, height, width, height); // // zombie_down = new BufferedImage[2]; // zombie_up = new BufferedImage[2]; // zombie_left = new BufferedImage[2]; // zombie_right = new BufferedImage[2]; // // zombie_down[0] = sheet.crop(width * 4, height * 2, width, height); // zombie_down[1] = sheet.crop(width * 5, height * 2, width, height); // zombie_up[0] = sheet.crop(width * 6, height * 2, width, height); // zombie_up[1] = sheet.crop(width * 7, height * 2, width, height); // zombie_right[0] = sheet.crop(width * 4, height * 3, width, height); // zombie_right[1] = sheet.crop(width * 5, height * 3, width, height); // zombie_left[0] = sheet.crop(width * 6, height * 3, width, height); // zombie_left[1] = sheet.crop(width * 7, height * 3, width, height); // // dirt = sheet.crop(width, 0, width, height); // grass = sheet.crop(width * 2, 0, width, height); // stone = sheet.crop(width * 3, 0, width, height); // tree = sheet.crop(0, 0, width, height * 2); // rock = sheet.crop(0, height * 2, width, height); // } // // } // Path: Episode 34/TileGame/src/dev/codenmore/tilegame/tiles/GrassTile.java import dev.codenmore.tilegame.gfx.Assets; package dev.codenmore.tilegame.tiles; public class GrassTile extends Tile { public GrassTile(int id) {
super(Assets.grass, id);
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBookInventory.java
// Path: src/main/java/com/panicnot42/warpbook/item/WarpBookItem.java // public class WarpBookItem extends Item implements IColorable { // // public WarpBookItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // setMaxStackSize(1); // setCreativeTab(WarpBookMod.tabBook); // setMaxDamage(0); // } // // @Override // public int getMaxItemUseDuration(ItemStack itemStack) { // return 1; // } // // @Override // public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { // ItemStack itemStack = player.getHeldItem(hand); // // WarpBookMod.lastHeldBooks.put(player, itemStack); // if (player.isSneaking()) { // player.openGui(WarpBookMod.instance, WarpBookMod.WarpBookInventoryGuiIndex, world, (int)player.posX, (int)player.posY, (int)player.posZ); // } // else { // player.openGui(WarpBookMod.instance, WarpBookMod.WarpBookWarpGuiIndex, world, (int)player.posX, (int)player.posY, (int)player.posZ); // } // // return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) { // try { // tooltip.add(I18n.format("warpbook.booktooltip", stack.getTagCompound().getTagList("WarpPages", new NBTTagCompound().getId()).tagCount())); // } // catch (Exception e) { // // no pages // } // } // // public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { // return false; // } // // public static int getRespawnsLeft(ItemStack item) { // if (item.getTagCompound() == null) { // item.setTagCompound(new NBTTagCompound()); // } // return item.getTagCompound().getShort("deathPages"); // } // // public static void setRespawnsLeft(ItemStack item, int deaths) { // if (item.getTagCompound() == null) { // item.setTagCompound(new NBTTagCompound()); // } // item.getTagCompound().setShort("deathPages", (short)deaths); // } // // public static void decrRespawnsLeft(ItemStack item) { // setRespawnsLeft(item, getRespawnsLeft(item) - 1); // } // // public static int getCopyCost(ItemStack itemStack) { // // if(itemStack.getTagCompound() == null) { // itemStack.setTagCompound(new NBTTagCompound()); // } // // NBTTagList items = itemStack.getTagCompound().getTagList("WarpPages", new NBTTagCompound().getId()); // int count = 0; // for (int i = 0; i < items.tagCount(); ++i) { // ItemStack item = new ItemStack(items.getCompoundTagAt(i)); // if (((WarpItem)item.getItem()).isWarpCloneable(item)) { // count += item.getCount(); // } // } // return count; // } // // public static ItemStack copyBook(World world, ItemStack book) { // // ItemStack stack = new ItemStack(WarpBookMod.items.warpBookItem, 1); // NBTTagList pages = book.getTagCompound().getTagList("WarpPages", Constants.NBT.TAG_COMPOUND); // NBTTagList destPages = new NBTTagList(); // for (int i = 0; i < pages.tagCount(); ++i) { // NBTTagCompound page = pages.getCompoundTagAt(i); // int slot = page.getInteger("Slot"); // ItemStack item = new ItemStack(page); // if (item.getItem() instanceof IDeclareWarp && ((WarpItem)item.getItem()).isWarpCloneable(item)) { // NBTTagCompound tag = new NBTTagCompound(); // item.writeToNBT(tag); // tag.setInteger("Slot", slot); // destPages.appendTag(tag); // } // } // stack.setTagCompound(new NBTTagCompound()); // stack.getTagCompound().setTag("WarpPages", destPages); // // return stack; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // // switch(tintIndex) { // case 0: { // if(stack.hasTagCompound() && stack.getTagCompound().hasKey("color")) { // return stack.getTagCompound().getInteger("color"); // } // return WarpColors.LEATHER.getColor();//Leather // } // case 1: return WarpColors.UNBOUND.getColor();//The pages // default: return 0xFFFFFFFF;//The ender pearl // } // } // // }
import com.panicnot42.warpbook.item.WarpBookItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot;
package com.panicnot42.warpbook.inventory; public class SlotWarpBookInventory extends Slot { public SlotWarpBookInventory(InventoryPlayer inventory, int i, int j, int k) { super(inventory, i, j, k); } @Override public boolean canTakeStack(EntityPlayer par1EntityPlayer) {
// Path: src/main/java/com/panicnot42/warpbook/item/WarpBookItem.java // public class WarpBookItem extends Item implements IColorable { // // public WarpBookItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // setMaxStackSize(1); // setCreativeTab(WarpBookMod.tabBook); // setMaxDamage(0); // } // // @Override // public int getMaxItemUseDuration(ItemStack itemStack) { // return 1; // } // // @Override // public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { // ItemStack itemStack = player.getHeldItem(hand); // // WarpBookMod.lastHeldBooks.put(player, itemStack); // if (player.isSneaking()) { // player.openGui(WarpBookMod.instance, WarpBookMod.WarpBookInventoryGuiIndex, world, (int)player.posX, (int)player.posY, (int)player.posZ); // } // else { // player.openGui(WarpBookMod.instance, WarpBookMod.WarpBookWarpGuiIndex, world, (int)player.posX, (int)player.posY, (int)player.posZ); // } // // return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) { // try { // tooltip.add(I18n.format("warpbook.booktooltip", stack.getTagCompound().getTagList("WarpPages", new NBTTagCompound().getId()).tagCount())); // } // catch (Exception e) { // // no pages // } // } // // public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { // return false; // } // // public static int getRespawnsLeft(ItemStack item) { // if (item.getTagCompound() == null) { // item.setTagCompound(new NBTTagCompound()); // } // return item.getTagCompound().getShort("deathPages"); // } // // public static void setRespawnsLeft(ItemStack item, int deaths) { // if (item.getTagCompound() == null) { // item.setTagCompound(new NBTTagCompound()); // } // item.getTagCompound().setShort("deathPages", (short)deaths); // } // // public static void decrRespawnsLeft(ItemStack item) { // setRespawnsLeft(item, getRespawnsLeft(item) - 1); // } // // public static int getCopyCost(ItemStack itemStack) { // // if(itemStack.getTagCompound() == null) { // itemStack.setTagCompound(new NBTTagCompound()); // } // // NBTTagList items = itemStack.getTagCompound().getTagList("WarpPages", new NBTTagCompound().getId()); // int count = 0; // for (int i = 0; i < items.tagCount(); ++i) { // ItemStack item = new ItemStack(items.getCompoundTagAt(i)); // if (((WarpItem)item.getItem()).isWarpCloneable(item)) { // count += item.getCount(); // } // } // return count; // } // // public static ItemStack copyBook(World world, ItemStack book) { // // ItemStack stack = new ItemStack(WarpBookMod.items.warpBookItem, 1); // NBTTagList pages = book.getTagCompound().getTagList("WarpPages", Constants.NBT.TAG_COMPOUND); // NBTTagList destPages = new NBTTagList(); // for (int i = 0; i < pages.tagCount(); ++i) { // NBTTagCompound page = pages.getCompoundTagAt(i); // int slot = page.getInteger("Slot"); // ItemStack item = new ItemStack(page); // if (item.getItem() instanceof IDeclareWarp && ((WarpItem)item.getItem()).isWarpCloneable(item)) { // NBTTagCompound tag = new NBTTagCompound(); // item.writeToNBT(tag); // tag.setInteger("Slot", slot); // destPages.appendTag(tag); // } // } // stack.setTagCompound(new NBTTagCompound()); // stack.getTagCompound().setTag("WarpPages", destPages); // // return stack; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // // switch(tintIndex) { // case 0: { // if(stack.hasTagCompound() && stack.getTagCompound().hasKey("color")) { // return stack.getTagCompound().getInteger("color"); // } // return WarpColors.LEATHER.getColor();//Leather // } // case 1: return WarpColors.UNBOUND.getColor();//The pages // default: return 0xFFFFFFFF;//The ender pearl // } // } // // } // Path: src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBookInventory.java import com.panicnot42.warpbook.item.WarpBookItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; package com.panicnot42.warpbook.inventory; public class SlotWarpBookInventory extends Slot { public SlotWarpBookInventory(InventoryPlayer inventory, int i, int j, int k) { super(inventory, i, j, k); } @Override public boolean canTakeStack(EntityPlayer par1EntityPlayer) {
return getHasStack() && !(this.getStack().getItem() instanceof WarpBookItem);
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/inventory/InventoryBookCloner.java
// Path: src/main/java/com/panicnot42/warpbook/tileentity/TileEntityBookCloner.java // public class TileEntityBookCloner extends TileEntity { // private ItemStack pages; // private ItemStack template; // private ItemStack result; // private ItemStack cover; // // public TileEntityBookCloner() { // pages = ItemStack.EMPTY; // template = ItemStack.EMPTY; // result = ItemStack.EMPTY; // cover = ItemStack.EMPTY; // } // // @Override // public void readFromNBT(NBTTagCompound tag) { // super.readFromNBT(tag); // pages = new ItemStack(tag.getCompoundTag("pages")); // template = new ItemStack(tag.getCompoundTag("books")); // result = new ItemStack(tag.getCompoundTag("result")); // cover = new ItemStack(tag.getCompoundTag("cover")); // } // // @Override // public NBTTagCompound writeToNBT(NBTTagCompound tag) { // super.writeToNBT(tag); // if (!pages.isEmpty()) { // tag.setTag("pages", pages.writeToNBT(new NBTTagCompound())); // } // if (!template.isEmpty()) { // tag.setTag("books", template.writeToNBT(new NBTTagCompound())); // } // if (!result.isEmpty()) { // tag.setTag("result", result.writeToNBT(new NBTTagCompound())); // } // if (!cover.isEmpty()) { // tag.setTag("cover", cover.writeToNBT(new NBTTagCompound())); // } // // return tag; // } // // public ItemStack getPages() { // return pages; // } // // public ItemStack getTemplate() { // return template; // } // // public ItemStack getResult() { // return result; // } // // public ItemStack getCover() { // return cover; // } // // public void setItem(InvSlots invSlot, ItemStack stack) { // switch(invSlot) { // default: // case COVER: setCover(stack); break; // case PAGES: setPages(stack); break; // case RESULT: setResult(stack); break; // case TEMPLATE: setTemplate(stack); break; // } // } // // public void setCover(ItemStack cover) { // this.cover = cover; // this.markDirty(); // } // // public void setPages(ItemStack pages) { // this.pages = pages; // this.markDirty(); // } // // public void setTemplate(ItemStack books) { // this.template = books; // this.markDirty(); // } // // public void setResult(ItemStack result) { // this.result = result; // this.markDirty(); // } // // public boolean materialsReady() { // if (!pages.isEmpty() && !template.isEmpty() && !cover.isEmpty()) { // if (pages.getCount() >= WarpBookItem.getCopyCost(template)) { // return true; // } // } // return false; // } // // public void buildBook(World world) { // setResult(WarpBookItem.copyBook(world, template)); // markDirty(); // } // // public void consumeMaterials() { // int cost = WarpBookItem.getCopyCost(template); // pages.shrink(cost); // if (pages.isEmpty()) { // pages = ItemStack.EMPTY; // } // cover.shrink(1); // if (cover.isEmpty()) { // cover = ItemStack.EMPTY; // } // } // // }
import com.panicnot42.warpbook.tileentity.TileEntityBookCloner; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent;
package com.panicnot42.warpbook.inventory; public class InventoryBookCloner implements IInventory { private String name = "bookcloner.name";
// Path: src/main/java/com/panicnot42/warpbook/tileentity/TileEntityBookCloner.java // public class TileEntityBookCloner extends TileEntity { // private ItemStack pages; // private ItemStack template; // private ItemStack result; // private ItemStack cover; // // public TileEntityBookCloner() { // pages = ItemStack.EMPTY; // template = ItemStack.EMPTY; // result = ItemStack.EMPTY; // cover = ItemStack.EMPTY; // } // // @Override // public void readFromNBT(NBTTagCompound tag) { // super.readFromNBT(tag); // pages = new ItemStack(tag.getCompoundTag("pages")); // template = new ItemStack(tag.getCompoundTag("books")); // result = new ItemStack(tag.getCompoundTag("result")); // cover = new ItemStack(tag.getCompoundTag("cover")); // } // // @Override // public NBTTagCompound writeToNBT(NBTTagCompound tag) { // super.writeToNBT(tag); // if (!pages.isEmpty()) { // tag.setTag("pages", pages.writeToNBT(new NBTTagCompound())); // } // if (!template.isEmpty()) { // tag.setTag("books", template.writeToNBT(new NBTTagCompound())); // } // if (!result.isEmpty()) { // tag.setTag("result", result.writeToNBT(new NBTTagCompound())); // } // if (!cover.isEmpty()) { // tag.setTag("cover", cover.writeToNBT(new NBTTagCompound())); // } // // return tag; // } // // public ItemStack getPages() { // return pages; // } // // public ItemStack getTemplate() { // return template; // } // // public ItemStack getResult() { // return result; // } // // public ItemStack getCover() { // return cover; // } // // public void setItem(InvSlots invSlot, ItemStack stack) { // switch(invSlot) { // default: // case COVER: setCover(stack); break; // case PAGES: setPages(stack); break; // case RESULT: setResult(stack); break; // case TEMPLATE: setTemplate(stack); break; // } // } // // public void setCover(ItemStack cover) { // this.cover = cover; // this.markDirty(); // } // // public void setPages(ItemStack pages) { // this.pages = pages; // this.markDirty(); // } // // public void setTemplate(ItemStack books) { // this.template = books; // this.markDirty(); // } // // public void setResult(ItemStack result) { // this.result = result; // this.markDirty(); // } // // public boolean materialsReady() { // if (!pages.isEmpty() && !template.isEmpty() && !cover.isEmpty()) { // if (pages.getCount() >= WarpBookItem.getCopyCost(template)) { // return true; // } // } // return false; // } // // public void buildBook(World world) { // setResult(WarpBookItem.copyBook(world, template)); // markDirty(); // } // // public void consumeMaterials() { // int cost = WarpBookItem.getCopyCost(template); // pages.shrink(cost); // if (pages.isEmpty()) { // pages = ItemStack.EMPTY; // } // cover.shrink(1); // if (cover.isEmpty()) { // cover = ItemStack.EMPTY; // } // } // // } // Path: src/main/java/com/panicnot42/warpbook/inventory/InventoryBookCloner.java import com.panicnot42.warpbook.tileentity.TileEntityBookCloner; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; package com.panicnot42.warpbook.inventory; public class InventoryBookCloner implements IInventory { private String name = "bookcloner.name";
private final TileEntityBookCloner cloner;
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/Warp.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.util.HashMap; import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.warps; public class Warp implements IDeclareWarp { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a"; public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); NBTTagCompound tag; public Warp() { tag = new NBTTagCompound(); } public void setTag(NBTTagCompound tag) { this.tag = tag; } public NBTTagCompound getTag() { return tag; } @Override public String getName(World world, ItemStack stack) { return null; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); } @Override
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java import java.util.HashMap; import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.warps; public class Warp implements IDeclareWarp { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a"; public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); NBTTagCompound tag; public Warp() { tag = new NBTTagCompound(); } public void setTag(NBTTagCompound tag) { this.tag = tag; } public NBTTagCompound getTag() { return tag; } @Override public String getName(World world, ItemStack stack) { return null; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); } @Override
public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/Warp.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.util.HashMap; import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
public void setTag(NBTTagCompound tag) { this.tag = tag; } public NBTTagCompound getTag() { return tag; } @Override public String getName(World world, ItemStack stack) { return null; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); } @Override public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { return null; } @Override public boolean hasValidData(ItemStack stack) { return false; } @SideOnly(Side.CLIENT)
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java import java.util.HashMap; import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public void setTag(NBTTagCompound tag) { this.tag = tag; } public NBTTagCompound getTag() { return tag; } @Override public String getName(World world, ItemStack stack) { return null; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); } @Override public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { return null; } @Override public boolean hasValidData(ItemStack stack) { return false; } @SideOnly(Side.CLIENT)
public WarpColors getColor() {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/WarpLocus.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.util.List; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.warps; public class WarpLocus extends Warp { @Override public String getName(World world, ItemStack stack) { if(stack.hasTagCompound() && stack.getTagCompound().hasKey("name")) { return stack.getTagCompound().getString("name"); } return unbound; } @Override
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/WarpLocus.java import java.util.List; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.warps; public class WarpLocus extends Warp { @Override public String getName(World world, ItemStack stack) { if(stack.hasTagCompound() && stack.getTagCompound().hasKey("name")) { return stack.getTagCompound().getString("name"); } return unbound; } @Override
public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/WarpLocus.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.util.List; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
} } @Override public boolean hasValidData(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().hasKey("posX") && stack.getTagCompound().hasKey("posY") && stack.getTagCompound().hasKey("posZ") && stack.getTagCompound().hasKey("dim"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); if(hasValidData(stack)) { try { tooltip.add(I18n.format("warpbook.bindmsg", stack.getTagCompound().getInteger("posX"), stack.getTagCompound().getInteger("posY"), stack.getTagCompound().getInteger("posZ"), stack.getTagCompound().getInteger("dim"))); } catch (Exception e) {} } } @Override @SideOnly(Side.CLIENT)
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/WarpLocus.java import java.util.List; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; } } @Override public boolean hasValidData(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().hasKey("posX") && stack.getTagCompound().hasKey("posY") && stack.getTagCompound().hasKey("posZ") && stack.getTagCompound().hasKey("dim"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(ttprefix + getName(world, stack)); if(hasValidData(stack)) { try { tooltip.add(I18n.format("warpbook.bindmsg", stack.getTagCompound().getInteger("posX"), stack.getTagCompound().getInteger("posY"), stack.getTagCompound().getInteger("posZ"), stack.getTagCompound().getInteger("dim"))); } catch (Exception e) {} } } @Override @SideOnly(Side.CLIENT)
public WarpColors getColor() {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/net/packet/PacketEffect.java
// Path: src/main/java/com/panicnot42/warpbook/WarpSounds.java // @ObjectHolder("warpbook") // @Mod.EventBusSubscriber(modid = "warpbook") // public class WarpSounds // { // @ObjectHolder("depart") // public static final SoundEvent departSound = null; // // @ObjectHolder("arrive") // public static final SoundEvent arriveSound = null; // // @SubscribeEvent // public static void registerSounds(RegistryEvent.Register<SoundEvent> event) // { // ResourceLocation departLocation = new ResourceLocation("warpbook", "depart"); // ResourceLocation arriveLocation = new ResourceLocation("warpbook", "arrive"); // // event.getRegistry().registerAll( // new SoundEvent(departLocation).setRegistryName(departLocation), // new SoundEvent(arriveLocation).setRegistryName(arriveLocation) // ); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/net/NetUtils.java // public class NetUtils { // public static EntityPlayer getPlayerFromContext(MessageContext ctx) { // if (ctx.side == Side.SERVER) { // return ctx.getServerHandler().player; // } // else { // return getClientPlayer(); // } // } // // @SideOnly(Side.CLIENT) // private static EntityPlayer getClientPlayer() { // return Minecraft.getMinecraft().player; // } // }
import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import com.panicnot42.warpbook.WarpSounds; import com.panicnot42.warpbook.util.net.NetUtils; import net.minecraft.util.SoundCategory; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
package com.panicnot42.warpbook.net.packet; public class PacketEffect implements IMessage, IMessageHandler<PacketEffect, IMessage> { boolean enter; int x, y, z; public PacketEffect() { } public PacketEffect(boolean enter, int x, int y, int z) { this.enter = enter; this.x = x; this.y = y; this.z = z; } @Override public IMessage onMessage(PacketEffect message, MessageContext ctx) {
// Path: src/main/java/com/panicnot42/warpbook/WarpSounds.java // @ObjectHolder("warpbook") // @Mod.EventBusSubscriber(modid = "warpbook") // public class WarpSounds // { // @ObjectHolder("depart") // public static final SoundEvent departSound = null; // // @ObjectHolder("arrive") // public static final SoundEvent arriveSound = null; // // @SubscribeEvent // public static void registerSounds(RegistryEvent.Register<SoundEvent> event) // { // ResourceLocation departLocation = new ResourceLocation("warpbook", "depart"); // ResourceLocation arriveLocation = new ResourceLocation("warpbook", "arrive"); // // event.getRegistry().registerAll( // new SoundEvent(departLocation).setRegistryName(departLocation), // new SoundEvent(arriveLocation).setRegistryName(arriveLocation) // ); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/net/NetUtils.java // public class NetUtils { // public static EntityPlayer getPlayerFromContext(MessageContext ctx) { // if (ctx.side == Side.SERVER) { // return ctx.getServerHandler().player; // } // else { // return getClientPlayer(); // } // } // // @SideOnly(Side.CLIENT) // private static EntityPlayer getClientPlayer() { // return Minecraft.getMinecraft().player; // } // } // Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketEffect.java import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import com.panicnot42.warpbook.WarpSounds; import com.panicnot42.warpbook.util.net.NetUtils; import net.minecraft.util.SoundCategory; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; package com.panicnot42.warpbook.net.packet; public class PacketEffect implements IMessage, IMessageHandler<PacketEffect, IMessage> { boolean enter; int x, y, z; public PacketEffect() { } public PacketEffect(boolean enter, int x, int y, int z) { this.enter = enter; this.x = x; this.y = y; this.z = z; } @Override public IMessage onMessage(PacketEffect message, MessageContext ctx) {
EntityPlayer player = NetUtils.getPlayerFromContext(ctx);
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/net/packet/PacketEffect.java
// Path: src/main/java/com/panicnot42/warpbook/WarpSounds.java // @ObjectHolder("warpbook") // @Mod.EventBusSubscriber(modid = "warpbook") // public class WarpSounds // { // @ObjectHolder("depart") // public static final SoundEvent departSound = null; // // @ObjectHolder("arrive") // public static final SoundEvent arriveSound = null; // // @SubscribeEvent // public static void registerSounds(RegistryEvent.Register<SoundEvent> event) // { // ResourceLocation departLocation = new ResourceLocation("warpbook", "depart"); // ResourceLocation arriveLocation = new ResourceLocation("warpbook", "arrive"); // // event.getRegistry().registerAll( // new SoundEvent(departLocation).setRegistryName(departLocation), // new SoundEvent(arriveLocation).setRegistryName(arriveLocation) // ); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/net/NetUtils.java // public class NetUtils { // public static EntityPlayer getPlayerFromContext(MessageContext ctx) { // if (ctx.side == Side.SERVER) { // return ctx.getServerHandler().player; // } // else { // return getClientPlayer(); // } // } // // @SideOnly(Side.CLIENT) // private static EntityPlayer getClientPlayer() { // return Minecraft.getMinecraft().player; // } // }
import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import com.panicnot42.warpbook.WarpSounds; import com.panicnot42.warpbook.util.net.NetUtils; import net.minecraft.util.SoundCategory; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
package com.panicnot42.warpbook.net.packet; public class PacketEffect implements IMessage, IMessageHandler<PacketEffect, IMessage> { boolean enter; int x, y, z; public PacketEffect() { } public PacketEffect(boolean enter, int x, int y, int z) { this.enter = enter; this.x = x; this.y = y; this.z = z; } @Override public IMessage onMessage(PacketEffect message, MessageContext ctx) { EntityPlayer player = NetUtils.getPlayerFromContext(ctx); int particles = (2 - Minecraft.getMinecraft().gameSettings.particleSetting) * 50; if (message.enter) { for (int i = 0; i < (5 * particles); ++i) { player.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, message.x, message.y + (player.world.rand.nextDouble() * 2), message.z, (player.world.rand.nextDouble() / 10) - 0.05D, 0D, (player.world.rand.nextDouble() / 10) - 0.05D); }
// Path: src/main/java/com/panicnot42/warpbook/WarpSounds.java // @ObjectHolder("warpbook") // @Mod.EventBusSubscriber(modid = "warpbook") // public class WarpSounds // { // @ObjectHolder("depart") // public static final SoundEvent departSound = null; // // @ObjectHolder("arrive") // public static final SoundEvent arriveSound = null; // // @SubscribeEvent // public static void registerSounds(RegistryEvent.Register<SoundEvent> event) // { // ResourceLocation departLocation = new ResourceLocation("warpbook", "depart"); // ResourceLocation arriveLocation = new ResourceLocation("warpbook", "arrive"); // // event.getRegistry().registerAll( // new SoundEvent(departLocation).setRegistryName(departLocation), // new SoundEvent(arriveLocation).setRegistryName(arriveLocation) // ); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/net/NetUtils.java // public class NetUtils { // public static EntityPlayer getPlayerFromContext(MessageContext ctx) { // if (ctx.side == Side.SERVER) { // return ctx.getServerHandler().player; // } // else { // return getClientPlayer(); // } // } // // @SideOnly(Side.CLIENT) // private static EntityPlayer getClientPlayer() { // return Minecraft.getMinecraft().player; // } // } // Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketEffect.java import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import com.panicnot42.warpbook.WarpSounds; import com.panicnot42.warpbook.util.net.NetUtils; import net.minecraft.util.SoundCategory; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; package com.panicnot42.warpbook.net.packet; public class PacketEffect implements IMessage, IMessageHandler<PacketEffect, IMessage> { boolean enter; int x, y, z; public PacketEffect() { } public PacketEffect(boolean enter, int x, int y, int z) { this.enter = enter; this.x = x; this.y = y; this.z = z; } @Override public IMessage onMessage(PacketEffect message, MessageContext ctx) { EntityPlayer player = NetUtils.getPlayerFromContext(ctx); int particles = (2 - Minecraft.getMinecraft().gameSettings.particleSetting) * 50; if (message.enter) { for (int i = 0; i < (5 * particles); ++i) { player.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, message.x, message.y + (player.world.rand.nextDouble() * 2), message.z, (player.world.rand.nextDouble() / 10) - 0.05D, 0D, (player.world.rand.nextDouble() / 10) - 0.05D); }
player.world.playSound(player, player.posX, player.posY, player.posZ, WarpSounds.arriveSound, SoundCategory.PLAYERS, 1.0f, 1.0f);
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/tileentity/TileEntityTeleporter.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // }
import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
return tag; } private void read(NBTTagCompound tag) { warpItem = new ItemStack(tag.getCompoundTag("warpitem")); } private void write(NBTTagCompound tag) { if (!warpItem.isEmpty()) { NBTTagCompound pageTag = new NBTTagCompound(); warpItem.writeToNBT(pageTag); tag.setTag("warpitem", pageTag); } } public ItemStack getWarpItem() { return warpItem; } public void setWarpItem(ItemStack stack) { warpItem = stack; markDirty(); } @Override public boolean shouldRefresh(World w, BlockPos pos, IBlockState oldState, IBlockState newState) { return super.shouldRefresh(world, pos, oldState, newState); } @SideOnly(Side.CLIENT)
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // } // Path: src/main/java/com/panicnot42/warpbook/tileentity/TileEntityTeleporter.java import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; return tag; } private void read(NBTTagCompound tag) { warpItem = new ItemStack(tag.getCompoundTag("warpitem")); } private void write(NBTTagCompound tag) { if (!warpItem.isEmpty()) { NBTTagCompound pageTag = new NBTTagCompound(); warpItem.writeToNBT(pageTag); tag.setTag("warpitem", pageTag); } } public ItemStack getWarpItem() { return warpItem; } public void setWarpItem(ItemStack stack) { warpItem = stack; markDirty(); } @Override public boolean shouldRefresh(World w, BlockPos pos, IBlockState oldState, IBlockState newState) { return super.shouldRefresh(world, pos, oldState, newState); } @SideOnly(Side.CLIENT)
public WarpColors getWarpColor() {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/tileentity/TileEntityTeleporter.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // }
import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
} private void read(NBTTagCompound tag) { warpItem = new ItemStack(tag.getCompoundTag("warpitem")); } private void write(NBTTagCompound tag) { if (!warpItem.isEmpty()) { NBTTagCompound pageTag = new NBTTagCompound(); warpItem.writeToNBT(pageTag); tag.setTag("warpitem", pageTag); } } public ItemStack getWarpItem() { return warpItem; } public void setWarpItem(ItemStack stack) { warpItem = stack; markDirty(); } @Override public boolean shouldRefresh(World w, BlockPos pos, IBlockState oldState, IBlockState newState) { return super.shouldRefresh(world, pos, oldState, newState); } @SideOnly(Side.CLIENT) public WarpColors getWarpColor() {
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // } // Path: src/main/java/com/panicnot42/warpbook/tileentity/TileEntityTeleporter.java import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; } private void read(NBTTagCompound tag) { warpItem = new ItemStack(tag.getCompoundTag("warpitem")); } private void write(NBTTagCompound tag) { if (!warpItem.isEmpty()) { NBTTagCompound pageTag = new NBTTagCompound(); warpItem.writeToNBT(pageTag); tag.setTag("warpitem", pageTag); } } public ItemStack getWarpItem() { return warpItem; } public void setWarpItem(ItemStack stack) { warpItem = stack; markDirty(); } @Override public boolean shouldRefresh(World w, BlockPos pos, IBlockState oldState, IBlockState newState) { return super.shouldRefresh(world, pos, oldState, newState); } @SideOnly(Side.CLIENT) public WarpColors getWarpColor() {
return warpItem.getItem() instanceof WarpItem ? ((WarpItem) warpItem.getItem()).getWarpColor() : WarpColors.UNBOUND;
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.warps; public class WarpPlayer extends Warp { @Override public String getName(World world, ItemStack stack) { if (hasValidData(stack)) { String name = stack.getTagCompound().getString("player"); if(name != null) { return name; } } return unbound; } @Override
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.warps; public class WarpPlayer extends Warp { @Override public String getName(World world, ItemStack stack) { if (hasValidData(stack)) { String name = stack.getTagCompound().getString("player"); if(name != null) { return name; } } return unbound; } @Override
public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.warps; public class WarpPlayer extends Warp { @Override public String getName(World world, ItemStack stack) { if (hasValidData(stack)) { String name = stack.getTagCompound().getString("player"); if(name != null) { return name; } } return unbound; } @Override public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { if (!player.world.isRemote) { if(hasValidData(stack)) { UUID playerID = UUID.fromString(stack.getTagCompound().getString("playeruuid")); EntityPlayerMP playerTo = null; List<EntityPlayerMP> allPlayers = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers(); for (EntityPlayerMP playerS : allPlayers) { if (playerS.getUniqueID().equals(playerID)) { playerTo = playerS; } } if (player != playerTo && playerTo != null) { return new Waypoint("", "",
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.warps; public class WarpPlayer extends Warp { @Override public String getName(World world, ItemStack stack) { if (hasValidData(stack)) { String name = stack.getTagCompound().getString("player"); if(name != null) { return name; } } return unbound; } @Override public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { if (!player.world.isRemote) { if(hasValidData(stack)) { UUID playerID = UUID.fromString(stack.getTagCompound().getString("playeruuid")); EntityPlayerMP playerTo = null; List<EntityPlayerMP> allPlayers = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers(); for (EntityPlayerMP playerS : allPlayers) { if (playerS.getUniqueID().equals(playerID)) { playerTo = playerS; } } if (player != playerTo && playerTo != null) { return new Waypoint("", "",
MathUtils.round(playerTo.posX, RoundingMode.DOWN),
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
playerTo = playerS; } } if (player != playerTo && playerTo != null) { return new Waypoint("", "", MathUtils.round(playerTo.posX, RoundingMode.DOWN), MathUtils.round(playerTo.posY, RoundingMode.DOWN), MathUtils.round(playerTo.posZ, RoundingMode.DOWN), playerTo.dimension); } } } return null; } @Override public boolean hasValidData(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().hasKey("playeruuid"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) { tooltip.add(ttprefix + getName(world, stack)); } @Override @SideOnly(Side.CLIENT)
// Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/warps/WarpPlayer.java import java.math.RoundingMode; import java.util.List; import java.util.UUID; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; playerTo = playerS; } } if (player != playerTo && playerTo != null) { return new Waypoint("", "", MathUtils.round(playerTo.posX, RoundingMode.DOWN), MathUtils.round(playerTo.posY, RoundingMode.DOWN), MathUtils.round(playerTo.posZ, RoundingMode.DOWN), playerTo.dimension); } } } return null; } @Override public boolean hasValidData(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().hasKey("playeruuid"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) { tooltip.add(ttprefix + getName(world, stack)); } @Override @SideOnly(Side.CLIENT)
public WarpColors getColor() {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/item/WarpItem.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // }
import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.item; public class WarpItem extends Item implements IDeclareWarp, IColorable { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a";
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // } // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.item; public class WarpItem extends Item implements IDeclareWarp, IColorable { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a";
public Warp warp = new Warp();
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/item/WarpItem.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // }
import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.panicnot42.warpbook.item; public class WarpItem extends Item implements IDeclareWarp, IColorable { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a"; public Warp warp = new Warp(); public boolean cloneable = false;; public WarpItem(String name) { setUnlocalizedName(name); setRegistryName(name); } public WarpItem setWarp(Warp warp) { this.warp = warp; return this; } public WarpItem setCloneable(boolean is) { this.cloneable = is; return this; } @Override public String getName(World world, ItemStack stack) { return warp.getName(world, stack); } @Override
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // } // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.panicnot42.warpbook.item; public class WarpItem extends Item implements IDeclareWarp, IColorable { public static final String unbound = "§4§kUnbound"; public static final String ttprefix = "§a"; public Warp warp = new Warp(); public boolean cloneable = false;; public WarpItem(String name) { setUnlocalizedName(name); setRegistryName(name); } public WarpItem setWarp(Warp warp) { this.warp = warp; return this; } public WarpItem setCloneable(boolean is) { this.cloneable = is; return this; } @Override public String getName(World world, ItemStack stack) { return warp.getName(world, stack); } @Override
public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/item/WarpItem.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // }
import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
return warp.getWaypoint(player, stack); } @Override public boolean hasValidData(ItemStack stack) { return warp.hasValidData(stack); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { warp.addInformation(stack, world, tooltip, flagIn); } /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ public boolean isWarpCloneable(ItemStack stack) { return cloneable; } public boolean canGoInBook() { return false; } @Override @SideOnly(Side.CLIENT) public int getColor(ItemStack stack, int tintIndex) { return 0xFFFFFFFF; } @SideOnly(Side.CLIENT)
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/core/WarpColors.java // public enum WarpColors { // // UNBOUND(0xC3C36A, 0xC3C36A),//The default tawny color of a warp page // BOUND(0x098C76, 0x6CF4DC),//The color of an ender pearl // //0x9F1CE5 The original ugly purple player page // PLAYER(0x8e0000, 0xE13232),//Red color.. blood maybe? // HYPER(0x09AA38, 0x53FF41),//Hyper Green // DEATHLY(0x131313, 0x686868),//Near Black // LEATHER(0x654b17, 0x654b17);//The color of vanilla books // // private int color; // private int specColor; // // WarpColors(int color, int specColor) { // this.color = color; // this.specColor = specColor; // } // // public int getColor() { // return color; // } // // public int getSpecColor() { // return specColor; // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // // Path: src/main/java/com/panicnot42/warpbook/warps/Warp.java // public class Warp implements IDeclareWarp { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public static HashMap<String, Class<Warp>> warpRegistry = new HashMap<>(); // // NBTTagCompound tag; // // public Warp() { // tag = new NBTTagCompound(); // } // // public void setTag(NBTTagCompound tag) { // this.tag = tag; // } // // public NBTTagCompound getTag() { // return tag; // } // // @Override // public String getName(World world, ItemStack stack) { // return null; // } // // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(ttprefix + getName(world, stack)); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return null; // } // // @Override // public boolean hasValidData(ItemStack stack) { // return false; // } // // @SideOnly(Side.CLIENT) // public WarpColors getColor() { // return WarpColors.UNBOUND; // } // // } // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java import java.util.List; import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.core.WarpColors; import com.panicnot42.warpbook.util.Waypoint; import com.panicnot42.warpbook.warps.Warp; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; return warp.getWaypoint(player, stack); } @Override public boolean hasValidData(ItemStack stack) { return warp.hasValidData(stack); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { warp.addInformation(stack, world, tooltip, flagIn); } /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ public boolean isWarpCloneable(ItemStack stack) { return cloneable; } public boolean canGoInBook() { return false; } @Override @SideOnly(Side.CLIENT) public int getColor(ItemStack stack, int tintIndex) { return 0xFFFFFFFF; } @SideOnly(Side.CLIENT)
public WarpColors getWarpColor() {
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBookDeathly.java
// Path: src/main/java/com/panicnot42/warpbook/inventory/container/InventoryWarpBookSpecial.java // public class InventoryWarpBookSpecial implements IInventory { // ItemStack deathly, heldItem; // // public InventoryWarpBookSpecial(ItemStack heldItem) { // int deaths = WarpBookItem.getRespawnsLeft(heldItem); // deathly = deaths == 0 ? ItemStack.EMPTY : new ItemStack(WarpBookMod.items.deathlyWarpPageItem, deaths); // this.heldItem = heldItem; // } // // @Override // public int getSizeInventory() { // return 1; // } // // @Override // public ItemStack getStackInSlot(int slot) { // return slot == 0 ? deathly : ItemStack.EMPTY; // } // // @Override // public ItemStack decrStackSize(int slot, int quantity) { // ItemStack stack = getStackInSlot(slot); // if (stack != ItemStack.EMPTY) { // if (stack.getCount() > quantity) { // stack = stack.splitStack(quantity); // markDirty(); // } // else { // setInventorySlotContents(slot, ItemStack.EMPTY); // } // } // return stack; // } // // @Override // public ItemStack removeStackFromSlot(int slot) { // ItemStack stack = getStackInSlot(slot); // setInventorySlotContents(slot, ItemStack.EMPTY); // return stack; // } // // @Override // public void setInventorySlotContents(int slot, ItemStack itemStack) { // if (slot == 0) { // deathly = itemStack; // } // if (itemStack != null && itemStack.getCount() > getInventoryStackLimit()) { // itemStack.setCount(getInventoryStackLimit()); // } // markDirty(); // } // // @Override // public int getInventoryStackLimit() { // return 16; // } // // @Override // public void markDirty() { // WarpBookItem.setRespawnsLeft(heldItem, deathly == ItemStack.EMPTY ? 0 : deathly.getCount()); // } // // @Override // public boolean isUsableByPlayer(EntityPlayer player) { // return true; // } // // @Override // public void openInventory(EntityPlayer player) { // // } // // @Override // public void closeInventory(EntityPlayer player) { // // } // // @Override // public boolean isItemValidForSlot(int slot, ItemStack itemStack) { // return slot == 0 ? itemStack.getItem() instanceof ItemEnderPearl : itemStack.getItem() instanceof LegacyWarpPageItem && itemStack.getItemDamage() == 3; // } // // @Override // public int getField(int id) { // return 0; // } // // @Override // public void setField(int id, int value) { // // } // // @Override // public int getFieldCount() { // return 0; // } // // @Override // public void clear() { // // } // // @Override // public String getName() { // return null; // } // // @Override // public boolean hasCustomName() { // return false; // } // // @Override // public ITextComponent getDisplayName() { // return null; // } // // @Override // public boolean isEmpty() { // return getSizeInventory() == 0; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/item/DeathlyWarpPageItem.java // public class DeathlyWarpPageItem extends Item implements IColorable { // public DeathlyWarpPageItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // setMaxStackSize(16); // setCreativeTab(WarpBookMod.tabBook); // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // switch(tintIndex) { // case 0: return pageColor(); // case 1: return symbolColor(); // default: return 0x00FFFFFF; // } // } // // @SideOnly(Side.CLIENT) // public int pageColor() { // return WarpColors.DEATHLY.getColor(); // } // // @SideOnly(Side.CLIENT) // public int symbolColor() { // return 0x00BBBBBB; // } // }
import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import com.panicnot42.warpbook.inventory.container.InventoryWarpBookSpecial; import com.panicnot42.warpbook.item.DeathlyWarpPageItem;
package com.panicnot42.warpbook.inventory; public class SlotWarpBookDeathly extends Slot { public SlotWarpBookDeathly(InventoryWarpBookSpecial inventorySpecial, int i, int j, int k) { super(inventorySpecial, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
// Path: src/main/java/com/panicnot42/warpbook/inventory/container/InventoryWarpBookSpecial.java // public class InventoryWarpBookSpecial implements IInventory { // ItemStack deathly, heldItem; // // public InventoryWarpBookSpecial(ItemStack heldItem) { // int deaths = WarpBookItem.getRespawnsLeft(heldItem); // deathly = deaths == 0 ? ItemStack.EMPTY : new ItemStack(WarpBookMod.items.deathlyWarpPageItem, deaths); // this.heldItem = heldItem; // } // // @Override // public int getSizeInventory() { // return 1; // } // // @Override // public ItemStack getStackInSlot(int slot) { // return slot == 0 ? deathly : ItemStack.EMPTY; // } // // @Override // public ItemStack decrStackSize(int slot, int quantity) { // ItemStack stack = getStackInSlot(slot); // if (stack != ItemStack.EMPTY) { // if (stack.getCount() > quantity) { // stack = stack.splitStack(quantity); // markDirty(); // } // else { // setInventorySlotContents(slot, ItemStack.EMPTY); // } // } // return stack; // } // // @Override // public ItemStack removeStackFromSlot(int slot) { // ItemStack stack = getStackInSlot(slot); // setInventorySlotContents(slot, ItemStack.EMPTY); // return stack; // } // // @Override // public void setInventorySlotContents(int slot, ItemStack itemStack) { // if (slot == 0) { // deathly = itemStack; // } // if (itemStack != null && itemStack.getCount() > getInventoryStackLimit()) { // itemStack.setCount(getInventoryStackLimit()); // } // markDirty(); // } // // @Override // public int getInventoryStackLimit() { // return 16; // } // // @Override // public void markDirty() { // WarpBookItem.setRespawnsLeft(heldItem, deathly == ItemStack.EMPTY ? 0 : deathly.getCount()); // } // // @Override // public boolean isUsableByPlayer(EntityPlayer player) { // return true; // } // // @Override // public void openInventory(EntityPlayer player) { // // } // // @Override // public void closeInventory(EntityPlayer player) { // // } // // @Override // public boolean isItemValidForSlot(int slot, ItemStack itemStack) { // return slot == 0 ? itemStack.getItem() instanceof ItemEnderPearl : itemStack.getItem() instanceof LegacyWarpPageItem && itemStack.getItemDamage() == 3; // } // // @Override // public int getField(int id) { // return 0; // } // // @Override // public void setField(int id, int value) { // // } // // @Override // public int getFieldCount() { // return 0; // } // // @Override // public void clear() { // // } // // @Override // public String getName() { // return null; // } // // @Override // public boolean hasCustomName() { // return false; // } // // @Override // public ITextComponent getDisplayName() { // return null; // } // // @Override // public boolean isEmpty() { // return getSizeInventory() == 0; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/item/DeathlyWarpPageItem.java // public class DeathlyWarpPageItem extends Item implements IColorable { // public DeathlyWarpPageItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // setMaxStackSize(16); // setCreativeTab(WarpBookMod.tabBook); // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // switch(tintIndex) { // case 0: return pageColor(); // case 1: return symbolColor(); // default: return 0x00FFFFFF; // } // } // // @SideOnly(Side.CLIENT) // public int pageColor() { // return WarpColors.DEATHLY.getColor(); // } // // @SideOnly(Side.CLIENT) // public int symbolColor() { // return 0x00BBBBBB; // } // } // Path: src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBookDeathly.java import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import com.panicnot42.warpbook.inventory.container.InventoryWarpBookSpecial; import com.panicnot42.warpbook.item.DeathlyWarpPageItem; package com.panicnot42.warpbook.inventory; public class SlotWarpBookDeathly extends Slot { public SlotWarpBookDeathly(InventoryWarpBookSpecial inventorySpecial, int i, int j, int k) { super(inventorySpecial, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
return itemStack.getItem() instanceof DeathlyWarpPageItem;
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/WarpWorldStorage.java
// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java // public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> { // public HashMap<String, Waypoint> table; // // public PacketSyncWaypoints() { // } // // public PacketSyncWaypoints(HashMap<String, Waypoint> table) { // this.table = table; // } // // @Override // public void fromBytes(ByteBuf buffer) { // NBTTagCompound tag = ByteBufUtils.readTag(buffer); // table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class); // } // // @Override // public void toBytes(ByteBuf buffer) { // NBTTagCompound tag = new NBTTagCompound(); // NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table); // ByteBufUtils.writeTag(buffer, tag); // } // // @Override // public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) { // World world = Minecraft.getMinecraft().player.world; // WarpWorldStorage s = WarpWorldStorage.get(world); // s.table = message.table; // s.save(world); // return null; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.math.RoundingMode; import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import io.netty.channel.ChannelFutureListener; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent; import net.minecraftforge.fml.common.network.FMLOutboundHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; import net.minecraftforge.fml.relauncher.Side;
for (Entry<String, Waypoint> waypointSource : table.entrySet()) { NBTTagCompound waypoint = new NBTTagCompound(); waypoint.setString("name", waypointSource.getKey()); NBTTagCompound data = new NBTTagCompound(); waypointSource.getValue().writeToNBT(data); waypoint.setTag("data", data); waypoints.appendTag(waypoint); } NBTTagList deathsNBT = new NBTTagList(); for (Entry<UUID, Waypoint> deathSource : deaths.entrySet()) { NBTTagCompound death = new NBTTagCompound(); death.setString("uuid", deathSource.getKey().toString()); NBTTagCompound data = new NBTTagCompound(); deathSource.getValue().writeToNBT(data); death.setTag("data", data); deathsNBT.appendTag(death); } var1.setTag("waypoints", waypoints); var1.setTag("deaths", deathsNBT); return var1; } void updateClient(EntityPlayerMP player, ServerConnectionFromClientEvent e) { FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager()));
// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java // public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> { // public HashMap<String, Waypoint> table; // // public PacketSyncWaypoints() { // } // // public PacketSyncWaypoints(HashMap<String, Waypoint> table) { // this.table = table; // } // // @Override // public void fromBytes(ByteBuf buffer) { // NBTTagCompound tag = ByteBufUtils.readTag(buffer); // table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class); // } // // @Override // public void toBytes(ByteBuf buffer) { // NBTTagCompound tag = new NBTTagCompound(); // NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table); // ByteBufUtils.writeTag(buffer, tag); // } // // @Override // public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) { // World world = Minecraft.getMinecraft().player.world; // WarpWorldStorage s = WarpWorldStorage.get(world); // s.table = message.table; // s.save(world); // return null; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/WarpWorldStorage.java import java.math.RoundingMode; import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import io.netty.channel.ChannelFutureListener; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent; import net.minecraftforge.fml.common.network.FMLOutboundHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; import net.minecraftforge.fml.relauncher.Side; for (Entry<String, Waypoint> waypointSource : table.entrySet()) { NBTTagCompound waypoint = new NBTTagCompound(); waypoint.setString("name", waypointSource.getKey()); NBTTagCompound data = new NBTTagCompound(); waypointSource.getValue().writeToNBT(data); waypoint.setTag("data", data); waypoints.appendTag(waypoint); } NBTTagList deathsNBT = new NBTTagList(); for (Entry<UUID, Waypoint> deathSource : deaths.entrySet()) { NBTTagCompound death = new NBTTagCompound(); death.setString("uuid", deathSource.getKey().toString()); NBTTagCompound data = new NBTTagCompound(); deathSource.getValue().writeToNBT(data); death.setTag("data", data); deathsNBT.appendTag(death); } var1.setTag("waypoints", waypoints); var1.setTag("deaths", deathsNBT); return var1; } void updateClient(EntityPlayerMP player, ServerConnectionFromClientEvent e) { FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager()));
channel.writeAndFlush(new PacketSyncWaypoints(table)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/WarpWorldStorage.java
// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java // public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> { // public HashMap<String, Waypoint> table; // // public PacketSyncWaypoints() { // } // // public PacketSyncWaypoints(HashMap<String, Waypoint> table) { // this.table = table; // } // // @Override // public void fromBytes(ByteBuf buffer) { // NBTTagCompound tag = ByteBufUtils.readTag(buffer); // table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class); // } // // @Override // public void toBytes(ByteBuf buffer) { // NBTTagCompound tag = new NBTTagCompound(); // NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table); // ByteBufUtils.writeTag(buffer, tag); // } // // @Override // public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) { // World world = Minecraft.getMinecraft().player.world; // WarpWorldStorage s = WarpWorldStorage.get(world); // s.table = message.table; // s.save(world); // return null; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // }
import java.math.RoundingMode; import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import io.netty.channel.ChannelFutureListener; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent; import net.minecraftforge.fml.common.network.FMLOutboundHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; import net.minecraftforge.fml.relauncher.Side;
FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager())); channel.writeAndFlush(new PacketSyncWaypoints(table)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public boolean waypointExists(String name) { return table.containsKey(name); } public Waypoint getWaypoint(String name) { return table.get(name); } public void addWaypoint(Waypoint point) { table.put(point.name, point); this.markDirty(); } public Set<String> listWaypoints() { return table.keySet(); } public boolean deleteWaypoint(String waypoint) { boolean res = table.remove(waypoint) != null; this.markDirty(); return res; } public void setLastDeath(UUID id, double posX, double posY, double posZ, int dim) {
// Path: src/main/java/com/panicnot42/warpbook/net/packet/PacketSyncWaypoints.java // public class PacketSyncWaypoints implements IMessage, IMessageHandler<PacketSyncWaypoints, IMessage> { // public HashMap<String, Waypoint> table; // // public PacketSyncWaypoints() { // } // // public PacketSyncWaypoints(HashMap<String, Waypoint> table) { // this.table = table; // } // // @Override // public void fromBytes(ByteBuf buffer) { // NBTTagCompound tag = ByteBufUtils.readTag(buffer); // table = NBTUtils.readHashMapFromNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), Waypoint.class); // } // // @Override // public void toBytes(ByteBuf buffer) { // NBTTagCompound tag = new NBTTagCompound(); // NBTUtils.writeHashMapToNBT(tag.getTagList("data", Constants.NBT.TAG_COMPOUND), table); // ByteBufUtils.writeTag(buffer, tag); // } // // @Override // public IMessage onMessage(PacketSyncWaypoints message, MessageContext ctx) { // World world = Minecraft.getMinecraft().player.world; // WarpWorldStorage s = WarpWorldStorage.get(world); // s.table = message.table; // s.save(world); // return null; // } // // } // // Path: src/main/java/com/panicnot42/warpbook/util/MathUtils.java // public class MathUtils { // public static int round(double value, RoundingMode mode) { // return new BigDecimal(value).setScale(0, mode).intValue(); // } // } // // Path: src/main/java/com/panicnot42/warpbook/util/Waypoint.java // public class Waypoint implements INBTSerializable { // public String friendlyName, name; // public int x, y, z, dim; // // public Waypoint(String friendlyName, String name, int x, int y, int z, int dim) { // this.friendlyName = friendlyName; // this.name = name; // this.x = x; // this.y = y; // this.z = z; // this.dim = dim; // } // // public Waypoint(NBTTagCompound var1) { // readFromNBT(var1); // } // // @Override // public void readFromNBT(NBTTagCompound var1) { // this.friendlyName = var1.getString("friendlyName"); // this.x = var1.getInteger("x"); // this.y = var1.getInteger("y"); // this.z = var1.getInteger("z"); // this.dim = var1.getInteger("dim"); // this.name = var1.getString("name"); // } // // @Override // public void writeToNBT(NBTTagCompound var1) { // var1.setString("friendlyName", this.friendlyName); // var1.setInteger("x", this.x); // var1.setInteger("y", this.y); // var1.setInteger("z", this.z); // var1.setInteger("dim", this.dim); // var1.setString("name", this.name); // } // // } // Path: src/main/java/com/panicnot42/warpbook/WarpWorldStorage.java import java.math.RoundingMode; import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import com.panicnot42.warpbook.net.packet.PacketSyncWaypoints; import com.panicnot42.warpbook.util.MathUtils; import com.panicnot42.warpbook.util.Waypoint; import io.netty.channel.ChannelFutureListener; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent; import net.minecraftforge.fml.common.network.FMLOutboundHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; import net.minecraftforge.fml.relauncher.Side; FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel(Properties.modid, Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(NetworkDispatcher.get(e.getManager())); channel.writeAndFlush(new PacketSyncWaypoints(table)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public boolean waypointExists(String name) { return table.containsKey(name); } public Waypoint getWaypoint(String name) { return table.get(name); } public void addWaypoint(Waypoint point) { table.put(point.name, point); this.markDirty(); } public Set<String> listWaypoints() { return table.keySet(); } public boolean deleteWaypoint(String waypoint) { boolean res = table.remove(waypoint) != null; this.markDirty(); return res; } public void setLastDeath(UUID id, double posX, double posY, double posZ, int dim) {
deaths.put(id, new Waypoint("Death Point", "death", MathUtils.round(posX, RoundingMode.DOWN), MathUtils.round(posY, RoundingMode.DOWN), MathUtils.round(posZ, RoundingMode.DOWN), dim));
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBook.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // }
import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack;
package com.panicnot42.warpbook.inventory; public class SlotWarpBook extends Slot { public SlotWarpBook(InventoryWarpBook inventory, int i, int j, int k) { super(inventory, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // } // Path: src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBook.java import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; package com.panicnot42.warpbook.inventory; public class SlotWarpBook extends Slot { public SlotWarpBook(InventoryWarpBook inventory, int i, int j, int k) { super(inventory, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
return itemStack.getItem() instanceof IDeclareWarp && ((WarpItem)itemStack.getItem()).canGoInBook();
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBook.java
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // }
import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack;
package com.panicnot42.warpbook.inventory; public class SlotWarpBook extends Slot { public SlotWarpBook(InventoryWarpBook inventory, int i, int j, int k) { super(inventory, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
// Path: src/main/java/com/panicnot42/warpbook/core/IDeclareWarp.java // public interface IDeclareWarp { // /** Used by the warpbook for generating it's listing. Must be used for warp book pages */ // String getName(World world, ItemStack stack); // // /** Gets the waypoint for this object */ // Waypoint getWaypoint(EntityPlayer player, ItemStack stack); // // /** Does this stack have valid waypoint data? */ // boolean hasValidData(ItemStack stack); // // } // // Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // } // Path: src/main/java/com/panicnot42/warpbook/inventory/SlotWarpBook.java import com.panicnot42.warpbook.core.IDeclareWarp; import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; package com.panicnot42.warpbook.inventory; public class SlotWarpBook extends Slot { public SlotWarpBook(InventoryWarpBook inventory, int i, int j, int k) { super(inventory, i, j, k); } public static boolean itemValid(ItemStack itemStack) {
return itemStack.getItem() instanceof IDeclareWarp && ((WarpItem)itemStack.getItem()).canGoInBook();
Outurnate/WarpBook
src/main/java/com/panicnot42/warpbook/crafting/WarpPageShapeless.java
// Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // }
import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.util.NonNullList;
package com.panicnot42.warpbook.crafting; public class WarpPageShapeless extends ShapelessRecipes { ItemStack recipeOutput; public WarpPageShapeless(ItemStack recipeOutput, NonNullList<Ingredient> ingredients) { super("", recipeOutput, ingredients); this.recipeOutput = recipeOutput; } @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack output = recipeOutput.copy(); try { for (int i = 0; i < inventory.getSizeInventory(); ++i) { ItemStack workingStack = inventory.getStackInSlot(i);
// Path: src/main/java/com/panicnot42/warpbook/item/WarpItem.java // public class WarpItem extends Item implements IDeclareWarp, IColorable { // // public static final String unbound = "§4§kUnbound"; // public static final String ttprefix = "§a"; // // public Warp warp = new Warp(); // public boolean cloneable = false;; // // public WarpItem(String name) { // setUnlocalizedName(name); // setRegistryName(name); // } // // public WarpItem setWarp(Warp warp) { // this.warp = warp; // return this; // } // // public WarpItem setCloneable(boolean is) { // this.cloneable = is; // return this; // } // // @Override // public String getName(World world, ItemStack stack) { // return warp.getName(world, stack); // } // // @Override // public Waypoint getWaypoint(EntityPlayer player, ItemStack stack) { // return warp.getWaypoint(player, stack); // } // // @Override // public boolean hasValidData(ItemStack stack) { // return warp.hasValidData(stack); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) { // warp.addInformation(stack, world, tooltip, flagIn); // } // // /** Can this be copied to a page? Either in the book cloner or via a copy recipe */ // public boolean isWarpCloneable(ItemStack stack) { // return cloneable; // } // // public boolean canGoInBook() { // return false; // } // // @Override // @SideOnly(Side.CLIENT) // public int getColor(ItemStack stack, int tintIndex) { // return 0xFFFFFFFF; // } // // @SideOnly(Side.CLIENT) // public WarpColors getWarpColor() { // return warp.getColor(); // } // // } // Path: src/main/java/com/panicnot42/warpbook/crafting/WarpPageShapeless.java import com.panicnot42.warpbook.item.WarpItem; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.util.NonNullList; package com.panicnot42.warpbook.crafting; public class WarpPageShapeless extends ShapelessRecipes { ItemStack recipeOutput; public WarpPageShapeless(ItemStack recipeOutput, NonNullList<Ingredient> ingredients) { super("", recipeOutput, ingredients); this.recipeOutput = recipeOutput; } @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack output = recipeOutput.copy(); try { for (int i = 0; i < inventory.getSizeInventory(); ++i) { ItemStack workingStack = inventory.getStackInSlot(i);
if (inventory.getStackInSlot(i) != null && workingStack.getItem() instanceof WarpItem) {
aaschmid/gradle-cpd-plugin
src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporter.java
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // }
import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.util.List; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report.Xml; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging;
package de.aaschmid.gradle.plugins.cpd.internal.worker; class CpdReporter { private static final Logger logger = Logging.getLogger(CpdReporter.class);
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporter.java import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.util.List; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report.Xml; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; package de.aaschmid.gradle.plugins.cpd.internal.worker; class CpdReporter { private static final Logger logger = Logging.getLogger(CpdReporter.class);
void generate(List<Report> reports, List<Match> matches) {
aaschmid/gradle-cpd-plugin
src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporter.java
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // }
import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.util.List; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report.Xml; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging;
* CPDRenderer} because only worker classloader knows about PMD / CPD library. * * @param report the configured reports used * @return a full configured {@link CPDRenderer} to generate a CPD single file reports. */ CPDRenderer createRendererFor(Report report) { if (report instanceof Report.Csv) { char separator = ((Report.Csv) report).getSeparator(); boolean lineCountPerFile = !((Report.Csv) report).isIncludeLineCount(); if (logger.isDebugEnabled()) { logger.debug("Creating renderer to generate CSV file separated by '{}'{}.", separator, lineCountPerFile ? " with line count per file" : ""); } return new CSVRenderer(separator, lineCountPerFile); } else if (report instanceof Report.Text) { String lineSeparator = ((Report.Text) report).getLineSeparator(); boolean trimLeadingCommonSourceWhitespaces = ((Report.Text) report).isTrimLeadingCommonSourceWhitespaces(); if (logger.isDebugEnabled()) { logger.debug("Creating renderer to generate simple text file separated by '{}' and trimmed '{}'.", lineSeparator, trimLeadingCommonSourceWhitespaces); } SimpleRenderer result = new SimpleRenderer(lineSeparator); setTrimLeadingWhitespacesByReflection(result, trimLeadingCommonSourceWhitespaces); return result; } else if (report instanceof Report.Vs) { return new VSRenderer();
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporter.java import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.util.List; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report.Xml; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; * CPDRenderer} because only worker classloader knows about PMD / CPD library. * * @param report the configured reports used * @return a full configured {@link CPDRenderer} to generate a CPD single file reports. */ CPDRenderer createRendererFor(Report report) { if (report instanceof Report.Csv) { char separator = ((Report.Csv) report).getSeparator(); boolean lineCountPerFile = !((Report.Csv) report).isIncludeLineCount(); if (logger.isDebugEnabled()) { logger.debug("Creating renderer to generate CSV file separated by '{}'{}.", separator, lineCountPerFile ? " with line count per file" : ""); } return new CSVRenderer(separator, lineCountPerFile); } else if (report instanceof Report.Text) { String lineSeparator = ((Report.Text) report).getLineSeparator(); boolean trimLeadingCommonSourceWhitespaces = ((Report.Text) report).isTrimLeadingCommonSourceWhitespaces(); if (logger.isDebugEnabled()) { logger.debug("Creating renderer to generate simple text file separated by '{}' and trimmed '{}'.", lineSeparator, trimLeadingCommonSourceWhitespaces); } SimpleRenderer result = new SimpleRenderer(lineSeparator); setTrimLeadingWhitespacesByReflection(result, trimLeadingCommonSourceWhitespaces); return result; } else if (report instanceof Report.Vs) { return new VSRenderer();
} else if (report instanceof Report.Xml) {
aaschmid/gradle-cpd-plugin
src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdAction.java
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // }
import java.io.File; import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import java.util.Properties; import javax.inject.Inject; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import net.sourceforge.pmd.cpd.AnyLanguage; import net.sourceforge.pmd.cpd.CPDConfiguration; import net.sourceforge.pmd.cpd.Language; import net.sourceforge.pmd.cpd.LanguageFactory; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.Tokenizer; import org.gradle.api.GradleException; import org.gradle.workers.WorkAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
// Visible for testing CpdAction(CpdExecutor executor, CpdReporter reporter) { this.executor = executor; this.reporter = reporter; } @Override public void execute() { List<Match> matches = executor.run(createCpdConfiguration(getParameters()), getParameters().getSourceFiles().getFiles()); reporter.generate(getParameters().getReportParameters().get(), matches); logResult(matches); } private CPDConfiguration createCpdConfiguration(CpdWorkParameters config) { CPDConfiguration result = new CPDConfiguration(); result.setEncoding(config.getEncoding().get()); result.setLanguage(createLanguage(config.getLanguage().get(), createLanguageProperties(config))); result.setMinimumTileSize(config.getMinimumTokenCount().get()); result.setSkipDuplicates(config.getSkipDuplicateFiles().get()); result.setSkipLexicalErrors(config.getSkipLexicalErrors().get()); return result; } private void logResult(List<Match> matches) { if (matches.isEmpty()) { if (logger.isInfoEnabled()) { logger.info("No duplicates over {} tokens found.", getParameters().getMinimumTokenCount().get()); } } else { String message = "CPD found duplicate code.";
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdAction.java import java.io.File; import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import java.util.Properties; import javax.inject.Inject; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import net.sourceforge.pmd.cpd.AnyLanguage; import net.sourceforge.pmd.cpd.CPDConfiguration; import net.sourceforge.pmd.cpd.Language; import net.sourceforge.pmd.cpd.LanguageFactory; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.Tokenizer; import org.gradle.api.GradleException; import org.gradle.workers.WorkAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; // Visible for testing CpdAction(CpdExecutor executor, CpdReporter reporter) { this.executor = executor; this.reporter = reporter; } @Override public void execute() { List<Match> matches = executor.run(createCpdConfiguration(getParameters()), getParameters().getSourceFiles().getFiles()); reporter.generate(getParameters().getReportParameters().get(), matches); logResult(matches); } private CPDConfiguration createCpdConfiguration(CpdWorkParameters config) { CPDConfiguration result = new CPDConfiguration(); result.setEncoding(config.getEncoding().get()); result.setLanguage(createLanguage(config.getLanguage().get(), createLanguageProperties(config))); result.setMinimumTileSize(config.getMinimumTokenCount().get()); result.setSkipDuplicates(config.getSkipDuplicateFiles().get()); result.setSkipLexicalErrors(config.getSkipLexicalErrors().get()); return result; } private void logResult(List<Match> matches) { if (matches.isEmpty()) { if (logger.isInfoEnabled()) { logger.info("No duplicates over {} tokens found.", getParameters().getMinimumTokenCount().get()); } } else { String message = "CPD found duplicate code.";
Report report = getParameters().getReportParameters().get().get(0);
aaschmid/gradle-cpd-plugin
src/test/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporterTest.java
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestTag.java // public interface TestTag { // // String INTEGRATION_TEST = "integrationTest"; // }
import java.io.File; import java.io.IOException; import java.nio.file.Path; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.test.TestTag; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Mark; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.cpd.SourceCode.StringCodeLoader; import net.sourceforge.pmd.cpd.TokenEntry; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.contentOf; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when;
package de.aaschmid.gradle.plugins.cpd.internal.worker; @ExtendWith(MockitoExtension.class) class CpdReporterTest { @InjectMocks CpdReporter underTest; @Test void generate_shouldReThrowRendererThrownIoExceptionAsGradleException(@TempDir Path tempDir) throws Exception { // Given:
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestTag.java // public interface TestTag { // // String INTEGRATION_TEST = "integrationTest"; // } // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporterTest.java import java.io.File; import java.io.IOException; import java.nio.file.Path; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.test.TestTag; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Mark; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.cpd.SourceCode.StringCodeLoader; import net.sourceforge.pmd.cpd.TokenEntry; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.contentOf; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; package de.aaschmid.gradle.plugins.cpd.internal.worker; @ExtendWith(MockitoExtension.class) class CpdReporterTest { @InjectMocks CpdReporter underTest; @Test void generate_shouldReThrowRendererThrownIoExceptionAsGradleException(@TempDir Path tempDir) throws Exception { // Given:
Report report = mock(Report.class);
aaschmid/gradle-cpd-plugin
src/test/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporterTest.java
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestTag.java // public interface TestTag { // // String INTEGRATION_TEST = "integrationTest"; // }
import java.io.File; import java.io.IOException; import java.nio.file.Path; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.test.TestTag; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Mark; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.cpd.SourceCode.StringCodeLoader; import net.sourceforge.pmd.cpd.TokenEntry; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.contentOf; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when;
package de.aaschmid.gradle.plugins.cpd.internal.worker; @ExtendWith(MockitoExtension.class) class CpdReporterTest { @InjectMocks CpdReporter underTest; @Test void generate_shouldReThrowRendererThrownIoExceptionAsGradleException(@TempDir Path tempDir) throws Exception { // Given: Report report = mock(Report.class); when(report.getDestination()).thenReturn(tempDir.resolve("report.file").toFile()); CPDRenderer cpdRenderer = mock(CPDRenderer.class); doThrow(new IOException("foo")).when(cpdRenderer).render(any(), any()); CpdReporter underTestSpy = spy(underTest); doReturn(cpdRenderer).when(underTestSpy).createRendererFor(report); // Expect: assertThatThrownBy(() -> underTestSpy.generate(singletonList(report), emptyList())) .isInstanceOf(GradleException.class) .hasMessage("foo") .hasCauseInstanceOf(IOException.class); }
// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdWorkParameters.java // abstract class Report implements Serializable { // private final File destination; // // Report(File destination) { // this.destination = requireNonNull(destination, "'destination' must not be null for any report."); // } // // File getDestination() { // return destination; // } // // public static class Csv extends Report { // private final Character separator; // private final boolean includeLineCount; // // public Csv(File destination, Character separator, boolean includeLineCount) { // super(destination); // this.separator = separator; // this.includeLineCount = includeLineCount; // } // // Character getSeparator() { // return separator; // } // // boolean isIncludeLineCount() { // return includeLineCount; // } // } // // public static class Text extends Report { // private final String lineSeparator; // private final boolean trimLeadingCommonSourceWhitespaces; // // public Text(File destination, String lineSeparator, boolean trimLeadingCommonSourceWhitespaces) { // super(destination); // this.lineSeparator = lineSeparator; // this.trimLeadingCommonSourceWhitespaces = trimLeadingCommonSourceWhitespaces; // } // // String getLineSeparator() { // return lineSeparator; // } // // boolean isTrimLeadingCommonSourceWhitespaces() { // return trimLeadingCommonSourceWhitespaces; // } // } // // public static class Vs extends Report { // public Vs(File destination) { // super(destination); // } // } // // public static class Xml extends Report { // private final String encoding; // // public Xml(File destination, String encoding) { // super(destination); // this.encoding = encoding; // } // // String getEncoding() { // return encoding; // } // } // } // // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestTag.java // public interface TestTag { // // String INTEGRATION_TEST = "integrationTest"; // } // Path: src/test/java/de/aaschmid/gradle/plugins/cpd/internal/worker/CpdReporterTest.java import java.io.File; import java.io.IOException; import java.nio.file.Path; import de.aaschmid.gradle.plugins.cpd.internal.worker.CpdWorkParameters.Report; import de.aaschmid.gradle.plugins.cpd.test.TestTag; import net.sourceforge.pmd.cpd.CSVRenderer; import net.sourceforge.pmd.cpd.Mark; import net.sourceforge.pmd.cpd.Match; import net.sourceforge.pmd.cpd.SimpleRenderer; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.cpd.SourceCode.StringCodeLoader; import net.sourceforge.pmd.cpd.TokenEntry; import net.sourceforge.pmd.cpd.VSRenderer; import net.sourceforge.pmd.cpd.XMLRenderer; import net.sourceforge.pmd.cpd.renderer.CPDRenderer; import org.gradle.api.GradleException; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.contentOf; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; package de.aaschmid.gradle.plugins.cpd.internal.worker; @ExtendWith(MockitoExtension.class) class CpdReporterTest { @InjectMocks CpdReporter underTest; @Test void generate_shouldReThrowRendererThrownIoExceptionAsGradleException(@TempDir Path tempDir) throws Exception { // Given: Report report = mock(Report.class); when(report.getDestination()).thenReturn(tempDir.resolve("report.file").toFile()); CPDRenderer cpdRenderer = mock(CPDRenderer.class); doThrow(new IOException("foo")).when(cpdRenderer).render(any(), any()); CpdReporter underTestSpy = spy(underTest); doReturn(cpdRenderer).when(underTestSpy).createRendererFor(report); // Expect: assertThatThrownBy(() -> underTestSpy.generate(singletonList(report), emptyList())) .isInstanceOf(GradleException.class) .hasMessage("foo") .hasCauseInstanceOf(IOException.class); }
@Tag(TestTag.INTEGRATION_TEST)
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/SeleniumTestRunner.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // }
import com.google.common.base.Throwables; import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import org.junit.internal.runners.model.ReflectiveCallable; import org.junit.internal.runners.statements.Fail; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import org.phabricator.sprint.selenium.testing.drivers.Browser; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method;
package org.phabricator.sprint.selenium.testing; public class SeleniumTestRunner extends BlockJUnit4ClassRunner { /** * Creates a BlockJUnit4ClassRunner to run {@code klass} * * @param klass The class under test * @throws org.junit.runners.model.InitializationError * if the test class is malformed. */ public SeleniumTestRunner(Class<?> klass) throws InitializationError { super(klass);
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/SeleniumTestRunner.java import com.google.common.base.Throwables; import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import org.junit.internal.runners.model.ReflectiveCallable; import org.junit.internal.runners.statements.Fail; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import org.phabricator.sprint.selenium.testing.drivers.Browser; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; package org.phabricator.sprint.selenium.testing; public class SeleniumTestRunner extends BlockJUnit4ClassRunner { /** * Creates a BlockJUnit4ClassRunner to run {@code klass} * * @param klass The class under test * @throws org.junit.runners.model.InitializationError * if the test class is malformed. */ public SeleniumTestRunner(Class<?> klass) throws InitializationError { super(klass);
Browser browser = Browser.detect();
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/SeleniumTestRunner.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // }
import com.google.common.base.Throwables; import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import org.junit.internal.runners.model.ReflectiveCallable; import org.junit.internal.runners.statements.Fail; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import org.phabricator.sprint.selenium.testing.drivers.Browser; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method;
package org.phabricator.sprint.selenium.testing; public class SeleniumTestRunner extends BlockJUnit4ClassRunner { /** * Creates a BlockJUnit4ClassRunner to run {@code klass} * * @param klass The class under test * @throws org.junit.runners.model.InitializationError * if the test class is malformed. */ public SeleniumTestRunner(Class<?> klass) throws InitializationError { super(klass); Browser browser = Browser.detect();
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/SeleniumTestRunner.java import com.google.common.base.Throwables; import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import org.junit.internal.runners.model.ReflectiveCallable; import org.junit.internal.runners.statements.Fail; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import org.phabricator.sprint.selenium.testing.drivers.Browser; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; package org.phabricator.sprint.selenium.testing; public class SeleniumTestRunner extends BlockJUnit4ClassRunner { /** * Creates a BlockJUnit4ClassRunner to run {@code klass} * * @param klass The class under test * @throws org.junit.runners.model.InitializationError * if the test class is malformed. */ public SeleniumTestRunner(Class<?> klass) throws InitializationError { super(klass); Browser browser = Browser.detect();
if (browser == null && isInDevMode()) {
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/DefaultDriverSupplier.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // }
import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import java.lang.reflect.InvocationTargetException; import java.util.logging.Logger; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriver; import com.google.common.base.Supplier; import com.google.common.base.Throwables;
package org.phabricator.sprint.selenium.testing.drivers; public class DefaultDriverSupplier implements Supplier<WebDriver> { private static final Logger log = Logger.getLogger(DefaultDriverSupplier.class.getName()); private Class<? extends WebDriver> driverClass; private final Capabilities desiredCapabilities; private final Capabilities requiredCapabilities; public DefaultDriverSupplier(Capabilities desiredCapabilities, Capabilities requiredCapabilities) { this.desiredCapabilities = desiredCapabilities; this.requiredCapabilities = requiredCapabilities; try { // Only support a default driver if we're actually in dev mode.
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/DevMode.java // public static boolean isInDevMode() { // return isInDevMode("/org/openqa/selenium/firefox/webdriver.xpi"); // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/DefaultDriverSupplier.java import static org.phabricator.sprint.selenium.testing.DevMode.isInDevMode; import java.lang.reflect.InvocationTargetException; import java.util.logging.Logger; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriver; import com.google.common.base.Supplier; import com.google.common.base.Throwables; package org.phabricator.sprint.selenium.testing.drivers; public class DefaultDriverSupplier implements Supplier<WebDriver> { private static final Logger log = Logger.getLogger(DefaultDriverSupplier.class.getName()); private Class<? extends WebDriver> driverClass; private final Capabilities desiredCapabilities; private final Capabilities requiredCapabilities; public DefaultDriverSupplier(Capabilities desiredCapabilities, Capabilities requiredCapabilities) { this.desiredCapabilities = desiredCapabilities; this.requiredCapabilities = requiredCapabilities; try { // Only support a default driver if we're actually in dev mode.
if (isInDevMode()) {
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/LabsTestEnvironment.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/PhabricatorAppServer.java // public class PhabricatorAppServer implements AppServer { // // private static final String HOSTNAME_FOR_TEST_ENV_NAME = "HOSTNAME"; // private static final String ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME = "ALTERNATIVE_HOSTNAME"; // private static final String FIXED_HTTP_PORT_ENV_NAME = "TEST_HTTP_PORT"; // private static final String FIXED_HTTPS_PORT_ENV_NAME = "TEST_HTTPS_PORT"; // // private static final int DEFAULT_HTTP_PORT = 80; // private static final int DEFAULT_HTTPS_PORT = 2410; // private static final String DEFAULT_CONTEXT_PATH = "/"; // private static final String JS_SRC_CONTEXT_PATH = "/javascript"; // private static final String CLOSURE_CONTEXT_PATH = "/third_party/closure/goog"; // private static final String THIRD_PARTY_JS_CONTEXT_PATH = "/third_party/js"; // // private static final NetworkUtils networkUtils = new NetworkUtils(); // // private int port; // private int securePort; // private File path; // private File jsSrcRoot; // private final String hostName; // // public PhabricatorAppServer() { // this(detectHostname()); // } // // public static String detectHostname() { // String hostnameFromProperty = System.getenv(HOSTNAME_FOR_TEST_ENV_NAME); // return hostnameFromProperty == null ? "localhost" : hostnameFromProperty; // } // // public PhabricatorAppServer(String hostName) { // this.hostName = "phab08.wmflabs.org"; // this.port = DEFAULT_HTTP_PORT; // } // // private int getHttpPort() { // String port = System.getenv(FIXED_HTTP_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // private int getHttpsPort() { // String port = System.getenv(FIXED_HTTPS_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // public String getHostName() { // return hostName; // } // // public String getAlternateHostName() { // String alternativeHostnameFromProperty = System.getenv(ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME); // return alternativeHostnameFromProperty == null ? // networkUtils.getPrivateLocalAddress() : alternativeHostnameFromProperty; // } // // public String whereIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getHostName() + ":" + port + relativeUrl; // } // // public String whereElseIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getAlternateHostName() + ":" + port + relativeUrl; // } // // public String whereIsSecure(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "https://" + getHostName() + ":" + securePort + relativeUrl; // } // // public String whereIsWithCredentials(String relativeUrl, String user, String pass) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + user + ":" + pass + "@" + getHostName() + ":" + port + relativeUrl; // } // // protected String getMainContextPath(String relativeUrl) { // if (!relativeUrl.startsWith("/")) { // relativeUrl = DEFAULT_CONTEXT_PATH + "/" + relativeUrl; // } // return relativeUrl; // } // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // }
import org.phabricator.sprint.selenium.environment.webserver.AppServer; import org.phabricator.sprint.selenium.environment.webserver.PhabricatorAppServer; import org.openqa.selenium.net.NetworkUtils; import org.phabricator.sprint.selenium.testing.drivers.Browser;
package org.phabricator.sprint.selenium.environment; public class LabsTestEnvironment implements TestEnvironment { private AppServer appServer; public LabsTestEnvironment() { String servingHost = getServingHost();
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/PhabricatorAppServer.java // public class PhabricatorAppServer implements AppServer { // // private static final String HOSTNAME_FOR_TEST_ENV_NAME = "HOSTNAME"; // private static final String ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME = "ALTERNATIVE_HOSTNAME"; // private static final String FIXED_HTTP_PORT_ENV_NAME = "TEST_HTTP_PORT"; // private static final String FIXED_HTTPS_PORT_ENV_NAME = "TEST_HTTPS_PORT"; // // private static final int DEFAULT_HTTP_PORT = 80; // private static final int DEFAULT_HTTPS_PORT = 2410; // private static final String DEFAULT_CONTEXT_PATH = "/"; // private static final String JS_SRC_CONTEXT_PATH = "/javascript"; // private static final String CLOSURE_CONTEXT_PATH = "/third_party/closure/goog"; // private static final String THIRD_PARTY_JS_CONTEXT_PATH = "/third_party/js"; // // private static final NetworkUtils networkUtils = new NetworkUtils(); // // private int port; // private int securePort; // private File path; // private File jsSrcRoot; // private final String hostName; // // public PhabricatorAppServer() { // this(detectHostname()); // } // // public static String detectHostname() { // String hostnameFromProperty = System.getenv(HOSTNAME_FOR_TEST_ENV_NAME); // return hostnameFromProperty == null ? "localhost" : hostnameFromProperty; // } // // public PhabricatorAppServer(String hostName) { // this.hostName = "phab08.wmflabs.org"; // this.port = DEFAULT_HTTP_PORT; // } // // private int getHttpPort() { // String port = System.getenv(FIXED_HTTP_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // private int getHttpsPort() { // String port = System.getenv(FIXED_HTTPS_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // public String getHostName() { // return hostName; // } // // public String getAlternateHostName() { // String alternativeHostnameFromProperty = System.getenv(ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME); // return alternativeHostnameFromProperty == null ? // networkUtils.getPrivateLocalAddress() : alternativeHostnameFromProperty; // } // // public String whereIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getHostName() + ":" + port + relativeUrl; // } // // public String whereElseIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getAlternateHostName() + ":" + port + relativeUrl; // } // // public String whereIsSecure(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "https://" + getHostName() + ":" + securePort + relativeUrl; // } // // public String whereIsWithCredentials(String relativeUrl, String user, String pass) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + user + ":" + pass + "@" + getHostName() + ":" + port + relativeUrl; // } // // protected String getMainContextPath(String relativeUrl) { // if (!relativeUrl.startsWith("/")) { // relativeUrl = DEFAULT_CONTEXT_PATH + "/" + relativeUrl; // } // return relativeUrl; // } // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/LabsTestEnvironment.java import org.phabricator.sprint.selenium.environment.webserver.AppServer; import org.phabricator.sprint.selenium.environment.webserver.PhabricatorAppServer; import org.openqa.selenium.net.NetworkUtils; import org.phabricator.sprint.selenium.testing.drivers.Browser; package org.phabricator.sprint.selenium.environment; public class LabsTestEnvironment implements TestEnvironment { private AppServer appServer; public LabsTestEnvironment() { String servingHost = getServingHost();
appServer = servingHost == null ? new PhabricatorAppServer() : new PhabricatorAppServer(servingHost);
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/LabsTestEnvironment.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/PhabricatorAppServer.java // public class PhabricatorAppServer implements AppServer { // // private static final String HOSTNAME_FOR_TEST_ENV_NAME = "HOSTNAME"; // private static final String ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME = "ALTERNATIVE_HOSTNAME"; // private static final String FIXED_HTTP_PORT_ENV_NAME = "TEST_HTTP_PORT"; // private static final String FIXED_HTTPS_PORT_ENV_NAME = "TEST_HTTPS_PORT"; // // private static final int DEFAULT_HTTP_PORT = 80; // private static final int DEFAULT_HTTPS_PORT = 2410; // private static final String DEFAULT_CONTEXT_PATH = "/"; // private static final String JS_SRC_CONTEXT_PATH = "/javascript"; // private static final String CLOSURE_CONTEXT_PATH = "/third_party/closure/goog"; // private static final String THIRD_PARTY_JS_CONTEXT_PATH = "/third_party/js"; // // private static final NetworkUtils networkUtils = new NetworkUtils(); // // private int port; // private int securePort; // private File path; // private File jsSrcRoot; // private final String hostName; // // public PhabricatorAppServer() { // this(detectHostname()); // } // // public static String detectHostname() { // String hostnameFromProperty = System.getenv(HOSTNAME_FOR_TEST_ENV_NAME); // return hostnameFromProperty == null ? "localhost" : hostnameFromProperty; // } // // public PhabricatorAppServer(String hostName) { // this.hostName = "phab08.wmflabs.org"; // this.port = DEFAULT_HTTP_PORT; // } // // private int getHttpPort() { // String port = System.getenv(FIXED_HTTP_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // private int getHttpsPort() { // String port = System.getenv(FIXED_HTTPS_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // public String getHostName() { // return hostName; // } // // public String getAlternateHostName() { // String alternativeHostnameFromProperty = System.getenv(ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME); // return alternativeHostnameFromProperty == null ? // networkUtils.getPrivateLocalAddress() : alternativeHostnameFromProperty; // } // // public String whereIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getHostName() + ":" + port + relativeUrl; // } // // public String whereElseIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getAlternateHostName() + ":" + port + relativeUrl; // } // // public String whereIsSecure(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "https://" + getHostName() + ":" + securePort + relativeUrl; // } // // public String whereIsWithCredentials(String relativeUrl, String user, String pass) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + user + ":" + pass + "@" + getHostName() + ":" + port + relativeUrl; // } // // protected String getMainContextPath(String relativeUrl) { // if (!relativeUrl.startsWith("/")) { // relativeUrl = DEFAULT_CONTEXT_PATH + "/" + relativeUrl; // } // return relativeUrl; // } // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // }
import org.phabricator.sprint.selenium.environment.webserver.AppServer; import org.phabricator.sprint.selenium.environment.webserver.PhabricatorAppServer; import org.openqa.selenium.net.NetworkUtils; import org.phabricator.sprint.selenium.testing.drivers.Browser;
package org.phabricator.sprint.selenium.environment; public class LabsTestEnvironment implements TestEnvironment { private AppServer appServer; public LabsTestEnvironment() { String servingHost = getServingHost(); appServer = servingHost == null ? new PhabricatorAppServer() : new PhabricatorAppServer(servingHost); } public AppServer getAppServer() { return appServer; } public static void main(String[] args) { new LabsTestEnvironment(); } private String getServingHost() {
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/PhabricatorAppServer.java // public class PhabricatorAppServer implements AppServer { // // private static final String HOSTNAME_FOR_TEST_ENV_NAME = "HOSTNAME"; // private static final String ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME = "ALTERNATIVE_HOSTNAME"; // private static final String FIXED_HTTP_PORT_ENV_NAME = "TEST_HTTP_PORT"; // private static final String FIXED_HTTPS_PORT_ENV_NAME = "TEST_HTTPS_PORT"; // // private static final int DEFAULT_HTTP_PORT = 80; // private static final int DEFAULT_HTTPS_PORT = 2410; // private static final String DEFAULT_CONTEXT_PATH = "/"; // private static final String JS_SRC_CONTEXT_PATH = "/javascript"; // private static final String CLOSURE_CONTEXT_PATH = "/third_party/closure/goog"; // private static final String THIRD_PARTY_JS_CONTEXT_PATH = "/third_party/js"; // // private static final NetworkUtils networkUtils = new NetworkUtils(); // // private int port; // private int securePort; // private File path; // private File jsSrcRoot; // private final String hostName; // // public PhabricatorAppServer() { // this(detectHostname()); // } // // public static String detectHostname() { // String hostnameFromProperty = System.getenv(HOSTNAME_FOR_TEST_ENV_NAME); // return hostnameFromProperty == null ? "localhost" : hostnameFromProperty; // } // // public PhabricatorAppServer(String hostName) { // this.hostName = "phab08.wmflabs.org"; // this.port = DEFAULT_HTTP_PORT; // } // // private int getHttpPort() { // String port = System.getenv(FIXED_HTTP_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // private int getHttpsPort() { // String port = System.getenv(FIXED_HTTPS_PORT_ENV_NAME); // return port == null ? findFreePort() : Integer.parseInt(port); // } // // public String getHostName() { // return hostName; // } // // public String getAlternateHostName() { // String alternativeHostnameFromProperty = System.getenv(ALTERNATIVE_HOSTNAME_FOR_TEST_ENV_NAME); // return alternativeHostnameFromProperty == null ? // networkUtils.getPrivateLocalAddress() : alternativeHostnameFromProperty; // } // // public String whereIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getHostName() + ":" + port + relativeUrl; // } // // public String whereElseIs(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + getAlternateHostName() + ":" + port + relativeUrl; // } // // public String whereIsSecure(String relativeUrl) { // relativeUrl = getMainContextPath(relativeUrl); // return "https://" + getHostName() + ":" + securePort + relativeUrl; // } // // public String whereIsWithCredentials(String relativeUrl, String user, String pass) { // relativeUrl = getMainContextPath(relativeUrl); // return "http://" + user + ":" + pass + "@" + getHostName() + ":" + port + relativeUrl; // } // // protected String getMainContextPath(String relativeUrl) { // if (!relativeUrl.startsWith("/")) { // relativeUrl = DEFAULT_CONTEXT_PATH + "/" + relativeUrl; // } // return relativeUrl; // } // // } // // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/testing/drivers/Browser.java // public enum Browser { // // android, // android_real_phone, // chrome, // ff, // htmlunit { // @Override // public boolean isJavascriptEnabled() { // return false; // } // }, // htmlunit_js, // ie, // ipad, // iphone, // none, // For those cases where you don't actually want a browser // opera, // opera_mobile, // phantomjs, // safari; // // private static final Logger log = Logger.getLogger(Browser.class.getName()); // // public static Browser detect() { // String browserName = "htmlunit"; // if (browserName == null) { // log.info("No browser detected, returning null"); // return null; // } // // try { // return Browser.valueOf(browserName); // } catch (IllegalArgumentException e) { // log.severe("Cannot locate matching browser for: " + browserName); // return null; // } // } // // public boolean isJavascriptEnabled() { // return true; // } // // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/LabsTestEnvironment.java import org.phabricator.sprint.selenium.environment.webserver.AppServer; import org.phabricator.sprint.selenium.environment.webserver.PhabricatorAppServer; import org.openqa.selenium.net.NetworkUtils; import org.phabricator.sprint.selenium.testing.drivers.Browser; package org.phabricator.sprint.selenium.environment; public class LabsTestEnvironment implements TestEnvironment { private AppServer appServer; public LabsTestEnvironment() { String servingHost = getServingHost(); appServer = servingHost == null ? new PhabricatorAppServer() : new PhabricatorAppServer(servingHost); } public AppServer getAppServer() { return appServer; } public static void main(String[] args) { new LabsTestEnvironment(); } private String getServingHost() {
Browser browser = Browser.detect();
wikimedia/phabricator-extensions-Sprint
src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/Pages.java
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // }
import org.phabricator.sprint.selenium.environment.webserver.AppServer;
package org.phabricator.sprint.selenium; public class Pages { public String SprintProjectList; public String SprintProjectReport; public String SprintProjectBurn; public String SprintProjectProfile; public String SprintProjectTag; public String SprintProjectBoard; public String SprintProjectBoardMove; public String SprintProjectBoardTaskEdit; public String SprintProjectBoardTaskCreate; public String SprintPhabricatorProjectArchive; public String SprintPhabricatorProjectDetails; public String SprintPhabricatorProjectFeed; public String SprintPhabricatorProjectIcon; public String SprintPhabricatorProjectMembers; public String SprintPhabricatorProjectPicture; public String SprintPhabricatorProjectUpdate;
// Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/environment/webserver/AppServer.java // public interface AppServer { // // String getHostName(); // // String getAlternateHostName(); // // String whereIs(String relativeUrl); // // String whereElseIs(String relativeUrl); // // String whereIsSecure(String relativeUrl); // // String whereIsWithCredentials(String relativeUrl, String user, String password); // // } // Path: src/tests/selenium/phabricator.sprint/src/org/phabricator/sprint/selenium/Pages.java import org.phabricator.sprint.selenium.environment.webserver.AppServer; package org.phabricator.sprint.selenium; public class Pages { public String SprintProjectList; public String SprintProjectReport; public String SprintProjectBurn; public String SprintProjectProfile; public String SprintProjectTag; public String SprintProjectBoard; public String SprintProjectBoardMove; public String SprintProjectBoardTaskEdit; public String SprintProjectBoardTaskCreate; public String SprintPhabricatorProjectArchive; public String SprintPhabricatorProjectDetails; public String SprintPhabricatorProjectFeed; public String SprintPhabricatorProjectIcon; public String SprintPhabricatorProjectMembers; public String SprintPhabricatorProjectPicture; public String SprintPhabricatorProjectUpdate;
public Pages(AppServer appServer) {
Dn9x/dn-modbus
src/com/dn9x/modbus/entity/ControllerEntity.java
// Path: src/com/dn9x/modbus/controller/IController.java // public interface IController { // // /** // * 用于显示测试使用的 // */ // void showTest(); // // /** // * 写入单个数据到寄存器,这里是之写入Digital Output类型的寄存器,只有0和1 // * @param ip // * @param address // * @param value // */ // void setDigitalValue(String ip, int port, int slaveId, int address, int value); // // /** // * 这里写入0-100的数字到寄存器,寄存器的类型是RE // * @param ip // * @param address // * @param value // */ // void setRegisterValue(String ip, int port, int slaveId, int address, int value); // // // /** // * 批量写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(Map<Integer, Integer> data) throws Exception; // // // // /** // * 写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(int address, int value) throws Exception; // // } // // Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // }
import java.util.Map; import net.wimpi.modbus.Modbus; import com.dn9x.modbus.controller.IController; import com.dn9x.modbus.util.SimulationMode;
package com.dn9x.modbus.entity; public class ControllerEntity { private int id;
// Path: src/com/dn9x/modbus/controller/IController.java // public interface IController { // // /** // * 用于显示测试使用的 // */ // void showTest(); // // /** // * 写入单个数据到寄存器,这里是之写入Digital Output类型的寄存器,只有0和1 // * @param ip // * @param address // * @param value // */ // void setDigitalValue(String ip, int port, int slaveId, int address, int value); // // /** // * 这里写入0-100的数字到寄存器,寄存器的类型是RE // * @param ip // * @param address // * @param value // */ // void setRegisterValue(String ip, int port, int slaveId, int address, int value); // // // /** // * 批量写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(Map<Integer, Integer> data) throws Exception; // // // // /** // * 写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(int address, int value) throws Exception; // // } // // Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // } // Path: src/com/dn9x/modbus/entity/ControllerEntity.java import java.util.Map; import net.wimpi.modbus.Modbus; import com.dn9x.modbus.controller.IController; import com.dn9x.modbus.util.SimulationMode; package com.dn9x.modbus.entity; public class ControllerEntity { private int id;
private SimulationMode mode;
Dn9x/dn-modbus
src/com/dn9x/modbus/entity/ControllerEntity.java
// Path: src/com/dn9x/modbus/controller/IController.java // public interface IController { // // /** // * 用于显示测试使用的 // */ // void showTest(); // // /** // * 写入单个数据到寄存器,这里是之写入Digital Output类型的寄存器,只有0和1 // * @param ip // * @param address // * @param value // */ // void setDigitalValue(String ip, int port, int slaveId, int address, int value); // // /** // * 这里写入0-100的数字到寄存器,寄存器的类型是RE // * @param ip // * @param address // * @param value // */ // void setRegisterValue(String ip, int port, int slaveId, int address, int value); // // // /** // * 批量写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(Map<Integer, Integer> data) throws Exception; // // // // /** // * 写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(int address, int value) throws Exception; // // } // // Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // }
import java.util.Map; import net.wimpi.modbus.Modbus; import com.dn9x.modbus.controller.IController; import com.dn9x.modbus.util.SimulationMode;
package com.dn9x.modbus.entity; public class ControllerEntity { private int id; private SimulationMode mode;
// Path: src/com/dn9x/modbus/controller/IController.java // public interface IController { // // /** // * 用于显示测试使用的 // */ // void showTest(); // // /** // * 写入单个数据到寄存器,这里是之写入Digital Output类型的寄存器,只有0和1 // * @param ip // * @param address // * @param value // */ // void setDigitalValue(String ip, int port, int slaveId, int address, int value); // // /** // * 这里写入0-100的数字到寄存器,寄存器的类型是RE // * @param ip // * @param address // * @param value // */ // void setRegisterValue(String ip, int port, int slaveId, int address, int value); // // // /** // * 批量写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(Map<Integer, Integer> data) throws Exception; // // // // /** // * 写入数据到寄存器 // * @param data // * @throws Exception // */ // void setValue(int address, int value) throws Exception; // // } // // Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // } // Path: src/com/dn9x/modbus/entity/ControllerEntity.java import java.util.Map; import net.wimpi.modbus.Modbus; import com.dn9x.modbus.controller.IController; import com.dn9x.modbus.util.SimulationMode; package com.dn9x.modbus.entity; public class ControllerEntity { private int id; private SimulationMode mode;
private IController controller;
Dn9x/dn-modbus
src/com/dn9x/modbus/util/ModbusUtil.java
// Path: src/com/dn9x/modbus/procimg/UnityRegister.java // public class UnityRegister implements Register { // // protected byte[] m_Register = new byte[2]; // // public UnityRegister() { // m_Register = null; // } // // // public UnityRegister(byte b1, byte b2) { // m_Register[0] = b1; // m_Register[1] = b2; // } // // public UnityRegister(int value) { // setValue(value); // } // // @Override // public int getValue() { // return ((m_Register[0] & 0xff) << 8 | (m_Register[1] & 0xff)); // } // // @Override // public int toUnsignedShort() { // return ((m_Register[0] & 0xff) << 8 | (m_Register[1] & 0xff)); // } // // @Override // public short toShort() { // return (short) ((m_Register[0] << 8) | (m_Register[1] & 0xff)); // } // // @Override // public byte[] toBytes() { // return m_Register; // } // // @Override // public void setValue(int v) { // setValue((short) v); // } // // @Override // public void setValue(short s) { // if (m_Register == null) { // m_Register = new byte[2]; // } // m_Register[0] = (byte) (0xff & (s >> 8)); // m_Register[1] = (byte) (0xff & s); // // onChanged(); // } // // @Override // public void setValue(byte[] bytes) { // if (bytes.length < 2) { // throw new IllegalArgumentException(); // } else { // m_Register[0] = bytes[0]; // m_Register[1] = bytes[1]; // } // // onChanged(); // } // // // public void onChanged(){ // System.out.println(">>>>>>>>>>>>UnityRegister:这里set了值:" + m_Register); // } // // }
import java.net.InetAddress; import net.wimpi.modbus.Modbus; import net.wimpi.modbus.ModbusException; import net.wimpi.modbus.ModbusIOException; import net.wimpi.modbus.ModbusSlaveException; import net.wimpi.modbus.io.ModbusTCPTransaction; import net.wimpi.modbus.msg.ReadCoilsRequest; import net.wimpi.modbus.msg.ReadCoilsResponse; import net.wimpi.modbus.msg.ReadInputDiscretesRequest; import net.wimpi.modbus.msg.ReadInputDiscretesResponse; import net.wimpi.modbus.msg.ReadInputRegistersRequest; import net.wimpi.modbus.msg.ReadInputRegistersResponse; import net.wimpi.modbus.msg.ReadMultipleRegistersRequest; import net.wimpi.modbus.msg.ReadMultipleRegistersResponse; import net.wimpi.modbus.msg.WriteCoilRequest; import net.wimpi.modbus.msg.WriteSingleRegisterRequest; import net.wimpi.modbus.net.TCPMasterConnection; import com.dn9x.modbus.procimg.UnityRegister;
con.close(); } catch (Exception e) { e.printStackTrace(); } return data; } /** * 写入数据到真机,数据类型是RE * * @param ip * @param port * @param slaveId * @param address * @param value */ public static void writeRegister(String ip, int port, int slaveId, int address, int value) { try { InetAddress addr = InetAddress.getByName(ip); TCPMasterConnection connection = new TCPMasterConnection(addr); connection.setPort(port); connection.connect(); ModbusTCPTransaction trans = new ModbusTCPTransaction(connection);
// Path: src/com/dn9x/modbus/procimg/UnityRegister.java // public class UnityRegister implements Register { // // protected byte[] m_Register = new byte[2]; // // public UnityRegister() { // m_Register = null; // } // // // public UnityRegister(byte b1, byte b2) { // m_Register[0] = b1; // m_Register[1] = b2; // } // // public UnityRegister(int value) { // setValue(value); // } // // @Override // public int getValue() { // return ((m_Register[0] & 0xff) << 8 | (m_Register[1] & 0xff)); // } // // @Override // public int toUnsignedShort() { // return ((m_Register[0] & 0xff) << 8 | (m_Register[1] & 0xff)); // } // // @Override // public short toShort() { // return (short) ((m_Register[0] << 8) | (m_Register[1] & 0xff)); // } // // @Override // public byte[] toBytes() { // return m_Register; // } // // @Override // public void setValue(int v) { // setValue((short) v); // } // // @Override // public void setValue(short s) { // if (m_Register == null) { // m_Register = new byte[2]; // } // m_Register[0] = (byte) (0xff & (s >> 8)); // m_Register[1] = (byte) (0xff & s); // // onChanged(); // } // // @Override // public void setValue(byte[] bytes) { // if (bytes.length < 2) { // throw new IllegalArgumentException(); // } else { // m_Register[0] = bytes[0]; // m_Register[1] = bytes[1]; // } // // onChanged(); // } // // // public void onChanged(){ // System.out.println(">>>>>>>>>>>>UnityRegister:这里set了值:" + m_Register); // } // // } // Path: src/com/dn9x/modbus/util/ModbusUtil.java import java.net.InetAddress; import net.wimpi.modbus.Modbus; import net.wimpi.modbus.ModbusException; import net.wimpi.modbus.ModbusIOException; import net.wimpi.modbus.ModbusSlaveException; import net.wimpi.modbus.io.ModbusTCPTransaction; import net.wimpi.modbus.msg.ReadCoilsRequest; import net.wimpi.modbus.msg.ReadCoilsResponse; import net.wimpi.modbus.msg.ReadInputDiscretesRequest; import net.wimpi.modbus.msg.ReadInputDiscretesResponse; import net.wimpi.modbus.msg.ReadInputRegistersRequest; import net.wimpi.modbus.msg.ReadInputRegistersResponse; import net.wimpi.modbus.msg.ReadMultipleRegistersRequest; import net.wimpi.modbus.msg.ReadMultipleRegistersResponse; import net.wimpi.modbus.msg.WriteCoilRequest; import net.wimpi.modbus.msg.WriteSingleRegisterRequest; import net.wimpi.modbus.net.TCPMasterConnection; import com.dn9x.modbus.procimg.UnityRegister; con.close(); } catch (Exception e) { e.printStackTrace(); } return data; } /** * 写入数据到真机,数据类型是RE * * @param ip * @param port * @param slaveId * @param address * @param value */ public static void writeRegister(String ip, int port, int slaveId, int address, int value) { try { InetAddress addr = InetAddress.getByName(ip); TCPMasterConnection connection = new TCPMasterConnection(addr); connection.setPort(port); connection.connect(); ModbusTCPTransaction trans = new ModbusTCPTransaction(connection);
UnityRegister register = new UnityRegister(value);
Dn9x/dn-modbus
src/com/dn9x/modbus/UnityBridge.java
// Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // }
import java.util.Map; import com.dn9x.modbus.util.SimulationMode;
package com.dn9x.modbus; public interface UnityBridge { /** * 根据controllerId查询这个控制器下面的所有的寄存器状态, * @param countrollerId * @return */ Map<Integer, Integer> getAllRegisterState(int controllerId); /** * 根据控制器id设置控制器下的所有的寄存器信息 * @param countrollerId * @param data */ void setAllRegisterState(int controllerId, Map<Integer, Integer> data); /** * 查询所有寄存器的数目 * @param controllerId * @return */ int getTotalRegisters(int controllerId); /** * 根据控制器和寄存器的id查询寄存器的状态 * @param controllerId * @param registerAddress * @return */ int getRegisterState(int controllerId, int registerAddress); /** * 设置控制器和寄存器的值 * @param controllerId * @param registerAddress * @param value */ void setRegisterState(int controllerId, int registerAddress, int value); /** * 这里查询寄存器是否是读写的,这里的意思是寄存器原本的类型是否是读写的,比如inputRegister就不能写入, * @param controllerId * @param registerAddress * @return */ boolean isRegisterWritable(int controllerId, int registerAddress); /** * 这里查询寄存器是否是读写的,这里的意思是寄存器原本的类型是否是读写的,比如inputRegister就不能写入, * @param controllerId * @param registerAddress * @return */ boolean isRegisterReadOnly(int controllerId, int registerAddress); /** * 查询所有的控制器数目 * @return */ int getTotalControllers(); /** * 设置所有控制器的状态,如果传递的值是SimulationMode.SimulateOnly,那么就重置所有的controller的所有寄存器为默认值,默认值从配置文件读取 * 如果设置的值是SimulationMode.SimulateAndForwarding那么就读取所有的真机设备的寄存器的值,覆盖到本地。 然后调用sendControllerRegisterStateChangedNotification方法进行通知 * @param mode */
// Path: src/com/dn9x/modbus/util/SimulationMode.java // public enum SimulationMode { // SimulateOnly, // SimulateAndForwarding // } // Path: src/com/dn9x/modbus/UnityBridge.java import java.util.Map; import com.dn9x.modbus.util.SimulationMode; package com.dn9x.modbus; public interface UnityBridge { /** * 根据controllerId查询这个控制器下面的所有的寄存器状态, * @param countrollerId * @return */ Map<Integer, Integer> getAllRegisterState(int controllerId); /** * 根据控制器id设置控制器下的所有的寄存器信息 * @param countrollerId * @param data */ void setAllRegisterState(int controllerId, Map<Integer, Integer> data); /** * 查询所有寄存器的数目 * @param controllerId * @return */ int getTotalRegisters(int controllerId); /** * 根据控制器和寄存器的id查询寄存器的状态 * @param controllerId * @param registerAddress * @return */ int getRegisterState(int controllerId, int registerAddress); /** * 设置控制器和寄存器的值 * @param controllerId * @param registerAddress * @param value */ void setRegisterState(int controllerId, int registerAddress, int value); /** * 这里查询寄存器是否是读写的,这里的意思是寄存器原本的类型是否是读写的,比如inputRegister就不能写入, * @param controllerId * @param registerAddress * @return */ boolean isRegisterWritable(int controllerId, int registerAddress); /** * 这里查询寄存器是否是读写的,这里的意思是寄存器原本的类型是否是读写的,比如inputRegister就不能写入, * @param controllerId * @param registerAddress * @return */ boolean isRegisterReadOnly(int controllerId, int registerAddress); /** * 查询所有的控制器数目 * @return */ int getTotalControllers(); /** * 设置所有控制器的状态,如果传递的值是SimulationMode.SimulateOnly,那么就重置所有的controller的所有寄存器为默认值,默认值从配置文件读取 * 如果设置的值是SimulationMode.SimulateAndForwarding那么就读取所有的真机设备的寄存器的值,覆盖到本地。 然后调用sendControllerRegisterStateChangedNotification方法进行通知 * @param mode */
void setSimulationMode(SimulationMode mode);
NPException/Dimensional-Pockets
java/net/gtn/dimensionalpocket/common/core/BiomeHelper.java
// Path: java/net/gtn/dimensionalpocket/common/lib/Reference.java // public class Reference { // // public static final String MOD_ID = "dimensionalPockets"; // public static final String MOD_NAME = "Dimensional Pockets"; // public static final String VERSION = "1.0.5"; // // public static final String MOD_IDENTIFIER = MOD_ID + ":"; // // public static final String CLIENT_PROXY_CLASS = "net.gtn.dimensionalpocket.client.ClientProxy"; // public static final String SERVER_PROXY_CLASS = "net.gtn.dimensionalpocket.common.CommonProxy"; // // public static final String MOD_DOWNLOAD_URL = "http://minecraft.curseforge.com/mc-mods/226990-dimensional-pockets"; // public static final String MOD_CHANGELOG_URL = "https://github.com/NPException/Dimensional-Pockets/wiki/Changelog"; // public static final String MOD_WIKI_URL = "https://github.com/NPException/Dimensional-Pockets/wiki"; // public static final String REMOTE_VERSION_FILE = "https://raw.githubusercontent.com/NPException/Dimensional-Pockets/master/latest_versions.json"; // // /* // * DEBUGGING CONFIGS // */ // @ConfigBoolean(category = "Debugging", comment = { "If set to \"true\" a RuntimeException will be thrown if there ever", // "is a client-only method called by the server or vice versa." }) // public static boolean ENFORCE_SIDED_METHODS = false; // // @ConfigBoolean(category = "Debugging", comment = "Set this to \"true\" if you desperately want to try to break your world :P") // public static boolean CAN_BREAK_POCKET_WALL_IN_CREATIVE = false; // // /* // * CLIENT PERFORMANCE CONFIGS // */ // @ConfigInteger(category = "Graphics", minValue = 1, maxValue = 50, comment = { "If you experience low FPS, try reducing this number first", // "before switching fancy rendering off entirely.", // "Or if you have render power to spare you could raise this value.", // "(This setting only affects the client. This setting will have no effect if you use the particle field shader)" }) // public static int NUMBER_OF_PARTICLE_PLANES = 15; // // @ConfigInteger(category = "Graphics", minValue = 0, maxValue = 2, // comment = { "0 = Particle field appearance based on Minecraft's Graphics settings (fancy or fast)", // "1 = Particle field appearance forced to non-fancy version", // "2 = Particle field appearance forced to fancy version", // "(This setting only affects the client)" }) // public static int FORCE_FANCY_RENDERING = 0; // // public static boolean useFancyField() { // return FORCE_FANCY_RENDERING != 1; // } // // public static int numberOfParticlePlanes() { // return FORCE_FANCY_RENDERING == 0 // && NUMBER_OF_PARTICLE_PLANES > 3 // && !Minecraft.getMinecraft().gameSettings.fancyGraphics // ? 3 // : NUMBER_OF_PARTICLE_PLANES; // } // // @ConfigBoolean(category = "Graphics", comment = "If set to true, a shader will be used for the particle field rendering instead of the old method.") // public static boolean USE_SHADER_FOR_PARTICLE_FIELD = false; // // /* // * GAMEPLAY CONFIGS // */ // @ConfigInteger(category = "Gameplay") // public static int DIMENSION_ID = 33; // // @ConfigInteger(category = "Gameplay") // public static int BIOME_ID = 99; // // @ConfigFloat(category = "Gameplay", minValue = 0.0F, maxValue = 6000000.0F, comment = "You can change this to modify the resistance of the DP to explosions.") // public static float DIMENSIONAL_POCKET_RESISTANCE = 15F; // // @ConfigBoolean(category = "Gameplay", comment = "Decides whether or not any player spawns with a book upon new spawn.") // public static boolean SHOULD_SPAWN_WITH_BOOK = true; // // @ConfigInteger(category = "Gameplay", minValue = 0, // comment = { "This is the number of Dimensional Pockets you can craft with a pair of crystals before they break.", // "If set to 0, crystals will never break." }) // public static int CRAFTINGS_PER_CRYSTAL = 4; // // @ConfigBoolean(category = "Gameplay", comment = "Decides if the Nether Crystal and End Crystal can be crafted without hostile mob drops.\n" // + "The Nether Crystal will use gold nuggets instead of Ghast tears, and the End Crystal will use Quartz instead of Ender Eyes") // public static boolean USE_PEACEFUL_RECIPES = false; // // /* // * GENERAL CONFIGS // */ // @ConfigBoolean(category = "General") // public static boolean KEEP_POCKET_ROOMS_CHUNK_LOADED = true; // // @ConfigBoolean(category = "General", comment = "If you do not want the mod to check for more recent versions, set this to \"false\".") // public static boolean DO_VERSION_CHECK = true; // // @ConfigBoolean(category = "General", comment = "If you have a hard time distinguishing colours, you can change this to true.\n" // + "Gameplay relevant parts of the mod will be displayed in a less color dependent way then.") // public static boolean COLOR_BLIND_MODE = false; // // /* // * ANALYTICS // */ // @ConfigBoolean(category = "Analytics", // comment = { "If this is set to true AND you have snooper enabled in Minecraft, the mod will collect anonymous usage data.", // "For example how much RF and Fluids pass through Pockets and how many players get trapped." }) // public static boolean MAY_COLLECT_ANONYMOUS_USAGE_DATA = true; // }
import java.util.List; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.gtn.dimensionalpocket.common.lib.Reference; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import com.google.common.collect.Lists;
package net.gtn.dimensionalpocket.common.core; public class BiomeHelper { private static BiomeGenBase pocketBiome; private static boolean init = false; public static void init() { if (init) { DPLogger.severe("Tried calling BiomeHelper.init() again!"); return; } init = true;
// Path: java/net/gtn/dimensionalpocket/common/lib/Reference.java // public class Reference { // // public static final String MOD_ID = "dimensionalPockets"; // public static final String MOD_NAME = "Dimensional Pockets"; // public static final String VERSION = "1.0.5"; // // public static final String MOD_IDENTIFIER = MOD_ID + ":"; // // public static final String CLIENT_PROXY_CLASS = "net.gtn.dimensionalpocket.client.ClientProxy"; // public static final String SERVER_PROXY_CLASS = "net.gtn.dimensionalpocket.common.CommonProxy"; // // public static final String MOD_DOWNLOAD_URL = "http://minecraft.curseforge.com/mc-mods/226990-dimensional-pockets"; // public static final String MOD_CHANGELOG_URL = "https://github.com/NPException/Dimensional-Pockets/wiki/Changelog"; // public static final String MOD_WIKI_URL = "https://github.com/NPException/Dimensional-Pockets/wiki"; // public static final String REMOTE_VERSION_FILE = "https://raw.githubusercontent.com/NPException/Dimensional-Pockets/master/latest_versions.json"; // // /* // * DEBUGGING CONFIGS // */ // @ConfigBoolean(category = "Debugging", comment = { "If set to \"true\" a RuntimeException will be thrown if there ever", // "is a client-only method called by the server or vice versa." }) // public static boolean ENFORCE_SIDED_METHODS = false; // // @ConfigBoolean(category = "Debugging", comment = "Set this to \"true\" if you desperately want to try to break your world :P") // public static boolean CAN_BREAK_POCKET_WALL_IN_CREATIVE = false; // // /* // * CLIENT PERFORMANCE CONFIGS // */ // @ConfigInteger(category = "Graphics", minValue = 1, maxValue = 50, comment = { "If you experience low FPS, try reducing this number first", // "before switching fancy rendering off entirely.", // "Or if you have render power to spare you could raise this value.", // "(This setting only affects the client. This setting will have no effect if you use the particle field shader)" }) // public static int NUMBER_OF_PARTICLE_PLANES = 15; // // @ConfigInteger(category = "Graphics", minValue = 0, maxValue = 2, // comment = { "0 = Particle field appearance based on Minecraft's Graphics settings (fancy or fast)", // "1 = Particle field appearance forced to non-fancy version", // "2 = Particle field appearance forced to fancy version", // "(This setting only affects the client)" }) // public static int FORCE_FANCY_RENDERING = 0; // // public static boolean useFancyField() { // return FORCE_FANCY_RENDERING != 1; // } // // public static int numberOfParticlePlanes() { // return FORCE_FANCY_RENDERING == 0 // && NUMBER_OF_PARTICLE_PLANES > 3 // && !Minecraft.getMinecraft().gameSettings.fancyGraphics // ? 3 // : NUMBER_OF_PARTICLE_PLANES; // } // // @ConfigBoolean(category = "Graphics", comment = "If set to true, a shader will be used for the particle field rendering instead of the old method.") // public static boolean USE_SHADER_FOR_PARTICLE_FIELD = false; // // /* // * GAMEPLAY CONFIGS // */ // @ConfigInteger(category = "Gameplay") // public static int DIMENSION_ID = 33; // // @ConfigInteger(category = "Gameplay") // public static int BIOME_ID = 99; // // @ConfigFloat(category = "Gameplay", minValue = 0.0F, maxValue = 6000000.0F, comment = "You can change this to modify the resistance of the DP to explosions.") // public static float DIMENSIONAL_POCKET_RESISTANCE = 15F; // // @ConfigBoolean(category = "Gameplay", comment = "Decides whether or not any player spawns with a book upon new spawn.") // public static boolean SHOULD_SPAWN_WITH_BOOK = true; // // @ConfigInteger(category = "Gameplay", minValue = 0, // comment = { "This is the number of Dimensional Pockets you can craft with a pair of crystals before they break.", // "If set to 0, crystals will never break." }) // public static int CRAFTINGS_PER_CRYSTAL = 4; // // @ConfigBoolean(category = "Gameplay", comment = "Decides if the Nether Crystal and End Crystal can be crafted without hostile mob drops.\n" // + "The Nether Crystal will use gold nuggets instead of Ghast tears, and the End Crystal will use Quartz instead of Ender Eyes") // public static boolean USE_PEACEFUL_RECIPES = false; // // /* // * GENERAL CONFIGS // */ // @ConfigBoolean(category = "General") // public static boolean KEEP_POCKET_ROOMS_CHUNK_LOADED = true; // // @ConfigBoolean(category = "General", comment = "If you do not want the mod to check for more recent versions, set this to \"false\".") // public static boolean DO_VERSION_CHECK = true; // // @ConfigBoolean(category = "General", comment = "If you have a hard time distinguishing colours, you can change this to true.\n" // + "Gameplay relevant parts of the mod will be displayed in a less color dependent way then.") // public static boolean COLOR_BLIND_MODE = false; // // /* // * ANALYTICS // */ // @ConfigBoolean(category = "Analytics", // comment = { "If this is set to true AND you have snooper enabled in Minecraft, the mod will collect anonymous usage data.", // "For example how much RF and Fluids pass through Pockets and how many players get trapped." }) // public static boolean MAY_COLLECT_ANONYMOUS_USAGE_DATA = true; // } // Path: java/net/gtn/dimensionalpocket/common/core/BiomeHelper.java import java.util.List; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.gtn.dimensionalpocket.common.lib.Reference; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import com.google.common.collect.Lists; package net.gtn.dimensionalpocket.common.core; public class BiomeHelper { private static BiomeGenBase pocketBiome; private static boolean init = false; public static void init() { if (init) { DPLogger.severe("Tried calling BiomeHelper.init() again!"); return; } init = true;
pocketBiome = new BiomeGenBase(Reference.BIOME_ID) {
NPException/Dimensional-Pockets
java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // }
import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract {
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // } // Path: java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract {
private GuiWidget<GuiArrow> rightArrow, leftArrow;
NPException/Dimensional-Pockets
java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // }
import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract { private GuiWidget<GuiArrow> rightArrow, leftArrow;
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // } // Path: java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract { private GuiWidget<GuiArrow> rightArrow, leftArrow;
private GuiItemStack itemStackArray[] = new GuiItemStack[10];
NPException/Dimensional-Pockets
java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // }
import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract { private GuiWidget<GuiArrow> rightArrow, leftArrow; private GuiItemStack itemStackArray[] = new GuiItemStack[10]; private int currentPage; private int MAX_PAGE; private int CRAFTING_RECIPE_POCKET; private int CRAFTING_RECIPE_END_CRYSTAL; private int CRAFTING_RECIPE_NETHER_CRYSTAL; public GuiInfoBook(EntityPlayer player) { super(player);
// Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiArrow.java // @SideOnly(Side.CLIENT) // public class GuiArrow extends GuiTexturedButton<GuiArrow> { // // public GuiArrow(int x, int y) { // super(x, y, 0, 180, 18, 10); // } // // @Override // public int getTextureXShift(int pass) { // return 23 * pass; // } // } // // Path: java/net/gtn/dimensionalpocket/client/gui/components/GuiItemStack.java // public class GuiItemStack extends GuiWidget<GuiItemStack> { // // private ItemStack itemStack = new ItemStack(Blocks.stone); // // public GuiItemStack(ItemStack itemStack, int x, int y) { // super(x, y, 19, 19); // this.itemStack = itemStack; // } // // public void setItemStack(ItemStack itemStack) { // this.itemStack = itemStack; // } // // public ItemStack getItemStack() { // return itemStack; // } // // @Override // public boolean shouldPlaySoundOnClick() { // return false; // } // // @Override // public void renderBackground(int mouseX, int mouseY) { // RenderUtils.renderItemStackInGUI(itemStack, fontRendererObj, itemRender, x + 2, y + 2, 100.0F); // } // // @Override // public void renderForeground(int mouseX, int mouseY) { // if (canClick(mouseX, mouseY)) { // renderToolTip(itemStack, mouseX, mouseY); // } // } // } // // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java // @SideOnly(Side.CLIENT) // public class GuiSheet { // // private static final String GUI_SHEET_LOCATION = "textures/gui/"; // // public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); // // private static ResourceLocation getResource(String loc) { // return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png"); // } // // } // Path: java/net/gtn/dimensionalpocket/client/gui/GuiInfoBook.java import static org.lwjgl.opengl.GL11.*; import net.gtn.dimensionalpocket.oc.client.gui.GuiContainerAbstract; import net.gtn.dimensionalpocket.oc.client.gui.components.GuiWidget; import net.gtn.dimensionalpocket.oc.client.lib.Colour; import net.gtn.dimensionalpocket.client.ClientProxy; import net.gtn.dimensionalpocket.client.gui.components.GuiArrow; import net.gtn.dimensionalpocket.client.gui.components.GuiItemStack; import net.gtn.dimensionalpocket.client.utils.GuiSheet; import net.gtn.dimensionalpocket.client.utils.RecipeHelper; import net.gtn.dimensionalpocket.common.core.utils.DPLogger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.gtn.dimensionalpocket.client.gui; @SideOnly(Side.CLIENT) public class GuiInfoBook extends GuiContainerAbstract { private GuiWidget<GuiArrow> rightArrow, leftArrow; private GuiItemStack itemStackArray[] = new GuiItemStack[10]; private int currentPage; private int MAX_PAGE; private int CRAFTING_RECIPE_POCKET; private int CRAFTING_RECIPE_END_CRYSTAL; private int CRAFTING_RECIPE_NETHER_CRYSTAL; public GuiInfoBook(EntityPlayer player) { super(player);
setMainTexture(GuiSheet.GUI_INFO_BOOK);
NPException/Dimensional-Pockets
java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java
// Path: java/net/gtn/dimensionalpocket/common/lib/Reference.java // public class Reference { // // public static final String MOD_ID = "dimensionalPockets"; // public static final String MOD_NAME = "Dimensional Pockets"; // public static final String VERSION = "1.0.5"; // // public static final String MOD_IDENTIFIER = MOD_ID + ":"; // // public static final String CLIENT_PROXY_CLASS = "net.gtn.dimensionalpocket.client.ClientProxy"; // public static final String SERVER_PROXY_CLASS = "net.gtn.dimensionalpocket.common.CommonProxy"; // // public static final String MOD_DOWNLOAD_URL = "http://minecraft.curseforge.com/mc-mods/226990-dimensional-pockets"; // public static final String MOD_CHANGELOG_URL = "https://github.com/NPException/Dimensional-Pockets/wiki/Changelog"; // public static final String MOD_WIKI_URL = "https://github.com/NPException/Dimensional-Pockets/wiki"; // public static final String REMOTE_VERSION_FILE = "https://raw.githubusercontent.com/NPException/Dimensional-Pockets/master/latest_versions.json"; // // /* // * DEBUGGING CONFIGS // */ // @ConfigBoolean(category = "Debugging", comment = { "If set to \"true\" a RuntimeException will be thrown if there ever", // "is a client-only method called by the server or vice versa." }) // public static boolean ENFORCE_SIDED_METHODS = false; // // @ConfigBoolean(category = "Debugging", comment = "Set this to \"true\" if you desperately want to try to break your world :P") // public static boolean CAN_BREAK_POCKET_WALL_IN_CREATIVE = false; // // /* // * CLIENT PERFORMANCE CONFIGS // */ // @ConfigInteger(category = "Graphics", minValue = 1, maxValue = 50, comment = { "If you experience low FPS, try reducing this number first", // "before switching fancy rendering off entirely.", // "Or if you have render power to spare you could raise this value.", // "(This setting only affects the client. This setting will have no effect if you use the particle field shader)" }) // public static int NUMBER_OF_PARTICLE_PLANES = 15; // // @ConfigInteger(category = "Graphics", minValue = 0, maxValue = 2, // comment = { "0 = Particle field appearance based on Minecraft's Graphics settings (fancy or fast)", // "1 = Particle field appearance forced to non-fancy version", // "2 = Particle field appearance forced to fancy version", // "(This setting only affects the client)" }) // public static int FORCE_FANCY_RENDERING = 0; // // public static boolean useFancyField() { // return FORCE_FANCY_RENDERING != 1; // } // // public static int numberOfParticlePlanes() { // return FORCE_FANCY_RENDERING == 0 // && NUMBER_OF_PARTICLE_PLANES > 3 // && !Minecraft.getMinecraft().gameSettings.fancyGraphics // ? 3 // : NUMBER_OF_PARTICLE_PLANES; // } // // @ConfigBoolean(category = "Graphics", comment = "If set to true, a shader will be used for the particle field rendering instead of the old method.") // public static boolean USE_SHADER_FOR_PARTICLE_FIELD = false; // // /* // * GAMEPLAY CONFIGS // */ // @ConfigInteger(category = "Gameplay") // public static int DIMENSION_ID = 33; // // @ConfigInteger(category = "Gameplay") // public static int BIOME_ID = 99; // // @ConfigFloat(category = "Gameplay", minValue = 0.0F, maxValue = 6000000.0F, comment = "You can change this to modify the resistance of the DP to explosions.") // public static float DIMENSIONAL_POCKET_RESISTANCE = 15F; // // @ConfigBoolean(category = "Gameplay", comment = "Decides whether or not any player spawns with a book upon new spawn.") // public static boolean SHOULD_SPAWN_WITH_BOOK = true; // // @ConfigInteger(category = "Gameplay", minValue = 0, // comment = { "This is the number of Dimensional Pockets you can craft with a pair of crystals before they break.", // "If set to 0, crystals will never break." }) // public static int CRAFTINGS_PER_CRYSTAL = 4; // // @ConfigBoolean(category = "Gameplay", comment = "Decides if the Nether Crystal and End Crystal can be crafted without hostile mob drops.\n" // + "The Nether Crystal will use gold nuggets instead of Ghast tears, and the End Crystal will use Quartz instead of Ender Eyes") // public static boolean USE_PEACEFUL_RECIPES = false; // // /* // * GENERAL CONFIGS // */ // @ConfigBoolean(category = "General") // public static boolean KEEP_POCKET_ROOMS_CHUNK_LOADED = true; // // @ConfigBoolean(category = "General", comment = "If you do not want the mod to check for more recent versions, set this to \"false\".") // public static boolean DO_VERSION_CHECK = true; // // @ConfigBoolean(category = "General", comment = "If you have a hard time distinguishing colours, you can change this to true.\n" // + "Gameplay relevant parts of the mod will be displayed in a less color dependent way then.") // public static boolean COLOR_BLIND_MODE = false; // // /* // * ANALYTICS // */ // @ConfigBoolean(category = "Analytics", // comment = { "If this is set to true AND you have snooper enabled in Minecraft, the mod will collect anonymous usage data.", // "For example how much RF and Fluids pass through Pockets and how many players get trapped." }) // public static boolean MAY_COLLECT_ANONYMOUS_USAGE_DATA = true; // }
import net.gtn.dimensionalpocket.common.lib.Reference; import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.gtn.dimensionalpocket.client.utils; @SideOnly(Side.CLIENT) public class GuiSheet { private static final String GUI_SHEET_LOCATION = "textures/gui/"; public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); private static ResourceLocation getResource(String loc) {
// Path: java/net/gtn/dimensionalpocket/common/lib/Reference.java // public class Reference { // // public static final String MOD_ID = "dimensionalPockets"; // public static final String MOD_NAME = "Dimensional Pockets"; // public static final String VERSION = "1.0.5"; // // public static final String MOD_IDENTIFIER = MOD_ID + ":"; // // public static final String CLIENT_PROXY_CLASS = "net.gtn.dimensionalpocket.client.ClientProxy"; // public static final String SERVER_PROXY_CLASS = "net.gtn.dimensionalpocket.common.CommonProxy"; // // public static final String MOD_DOWNLOAD_URL = "http://minecraft.curseforge.com/mc-mods/226990-dimensional-pockets"; // public static final String MOD_CHANGELOG_URL = "https://github.com/NPException/Dimensional-Pockets/wiki/Changelog"; // public static final String MOD_WIKI_URL = "https://github.com/NPException/Dimensional-Pockets/wiki"; // public static final String REMOTE_VERSION_FILE = "https://raw.githubusercontent.com/NPException/Dimensional-Pockets/master/latest_versions.json"; // // /* // * DEBUGGING CONFIGS // */ // @ConfigBoolean(category = "Debugging", comment = { "If set to \"true\" a RuntimeException will be thrown if there ever", // "is a client-only method called by the server or vice versa." }) // public static boolean ENFORCE_SIDED_METHODS = false; // // @ConfigBoolean(category = "Debugging", comment = "Set this to \"true\" if you desperately want to try to break your world :P") // public static boolean CAN_BREAK_POCKET_WALL_IN_CREATIVE = false; // // /* // * CLIENT PERFORMANCE CONFIGS // */ // @ConfigInteger(category = "Graphics", minValue = 1, maxValue = 50, comment = { "If you experience low FPS, try reducing this number first", // "before switching fancy rendering off entirely.", // "Or if you have render power to spare you could raise this value.", // "(This setting only affects the client. This setting will have no effect if you use the particle field shader)" }) // public static int NUMBER_OF_PARTICLE_PLANES = 15; // // @ConfigInteger(category = "Graphics", minValue = 0, maxValue = 2, // comment = { "0 = Particle field appearance based on Minecraft's Graphics settings (fancy or fast)", // "1 = Particle field appearance forced to non-fancy version", // "2 = Particle field appearance forced to fancy version", // "(This setting only affects the client)" }) // public static int FORCE_FANCY_RENDERING = 0; // // public static boolean useFancyField() { // return FORCE_FANCY_RENDERING != 1; // } // // public static int numberOfParticlePlanes() { // return FORCE_FANCY_RENDERING == 0 // && NUMBER_OF_PARTICLE_PLANES > 3 // && !Minecraft.getMinecraft().gameSettings.fancyGraphics // ? 3 // : NUMBER_OF_PARTICLE_PLANES; // } // // @ConfigBoolean(category = "Graphics", comment = "If set to true, a shader will be used for the particle field rendering instead of the old method.") // public static boolean USE_SHADER_FOR_PARTICLE_FIELD = false; // // /* // * GAMEPLAY CONFIGS // */ // @ConfigInteger(category = "Gameplay") // public static int DIMENSION_ID = 33; // // @ConfigInteger(category = "Gameplay") // public static int BIOME_ID = 99; // // @ConfigFloat(category = "Gameplay", minValue = 0.0F, maxValue = 6000000.0F, comment = "You can change this to modify the resistance of the DP to explosions.") // public static float DIMENSIONAL_POCKET_RESISTANCE = 15F; // // @ConfigBoolean(category = "Gameplay", comment = "Decides whether or not any player spawns with a book upon new spawn.") // public static boolean SHOULD_SPAWN_WITH_BOOK = true; // // @ConfigInteger(category = "Gameplay", minValue = 0, // comment = { "This is the number of Dimensional Pockets you can craft with a pair of crystals before they break.", // "If set to 0, crystals will never break." }) // public static int CRAFTINGS_PER_CRYSTAL = 4; // // @ConfigBoolean(category = "Gameplay", comment = "Decides if the Nether Crystal and End Crystal can be crafted without hostile mob drops.\n" // + "The Nether Crystal will use gold nuggets instead of Ghast tears, and the End Crystal will use Quartz instead of Ender Eyes") // public static boolean USE_PEACEFUL_RECIPES = false; // // /* // * GENERAL CONFIGS // */ // @ConfigBoolean(category = "General") // public static boolean KEEP_POCKET_ROOMS_CHUNK_LOADED = true; // // @ConfigBoolean(category = "General", comment = "If you do not want the mod to check for more recent versions, set this to \"false\".") // public static boolean DO_VERSION_CHECK = true; // // @ConfigBoolean(category = "General", comment = "If you have a hard time distinguishing colours, you can change this to true.\n" // + "Gameplay relevant parts of the mod will be displayed in a less color dependent way then.") // public static boolean COLOR_BLIND_MODE = false; // // /* // * ANALYTICS // */ // @ConfigBoolean(category = "Analytics", // comment = { "If this is set to true AND you have snooper enabled in Minecraft, the mod will collect anonymous usage data.", // "For example how much RF and Fluids pass through Pockets and how many players get trapped." }) // public static boolean MAY_COLLECT_ANONYMOUS_USAGE_DATA = true; // } // Path: java/net/gtn/dimensionalpocket/client/utils/GuiSheet.java import net.gtn.dimensionalpocket.common.lib.Reference; import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.gtn.dimensionalpocket.client.utils; @SideOnly(Side.CLIENT) public class GuiSheet { private static final String GUI_SHEET_LOCATION = "textures/gui/"; public static final ResourceLocation GUI_INFO_BOOK = getResource("guideDP"); private static ResourceLocation getResource(String loc) {
return new ResourceLocation(Reference.MOD_ID.toLowerCase(), GUI_SHEET_LOCATION + loc + ".png");
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/NoteFrequencyCalculator.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // }
import com.github.cythara.Note; import java.util.Arrays; import java.util.List;
package com.github.cythara.tuning; public class NoteFrequencyCalculator { private static List<String> notes = Arrays.asList("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"); private float referenceFrequency; public NoteFrequencyCalculator(float referenceFrequency) { this.referenceFrequency = referenceFrequency; }
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // Path: app/src/main/java/com/github/cythara/tuning/NoteFrequencyCalculator.java import com.github.cythara.Note; import java.util.Arrays; import java.util.List; package com.github.cythara.tuning; public class NoteFrequencyCalculator { private static List<String> notes = Arrays.asList("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"); private float referenceFrequency; public NoteFrequencyCalculator(float referenceFrequency) { this.referenceFrequency = referenceFrequency; }
public double getFrequency(Note note) {
gstraube/cythara
app/src/test/java/com/github/cythara/tuning/NoteFrequencyCalculatorTest.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import org.junit.Assert; import org.junit.Test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader;
package com.github.cythara.tuning; public class NoteFrequencyCalculatorTest { @Test public void TestCalc() { InputStream resourceAsStream = getClass().getResourceAsStream("note_frequencies.csv"); try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream))) { while (reader.ready()) { String line = reader.readLine(); String[] components = line.split(","); String noteWithOctave = components[0].split("/")[0]; String frequency = components[1]; String noteName = noteWithOctave.substring(0, 1); String octave = noteWithOctave.substring(1); String sign = ""; if (noteWithOctave.contains("#")) { noteName = noteWithOctave.substring(0, 1); octave = noteWithOctave.substring(2); sign = "#"; } String finalNoteName = noteName; String finalOctave = octave; String finalSign = sign;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/test/java/com/github/cythara/tuning/NoteFrequencyCalculatorTest.java import com.github.cythara.Note; import com.github.cythara.NoteName; import org.junit.Assert; import org.junit.Test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; package com.github.cythara.tuning; public class NoteFrequencyCalculatorTest { @Test public void TestCalc() { InputStream resourceAsStream = getClass().getResourceAsStream("note_frequencies.csv"); try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream))) { while (reader.ready()) { String line = reader.readLine(); String[] components = line.split(","); String noteWithOctave = components[0].split("/")[0]; String frequency = components[1]; String noteName = noteWithOctave.substring(0, 1); String octave = noteWithOctave.substring(1); String sign = ""; if (noteWithOctave.contains("#")) { noteName = noteWithOctave.substring(0, 1); octave = noteWithOctave.substring(2); sign = "#"; } String finalNoteName = noteName; String finalOctave = octave; String finalSign = sign;
Note note = new Note() {
gstraube/cythara
app/src/test/java/com/github/cythara/tuning/NoteFrequencyCalculatorTest.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import org.junit.Assert; import org.junit.Test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader;
package com.github.cythara.tuning; public class NoteFrequencyCalculatorTest { @Test public void TestCalc() { InputStream resourceAsStream = getClass().getResourceAsStream("note_frequencies.csv"); try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream))) { while (reader.ready()) { String line = reader.readLine(); String[] components = line.split(","); String noteWithOctave = components[0].split("/")[0]; String frequency = components[1]; String noteName = noteWithOctave.substring(0, 1); String octave = noteWithOctave.substring(1); String sign = ""; if (noteWithOctave.contains("#")) { noteName = noteWithOctave.substring(0, 1); octave = noteWithOctave.substring(2); sign = "#"; } String finalNoteName = noteName; String finalOctave = octave; String finalSign = sign; Note note = new Note() { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/test/java/com/github/cythara/tuning/NoteFrequencyCalculatorTest.java import com.github.cythara.Note; import com.github.cythara.NoteName; import org.junit.Assert; import org.junit.Test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; package com.github.cythara.tuning; public class NoteFrequencyCalculatorTest { @Test public void TestCalc() { InputStream resourceAsStream = getClass().getResourceAsStream("note_frequencies.csv"); try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream))) { while (reader.ready()) { String line = reader.readLine(); String[] components = line.split(","); String noteWithOctave = components[0].split("/")[0]; String frequency = components[1]; String noteName = noteWithOctave.substring(0, 1); String octave = noteWithOctave.substring(1); String sign = ""; if (noteWithOctave.contains("#")) { noteName = noteWithOctave.substring(0, 1); octave = noteWithOctave.substring(2); sign = "#"; } String finalNoteName = noteName; String finalOctave = octave; String finalSign = sign; Note note = new Note() { @Override
public NoteName getName() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ViolinTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class ViolinTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ViolinTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class ViolinTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ViolinTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class ViolinTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G3(G, 3), D4(D, 4), A4(A, 4), E5(E, 5); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ViolinTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class ViolinTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G3(G, 3), D4(D, 4), A4(A, 4), E5(E, 5); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/UkuleleDTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class UkuleleDTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/UkuleleDTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class UkuleleDTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/UkuleleDTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class UkuleleDTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { A4(A, 4), D4(D, 4), F4_SHARP(F, 4, "#"), B4(B, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/UkuleleDTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class UkuleleDTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { A4(A, 4), D4(D, 4), F4_SHARP(F, 4, "#"), B4(B, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/OpenGGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class OpenGGuitarTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/OpenGGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class OpenGGuitarTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/OpenGGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class OpenGGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { D2(D, 2), G2(G, 2), D3(D, 3), G3(G, 3), B3(B, 3), D4(D, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/OpenGGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class OpenGGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { D2(D, 2), G2(G, 2), D3(D, 3), G3(G, 3), B3(B, 3), D4(D, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/BassTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class BassTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/BassTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class BassTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/BassTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class BassTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { E1(E, 1), A1(A, 1), D2(D, 2), G2(G, 2); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/BassTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class BassTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { E1(E, 1), A1(A, 1), D2(D, 2), G2(G, 2); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/CelloTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class CelloTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/CelloTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class CelloTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/CelloTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class CelloTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2(C, 2), G2(G, 2), D3(D, 3), A3(A, 3); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/CelloTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class CelloTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2(C, 2), G2(G, 2), D3(D, 3), A3(A, 3); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropDGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropDGuitarTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropDGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropDGuitarTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropDGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropDGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { D2(D, 2), A2(A, 2), D3(D, 3), G3(G, 3), B3(B, 3), E4(E, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropDGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropDGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { D2(D, 2), A2(A, 2), D3(D, 3), G3(G, 3), B3(B, 3), E4(E, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCGuitarTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCGuitarTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2(C, 2), G2(G, 2), C3(C, 3), F3(F, 3), A3(A, 3), D4(D, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2(C, 2), G2(G, 2), C3(C, 3), F3(F, 3), A3(A, 3), D4(D, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ChromaticTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class ChromaticTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ChromaticTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class ChromaticTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ChromaticTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
G7(G, 7), G7_SHARP(G, 7, "#"), A7(A, 7), A7_SHARP(A, 7, "#"), B7(B, 7), C8(C, 8), C8_SHARP(C, 8, "#"), D8(D, 8), D8_SHARP(D, 8, "#"), E8(E, 8), F8(F, 8), F8_SHARP(F, 8, "#"), G8(G, 8), G8_SHARP(G, 8, "#"), A8(A, 8), A8_SHARP(A, 8, "#"), B8(B, 8), C9(C, 9), C9_SHARP(C, 9, "#"), D9(D, 9), D9_SHARP(D, 9, "#"), E9(E, 9), F9(F, 9), F9_SHARP(F, 9, "#"), G9(G, 9); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ChromaticTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; G7(G, 7), G7_SHARP(G, 7, "#"), A7(A, 7), A7_SHARP(A, 7, "#"), B7(B, 7), C8(C, 8), C8_SHARP(C, 8, "#"), D8(D, 8), D8_SHARP(D, 8, "#"), E8(E, 8), F8(F, 8), F8_SHARP(F, 8, "#"), G8(G, 8), G8_SHARP(G, 8, "#"), A8(A, 8), A8_SHARP(A, 8, "#"), B8(B, 8), C9(C, 9), C9_SHARP(C, 9, "#"), D9(D, 9), D9_SHARP(D, 9, "#"), E9(E, 9), F9(F, 9), F9_SHARP(F, 9, "#"), G9(G, 9); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/OudStdTurkishTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class OudStdTurkishTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/OudStdTurkishTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class OudStdTurkishTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/OudStdTurkishTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class OudStdTurkishTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } public enum Pitch implements Note { C2_SHARP(C, 2, "#"), F2_SHARP(F, 2, "#"), B2(B, 2), E3(E, 3), A3(A, 3), D4(D, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/OudStdTurkishTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class OudStdTurkishTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } public enum Pitch implements Note { C2_SHARP(C, 2, "#"), F2_SHARP(F, 2, "#"), B2(B, 2), E3(E, 3), A3(A, 3), D4(D, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/UkuleleTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class UkuleleTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/UkuleleTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class UkuleleTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/UkuleleTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class UkuleleTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G4(G, 4), C4(C, 4), E4(E, 4), A4(A, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/UkuleleTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class UkuleleTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G4(G, 4), C4(C, 4), E4(E, 4), A4(A, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/test/java/com/github/cythara/PitchComparatorTest.java
// Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java // public class GuitarTuning implements Tuning { // // @Override // public Note[] getNotes() { // return Pitch.values(); // } // // @Override // public Note findNote(String name) { // return Pitch.valueOf(name); // } // // public enum Pitch implements Note { // // E4(E, 4), // B3(B, 3), // G3(G, 3), // D3(D, 3), // A2(A, 2), // E2(E, 2); // // private final String sign; // private final int octave; // private NoteName name; // // Pitch(NoteName name, int octave) { // this.name = name; // this.octave = octave; // this.sign = ""; // } // // public NoteName getName() { // return name; // } // // @Override // public int getOctave() { // return octave; // } // // @Override // public String getSign() { // return sign; // } // } // } // // Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java // public enum Pitch implements Note { // // E4(E, 4), // B3(B, 3), // G3(G, 3), // D3(D, 3), // A2(A, 2), // E2(E, 2); // // private final String sign; // private final int octave; // private NoteName name; // // Pitch(NoteName name, int octave) { // this.name = name; // this.octave = octave; // this.sign = ""; // } // // public NoteName getName() { // return name; // } // // @Override // public int getOctave() { // return octave; // } // // @Override // public String getSign() { // return sign; // } // }
import com.github.cythara.tuning.GuitarTuning; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; import java.util.Map; import static com.github.cythara.tuning.GuitarTuning.Pitch.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.closeTo; import static org.junit.Assert.*;
package com.github.cythara; @RunWith(PowerMockRunner.class) @PrepareForTest(MainActivity.class) public class PitchComparatorTest { @Test public void retrieveNote() { PowerMockito.mockStatic(MainActivity.class);
// Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java // public class GuitarTuning implements Tuning { // // @Override // public Note[] getNotes() { // return Pitch.values(); // } // // @Override // public Note findNote(String name) { // return Pitch.valueOf(name); // } // // public enum Pitch implements Note { // // E4(E, 4), // B3(B, 3), // G3(G, 3), // D3(D, 3), // A2(A, 2), // E2(E, 2); // // private final String sign; // private final int octave; // private NoteName name; // // Pitch(NoteName name, int octave) { // this.name = name; // this.octave = octave; // this.sign = ""; // } // // public NoteName getName() { // return name; // } // // @Override // public int getOctave() { // return octave; // } // // @Override // public String getSign() { // return sign; // } // } // } // // Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java // public enum Pitch implements Note { // // E4(E, 4), // B3(B, 3), // G3(G, 3), // D3(D, 3), // A2(A, 2), // E2(E, 2); // // private final String sign; // private final int octave; // private NoteName name; // // Pitch(NoteName name, int octave) { // this.name = name; // this.octave = octave; // this.sign = ""; // } // // public NoteName getName() { // return name; // } // // @Override // public int getOctave() { // return octave; // } // // @Override // public String getSign() { // return sign; // } // } // Path: app/src/test/java/com/github/cythara/PitchComparatorTest.java import com.github.cythara.tuning.GuitarTuning; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; import java.util.Map; import static com.github.cythara.tuning.GuitarTuning.Pitch.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.closeTo; import static org.junit.Assert.*; package com.github.cythara; @RunWith(PowerMockRunner.class) @PrepareForTest(MainActivity.class) public class PitchComparatorTest { @Test public void retrieveNote() { PowerMockito.mockStatic(MainActivity.class);
Mockito.when(MainActivity.getCurrentTuning()).thenReturn(new GuitarTuning());
gstraube/cythara
app/src/main/java/com/github/cythara/PitchComparator.java
// Path: app/src/main/java/com/github/cythara/tuning/NoteFrequencyCalculator.java // public class NoteFrequencyCalculator { // // private static List<String> notes = // Arrays.asList("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"); // private float referenceFrequency; // // public NoteFrequencyCalculator(float referenceFrequency) { // this.referenceFrequency = referenceFrequency; // } // // public double getFrequency(Note note) { // int semitonesPerOctave = 12; // int referenceOctave = 4; // double distance = semitonesPerOctave * (note.getOctave() - referenceOctave); // // distance += notes.indexOf(note.getName() + note.getSign()) - notes.indexOf("A"); // // return referenceFrequency * Math.pow(2, distance / 12); // } // }
import com.github.cythara.tuning.NoteFrequencyCalculator; import java.util.Arrays;
package com.github.cythara; class PitchComparator { static PitchDifference retrieveNote(float pitch) { Tuning tuning = MainActivity.getCurrentTuning(); int referencePitch = MainActivity.getReferencePitch(); Note[] tuningNotes = tuning.getNotes(); Note[] notes; if (MainActivity.isAutoModeEnabled()) { notes = tuningNotes; } else { notes = new Note[]{tuningNotes[MainActivity.getReferencePosition()]}; }
// Path: app/src/main/java/com/github/cythara/tuning/NoteFrequencyCalculator.java // public class NoteFrequencyCalculator { // // private static List<String> notes = // Arrays.asList("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"); // private float referenceFrequency; // // public NoteFrequencyCalculator(float referenceFrequency) { // this.referenceFrequency = referenceFrequency; // } // // public double getFrequency(Note note) { // int semitonesPerOctave = 12; // int referenceOctave = 4; // double distance = semitonesPerOctave * (note.getOctave() - referenceOctave); // // distance += notes.indexOf(note.getName() + note.getSign()) - notes.indexOf("A"); // // return referenceFrequency * Math.pow(2, distance / 12); // } // } // Path: app/src/main/java/com/github/cythara/PitchComparator.java import com.github.cythara.tuning.NoteFrequencyCalculator; import java.util.Arrays; package com.github.cythara; class PitchComparator { static PitchDifference retrieveNote(float pitch) { Tuning tuning = MainActivity.getCurrentTuning(); int referencePitch = MainActivity.getReferencePitch(); Note[] tuningNotes = tuning.getNotes(); Note[] notes; if (MainActivity.isAutoModeEnabled()) { notes = tuningNotes; } else { notes = new Note[]{tuningNotes[MainActivity.getReferencePosition()]}; }
NoteFrequencyCalculator noteFrequencyCalculator =
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCBassTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCBassTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCBassTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCBassTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCBassTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCBassTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C1(C, 1), G1(G, 1), C2(C, 2), F2(F, 2); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCBassTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCBassTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C1(C, 1), G1(G, 1), C2(C, 2), F2(F, 2); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ViolaTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class ViolaTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ViolaTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class ViolaTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/ViolaTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class ViolaTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C3(C, 3), G3(G, 3), D4(D, 4), A4(A, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/ViolaTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class ViolaTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C3(C, 3), G3(G, 3), D4(D, 4), A4(A, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCSharpGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCSharpGuitarTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCSharpGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCSharpGuitarTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/DropCSharpGuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class DropCSharpGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2_SHARP(C, 2, "#"), A2(A, 2), D3(D, 3), G3(G, 3), B3(B, 3), E4(E, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/DropCSharpGuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class DropCSharpGuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { C2_SHARP(C, 2, "#"), A2(A, 2), D3(D, 3), G3(G, 3), B3(B, 3), E4(E, 4); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/GuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class GuitarTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class GuitarTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/GuitarTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class GuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } public enum Pitch implements Note { E4(E, 4), B3(B, 3), G3(G, 3), D3(D, 3), A2(A, 2), E2(E, 2); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/GuitarTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class GuitarTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } public enum Pitch implements Note { E4(E, 4), B3(B, 3), G3(G, 3), D3(D, 3), A2(A, 2), E2(E, 2); private final String sign; private final int octave;
private NoteName name;
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/BanjoTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class BanjoTuning implements Tuning { @Override
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/BanjoTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class BanjoTuning implements Tuning { @Override
public Note[] getNotes() {
gstraube/cythara
app/src/main/java/com/github/cythara/tuning/BanjoTuning.java
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // }
import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*;
package com.github.cythara.tuning; public class BanjoTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G4(G, 4), D3(D, 3), G3(G, 3), B3(B, 3), D4(D, 4); private final String sign; private final int octave;
// Path: app/src/main/java/com/github/cythara/Note.java // public interface Note { // // NoteName getName(); // // int getOctave(); // // String getSign(); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // // Path: app/src/main/java/com/github/cythara/Tuning.java // public interface Tuning { // // Note[] getNotes(); // // Note findNote(String name); // } // // Path: app/src/main/java/com/github/cythara/NoteName.java // public enum NoteName { // // C("C", "Do"), // D("D", "Re"), // E("E", "Mi"), // F("F", "Fa"), // G("G", "Sol"), // A("A", "La"), // B("B", "Si"); // // private final String scientific; // private final String sol; // // NoteName(String scientific, String sol) { // this.scientific = scientific; // this.sol = sol; // } // // public String getScientific() { // return scientific; // } // // public String getSol() { // return sol; // } // // public static NoteName fromScientificName(String scientificName) { // for (NoteName noteName : NoteName.values()) { // if (noteName.getScientific().equalsIgnoreCase(scientificName)) { // return noteName; // } // } // // throw new IllegalArgumentException("Could not convert from name: " + scientificName); // } // } // Path: app/src/main/java/com/github/cythara/tuning/BanjoTuning.java import com.github.cythara.Note; import com.github.cythara.NoteName; import com.github.cythara.Tuning; import static com.github.cythara.NoteName.*; package com.github.cythara.tuning; public class BanjoTuning implements Tuning { @Override public Note[] getNotes() { return Pitch.values(); } @Override public Note findNote(String name) { return Pitch.valueOf(name); } private enum Pitch implements Note { G4(G, 4), D3(D, 3), G3(G, 3), B3(B, 3), D4(D, 4); private final String sign; private final int octave;
private NoteName name;
danikula/AndroidVideoCache
library/src/main/java/com/danikula/videocache/HttpUrlSource.java
// Path: library/src/main/java/com/danikula/videocache/headers/EmptyHeadersInjector.java // public class EmptyHeadersInjector implements HeaderInjector { // // @Override // public Map<String, String> addHeaders(String url) { // return new HashMap<>(); // } // // } // // Path: library/src/main/java/com/danikula/videocache/headers/HeaderInjector.java // public interface HeaderInjector { // // /** // * Adds headers to server's requests for corresponding url. // * // * @param url an url headers will be added for // * @return a map with headers, where keys are header's names, and values are header's values. {@code null} is not acceptable! // */ // Map<String, String> addHeaders(String url); // // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorage.java // public interface SourceInfoStorage { // // SourceInfo get(String url); // // void put(String url, SourceInfo sourceInfo); // // void release(); // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorageFactory.java // public class SourceInfoStorageFactory { // // public static SourceInfoStorage newSourceInfoStorage(Context context) { // return new DatabaseSourceInfoStorage(context); // } // // public static SourceInfoStorage newEmptySourceInfoStorage() { // return new NoSourceInfoStorage(); // } // } // // Path: library/src/main/java/com/danikula/videocache/Preconditions.java // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // Path: library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java // static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
import android.text.TextUtils; import com.danikula.videocache.headers.EmptyHeadersInjector; import com.danikula.videocache.headers.HeaderInjector; import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import static com.danikula.videocache.Preconditions.checkNotNull; import static com.danikula.videocache.ProxyCacheUtils.DEFAULT_BUFFER_SIZE; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; import static java.net.HttpURLConnection.HTTP_MOVED_TEMP; import static java.net.HttpURLConnection.HTTP_OK; import static java.net.HttpURLConnection.HTTP_PARTIAL; import static java.net.HttpURLConnection.HTTP_SEE_OTHER;
package com.danikula.videocache; /** * {@link Source} that uses http resource as source for {@link ProxyCache}. * * @author Alexey Danilov ([email protected]). */ public class HttpUrlSource implements Source { private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); private static final int MAX_REDIRECTS = 5;
// Path: library/src/main/java/com/danikula/videocache/headers/EmptyHeadersInjector.java // public class EmptyHeadersInjector implements HeaderInjector { // // @Override // public Map<String, String> addHeaders(String url) { // return new HashMap<>(); // } // // } // // Path: library/src/main/java/com/danikula/videocache/headers/HeaderInjector.java // public interface HeaderInjector { // // /** // * Adds headers to server's requests for corresponding url. // * // * @param url an url headers will be added for // * @return a map with headers, where keys are header's names, and values are header's values. {@code null} is not acceptable! // */ // Map<String, String> addHeaders(String url); // // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorage.java // public interface SourceInfoStorage { // // SourceInfo get(String url); // // void put(String url, SourceInfo sourceInfo); // // void release(); // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorageFactory.java // public class SourceInfoStorageFactory { // // public static SourceInfoStorage newSourceInfoStorage(Context context) { // return new DatabaseSourceInfoStorage(context); // } // // public static SourceInfoStorage newEmptySourceInfoStorage() { // return new NoSourceInfoStorage(); // } // } // // Path: library/src/main/java/com/danikula/videocache/Preconditions.java // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // Path: library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java // static final int DEFAULT_BUFFER_SIZE = 8 * 1024; // Path: library/src/main/java/com/danikula/videocache/HttpUrlSource.java import android.text.TextUtils; import com.danikula.videocache.headers.EmptyHeadersInjector; import com.danikula.videocache.headers.HeaderInjector; import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import static com.danikula.videocache.Preconditions.checkNotNull; import static com.danikula.videocache.ProxyCacheUtils.DEFAULT_BUFFER_SIZE; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; import static java.net.HttpURLConnection.HTTP_MOVED_TEMP; import static java.net.HttpURLConnection.HTTP_OK; import static java.net.HttpURLConnection.HTTP_PARTIAL; import static java.net.HttpURLConnection.HTTP_SEE_OTHER; package com.danikula.videocache; /** * {@link Source} that uses http resource as source for {@link ProxyCache}. * * @author Alexey Danilov ([email protected]). */ public class HttpUrlSource implements Source { private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); private static final int MAX_REDIRECTS = 5;
private final SourceInfoStorage sourceInfoStorage;
danikula/AndroidVideoCache
library/src/main/java/com/danikula/videocache/HttpUrlSource.java
// Path: library/src/main/java/com/danikula/videocache/headers/EmptyHeadersInjector.java // public class EmptyHeadersInjector implements HeaderInjector { // // @Override // public Map<String, String> addHeaders(String url) { // return new HashMap<>(); // } // // } // // Path: library/src/main/java/com/danikula/videocache/headers/HeaderInjector.java // public interface HeaderInjector { // // /** // * Adds headers to server's requests for corresponding url. // * // * @param url an url headers will be added for // * @return a map with headers, where keys are header's names, and values are header's values. {@code null} is not acceptable! // */ // Map<String, String> addHeaders(String url); // // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorage.java // public interface SourceInfoStorage { // // SourceInfo get(String url); // // void put(String url, SourceInfo sourceInfo); // // void release(); // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorageFactory.java // public class SourceInfoStorageFactory { // // public static SourceInfoStorage newSourceInfoStorage(Context context) { // return new DatabaseSourceInfoStorage(context); // } // // public static SourceInfoStorage newEmptySourceInfoStorage() { // return new NoSourceInfoStorage(); // } // } // // Path: library/src/main/java/com/danikula/videocache/Preconditions.java // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // Path: library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java // static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
import android.text.TextUtils; import com.danikula.videocache.headers.EmptyHeadersInjector; import com.danikula.videocache.headers.HeaderInjector; import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import static com.danikula.videocache.Preconditions.checkNotNull; import static com.danikula.videocache.ProxyCacheUtils.DEFAULT_BUFFER_SIZE; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; import static java.net.HttpURLConnection.HTTP_MOVED_TEMP; import static java.net.HttpURLConnection.HTTP_OK; import static java.net.HttpURLConnection.HTTP_PARTIAL; import static java.net.HttpURLConnection.HTTP_SEE_OTHER;
package com.danikula.videocache; /** * {@link Source} that uses http resource as source for {@link ProxyCache}. * * @author Alexey Danilov ([email protected]). */ public class HttpUrlSource implements Source { private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); private static final int MAX_REDIRECTS = 5; private final SourceInfoStorage sourceInfoStorage;
// Path: library/src/main/java/com/danikula/videocache/headers/EmptyHeadersInjector.java // public class EmptyHeadersInjector implements HeaderInjector { // // @Override // public Map<String, String> addHeaders(String url) { // return new HashMap<>(); // } // // } // // Path: library/src/main/java/com/danikula/videocache/headers/HeaderInjector.java // public interface HeaderInjector { // // /** // * Adds headers to server's requests for corresponding url. // * // * @param url an url headers will be added for // * @return a map with headers, where keys are header's names, and values are header's values. {@code null} is not acceptable! // */ // Map<String, String> addHeaders(String url); // // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorage.java // public interface SourceInfoStorage { // // SourceInfo get(String url); // // void put(String url, SourceInfo sourceInfo); // // void release(); // } // // Path: library/src/main/java/com/danikula/videocache/sourcestorage/SourceInfoStorageFactory.java // public class SourceInfoStorageFactory { // // public static SourceInfoStorage newSourceInfoStorage(Context context) { // return new DatabaseSourceInfoStorage(context); // } // // public static SourceInfoStorage newEmptySourceInfoStorage() { // return new NoSourceInfoStorage(); // } // } // // Path: library/src/main/java/com/danikula/videocache/Preconditions.java // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // Path: library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java // static final int DEFAULT_BUFFER_SIZE = 8 * 1024; // Path: library/src/main/java/com/danikula/videocache/HttpUrlSource.java import android.text.TextUtils; import com.danikula.videocache.headers.EmptyHeadersInjector; import com.danikula.videocache.headers.HeaderInjector; import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import static com.danikula.videocache.Preconditions.checkNotNull; import static com.danikula.videocache.ProxyCacheUtils.DEFAULT_BUFFER_SIZE; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; import static java.net.HttpURLConnection.HTTP_MOVED_TEMP; import static java.net.HttpURLConnection.HTTP_OK; import static java.net.HttpURLConnection.HTTP_PARTIAL; import static java.net.HttpURLConnection.HTTP_SEE_OTHER; package com.danikula.videocache; /** * {@link Source} that uses http resource as source for {@link ProxyCache}. * * @author Alexey Danilov ([email protected]). */ public class HttpUrlSource implements Source { private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); private static final int MAX_REDIRECTS = 5; private final SourceInfoStorage sourceInfoStorage;
private final HeaderInjector headerInjector;