Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
44612c402e | ||
![]() |
9b7b8131be | ||
![]() |
32e081936c | ||
![]() |
ae2e652a47 | ||
![]() |
d53d2381f2 | ||
![]() |
701fca83b6 | ||
![]() |
ccfcb79526 |
|
@ -24,7 +24,7 @@ apply plugin: 'forge'
|
|||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
version = "1.0.1"
|
||||
version = "1.2.4"
|
||||
group = "xamora.gp_dbc" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "gp_dbc"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Main
|
|||
public static GalacticPatrol gp = new GalacticPatrol();
|
||||
|
||||
public static final String MODID = "gp_dbc";
|
||||
public static final String VERSION = "0.0.1";
|
||||
public static final String VERSION = "1.0.2";
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
|
|
|
@ -96,11 +96,11 @@ public class CommandGP implements ICommand {
|
|||
|
||||
int error = 0;
|
||||
|
||||
if (arg.equals(COMMANDS[0])) // Add
|
||||
if (arg.equalsIgnoreCase(COMMANDS[0])) // Add
|
||||
error = gp.addToGalaticPatrol(player, true);
|
||||
else if (arg.equals(COMMANDS[1])) // Remove
|
||||
else if (arg.equalsIgnoreCase(COMMANDS[1])) // Remove
|
||||
error = gp.removeFromGalacticPatrol(player);
|
||||
else if (arg.equals(COMMANDS[2])) { // Inmate
|
||||
else if (arg.equalsIgnoreCase(COMMANDS[2])) { // Inmate
|
||||
if (args.size() != 1) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "/gp inmate sec [<player>]"));
|
||||
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);
|
||||
}
|
||||
else if (arg.equals(COMMANDS[4])) {// RemoveJail
|
||||
else if (arg.equalsIgnoreCase(COMMANDS[4])) {// RemoveJail
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
error = gp.jail.removeCell(Integer.parseInt(args.get(0)));
|
||||
|
@ -138,19 +138,21 @@ public class CommandGP implements ICommand {
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (arg.equals(COMMANDS[5])) { // addCriminal
|
||||
else if (arg.equalsIgnoreCase(COMMANDS[5])) { // addCriminal
|
||||
long rate = 0;
|
||||
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
rate = Long.parseLong(args.get(0));
|
||||
error = gp.criminals.addCriminal(player, rate) != null ? 0 : 1;
|
||||
} catch (Exception 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ConfigManager {
|
|||
static public double MULT_JAIL_TIME = 17.28; // 17.28 * 10 000 = 48 hours
|
||||
static public int REDUCE_ALIGN_KILL = 33;
|
||||
|
||||
// 7.2 * 24000 = 172 800 = 48h
|
||||
// 17.28 * 10 000 = 48 hours
|
||||
static public int MAX_RATE_CRIMINAL = 10000;
|
||||
static public long RATE_CRIMINAL_NOT_SAFE = 5000; // Not use
|
||||
static public int RATE_TO_HAVE_POSITION = 1000;
|
||||
|
|
|
@ -3,6 +3,7 @@ package xamora.gp_dbc.gui;
|
|||
import JinRyuu.JRMCore.JRMCoreH;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.config.ConfigManager;
|
||||
import xamora.gp_dbc.system.Handcuffed;
|
||||
import xamora.gp_dbc.utils.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -47,8 +48,8 @@ public class GuiHandcuffed extends Gui {
|
|||
|
||||
if (event.isCancelable())
|
||||
return;
|
||||
//if (time_left < -timeToWait)
|
||||
//return;
|
||||
if (time_left < -Handcuffed.timeToWait)
|
||||
handcuffed = false;
|
||||
|
||||
if (JRMCoreH.ko <= 0)
|
||||
return;
|
||||
|
|
|
@ -171,7 +171,7 @@ public class ItemGPHandcuff extends Item {
|
|||
long timeUsing = (System.currentTimeMillis() - timeStart) / 1000;
|
||||
if (useRemaining <= 0)
|
||||
return getIcon(stack, renderPass);
|
||||
else if (timeUsing >= 0 && timeUsing < TIME_HANDCUFFING )
|
||||
else if (timeUsing >= 0 && timeUsing < TIME_HANDCUFFING + 1 )
|
||||
return open;
|
||||
else
|
||||
return close;
|
||||
|
|
|
@ -4,7 +4,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import xamora.gp_dbc.Main;
|
||||
import xamora.gp_dbc.system.Handcuff;
|
||||
import xamora.gp_dbc.system.Handcuffed;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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;
|
||||
frustrum.setPosition(viewX, viewY, viewZ);
|
||||
WorldClient client = mc.theWorld;
|
||||
EntityPlayer mainPlayer = mc.thePlayer;
|
||||
EntityPlayer mc_ply = mc.thePlayer;
|
||||
|
||||
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) {
|
||||
if (player != null
|
||||
&& player.isInRangeToRender3d(renderingVector.xCoord, renderingVector.yCoord, renderingVector.zCoord) && (player.ignoreFrustumCheck || frustrum.isBoundingBoxInFrustum(player.boundingBox))
|
||||
&& player.isEntityAlive()
|
||||
&& 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;
|
||||
if (time_left < -Handcuffed.timeToWait)
|
||||
if (time_left < 0 && (!playerAroundUnhandcuffing.containsKey(player.getUniqueID()) || !playerAroundUnhandcuffing.get(player.getUniqueID()))) {
|
||||
playerAroundHandcuffed.remove(player.getUniqueID());
|
||||
playerAroundUnhandcuffing.remove(player.getUniqueID());
|
||||
}
|
||||
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) {
|
||||
if (passedEntity.riddenByEntity != null)
|
||||
return;
|
||||
public void renderHandcuff(EntityPlayer player, float partialTicks, Entity viewPoint, int opacity) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) passedEntity;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
float pastTranslate = 0.0F;
|
||||
|
||||
float distance = passedEntity.getDistanceToEntity(viewPoint);
|
||||
|
||||
double x = passedEntity.lastTickPosX + (passedEntity.posX - passedEntity.lastTickPosX) * partialTicks;
|
||||
double y = passedEntity.lastTickPosY + (passedEntity.posY - passedEntity.lastTickPosY) * partialTicks;
|
||||
double z = passedEntity.lastTickPosZ + (passedEntity.posZ - passedEntity.lastTickPosZ) * partialTicks;
|
||||
double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
float scale = 0.026666673F;
|
||||
|
||||
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.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
float viewX = RenderManager.instance.playerViewX;
|
||||
if (passedEntity == mc.thePlayer)
|
||||
if (player == mc.thePlayer)
|
||||
viewX = Math.min(Math.max(RenderManager.instance.playerViewX, -5), 5);
|
||||
GL11.glRotatef(viewX, 1.0F, 0.0F, 0.0F);
|
||||
//System.out.println(RenderManager.instance.playerViewX);
|
||||
|
@ -108,7 +108,7 @@ public class RenderHandcuffIcon extends Gui {
|
|||
float s = 0.60F;
|
||||
|
||||
int pos_y = 0;
|
||||
if (passedEntity == mc.thePlayer)
|
||||
if (player == mc.thePlayer)
|
||||
pos_y = 120;
|
||||
float size = 20;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package xamora.gp_dbc.system;
|
|||
|
||||
import xamora.gp_dbc.utils.Pos;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import xamora.gp_dbc.utils.TeleportUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -83,9 +84,7 @@ public class Cell {
|
|||
|
||||
public void tpTo(EntityPlayer player) {
|
||||
Pos pos = getPos();
|
||||
if (player.dimension != pos.dimension)
|
||||
player.travelToDimension(pos.dimension);
|
||||
player.setPositionAndUpdate(pos.x + 0.5, pos.y + 1, pos.z + 0.5);
|
||||
TeleportUtils.teleportDimension(player, pos.x + 0.5, pos.y + 1, pos.z + 0.5, pos.dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package xamora.gp_dbc.system;
|
||||
|
||||
import JinRyuu.JRMCore.JRMCoreH;
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import com.forgeessentials.chat.ModuleChat;
|
||||
import xamora.gp_dbc.Main;
|
||||
|
@ -8,6 +9,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import xamora.gp_dbc.config.ConfigManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static xamora.gp_dbc.config.ConfigManager.*;
|
||||
|
@ -20,6 +23,8 @@ public class Criminal {
|
|||
private long last_time_pos;
|
||||
private Pos last_pos;
|
||||
|
||||
public HashMap<UUID, Integer> victims_alignLoose = new HashMap<>();
|
||||
|
||||
public Criminal(EntityPlayer player) {
|
||||
this(player, 0);
|
||||
}
|
||||
|
@ -42,11 +47,24 @@ public class Criminal {
|
|||
|
||||
public void addKill(EntityPlayer killed) {
|
||||
JGPlayerMP jgKilled = new JGPlayerMP(killed);
|
||||
NBTTagCompound nbt = jgKilled.connectBaseNBT();
|
||||
long add = Math.max(jgKilled.getAlignment() - 33, 0);
|
||||
jgKilled.connectBaseNBT();
|
||||
int add = Math.max(jgKilled.getAlignment() - 33, 0);
|
||||
if (Main.gp.isInGalacticPatrol(killed))
|
||||
add *= 2;
|
||||
rate += add;
|
||||
|
||||
victims_alignLoose.put(killed.getUniqueID(), add);
|
||||
}
|
||||
|
||||
public boolean cancelVictim(UUID killed) {
|
||||
if (!victims_alignLoose.containsKey(killed))
|
||||
return false;
|
||||
|
||||
int align = victims_alignLoose.get(killed);
|
||||
rate -= align;
|
||||
victims_alignLoose.remove(killed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Jail in second
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package xamora.gp_dbc.system;
|
||||
|
||||
import JinRyuu.JRMCore.server.JGPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fastcraft.U;
|
||||
import xamora.gp_dbc.config.ConfigManager;
|
||||
import xamora.gp_dbc.utils.Data;
|
||||
import xamora.gp_dbc.utils.PlayerUtils;
|
||||
|
@ -13,6 +15,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -52,16 +55,30 @@ public class Criminals {
|
|||
return;
|
||||
}
|
||||
|
||||
Criminal criminal = null;
|
||||
if (isCriminal(killer.getUniqueID()))
|
||||
criminal = getCriminal(killer.getUniqueID());
|
||||
else
|
||||
criminal = addCriminal(killer, 0);
|
||||
JGPlayerMP jgKilled = new JGPlayerMP(dead);
|
||||
jgKilled.connectBaseNBT();
|
||||
if (jgKilled.getAlignment() < 33)
|
||||
return;
|
||||
|
||||
if (isCriminal(killer.getUniqueID()))
|
||||
getCriminal(killer.getUniqueID()).addKill(dead);
|
||||
else
|
||||
addCriminal(killer, 0).addKill(dead);
|
||||
|
||||
criminal.addKill(dead);
|
||||
Data.saveDataString(listCriminalToString(criminals), "criminals");
|
||||
}
|
||||
|
||||
public boolean cancelVictim(UUID killer, UUID dead) {
|
||||
if (!isCriminal(killer))
|
||||
return false;
|
||||
Criminal criminal = getCriminal(killer);
|
||||
boolean canceled = criminal.cancelVictim(dead);
|
||||
if (criminal.getRate() <= 0)
|
||||
criminals.remove(criminal);
|
||||
|
||||
return canceled;
|
||||
}
|
||||
|
||||
public Criminal getCriminal(UUID uuid) {
|
||||
for (Criminal criminal : criminals)
|
||||
if (criminal.getUuid().equals(uuid))
|
||||
|
@ -78,7 +95,7 @@ public class Criminals {
|
|||
if (gp.isInGalacticPatrol(player))
|
||||
return null;
|
||||
|
||||
Criminal criminal = null;
|
||||
Criminal criminal;
|
||||
if (isCriminal(player.getUniqueID())) {
|
||||
criminal = getCriminal(player.getUniqueID());
|
||||
criminal.setRate(criminal.getRate() + rate);
|
||||
|
|
|
@ -4,6 +4,7 @@ import xamora.gp_dbc.Main;
|
|||
import xamora.gp_dbc.config.ConfigManager;
|
||||
import xamora.gp_dbc.utils.Data;
|
||||
import xamora.gp_dbc.utils.Pos;
|
||||
import xamora.gp_dbc.utils.TeleportUtils;
|
||||
import xamora.gp_dbc.utils.TimeUtils;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -221,9 +222,7 @@ public class Jail {
|
|||
|
||||
public void tpOutOfJail(EntityPlayer player) {
|
||||
Pos pos = ConfigManager.pos_exit_jail;
|
||||
if (player.dimension != pos.dimension)
|
||||
player.travelToDimension(pos.dimension);
|
||||
player.setPositionAndUpdate(pos.x + 0.5, pos.y, pos.z + 0.5);
|
||||
TeleportUtils.teleportDimension(player, pos.x + 0.5, pos.y + 1, pos.z + 0.5, pos.dimension);
|
||||
}
|
||||
|
||||
public Cell getRandomCell() throws Exception {
|
||||
|
|
|
@ -24,7 +24,7 @@ import static xamora.gp_dbc.Main.gp;
|
|||
public class JailEvent {
|
||||
|
||||
int tick_time = 0;
|
||||
final int SLOWTICK_MAX = 20;//2000;
|
||||
final int SLOWTICK_MAX = 100;
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
|
@ -108,12 +108,12 @@ public class JailEvent {
|
|||
|
||||
@SideOnly(Side.SERVER)
|
||||
@SubscribeEvent
|
||||
public void checkDeathCancel(LivingHurtEvent event) {
|
||||
public void checkHurtCancel(LivingHurtEvent event) {
|
||||
if (!(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer)event.entity;
|
||||
if (gp.jail.isInJail(player))
|
||||
if (gp.jail.isInJail(player) || Handcuff.isHandcuffed(player))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class Data {
|
|||
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path, true));
|
||||
|
||||
for (int i = 0; i < list.size() - 2; i++)
|
||||
for (int i = 0; i < list.size() - 1; i++)
|
||||
bufferedWriter.write(list.get(i) + "\n");
|
||||
if (list.size() > 0)
|
||||
bufferedWriter.write(list.get(list.size() - 1));
|
||||
|
|
42
src/main/java/xamora/gp_dbc/utils/TeleportUtils.java
Normal file
42
src/main/java/xamora/gp_dbc/utils/TeleportUtils.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package xamora.gp_dbc.utils;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class TeleportUtils extends Teleporter
|
||||
{
|
||||
|
||||
private final WorldServer worldServerInstance;
|
||||
|
||||
public TeleportUtils(WorldServer par1WorldServer) {
|
||||
super(par1WorldServer);
|
||||
this.worldServerInstance = par1WorldServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInPortal(Entity entity, double p2, double p3, double p4, float p5) {
|
||||
int i = MathHelper.floor_double(entity.posX);
|
||||
int j = MathHelper.floor_double(entity.posY);
|
||||
int k = MathHelper.floor_double(entity.posZ);
|
||||
|
||||
this.worldServerInstance.getBlock(i, j, k); //dummy load to maybe gen chunk
|
||||
int height = this.worldServerInstance.getHeightValue(i, k);
|
||||
entity.setPosition( i, height, k );
|
||||
return;
|
||||
|
||||
} // dont do ANY portal junk, just grab a dummy block then SHOVE the player setPosition() at height
|
||||
|
||||
public static void teleportDimension(EntityPlayer player, double x, double y, double z, int dimension) {
|
||||
MinecraftServer ms = MinecraftServer.getServer();
|
||||
WorldServer ws = ms.worldServerForDimension(dimension);
|
||||
Teleporter teleporter = new TeleportUtils(ws);
|
||||
ms.getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) player, dimension, teleporter);
|
||||
player.setPositionAndUpdate(x + 0.5, y, z + 0.5);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue