2
0
Fork 0

Added sneak and mountArmor modifiers

main
s 7 months ago
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')
}

@ -1,153 +1,31 @@
modName = CinderLoE
modVersion = 1.4.0
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
modId = cinder_loe
modGroup = com.zivilon.cinder_loe
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task.
channel = stable
mappingsVersion = 12
# Define other MCP mappings for dependency deobfuscation
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience
# Turns most publicly visible List, Map, etc. into proper List<Type>, Map<K, V> types
enableGenericInjection = false
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
generateGradleTokenClass = com.zivilon.cinder_loe.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenVersion =
gradleTokenGroupName = GROUPNAME
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = true
# Adds some debug arguments like verbose output and export
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage = mixins
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass = coremod.CoreMod
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories
includeWellKnownRepositories = false
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USERNAME and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = false
# mavenPublishUrl = http://jenkins.usrv.eu:8081/nexus/content/repositories/releases
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish on Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
customArchiveBaseName = CinderLoE
# Optional parameter to prevent the source code from being published
# noPublishedSources =
# Uncomment this to disable spotless checks
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
disableSpotless = true
# Uncomment this to disable checkstyle checks (currently wildcard import check).
disableCheckstyle = true
# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea

@ -2,12 +2,15 @@ package com.zivilon.cinder_loe;
import com.zivilon.cinder_loe.entity.corrupt.CorruptMan;
import com.zivilon.cinder_loe.items.BrokenHalo;
import com.zivilon.cinder_loe.network.PacketWarbandLocations;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFuelHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import lotr.common.LOTRMod;
import lotr.common.LOTRDimension;
import lotr.common.enchant.LOTREnchantment;
import lotr.common.enchant.LOTREnchantmentHelper;
import lotr.common.item.*;
@ -32,6 +35,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@ -47,6 +51,23 @@ public class CinderEventHandler implements IFuelHandler {
MinecraftForge.TERRAIN_GEN_BUS.register(this);
GameRegistry.registerFuelHandler(this);
}
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent event) {
World world = event.world;
if (world.isRemote)
return;
if (event.phase == TickEvent.Phase.END) {
if (world == DimensionManager.getWorld(LOTRDimension.MIDDLE_EARTH.dimensionID)) {
if (!world.playerEntities.isEmpty()) {
if (world.getTotalWorldTime() % 20L == 0L) {
PacketWarbandLocations.send_warband_locations(world);
}
}
}
}
}
@SubscribeEvent
public void onArrowLoose(ArrowLooseEvent event) {
Entity attacker = event.entityLiving;

@ -7,6 +7,7 @@ import com.zivilon.cinder_loe.client.render.*;
import com.zivilon.cinder_loe.client.render.corrupt.*;
import com.zivilon.cinder_loe.client.render.projectile.*;
import com.zivilon.cinder_loe.command.CommandCinderCharacter;
import com.zivilon.cinder_loe.command.CommandWarband;
import com.zivilon.cinder_loe.entity.*;
import com.zivilon.cinder_loe.entity.corrupt.*;
import com.zivilon.cinder_loe.entity.npc.*;
@ -23,6 +24,7 @@ import com.zivilon.cinder_loe.entity.npc.radagast.*;
import com.zivilon.cinder_loe.entity.projectile.*;
import com.zivilon.cinder_loe.entity.trader.*;
import com.zivilon.cinder_loe.items.*;
import com.zivilon.cinder_loe.network.*;
import com.zivilon.cinder_loe.potion.LoEPotions;
import com.zivilon.cinder_loe.tileentity.*;
import com.zivilon.cinder_loe.util.Utilities;
@ -321,6 +323,7 @@ public class CinderLoE {
registerBlocks();
registerItems();
ItemRegistration.registerItems();
PacketRegistration.register();
registerEntities();
modEventHandler = new CinderEventHandler();
LoEPotions.registerPotions();
@ -359,6 +362,7 @@ public class CinderLoE {
public void serverStarting(FMLServerStartingEvent event) {
CharacterRoleAPI.loadRolesFromFile();
event.registerServerCommand(new CommandCinderCharacter());
event.registerServerCommand(new CommandWarband());
}
public void registerEntities() { // Last ID added: 60

@ -13,6 +13,7 @@ public class CinderLoE_Config {
public static float enchantment_color_green;
public static float enchantment_color_blue;
public static String corrupt_faction;
public static String skeleton_faction;
public static boolean objective_lindon;
public static boolean objective_arnor;
@ -41,7 +42,8 @@ public class CinderLoE_Config {
enchantment_color_green = config.getFloat("EnchantmentColorGreen", Configuration.CATEGORY_GENERAL, 0.19f, 0.0f, 1.0f, "Configure green color for enchantments");
enchantment_color_blue = config.getFloat("EnchantmentColorBlue", Configuration.CATEGORY_GENERAL, 0.608f, 0.0f, 1.0f, "Configure blue color for enchantments");
corrupt_faction = config.getString("CorruptFaction", Configuration.CATEGORY_GENERAL, "MORDOR", "Configure the alignment the Corrupt npcs follow");
corrupt_faction = config.getString("CorruptFaction", Configuration.CATEGORY_GENERAL, "UTUMNO", "Configure the alignment the Corrupt npcs follow");
skeleton_faction = config.getString("SkeletonFaction", Configuration.CATEGORY_GENERAL, "UTUMNO", "Configure the alignment the Skeleton npcs follow");
objective_lindon = config.getBoolean("Lindon", Configuration.CATEGORY_GENERAL, false, "set true if Lindon Objective Complete");
objective_arnor = config.getBoolean("Arnor", Configuration.CATEGORY_GENERAL, false,"set true if Arnor Objective Complete");

@ -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()));
}
}
}

@ -27,7 +27,7 @@ public class DropTable {
public static void drop_items(LOTREntityNPC entity, DropContext[] context_flags, int looting_level) {
List<ItemStack> drops = generate_drops(entity, context_flags, looting_level);
if (drops == null) return;
if (drops == null || drops.size() < 1) return;
for (ItemStack drop : drops) {
entity.npcDropItem(drop, 0.0F, false, false);
}
@ -35,9 +35,12 @@ public class DropTable {
public static List<ItemStack> generate_drops(LOTREntityNPC entity, DropContext[] context_flags, int looting_level) {
DropTable table = ((ILootableEntity)entity).get_drop_table();
if (table == null) return null;
if (context_flags == null) context_flags = new DropContext[0];
if (table == null) {
return null;
}
if (context_flags == null) {
context_flags = new DropContext[0];
}
List<ItemStack> results = new ArrayList<>();
for (DropInstance drop : table.drop_list) {
ItemStack stack = get_drop(drop, looting_level, context_flags);
@ -49,8 +52,7 @@ public class DropTable {
}
public static ItemStack get_drop(DropInstance drop, int looting_level, DropContext[] context) {
if (!(Utilities.array_contains_array(drop.conditions, context))) return null;
if (!(Utilities.array_contains_array(context, drop.conditions))) return null;
if (drop instanceof SingleItemDrop) {
return get_single_drop((SingleItemDrop)drop, looting_level);
}

@ -1,5 +1,6 @@
package com.zivilon.cinder_loe.entity.corrupt;
import com.zivilon.cinder_loe.CinderLoE_Config;
import lotr.common.LOTRAchievement;
import lotr.common.LOTRFoods;
import lotr.common.LOTRMod;
@ -58,7 +59,7 @@ public class CorruptHobbit extends LOTREntityHobbitBounder {
}
@Override
public LOTRFaction getFaction() {
return this.faction != null ? this.faction : LOTRFaction.UTUMNO;
return LOTRFaction.valueOf(CinderLoE_Config.corrupt_faction);
}
@Override
protected float getSoundPitch() {

@ -21,6 +21,8 @@ public class CorruptMan extends LOTREntityGondorMan {
public CorruptMan(World world) {
super(world);
((EntityLiving) this).tasks.addTask(6, (EntityAIBase) new LOTREntityAIEat(this, LOTRFoods.ORC, 8000));
((EntityLiving) this).tasks.addTask(6, (EntityAIBase) new LOTREntityAIDrink(this, LOTRFoods.ORC_DRINK, 8000));
this.addTargetTasks(true);
}
@Override

@ -1,6 +1,7 @@
package com.zivilon.cinder_loe.entity.corrupt;
import com.zivilon.cinder_loe.CinderLoE_Config;
import lotr.common.LOTRLevelData;
import lotr.common.entity.ai.LOTREntityAIAttackOnCollide;
import lotr.common.entity.npc.LOTREntityGondorMan;
import lotr.common.entity.npc.LOTRNames;
@ -41,7 +42,15 @@ public class CorruptSkeleton extends CorruptMan {
@Override
public LOTRFaction getFaction() {
return LOTRFaction.UTUMNO;
/**
* ok doesnt work, will need an alternative, maybe a new method
if (hiredNPCInfo.getHiringPlayer() != null) {
if (LOTRLevelData.getData(hiredNPCInfo.getHiringPlayer()).getPledgeFaction() != null) {
return LOTRFaction.valueOf(String.valueOf(LOTRLevelData.getData(hiredNPCInfo.getHiringPlayer()).getPledgeFaction()));
}
}
*/
return LOTRFaction.valueOf(CinderLoE_Config.skeleton_faction);
}
@Override

@ -57,12 +57,6 @@ public class CorruptSkeletonArcher extends CorruptSkeleton {
}
}
@Override
public LOTRFaction getFaction() {
return LOTRFaction.UTUMNO;
}
@Override
public String getNPCName() {
return this.familyInfo.getName();

@ -1,6 +1,9 @@
package com.zivilon.cinder_loe.mixins;
import com.zivilon.cinder_loe.util.*;
import com.zivilon.cinder_loe.world.event.Warband;
import com.zivilon.cinder_loe.world.event.WarbandLocationInfo;
import com.zivilon.cinder_loe.world.event.WarbandTracker;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
@ -15,7 +18,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
@ -257,14 +263,36 @@ public abstract class MixinEntityLivingBase extends Entity implements IEntityLiv
}
}
public void setDead() {
super.setDead();
if (this.warband_uuid != null && this.warband_uuid.equals(this.getUniqueID())) {
WarbandLocationInfo info = WarbandTracker.locations.get(this.warband_uuid);
String faction_name = "";
if (info != null && info.warband != null && info.warband.faction != null) {
faction_name = info.warband.faction.faction.untranslatedFactionName();
}
ChatComponentTranslation message;
if (!faction_name.equals("")) {
message = new ChatComponentTranslation(
"warband.defeated.faction",
new ChatComponentTranslation(faction_name)
);
} else {
message = new ChatComponentTranslation(
"warband.defeated.no_faction"
);
}
message.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GRAY));
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(message);
WarbandTracker.remove(this.warband_uuid);
}
}
@Inject(method = "onUpdate", at = @At("TAIL"))
private void onUpdate(CallbackInfo ci) {
if (despawn_timer > -1) {
despawn_timer--;
if (despawn_timer == 0) {
if (warband_uuid == ((EntityLivingBase)(Object)this).getUniqueID()) {
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(EnumChatFormatting.GRAY + "Warband has disbanded"));
}
((EntityLivingBase)(Object)this).setDead();
}
}

@ -4,6 +4,7 @@ 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;
@ -27,35 +28,39 @@ import java.util.UUID;
@Mixin(LOTREntityAIAttackOnCollide.class)
public class MixinLOTREntityAIAttackOnCollide {
@Shadow
@Shadow(remap = false)
protected World worldObj;
@Shadow
@Shadow(remap = false)
protected EntityCreature theOwner;
@Shadow
@Shadow(remap = false)
protected EntityLivingBase attackTarget;
@Shadow
@Shadow(remap = false)
protected int attackTick;
@Shadow
@Shadow(remap = false)
protected void updateLookAndPathing() {}
public UUID leader_id;
public Entity leader;
@Overwrite
public void updateTask() {
if (warband_task()) return;
update_vanilla_task();
}
private boolean warband_task() {
EntityCreature entity = this.theOwner;
UUID leader_id = ((IEntityLivingBase)entity).get_warband_uuid();
if (leader_id != null) {
if (leader == null)
leader = find_entity_by_uuid(entity.worldObj, leader_id);
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; // Return here to not run default logic
return true; // Return here to not run default logic
}
}
update_vanilla_task();
return false;
}
private void update_vanilla_task() {
@ -95,13 +100,4 @@ public class MixinLOTREntityAIAttackOnCollide {
this.theOwner.swingItem();
}
}
private Entity find_entity_by_uuid(World world, UUID uuid) {
for (Object obj : world.loadedEntityList) {
if (obj instanceof Entity && uuid.equals(((Entity) obj).getUniqueID())) {
return (Entity)obj;
}
}
return null;
}
}

@ -3,6 +3,7 @@ package com.zivilon.cinder_loe.mixins;
import com.zivilon.cinder_loe.entity.Renegade;
import com.zivilon.cinder_loe.potion.LoEPotions;
import com.zivilon.cinder_loe.util.IEntityLivingBase;
import com.zivilon.cinder_loe.util.Utilities;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
@ -52,25 +53,29 @@ public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends Enti
@Overwrite(remap = true)
public boolean shouldExecute() {
if (warband_should_execute()) return false;
return original_should_execute();
}
private boolean warband_should_execute() {
EntityCreature self = taskOwner;
if (!(self instanceof IEntityLivingBase)) return original_should_execute();
if (!(self instanceof IEntityLivingBase)) return false;
UUID leader_id = ((IEntityLivingBase) self).get_warband_uuid();
if (leader_id == null) return original_should_execute();
if (leader_id == null) return false;
Entity leader = find_entity_by_uuid(self.worldObj, leader_id);
if (leader == null) return original_should_execute();
Entity leader = Utilities.find_entity_by_uuid(self.worldObj, leader_id);
if (leader == null) return false;
double distance_squared = self.getDistanceSqToEntity(leader);
if (distance_squared > 576.0D) {
self.setAttackTarget(null);
self.getNavigator().tryMoveToEntityLiving(leader, 1.3D);
return false;
return true;
}
return original_should_execute();
return false;
}
public boolean original_should_execute() {
if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0)
return false;
@ -97,15 +102,6 @@ public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends Enti
return true;
}
private Entity find_entity_by_uuid(World world, UUID uuid) {
for (Object obj : world.loadedEntityList) {
if (obj instanceof Entity && uuid.equals(((Entity) obj).getUniqueID())) {
return (Entity)obj;
}
}
return null;
}
/**
* @author Shinare
* @reason Added corrupting potion effect that makes all NPCs hostile

@ -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);
}
}
}

@ -3,6 +3,7 @@ package com.zivilon.cinder_loe.util;
import com.zivilon.cinder_loe.CinderLoE;
import com.zivilon.cinder_loe.client.render.item.RenderHelper;
import com.zivilon.cinder_loe.mixins.MixinEntity;
import com.zivilon.cinder_loe.droptables.*;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
@ -46,6 +47,7 @@ import net.minecraft.nbt.NBTTagString;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
public class Utilities {
@ -328,4 +330,12 @@ public class Utilities {
}
return true;
}
public static Entity find_entity_by_uuid(World world, UUID uuid) {
for (Object obj : world.loadedEntityList) {
if (obj instanceof Entity && uuid.equals(((Entity) obj).getUniqueID())) {
return (Entity)obj;
}
}
return null;
}
}

@ -18,12 +18,17 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import lotr.common.LOTRDimension;
import lotr.common.LOTRMod;
import lotr.common.entity.npc.LOTRSpeech;
import lotr.common.entity.npc.LOTREntityNPC;
import lotr.common.fac.LOTRFaction;
import lotr.common.world.biome.LOTRBiome;
import lotr.common.world.map.LOTRWaypoint;
import lotr.common.world.map.LOTRConquestGrid;
import lotr.common.world.map.LOTRConquestZone;
import java.util.ArrayList;
import java.util.List;
@ -32,13 +37,19 @@ import java.util.UUID;
public class Warband {
public static Random random = new Random();
public static World world = MinecraftServer.getServer().worldServerForDimension(LOTRDimension.MIDDLE_EARTH.dimensionID);
public static long last_warband_timestamp = System.currentTimeMillis() / 1000L - (60*60*4);
public static World world;;
public static long last_warband_timestamp = System.currentTimeMillis() / 1000L - (60*60*2); // Initialize at 2 hour cooldown on server startup
static {
if (FMLCommonHandler.instance().getSide().isServer()) {
world = MinecraftServer.getServer().worldServerForDimension(LOTRDimension.MIDDLE_EARTH.dimensionID);
}
}
public int x = 0;
public int z = 0;
public String direction = "null";
public String waypoint_name = "null";
public String direction = null;
public String waypoint_name = null;
public WarbandFaction faction = null;
public UUID warband_uuid = null;
@ -52,32 +63,50 @@ public class Warband {
}
public static void initialize_warband() {
LOTRWaypoint waypoint = get_random_waypoint();
initialize_warband(null, waypoint, true, null, null);
}
public static void initialize_warband(WarbandFaction faction, LOTRWaypoint waypoint) {
initialize_warband(faction, waypoint, true, null, null);
}
public static void initialize_warband(WarbandFaction faction, Integer x, Integer z) {
initialize_warband(faction, null, false, x, z);
}
public static void initialize_warband(WarbandFaction faction, LOTRWaypoint waypoint, Integer x, Integer z) {
initialize_warband(faction, waypoint, false, x, z);
}
public static void initialize_warband(WarbandFaction faction, LOTRWaypoint waypoint, boolean randomize, Integer x, Integer z) {
if (MinecraftServer.getServer().getConfigurationManager().playerEntityList.size() < 1)
return;
Warband warband = new Warband();
LOTRWaypoint waypoint = get_random_waypoint();
warband.waypoint_name = "lotr.waypoint." + waypoint.getCodeName();
warband.x = waypoint.getXCoord();
warband.z = waypoint.getZCoord();
switch (random.nextInt(8)) {
case 0: warband.direction = "North"; warband.z += random.nextInt(701) - 1000; break;
case 1: warband.direction = "South"; warband.z += random.nextInt(701) + 300; break;
case 2: warband.direction = "East"; warband.x += random.nextInt(701) + 300; break;
case 3: warband.direction = "West"; warband.x += random.nextInt(701) - 1000; break;
case 4: warband.direction = "North-East"; warband.z += random.nextInt(701) - 1000; warband.x += random.nextInt(701) + 300; break;
case 5: warband.direction = "North-West"; warband.z += random.nextInt(701) - 1000; warband.x += random.nextInt(701) - 1000; break;
case 6: warband.direction = "South-East"; warband.z += random.nextInt(701) + 300; warband.x += random.nextInt(701) + 300; break;
case 7: warband.direction = "South-West"; warband.z += random.nextInt(701) + 300; warband.x += random.nextInt(701) - 1000; break;
default: warband.direction = "none"; break;
if (waypoint != null) warband.waypoint_name = "lotr.waypoint." + waypoint.getCodeName();
if ((x == null || z == null) && waypoint == null) waypoint = get_random_waypoint();
if (x == null) x = waypoint.getXCoord();
if (z == null) z = waypoint.getZCoord();
warband.x = x;
warband.z = z;
if (randomize) {
switch (random.nextInt(8)) {
case 0: warband.direction = "North"; warband.z += random.nextInt(701) - 1000; break;
case 1: warband.direction = "South"; warband.z += random.nextInt(701) + 300; break;
case 2: warband.direction = "East"; warband.x += random.nextInt(701) + 300; break;
case 3: warband.direction = "West"; warband.x += random.nextInt(701) - 1000; break;
case 4: warband.direction = "North-East"; warband.z += random.nextInt(701) - 1000; warband.x += random.nextInt(701) + 300; break;
case 5: warband.direction = "North-West"; warband.z += random.nextInt(701) - 1000; warband.x += random.nextInt(701) - 1000; break;
case 6: warband.direction = "South-East"; warband.z += random.nextInt(701) + 300; warband.x += random.nextInt(701) + 300; break;
case 7: warband.direction = "South-West"; warband.z += random.nextInt(701) + 300; warband.x += random.nextInt(701) - 1000; break;
default: warband.direction = "none"; break;
}
}
System.out.println("Loading warband chunks at " + warband.x + "," + warband.z);
load_chunks_at(warband.x, warband.z);
warband.faction = get_warband_faction_by_biome(warband);
if (faction == null) faction = get_warband_faction_by_biome(warband);
warband.faction = faction;
spawn_warband(warband);
WarbandTracker.add(warband);
}
public static void load_chunks_at(int block_x, int block_z) {
@ -121,6 +150,7 @@ public class Warband {
}
}).start();
broadcast_warband(world, warband.faction.warband_name, warband.direction, warband.waypoint_name);
do_radial_conquest(world, warband.x, warband.z, warband.faction.faction, 50);
last_warband_timestamp = System.currentTimeMillis() / 1000L;
}
public static void spawn_boss_entity(Warband warband, int x, int y, int z) {
@ -192,13 +222,56 @@ public class Warband {
}
public static void broadcast_warband(World world, String faction_key, String direction, String waypoint_key) {
IChatComponent message = new ChatComponentTranslation(
"warband.found",
new ChatComponentTranslation(faction_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)),
new ChatComponentText(direction).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)),
new ChatComponentTranslation(waypoint_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA))
);
IChatComponent message;
if (waypoint_key != null && direction != null) {
message = new ChatComponentTranslation(
"warband.found",
new ChatComponentTranslation(faction_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)),
new ChatComponentText(direction).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)),
new ChatComponentTranslation(waypoint_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA))
);
} else if (waypoint_key == null){
message = new ChatComponentTranslation(
"warband.found.no_waypoint",
new ChatComponentTranslation(faction_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD))
);
} else {
message = new ChatComponentTranslation(
"warband.found.no_direction",
new ChatComponentTranslation(faction_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)),
new ChatComponentTranslation(waypoint_key).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA))
);
}
LOTRSpeech.messageAllPlayersInWorld(world, message);
}
public static void do_radial_conquest(World world, int posX, int posZ, LOTRFaction faction, float amount) {
if (!LOTRConquestGrid.conquestEnabled(world)) {
return;
}
LOTRConquestZone zone = LOTRConquestGrid.getZoneByWorldCoords(posX, posZ);
if (zone == null || zone.isDummyZone) {
return;
}
float current_strength = zone.getConquestStrength(faction, world);
float target_strength = current_strength + amount;
if (target_strength > 100000.0F) {
amount = 100000.0F - current_strength;
} else if (target_strength < 0.0F) {
amount = -current_strength;
}
if (amount == 0.0F) {
return;
}
if (amount < 0.0F) {
LOTRConquestGrid.doRadialConquest(world, zone, null, null, faction, -amount, -amount);
} else {
LOTRConquestGrid.doRadialConquest(world, zone, null, faction, null, amount, amount);
}
}
}

@ -885,6 +885,14 @@ public enum WarbandFaction {
}
}
public static WarbandFaction get_warband_by_name(String name) {
for (WarbandFaction faction : values()) {
if (faction.name().equals(name))
return faction;
}
return null;
}
public static class Troop {
public Class entity_class;
public int amount;

@ -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;
}
}

@ -7,8 +7,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
public class WarbandTickHandler {
public int tick_counter = 0;
// public static int INTERVAL_TICKS = 12000; // 10 minutes at 20 TPS
public static int INTERVAL_TICKS = 1200; // 1 minutes at 20 TPS
public static int INTERVAL_TICKS = 12000; // 10 minutes at 20 TPS
@SubscribeEvent
public void onServerTick(ServerTickEvent event) {
@ -22,10 +21,8 @@ public class WarbandTickHandler {
}
public void run_task() {
System.out.println("Warband ticked");
if (Warband.last_warband_timestamp > (System.currentTimeMillis() / 1000L) - 7200) return; // Do not spawn warband if less than 2 hours since last one
// if (Warband.random.nextInt(10) != 0) return;
System.out.println("Warband starting");
if (Warband.last_warband_timestamp > (System.currentTimeMillis() / 1000L) - (60*60*4)) return; // Do not spawn warband if less than 4 hours since last one
if (Warband.random.nextInt(10) != 0) return;
Warband.initialize_warband();
}
}

@ -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());
}
}

@ -366,7 +366,11 @@ lotr.unitinfo.Rhudaur=To Hire this unit you must have the Rhudaur Objective comp
lotr.unitinfo.Dale=To Hire this unit you must have the Dalish Objective complete.
lotr.unitinfo.Lindon=To Hire this unit you must have the Lindon Objective complete.
warband.found=Warband of %s has been found %s of %s
warband.found=Warband of %s was spotted %s of %s!
warband.found.no_direction=Warband of %s was spotted by %s!
warband.found.no_waypoint=Warband of %s has been found!
warband.defeated.faction=Warband of %s has been defeated!
warband.defeated.no_faction=Warband has been defeated!
warband.fac.MORGUL_VALE=Morgul Vale
warband.fac.WOOD_ELF_SCOUT=Woodland Realm scouts
warband.fac.RED_MOUNTAINS=Red Mountains

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

@ -52,8 +52,13 @@
"MixinLOTREntityNPC",
"MixinFoodStats",
"MixinLOTRItemMug",
<<<<<<< HEAD
"MixinLOTRNPCTargetSelector",
"MixinLOTREntityHorse"
=======
"MixinLOTRGuiMap",
"MixinLOTREntityAIOrcSkirmish"
>>>>>>> b62b012e70ebb6eea11d071eb443e10f77f855ce
],
"client": []
}

Loading…
Cancel
Save