/gist:2659fdde63e284faf6d2 Secret
Created
March 22, 2014 13:38
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.porterk.mg.pfg; | |
import org.bukkit.Location; | |
import org.bukkit.entity.Player; | |
import net.minecraft.server.v1_7_R1.Block; | |
import net.minecraft.server.v1_7_R1.EntityInsentient; | |
import net.minecraft.server.v1_7_R1.MathHelper; | |
import net.minecraft.server.v1_7_R1.PathfinderGoal; | |
public class PathfinderGoalBreak extends PathfinderGoal{ | |
protected EntityInsentient a; | |
protected Block block; | |
public PathfinderGoalBreak(EntityInsentient entityinsentient) { | |
this.a = entityinsentient; | |
} | |
@Override | |
public boolean a() { | |
return true; | |
} | |
@Override | |
public void e(){ | |
int direction = MathHelper.floor((double)((a.yaw * 4F) / 360F) + 0.5D) & 3; | |
int x = (int) a.locX; | |
int y = MathHelper.floor((int) a.locY + a.getHeadHeight()); | |
int z = (int) a.locZ; | |
int l; | |
if(a.getGoalTarget() != null){ | |
Location p = a.getGoalTarget().getBukkitEntity().getLocation(); | |
Location b; | |
org.bukkit.World world = a.world.getWorld(); | |
switch(direction) | |
{ | |
case 0: //Direction 0 = +Z | |
{ | |
block = a.world.getType(x, y, z +1); | |
b = new Location(world, x, y, z +1); | |
l = world.getBlockAt(x, y, z +1).getTypeId(); | |
if(l > 0){ | |
if(a.getGoalTarget() instanceof Player){ | |
world.getBlockAt(x, y, z +1).breakNaturally(); | |
a.world.broadcastEntityEffect(a, (byte) 14); | |
} | |
} | |
break; | |
} | |
case 1: //Direction 1 = -X | |
{ | |
block = a.world.getType(x -1, y, z); | |
b = new Location(world, x -1, y, z); | |
l = world.getBlockAt(x, y, z +1).getTypeId(); | |
if(l > 0){ | |
if(a.getGoalTarget() instanceof Player){ | |
world.getBlockAt(x -1, y, z).breakNaturally(); | |
a.world.broadcastEntityEffect(a, (byte) 14); | |
} | |
} | |
break; | |
} | |
case 2: //Direction 2 = -Z | |
{ | |
block = a.world.getType(x, y, z -1); | |
b = new Location(world, x, y, z -1); | |
l = world.getBlockAt(x, y, z +1).getTypeId(); | |
if(l > 0){ | |
if(a.getGoalTarget() instanceof Player){ | |
world.getBlockAt(x, y, z -1).breakNaturally(); | |
a.world.broadcastEntityEffect(a, (byte) 14); | |
} | |
} | |
break; | |
} | |
case 3: //Direction 3 = +X | |
{ | |
block = a.world.getType(x + 1, y, z); | |
b = new Location(world, x + 1, y, z); | |
l = world.getBlockAt(x, y, z +1).getTypeId(); | |
if(l > 0){ | |
if(a.getGoalTarget() instanceof Player){ | |
world.getBlockAt(x, y, z -1).breakNaturally(); | |
a.world.broadcastEntityEffect(a, (byte) 14); | |
} | |
} | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment