Added sneak and mountArmor modifiers
commit
646849e0d4
File diff suppressed because it is too large
Load Diff
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Add your dependencies here. Supported configurations:
|
|
||||||
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
|
|
||||||
* Available at runtime and compiletime for mods depending on this mod
|
|
||||||
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
|
|
||||||
* Available at runtime but not compiletime for mods depending on this mod
|
|
||||||
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
|
|
||||||
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
|
|
||||||
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
|
|
||||||
* Available at compiletime but not runtime for mods depending on this mod
|
|
||||||
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
|
|
||||||
* Not available at all for mods depending on this mod, only visible at runtime for this mod
|
|
||||||
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
|
|
||||||
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
|
|
||||||
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
|
|
||||||
* Available at runtime for mods depending on this mod
|
|
||||||
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
|
|
||||||
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
|
|
||||||
*
|
|
||||||
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
|
|
||||||
* Requires you to enable usesShadowedDependencies in gradle.properties
|
|
||||||
*
|
|
||||||
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
|
|
||||||
*
|
|
||||||
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
|
|
||||||
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
|
|
||||||
*
|
|
||||||
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
|
|
||||||
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
|
|
||||||
*
|
|
||||||
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
|
|
||||||
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
|
|
||||||
*
|
|
||||||
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
|
|
||||||
*/
|
|
||||||
dependencies {
|
|
||||||
implementation files('libs/cindercore.jar')
|
|
||||||
implementation files('libs/lotr.jar')
|
|
||||||
implementation files('libs/optifine.jar')
|
|
||||||
implementation files('libs/variabletriggers.jar')
|
|
||||||
}
|
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
package com.zivilon.cinder_loe.command;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.world.event.Warband;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandFaction;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandBase;
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
||||||
|
import lotr.common.world.map.LOTRWaypoint;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.character.CharacterRoleAPI;
|
||||||
|
import com.zivilon.cinder_loe.util.Utilities;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandWarband extends CommandBase {
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return "warband";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandUsage(ICommandSender sender) {
|
||||||
|
return "/warband <summon/reset> [faction_name] [waypoint] [x] [z]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRequiredPermissionLevel() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCommand(ICommandSender sender, String[] args) {
|
||||||
|
if(!validate_args(args)) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Incorrect arguments. Usage: " + getCommandUsage(sender)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String action = args[0];
|
||||||
|
System.out.println("Checking arg " + action);
|
||||||
|
switch (action) {
|
||||||
|
case "reset":
|
||||||
|
reset_warband();
|
||||||
|
sender.addChatMessage(new ChatComponentText("Warband timer has been reset. A new warband may now spawn."));
|
||||||
|
return;
|
||||||
|
case "list":
|
||||||
|
list_warbands(sender);
|
||||||
|
return;
|
||||||
|
case "summon":
|
||||||
|
summon_warband(sender, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void summon_warband(ICommandSender sender, String[] args) {
|
||||||
|
WarbandFaction faction = WarbandFaction.get_warband_by_name(args[1]);
|
||||||
|
LOTRWaypoint waypoint = null;
|
||||||
|
String waypoint_name = null;
|
||||||
|
int x = 0;
|
||||||
|
int z = 0;
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (!(sender instanceof EntityPlayer)) {
|
||||||
|
System.out.println("Console must specify location to summon warband. Options:");
|
||||||
|
System.out.println("/warband <summon> <faction_name> <waypoint>");
|
||||||
|
System.out.println("/warband <summon> <faction_name> <x> <z>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EntityPlayer player = (EntityPlayer)sender;
|
||||||
|
x = (int)player.posX;
|
||||||
|
z = (int)player.posZ;
|
||||||
|
Warband.initialize_warband(faction, x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 3) {
|
||||||
|
waypoint_name = args[2];
|
||||||
|
waypoint = LOTRWaypoint.waypointForName(waypoint_name);
|
||||||
|
if (waypoint == null) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Invalid waypoint \"" + waypoint_name + "\""));
|
||||||
|
}
|
||||||
|
Warband.initialize_warband(faction, waypoint);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 4) {
|
||||||
|
try {
|
||||||
|
x = Integer.parseInt(args[2]);
|
||||||
|
z = Integer.parseInt(args[3]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Invalid coordinates provided"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Warband.initialize_warband(faction, x, z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 4) {
|
||||||
|
try {
|
||||||
|
x = Integer.parseInt(args[3]);
|
||||||
|
z = Integer.parseInt(args[4]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Invalid coordinates provided"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waypoint_name = args[2];
|
||||||
|
waypoint = LOTRWaypoint.waypointForName(waypoint_name);
|
||||||
|
if (waypoint == null) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Invalid waypoint \"" + waypoint_name + "\""));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Warband.initialize_warband(faction, waypoint, x, z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean validate_args(String[] args) {
|
||||||
|
System.out.println("Validating...");
|
||||||
|
if (args.length < 1) return false;
|
||||||
|
String action = "";
|
||||||
|
System.out.println("Checking arg \"" + args[0] + "\"");
|
||||||
|
if (args[0].equals("summon") || args[0].equals("reset") || args[0].equals("list")) {
|
||||||
|
action = args[0];
|
||||||
|
} else {
|
||||||
|
System.out.println("Failed test 1");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (action.equals("summon")) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
System.out.println("Failed test 2");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WarbandFaction faction = WarbandFaction.get_warband_by_name(args[1]);
|
||||||
|
if (faction == null) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reset_warband() {
|
||||||
|
// Set last warband to have happened 10 hours ago, thus allowing new warband
|
||||||
|
Warband.last_warband_timestamp = System.currentTimeMillis() / 1000L - (60*60*10);
|
||||||
|
}
|
||||||
|
public static void list_warbands(ICommandSender sender) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("List of valid warbands:"));
|
||||||
|
for (WarbandFaction faction : WarbandFaction.values()) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("- " + faction.name()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.zivilon.cinder_loe.mixins;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.util.IEntityLivingBase;
|
||||||
|
|
||||||
|
import lotr.common.entity.npc.LOTREntityOrc;
|
||||||
|
import lotr.common.entity.ai.LOTREntityAIOrcSkirmish;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.*;
|
||||||
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||||
|
|
||||||
|
@Mixin(LOTREntityAIOrcSkirmish.class)
|
||||||
|
public class MixinLOTREntityAIOrcSkirmish {
|
||||||
|
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
private boolean canOrcSkirmish(EntityLivingBase entity) {
|
||||||
|
if (entity instanceof LOTREntityOrc) {
|
||||||
|
LOTREntityOrc orc = (LOTREntityOrc)entity;
|
||||||
|
if (((IEntityLivingBase)orc).get_warband_uuid() != null) return false;
|
||||||
|
return (!orc.isTrader() && !orc.hiredNPCInfo.isActive && orc.ridingEntity == null && orc.canOrcSkirmish());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
package com.zivilon.cinder_loe.mixins;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.CinderLoE;
|
||||||
|
import com.zivilon.cinder_loe.client.model.*;
|
||||||
|
import com.zivilon.cinder_loe.entity.Renegade;
|
||||||
|
import com.zivilon.cinder_loe.util.IEntityLivingBase;
|
||||||
|
import com.zivilon.cinder_loe.util.Utilities;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.EntityCreature;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.IEntityLivingData;
|
||||||
|
import net.minecraft.entity.IRangedAttackMob;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
|
import lotr.common.entity.npc.LOTREntityNPC;
|
||||||
|
import lotr.common.entity.ai.LOTREntityAIRangedAttack;
|
||||||
|
import lotr.common.item.LOTRItemSpear;
|
||||||
|
import lotr.common.item.LOTRWeaponStats;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Mixin(LOTREntityAIRangedAttack.class)
|
||||||
|
public class MixinLOTREntityAIRangedAttack {
|
||||||
|
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private EntityLiving theOwner;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private IRangedAttackMob theOwnerRanged;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private EntityLivingBase attackTarget;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int rangedAttackTime;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private double moveSpeed;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private double moveSpeedFlee = 1.5D;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int repathDelay;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int attackTimeMin;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int attackTimeMax;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private float attackRange;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private float attackRangeSq;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
public static Vec3 findPositionAwayFrom(EntityLivingBase entity, EntityLivingBase target, int min, int max) {return null;}
|
||||||
|
|
||||||
|
public UUID leader_id;
|
||||||
|
public Entity leader;
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
public void updateTask() {
|
||||||
|
if (warband_task()) return;
|
||||||
|
update_vanilla_task();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean warband_task() {
|
||||||
|
EntityLiving entity = this.theOwner;
|
||||||
|
UUID leader_id = ((IEntityLivingBase)entity).get_warband_uuid();
|
||||||
|
|
||||||
|
if (leader_id != null) {
|
||||||
|
if (leader == null)
|
||||||
|
leader = Utilities.find_entity_by_uuid(entity.worldObj, leader_id);
|
||||||
|
if (leader != null && entity.getDistanceSqToEntity(leader) > 576.0D) {
|
||||||
|
entity.setAttackTarget(null);
|
||||||
|
entity.getNavigator().tryMoveToEntityLiving(leader, 1.3D);
|
||||||
|
return true; // Return here to not run default logic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_vanilla_task() {
|
||||||
|
double distanceSq = this.theOwner.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
|
||||||
|
boolean canSee = this.theOwner.getEntitySenses().canSee((Entity)this.attackTarget);
|
||||||
|
if (canSee) {
|
||||||
|
this.repathDelay++;
|
||||||
|
} else {
|
||||||
|
this.repathDelay = 0;
|
||||||
|
}
|
||||||
|
if (distanceSq <= this.attackRangeSq) {
|
||||||
|
if (this.theOwner.getDistanceSqToEntity((Entity)this.attackTarget) < 25.0D) {
|
||||||
|
Vec3 vec = findPositionAwayFrom((EntityLivingBase)this.theOwner, this.attackTarget, 8, 16);
|
||||||
|
if (vec != null)
|
||||||
|
this.theOwner.getNavigator().tryMoveToXYZ(vec.xCoord, vec.yCoord, vec.zCoord, this.moveSpeedFlee);
|
||||||
|
} else if (this.repathDelay >= 20) {
|
||||||
|
this.theOwner.getNavigator().clearPathEntity();
|
||||||
|
this.repathDelay = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.theOwner.getNavigator().tryMoveToEntityLiving((Entity)this.attackTarget, this.moveSpeed);
|
||||||
|
}
|
||||||
|
this.theOwner.getLookHelper().setLookPositionWithEntity((Entity)this.attackTarget, 30.0F, 30.0F);
|
||||||
|
this.rangedAttackTime--;
|
||||||
|
if (this.rangedAttackTime == 0) {
|
||||||
|
if (distanceSq > this.attackRangeSq || !canSee)
|
||||||
|
return;
|
||||||
|
float distanceRatio = MathHelper.sqrt_double(distanceSq) / this.attackRange;
|
||||||
|
float power = distanceRatio;
|
||||||
|
power = MathHelper.clamp_float(power, 0.1F, 1.0F);
|
||||||
|
this.theOwnerRanged.attackEntityWithRangedAttack(this.attackTarget, power);
|
||||||
|
this.rangedAttackTime = MathHelper.floor_float(distanceRatio * (this.attackTimeMax - this.attackTimeMin) + this.attackTimeMin);
|
||||||
|
} else if (this.rangedAttackTime < 0) {
|
||||||
|
float distanceRatio = MathHelper.sqrt_double(distanceSq) / this.attackRange;
|
||||||
|
this.rangedAttackTime = MathHelper.floor_float(distanceRatio * (this.attackTimeMax - this.attackTimeMin) + this.attackTimeMin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,139 @@
|
|||||||
|
package com.zivilon.cinder_loe.mixins;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.world.event.Warband;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandTracker;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandLocationInfo;
|
||||||
|
|
||||||
|
import lotr.client.gui.LOTRGuiMap;
|
||||||
|
import lotr.client.gui.LOTRGuiMenuBase;
|
||||||
|
import lotr.client.LOTRClientProxy;
|
||||||
|
import lotr.common.LOTRLevelData;
|
||||||
|
import lotr.common.fac.LOTRFaction;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.*;
|
||||||
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(LOTRGuiMap.class)
|
||||||
|
public abstract class MixinLOTRGuiMap extends LOTRGuiMenuBase {
|
||||||
|
private static Map<UUID, WarbandLocationInfo> warband_locations = WarbandTracker.locations;
|
||||||
|
private static ResourceLocation WARBAND_ICON = new ResourceLocation("cinderloe", "textures/gui/alignment.png");
|
||||||
|
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private boolean loadingConquestGrid;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private boolean hasOverlay;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private static int mapXMin;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private static int mapXMax;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private static int mapYMin;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private static int mapYMax;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private void drawFancyRect(int x1, int y1, int x2, int y2) {}
|
||||||
|
@Shadow(remap = false)
|
||||||
|
public float[] transformCoords(float x, float z) { return null;}
|
||||||
|
|
||||||
|
@Inject(method = "func_73863_a", at = @At("HEAD"), remap = false)
|
||||||
|
public void inject_head(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
|
||||||
|
System.out.println("[MixinLOTRGuiMap] Inject at HEAD");
|
||||||
|
}
|
||||||
|
@Inject(method = "func_73863_a", at = @At( value = "INVOKE", target = "renderPlayers(II)V", shift = At.Shift.AFTER), remap = false)
|
||||||
|
public void inject_render_warbands(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
|
||||||
|
System.out.println("[MixinLOTRGuiMap] Running wrapper");
|
||||||
|
render_warbands(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Dynamic
|
||||||
|
private void render_warbands(int cursor_x, int cursor_y) {
|
||||||
|
System.out.println("[MixinLOTRGuiMap] Rendering warband icon");
|
||||||
|
String mouse_over_warband_name = null;
|
||||||
|
double mouse_over_warband_x = 0.0D;
|
||||||
|
double mouse_over_warband_y = 0.0D;
|
||||||
|
double shortest_distance_to_cursor = Double.MAX_VALUE;
|
||||||
|
int icon_width_half = 4;
|
||||||
|
for (Map.Entry<UUID, WarbandLocationInfo> entry : warband_locations.entrySet()) {
|
||||||
|
System.out.println("[MixinLOTRGuiMap] Iterated");
|
||||||
|
WarbandLocationInfo info = entry.getValue();
|
||||||
|
Warband warband = info.warband;
|
||||||
|
String warband_name = warband.faction.warband_name;
|
||||||
|
float[] pos = transformCoords((float)info.x, (float)info.z);
|
||||||
|
int map_x = Math.round(pos[0]);
|
||||||
|
int map_y = Math.round(pos[1]);
|
||||||
|
|
||||||
|
double distance_to_icon = render_warband_icon(warband, map_x, map_y, cursor_x, cursor_y);
|
||||||
|
if (distance_to_icon <= (icon_width_half + 3)) {
|
||||||
|
if (distance_to_icon <= shortest_distance_to_cursor) {
|
||||||
|
mouse_over_warband_name = StatCollector.translateToLocal(warband_name);
|
||||||
|
mouse_over_warband_x = map_x;
|
||||||
|
mouse_over_warband_y = map_y;
|
||||||
|
shortest_distance_to_cursor = distance_to_icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mouse_over_warband_name != null && !this.hasOverlay && !this.loadingConquestGrid) {
|
||||||
|
int name_width = this.mc.fontRenderer.getStringWidth(mouse_over_warband_name);
|
||||||
|
int name_height = this.mc.fontRenderer.FONT_HEIGHT;
|
||||||
|
int namebox_x = (int)Math.round(mouse_over_warband_x);
|
||||||
|
int namebox_y = (int)Math.round(mouse_over_warband_y);
|
||||||
|
namebox_y += icon_width_half + 3;
|
||||||
|
int border = 3;
|
||||||
|
int namebox_width = name_width + border * 2;
|
||||||
|
namebox_x -= namebox_width / 2;
|
||||||
|
int namebox_height = name_height + border * 2;
|
||||||
|
int map_border = 2;
|
||||||
|
namebox_x = Math.max(namebox_x, mapXMin + map_border);
|
||||||
|
namebox_x = Math.min(namebox_x, mapXMax - map_border - namebox_width);
|
||||||
|
namebox_y = Math.max(namebox_y, mapYMin + map_border);
|
||||||
|
namebox_y = Math.min(namebox_y, mapYMax - map_border - namebox_height);
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, 300.0F);
|
||||||
|
drawFancyRect(namebox_x, namebox_y, namebox_x + namebox_width, namebox_y + namebox_height);
|
||||||
|
this.mc.fontRenderer.drawString(mouse_over_warband_name, namebox_x + border, namebox_y + border, 16777215);
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, -300.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Dynamic
|
||||||
|
private double render_warband_icon(Warband warband, double map_x, double map_y, int mouse_x, int mouse_y) {
|
||||||
|
int icon_half = 4;
|
||||||
|
int icon_border = icon_half + 1;
|
||||||
|
|
||||||
|
map_x = Math.max(mapXMin + icon_border, Math.min(mapXMax - icon_border - 1, map_x));
|
||||||
|
map_y = Math.max(mapYMin + icon_border, Math.min(mapYMax - icon_border - 1, map_y));
|
||||||
|
|
||||||
|
// Determine ally/enemy icon
|
||||||
|
LOTRFaction faction = warband.faction.faction;
|
||||||
|
float alignment = LOTRLevelData.getData(mc.thePlayer).getAlignment(faction);
|
||||||
|
boolean is_ally = alignment > 0.0F;
|
||||||
|
|
||||||
|
load_warband_icon(is_ally, (int) map_x, (int) map_y);
|
||||||
|
|
||||||
|
// Return mouse distance to icon
|
||||||
|
double dx = map_x - mouse_x;
|
||||||
|
double dy = map_y - mouse_y;
|
||||||
|
return Math.hypot(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Dynamic
|
||||||
|
private void load_warband_icon(boolean ally, int x, int y) {
|
||||||
|
System.out.println("[MixinLOTRGuiMap] Loading warband icon: " + (ally ? "ally" : "enemy"));
|
||||||
|
mc.getTextureManager().bindTexture(LOTRClientProxy.alignmentTexture);
|
||||||
|
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||||
|
int variant = ally ? 16 : 0;
|
||||||
|
drawTexturedModalRect(x - 8, y - 8, variant, 228, 16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.zivilon.cinder_loe.network;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.network.PacketWarbandLocations.Handler;
|
||||||
|
import lotr.common.network.LOTRPacketHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
|
||||||
|
public class PacketRegistration {
|
||||||
|
public static void register() {
|
||||||
|
int id = 200;
|
||||||
|
LOTRPacketHandler.networkWrapper.registerMessage(PacketWarbandLocations.Handler.class, PacketWarbandLocations.class, id++, Side.CLIENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
package com.zivilon.cinder_loe.network;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.world.event.Warband;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandFaction;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandLocationInfo;
|
||||||
|
import com.zivilon.cinder_loe.world.event.WarbandTracker;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lotr.common.LOTRMod;
|
||||||
|
import lotr.common.network.LOTRPacketHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTUtil;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class PacketWarbandLocations implements IMessage {
|
||||||
|
public List<WarbandLocationInfo> locations = WarbandTracker.get_all();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeShort(locations.size());
|
||||||
|
for (WarbandLocationInfo loc : locations) {
|
||||||
|
buf.writeLong(loc.warband.warband_uuid.getMostSignificantBits());
|
||||||
|
buf.writeLong(loc.warband.warband_uuid.getLeastSignificantBits());
|
||||||
|
buf.writeDouble(loc.x);
|
||||||
|
buf.writeDouble(loc.z);
|
||||||
|
PacketBuffer packet = new PacketBuffer(buf);
|
||||||
|
write_string_to_buffer(packet, loc.warband.faction.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
locations.clear();
|
||||||
|
int count = buf.readShort();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
long msb = buf.readLong();
|
||||||
|
long lsb = buf.readLong();
|
||||||
|
UUID uuid = new UUID(msb, lsb);
|
||||||
|
double x = buf.readDouble();
|
||||||
|
double z = buf.readDouble();
|
||||||
|
|
||||||
|
PacketBuffer packet = new PacketBuffer(buf);
|
||||||
|
String faction_name = read_string_from_buffer(packet, Short.MAX_VALUE);
|
||||||
|
|
||||||
|
WarbandFaction faction = WarbandFaction.get_warband_by_name(faction_name);
|
||||||
|
|
||||||
|
Warband dummy = new Warband();
|
||||||
|
dummy.warband_uuid = uuid;
|
||||||
|
dummy.faction = faction;
|
||||||
|
dummy.x = (int) x;
|
||||||
|
dummy.z = (int) z;
|
||||||
|
locations.add(new WarbandLocationInfo(dummy, x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Handler implements IMessageHandler<PacketWarbandLocations, IMessage> {
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(PacketWarbandLocations message, MessageContext ctx) {
|
||||||
|
if (ctx.side.isServer()) {
|
||||||
|
System.out.println("[PacketWarbandLocations] WARNING: Client tried to update locations on server!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarbandTracker.clear_locations();
|
||||||
|
for (WarbandLocationInfo info : message.locations) {
|
||||||
|
WarbandTracker.add(info);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void send_warband_locations(World world) {
|
||||||
|
for (int i = 0; i < world.playerEntities.size(); i++) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer)world.playerEntities.get(i);
|
||||||
|
send_location(entityplayer, world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void send_location(EntityPlayer player, World world) {
|
||||||
|
PacketWarbandLocations locations = new PacketWarbandLocations();
|
||||||
|
LOTRPacketHandler.networkWrapper.sendTo((IMessage)locations, (EntityPlayerMP)player);
|
||||||
|
}
|
||||||
|
public static void write_string_to_buffer(PacketBuffer buffer, String string) {
|
||||||
|
try {
|
||||||
|
buffer.writeStringToBuffer(string);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("[PacketWarbandLocations] WARNING: Failed to write warband faction", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String read_string_from_buffer(PacketBuffer buffer, int max_length) {
|
||||||
|
try {
|
||||||
|
return buffer.readStringFromBuffer(max_length);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("[PacketWarbandLocations] WARNING: Failed to read warband faction", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.zivilon.cinder_loe.world.event;
|
||||||
|
|
||||||
|
public class WarbandLocationInfo {
|
||||||
|
public Warband warband;
|
||||||
|
public double x;
|
||||||
|
public double z;
|
||||||
|
|
||||||
|
public WarbandLocationInfo(Warband warband, double x, double z) {
|
||||||
|
this.warband = warband;
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.zivilon.cinder_loe.world.event;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class WarbandTracker {
|
||||||
|
public static Map<UUID, WarbandLocationInfo> locations = new HashMap<>();
|
||||||
|
|
||||||
|
public static void clear_locations() {
|
||||||
|
locations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void add(Warband warband) {
|
||||||
|
locations.put(warband.warband_uuid, new WarbandLocationInfo(warband, warband.x, warband.z));
|
||||||
|
}
|
||||||
|
public static void add(WarbandLocationInfo info) {
|
||||||
|
locations.put(info.warband.warband_uuid, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(UUID uuid) {
|
||||||
|
locations.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<WarbandLocationInfo> get_all() {
|
||||||
|
return new ArrayList<>(locations.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 608 B |
Binary file not shown.
|
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 578 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 654 B |
Loading…
Reference in New Issue