For sure remove handcuff icon in jail, add distance to display handcuff over the player
This commit is contained in:
parent
ccfcb79526
commit
701fca83b6
|
@ -96,11 +96,11 @@ public class CommandGP implements ICommand {
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if (arg.equals(COMMANDS[0])) // Add
|
if (arg.equalsIgnoreCase(COMMANDS[0])) // Add
|
||||||
error = gp.addToGalaticPatrol(player, true);
|
error = gp.addToGalaticPatrol(player, true);
|
||||||
else if (arg.equals(COMMANDS[1])) // Remove
|
else if (arg.equalsIgnoreCase(COMMANDS[1])) // Remove
|
||||||
error = gp.removeFromGalacticPatrol(player);
|
error = gp.removeFromGalacticPatrol(player);
|
||||||
else if (arg.equals(COMMANDS[2])) { // Inmate
|
else if (arg.equalsIgnoreCase(COMMANDS[2])) { // Inmate
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp inmate sec [<player>]"));
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp inmate sec [<player>]"));
|
||||||
return;
|
return;
|
||||||
|
@ -114,10 +114,10 @@ public class CommandGP implements ICommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[3])) { // freeInmate
|
else if (arg.equalsIgnoreCase(COMMANDS[3])) { // freeInmate
|
||||||
error = gp.jail.removePlayerFromJail(sender, player, true);
|
error = gp.jail.removePlayerFromJail(sender, player, true);
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[4])) {// RemoveJail
|
else if (arg.equalsIgnoreCase(COMMANDS[4])) {// RemoveJail
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
try {
|
try {
|
||||||
error = gp.jail.removeCell(Integer.parseInt(args.get(0)));
|
error = gp.jail.removeCell(Integer.parseInt(args.get(0)));
|
||||||
|
@ -138,19 +138,21 @@ public class CommandGP implements ICommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[5])) { // addCriminal
|
else if (arg.equalsIgnoreCase(COMMANDS[5])) { // addCriminal
|
||||||
long rate = 0;
|
long rate = 0;
|
||||||
|
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
try {
|
try {
|
||||||
rate = Long.parseLong(args.get(0));
|
rate = Long.parseLong(args.get(0));
|
||||||
|
error = gp.criminals.addCriminal(player, rate) != null ? 0 : 1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
|
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp addCriminal <rate> [<player>]"));
|
||||||
|
error = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = gp.criminals.addCriminal(player, rate) != null ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[6])) { // removeCriminal
|
else if (arg.equalsIgnoreCase(COMMANDS[6])) { // removeCriminal
|
||||||
error = gp.criminals.removeCriminal(player.getUniqueID()) ? 0 : 1;
|
error = gp.criminals.removeCriminal(player.getUniqueID()) ? 0 : 1;
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[7])) { // banGP
|
else if (arg.equals(COMMANDS[7])) { // banGP
|
||||||
|
@ -162,7 +164,7 @@ public class CommandGP implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (arg.equals(COMMANDS[8])) { // removeBanGP
|
else if (arg.equalsIgnoreCase(COMMANDS[8])) { // removeBanGP
|
||||||
error = gp.bannedFromGP.remove(player.getUniqueID()) == null ? 1 : 0;
|
error = gp.bannedFromGP.remove(player.getUniqueID()) == null ? 1 : 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class ItemGPHandcuff extends Item {
|
||||||
long timeUsing = (System.currentTimeMillis() - timeStart) / 1000;
|
long timeUsing = (System.currentTimeMillis() - timeStart) / 1000;
|
||||||
if (useRemaining <= 0)
|
if (useRemaining <= 0)
|
||||||
return getIcon(stack, renderPass);
|
return getIcon(stack, renderPass);
|
||||||
else if (timeUsing >= 0 && timeUsing < TIME_HANDCUFFING )
|
else if (timeUsing >= 0 && timeUsing < TIME_HANDCUFFING + 1 )
|
||||||
return open;
|
return open;
|
||||||
else
|
else
|
||||||
return close;
|
return close;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import xamora.gp_dbc.Main;
|
import xamora.gp_dbc.Main;
|
||||||
import xamora.gp_dbc.system.Handcuff;
|
|
||||||
import xamora.gp_dbc.system.Handcuffed;
|
import xamora.gp_dbc.system.Handcuffed;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
|
@ -53,46 +52,47 @@ public class RenderHandcuffIcon extends Gui {
|
||||||
double viewZ = cameraEntity.lastTickPosZ + (cameraEntity.posZ - cameraEntity.lastTickPosZ) * event.partialTicks;
|
double viewZ = cameraEntity.lastTickPosZ + (cameraEntity.posZ - cameraEntity.lastTickPosZ) * event.partialTicks;
|
||||||
frustrum.setPosition(viewX, viewY, viewZ);
|
frustrum.setPosition(viewX, viewY, viewZ);
|
||||||
WorldClient client = mc.theWorld;
|
WorldClient client = mc.theWorld;
|
||||||
EntityPlayer mainPlayer = mc.thePlayer;
|
EntityPlayer mc_ply = mc.thePlayer;
|
||||||
|
|
||||||
listPlayers = Minecraft.getMinecraft().theWorld.playerEntities;
|
listPlayers = Minecraft.getMinecraft().theWorld.playerEntities;
|
||||||
//Set<Entity> entities = (Set<Entity>)ReflectionHelper.getPrivateValue(WorldClient.class, client, new String[] { "entityList", "field_73032_d", "J" });
|
|
||||||
for (EntityPlayer player : listPlayers) {
|
for (EntityPlayer player : listPlayers) {
|
||||||
if (player != null
|
if (player != null
|
||||||
&& player.isInRangeToRender3d(renderingVector.xCoord, renderingVector.yCoord, renderingVector.zCoord) && (player.ignoreFrustumCheck || frustrum.isBoundingBoxInFrustum(player.boundingBox))
|
&& player.isInRangeToRender3d(renderingVector.xCoord, renderingVector.yCoord, renderingVector.zCoord) && (player.ignoreFrustumCheck || frustrum.isBoundingBoxInFrustum(player.boundingBox))
|
||||||
&& player.isEntityAlive()
|
&& player.isEntityAlive()
|
||||||
&& playerAroundHandcuffed.containsKey(player.getUniqueID())) {
|
&& playerAroundHandcuffed.containsKey(player.getUniqueID())) {
|
||||||
|
|
||||||
|
double distance = Math.sqrt(Math.pow(player.posX - mc_ply.posX, 2) + Math.pow(player.posY - mc_ply.posY, 2));
|
||||||
|
System.out.println("distance: " + distance);
|
||||||
|
if (distance > 10)
|
||||||
|
continue;
|
||||||
|
|
||||||
long time_left = (playerAroundHandcuffed.get(player.getUniqueID()) + (Handcuffed.timeToWait * 1000) - System.currentTimeMillis()) / 1000;
|
long time_left = (playerAroundHandcuffed.get(player.getUniqueID()) + (Handcuffed.timeToWait * 1000) - System.currentTimeMillis()) / 1000;
|
||||||
if (time_left < -Handcuffed.timeToWait)
|
if (time_left < 0 && (!playerAroundUnhandcuffing.containsKey(player.getUniqueID()) || !playerAroundUnhandcuffing.get(player.getUniqueID()))) {
|
||||||
playerAroundHandcuffed.remove(player.getUniqueID());
|
playerAroundHandcuffed.remove(player.getUniqueID());
|
||||||
|
playerAroundUnhandcuffing.remove(player.getUniqueID());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
renderPseudo((EntityLivingBase) player, event.partialTicks, (Entity) cameraEntity, 13816530);
|
renderHandcuff(player, event.partialTicks, cameraEntity, 13816530);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPseudo(EntityLivingBase passedEntity, float partialTicks, Entity viewPoint, int opacity) {
|
public void renderHandcuff(EntityPlayer player, float partialTicks, Entity viewPoint, int opacity) {
|
||||||
if (passedEntity.riddenByEntity != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityPlayer player = (EntityPlayer) passedEntity;
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
float pastTranslate = 0.0F;
|
float pastTranslate = 0.0F;
|
||||||
|
|
||||||
float distance = passedEntity.getDistanceToEntity(viewPoint);
|
double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||||
|
double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||||
double x = passedEntity.lastTickPosX + (passedEntity.posX - passedEntity.lastTickPosX) * partialTicks;
|
double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||||
double y = passedEntity.lastTickPosY + (passedEntity.posY - passedEntity.lastTickPosY) * partialTicks;
|
|
||||||
double z = passedEntity.lastTickPosZ + (passedEntity.posZ - passedEntity.lastTickPosZ) * partialTicks;
|
|
||||||
float scale = 0.026666673F;
|
float scale = 0.026666673F;
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float) (x - RenderManager.renderPosX), (float) (y - RenderManager.renderPosY + passedEntity.height + heightAbove), (float) (z - RenderManager.renderPosZ));
|
GL11.glTranslatef((float) (x - RenderManager.renderPosX), (float) (y - RenderManager.renderPosY + player.height + heightAbove), (float) (z - RenderManager.renderPosZ));
|
||||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||||
GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||||
float viewX = RenderManager.instance.playerViewX;
|
float viewX = RenderManager.instance.playerViewX;
|
||||||
if (passedEntity == mc.thePlayer)
|
if (player == mc.thePlayer)
|
||||||
viewX = Math.min(Math.max(RenderManager.instance.playerViewX, -5), 5);
|
viewX = Math.min(Math.max(RenderManager.instance.playerViewX, -5), 5);
|
||||||
GL11.glRotatef(viewX, 1.0F, 0.0F, 0.0F);
|
GL11.glRotatef(viewX, 1.0F, 0.0F, 0.0F);
|
||||||
//System.out.println(RenderManager.instance.playerViewX);
|
//System.out.println(RenderManager.instance.playerViewX);
|
||||||
|
@ -108,7 +108,7 @@ public class RenderHandcuffIcon extends Gui {
|
||||||
float s = 0.60F;
|
float s = 0.60F;
|
||||||
|
|
||||||
int pos_y = 0;
|
int pos_y = 0;
|
||||||
if (passedEntity == mc.thePlayer)
|
if (player == mc.thePlayer)
|
||||||
pos_y = 120;
|
pos_y = 120;
|
||||||
float size = 20;
|
float size = 20;
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ public class Criminals {
|
||||||
public Criminal addCriminal(EntityPlayer player, long rate) {
|
public Criminal addCriminal(EntityPlayer player, long rate) {
|
||||||
if (gp.isInGalacticPatrol(player))
|
if (gp.isInGalacticPatrol(player))
|
||||||
return null;
|
return null;
|
||||||
|
if (rate <= 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
Criminal criminal = null;
|
Criminal criminal = null;
|
||||||
if (isCriminal(player.getUniqueID())) {
|
if (isCriminal(player.getUniqueID())) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ public class Handcuffed {
|
||||||
public UUID jailer;
|
public UUID jailer;
|
||||||
|
|
||||||
public static long timeToWait = ConfigManager.TIME_TO_GO_IN_JAIL;
|
public static long timeToWait = ConfigManager.TIME_TO_GO_IN_JAIL;
|
||||||
public static long timeToUnhandcuff = ConfigManager.TIME_UNHANDCUFFING;
|
|
||||||
|
|
||||||
public Handcuffed(UUID inmate, UUID jailer) {
|
public Handcuffed(UUID inmate, UUID jailer) {
|
||||||
this(inmate, jailer, System.currentTimeMillis(), false);
|
this(inmate, jailer, System.currentTimeMillis(), false);
|
||||||
|
|
Loading…
Reference in a new issue