added Admin Unit Leveling tool, added some music files, undetermined if they work
parent
6a27a7ae1a
commit
d7fbd7c76d
@ -0,0 +1,82 @@
|
|||||||
|
package com.zivilon.cinder_loe.entity.npc.elf;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.CinderLoE;
|
||||||
|
import lotr.common.LOTRAchievement;
|
||||||
|
import lotr.common.LOTRMod;
|
||||||
|
import lotr.common.LOTRShields;
|
||||||
|
import lotr.common.entity.ai.LOTREntityAIAttackOnCollide;
|
||||||
|
import lotr.common.entity.npc.LOTREntityHighElf;
|
||||||
|
import lotr.common.entity.npc.LOTREntityHighElfWarrior;
|
||||||
|
import lotr.common.entity.npc.LOTREntityMoredain;
|
||||||
|
import lotr.common.entity.npc.LOTRNPCMount;
|
||||||
|
import net.minecraft.entity.IEntityLivingData;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
|
||||||
|
public class Sirrandrai extends LOTREntityHighElfWarrior {
|
||||||
|
public Sirrandrai(World world) {
|
||||||
|
super(world);
|
||||||
|
this.tasks.addTask(2, this.meleeAttackAI);
|
||||||
|
this.spawnRidingHorse = this.rand.nextInt(4) == 0;
|
||||||
|
this.npcShield = LOTRShields.ALIGNMENT_HIGH_ELF;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected EntityAIBase createElfMeleeAttackAI() {
|
||||||
|
return new LOTREntityAIAttackOnCollide(this, 1.5, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EntityAIBase createElfRangedAttackAI() {
|
||||||
|
return this.createElfMeleeAttackAI();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void applyEntityAttributes() {
|
||||||
|
super.applyEntityAttributes();
|
||||||
|
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(24.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
|
||||||
|
data = super.onSpawnWithEgg(data);
|
||||||
|
int i = this.rand.nextInt(2);
|
||||||
|
if (i == 0) {
|
||||||
|
this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.polearmHighElven));
|
||||||
|
if (this.rand.nextInt(5) == 0) {
|
||||||
|
this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon());
|
||||||
|
this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearHighElven));
|
||||||
|
}
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearHighElven));
|
||||||
|
this.npcItemsInv.setSpearBackup(null);
|
||||||
|
}
|
||||||
|
this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
|
||||||
|
this.npcItemsInv.setRangedWeapon(this.npcItemsInv.getMeleeWeapon());
|
||||||
|
this.setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsHighElven));
|
||||||
|
this.setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsHighElven));
|
||||||
|
this.setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyHighElven));
|
||||||
|
this.setCurrentItemOrArmor(4, new ItemStack(LOTRMod.helmetHighElven));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getAlignmentBonus() {
|
||||||
|
return 3.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSpeechBank(EntityPlayer entityplayer) {
|
||||||
|
if (this.isFriendlyAndAligned(entityplayer)) {
|
||||||
|
if (this.hiredNPCInfo.getHiringPlayer() == entityplayer) {
|
||||||
|
return "highElf/elf/hired";
|
||||||
|
}
|
||||||
|
return "highElf/warrior/friendly";
|
||||||
|
}
|
||||||
|
return "highElf/warrior/hostile";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
package com.zivilon.cinder_loe.items;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.CinderLoE;
|
||||||
|
import com.zivilon.cinder_loe.LoECreativeTabs;
|
||||||
|
import lotr.common.entity.npc.LOTREntityNPC;
|
||||||
|
import lotr.common.entity.npc.LOTRHiredNPCInfo;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.EnumAction;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class unitLevelTool extends Item {
|
||||||
|
|
||||||
|
public unitLevelTool() {
|
||||||
|
setCreativeTab(LoECreativeTabs.tabMiscLoE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumAction getItemUseAction(ItemStack itemstack) {
|
||||||
|
return EnumAction.bow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||||
|
List<LOTREntityNPC> hiredNPCs = this.findHiredNPCsNearPlayer(player);
|
||||||
|
|
||||||
|
if (!hiredNPCs.isEmpty()) {
|
||||||
|
for (LOTREntityNPC hiredNPC : hiredNPCs) {
|
||||||
|
if (hiredNPC != null && hiredNPC.hiredNPCInfo != null) {
|
||||||
|
try {
|
||||||
|
LOTRHiredNPCInfo npcInfo = hiredNPC.hiredNPCInfo;
|
||||||
|
|
||||||
|
Method addExperienceMethod = LOTRHiredNPCInfo.class.getDeclaredMethod("addExperience", int.class);
|
||||||
|
addExperienceMethod.setAccessible(true);
|
||||||
|
|
||||||
|
int xpToAdd = 1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
xpToAdd = Integer.parseInt(itemStack.getDisplayName());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Tool name wasnt a number, applying 1 Xp instead"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addExperienceMethod.invoke(npcInfo, xpToAdd);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LOTREntityNPC> findHiredNPCsNearPlayer(EntityPlayer player) {
|
||||||
|
// Logic to find all nearby hired NPCs within a certain range
|
||||||
|
double range = 20.0D; // Set the range within which the NPCs should be found
|
||||||
|
List<LOTREntityNPC> nearbyHiredNPCs = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Object entity : player.worldObj.getEntitiesWithinAABB(LOTREntityNPC.class, player.boundingBox.expand(range, range, range))) {
|
||||||
|
LOTREntityNPC npc = (LOTREntityNPC) entity;
|
||||||
|
|
||||||
|
// Check if the player has sufficient permission level (admin tool usage)
|
||||||
|
if (npc.hiredNPCInfo != null && player.canCommandSenderUseCommand(2, "")) {
|
||||||
|
nearbyHiredNPCs.add(npc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nearbyHiredNPCs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in New Issue