Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 1.8.3 Support; #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/com/comze_instancelabs/mgmobescape/IArena.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.comze_instancelabs.mgmobescape.v1_7._R4.V1_7_10Wither;
import com.comze_instancelabs.mgmobescape.v1_8._R1.V1_8Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R1.V1_8Wither;
import com.comze_instancelabs.mgmobescape.v1_8._R2.V1_8_3Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R2.V1_8_3Wither;
import com.comze_instancelabs.minigamesapi.Arena;
import com.comze_instancelabs.minigamesapi.ArenaType;
import com.comze_instancelabs.minigamesapi.MinigamesAPI;
Expand Down Expand Up @@ -83,6 +85,9 @@ public void started() {
} else if (m.mode1_8) {
ad = new V1_8Dragon();
setDragon(V1_8Dragon.spawnEnderdragon(m, arena, a.getDragonSpawn()));
} else if (m.mode1_8_3) {
ad = new V1_8_3Dragon();
setDragon(V1_8_3Dragon.spawnEnderdragon(m, arena, a.getDragonSpawn()));
} else {
ad = new V1_7Dragon();
setDragon(V1_7Dragon.spawnEnderdragon(m, arena, a.getDragonSpawn()));
Expand All @@ -103,6 +108,9 @@ public void started() {
} else if (m.mode1_8) {
aw = new V1_8Wither();
setWither(V1_8Wither.spawnWither(m, arena, a.getDragonSpawn()));
} else if (m.mode1_8_3) {
aw = new V1_8_3Wither();
setWither(V1_8_3Wither.spawnWither(m, arena, a.getDragonSpawn()));
} else {
aw = new V1_7Wither();
setWither(V1_7Wither.spawnWither(m, arena, a.getDragonSpawn()));
Expand Down
8 changes: 8 additions & 0 deletions src/com/comze_instancelabs/mgmobescape/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.comze_instancelabs.mgmobescape.v1_7._R3.V1_7_8Dragon;
import com.comze_instancelabs.mgmobescape.v1_7._R4.V1_7_10Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R1.V1_8Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R2.V1_8_3Dragon;
import com.comze_instancelabs.minigamesapi.Arena;
import com.comze_instancelabs.minigamesapi.ArenaSetup;
import com.comze_instancelabs.minigamesapi.ArenaState;
Expand Down Expand Up @@ -71,9 +72,11 @@ public class Main extends JavaPlugin implements Listener {
public static boolean mode1_7_8 = false;
public static boolean mode1_7_10 = false;
public static boolean mode1_8 = false;
public static boolean mode1_8_3 = false;

public HashMap<String, Integer> ppoint = new HashMap<String, Integer>();
public ArrayList<String> p_used_kit = new ArrayList<String>();


public void onEnable() {
cmdhandler = new ICommandHandler();
Expand All @@ -99,6 +102,9 @@ public void onEnable() {
} else if (version.contains("1_8_R1")) {
mode1_8 = true;
getLogger().info("Turned on 1.8 mode.");
} else if (version.contains("1_8_R2")) {
mode1_8_3 = true;
getLogger().info("Turned on 1.8.3 mode.");
}
registerEntities();

Expand Down Expand Up @@ -165,6 +171,8 @@ private boolean registerEntities() {
return V1_7_10Dragon.registerEntities();
} else if (mode1_8) {
return V1_8Dragon.registerEntities();
} else if (mode1_8_3) {
return V1_8_3Dragon.registerEntities();
}
return V1_7Dragon.registerEntities();
}
Expand Down
8 changes: 8 additions & 0 deletions src/com/comze_instancelabs/mgmobescape/mobtools/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.comze_instancelabs.mgmobescape.v1_7._R4.V1_7_10Wither;
import com.comze_instancelabs.mgmobescape.v1_8._R1.V1_8Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R1.V1_8Wither;
import com.comze_instancelabs.mgmobescape.v1_8._R2.V1_8_3Dragon;
import com.comze_instancelabs.mgmobescape.v1_8._R2.V1_8_3Wither;

public class Tools {

Expand Down Expand Up @@ -55,6 +57,9 @@ public void run() {
} else if (m.mode1_8) {
V1_8Dragon v = new V1_8Dragon();
v.removeEnderdragon(arena);
} else if (m.mode1_8_3) {
V1_8_3Dragon v = new V1_8_3Dragon();
v.removeEnderdragon(arena);
} else {
V1_7Dragon v = new V1_7Dragon();
v.removeEnderdragon(arena);
Expand All @@ -75,6 +80,9 @@ public void run() {
} else if (m.mode1_8) {
V1_8Wither v = new V1_8Wither();
v.removeWither(arena);
} else if (m.mode1_8_3) {
V1_8_3Wither v = new V1_8_3Wither();
v.removeWither(arena);
} else {
V1_7Wither v = new V1_7Wither();
v.removeWither(arena);
Expand Down
175 changes: 175 additions & 0 deletions src/com/comze_instancelabs/mgmobescape/v1_8/_R2/MEDragon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
package com.comze_instancelabs.mgmobescape.v1_8._R2;

import java.util.ArrayList;

import net.minecraft.server.v1_8_R2.DamageSource;
import net.minecraft.server.v1_8_R2.EntityComplexPart;
import net.minecraft.server.v1_8_R2.EntityEnderDragon;
import net.minecraft.server.v1_8_R2.World;

import org.bukkit.Location;
import org.bukkit.util.Vector;

import com.comze_instancelabs.mgmobescape.AbstractMEDragon;
import com.comze_instancelabs.mgmobescape.IArena;
import com.comze_instancelabs.mgmobescape.Main;
import com.comze_instancelabs.mgmobescape.mobtools.Tools;
import com.comze_instancelabs.minigamesapi.MinigamesAPI;

public class MEDragon extends EntityEnderDragon implements AbstractMEDragon {

private boolean onGround = false;
private ArrayList<Vector> points = new ArrayList();
private int currentid;
private double X;
private double Y;
private double Z;
private Main m;
private IArena arena;

public MEDragon(Main m, String arena, Location loc, World world, ArrayList<Vector> p) {
super(world);
this.m = m;
this.arena = (IArena) MinigamesAPI.getAPI().pinstances.get(m).getArenaByName(arena);
currentid = 0;
this.points = p;
setPosition(loc.getX(), loc.getY(), loc.getZ());
yaw = loc.getYaw() + 180;
while (yaw > 360) {
yaw -= 360;
}
while (yaw < 0) {
yaw += 360;
}
if (yaw < 45 || yaw > 315) {
yaw = 0F;
} else if (yaw < 135) {
yaw = 90F;
} else if (yaw < 225) {
yaw = 180F;
} else {
yaw = 270F;
}

double disX = (this.locX - points.get(currentid).getX());
double disY = (this.locY - points.get(currentid).getY());
double disZ = (this.locZ - points.get(currentid).getZ());

double tick = Math.sqrt(disX * disX + disY * disY + disZ * disZ) * 2 / m.mob_speed * Math.pow(0.98, currentid);

this.X = (Math.abs(disX) / tick);
this.Y = (Math.abs(disY) / tick);
this.Z = (Math.abs(disZ) / tick);
}

@Override
public void m() {
return;
}

public boolean damageEntity(DamageSource damagesource, int i) {
return false;
}

@Override
public int getExpReward() {
return 0;
}

public boolean a(EntityComplexPart entitycomplexpart, DamageSource damagesource, int i) {
return false;
}

public Vector getCurrentPosition() {
return points.get(currentid);
}

public Vector getCurrentPositionNext() {
if (currentid + 1 < points.size() - 1) {
return points.get(currentid + 1);
}
return points.get(currentid);
}

public Vector getNextPosition() {

double tempx = this.locX;
double tempy = this.locY;
double tempz = this.locZ;

if (((Math.abs((int) tempx - points.get(currentid).getX()) <= 1) && (Math.abs((int) tempz - points.get(currentid).getZ()) <= 3) && (Math.abs((int) tempy - points.get(currentid).getY()) <= 5)) || ((Math.abs((int) tempz - points.get(currentid).getZ()) <= 0) && (Math.abs((int) tempx - points.get(currentid).getX()) <= 3) && (Math.abs((int) tempy - points.get(currentid).getY()) <= 5))) {
if (currentid < points.size() - 1) {
currentid += 1;
} else {
// finish
arena.stop();
}

ArrayList<String> temp = arena.getAllPlayers();
for (String p : temp) {
if (m.ppoint.containsKey(p)) {
System.out.println("p:" + m.ppoint.get(p) + " d:" + currentid);
if (m.ppoint.get(p) < currentid - 1) {
// player fell behind mob
arena.spectate(p);
}
}
}

double disX = (this.locX - points.get(currentid).getX());
double disY = (this.locY - points.get(currentid).getY());
double disZ = (this.locZ - points.get(currentid).getZ());

double tick_ = Math.sqrt(disX * disX + disY * disY + disZ * disZ) * 2 / m.mob_speed * Math.pow(0.98, currentid);

this.X = (Math.abs(disX) / tick_);
this.Y = (Math.abs(disY) / tick_);
this.Z = (Math.abs(disZ) / tick_);

Tools.setYawPitchDragon(arena.getDragon(), new Vector(this.locX, this.locY, this.locZ), points.get(currentid));

}

Tools.setYawPitchDragon(arena.getDragon(), new Vector(this.locX, this.locY, this.locZ), points.get(currentid));

if (tempx < points.get(currentid).getX())
tempx += this.X;
else {
tempx -= this.X;
}

if ((int) tempy < points.get(currentid).getY()) {
tempy += this.Y;
} else {
tempy -= this.Y;
}

if (tempz < points.get(currentid).getZ())
tempz += this.Z;
else {
tempz -= this.Z;
}

return new Vector(tempx, tempy, tempz);
}

@Override
public void setYawPitch(float yaw, float pitch) {
this.yaw = yaw;
this.pitch = pitch;
}

/*
* public void setYawPitch(Vector l) { double dx = l.getX() - this.locX; double dy = l.getY() - this.locY; double dz = l.getZ() - this.locZ;
*
* if (dx != 0) { if (dx < 0) { this.yaw = (float) (1.5 * Math.PI); } else { this.yaw = (float) (0.5 * Math.PI); } this.yaw = (float) this.yaw -
* (float) Math.atan(dz / dx); } else if (dz < 0) { this.yaw = (float) Math.PI; }
*
* double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
*
* pitch = (float) -Math.atan(dy / dxz);
*
* this.yaw = -yaw * 180F / (float) Math.PI - 180F; this.pitch = pitch * 180F / (float) Math.PI - 180F; }
*/

}
Loading