|
|
|
@ -42,19 +42,19 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
GameRegistry.registerFuelHandler(this);
|
|
|
|
GameRegistry.registerFuelHandler(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@SubscribeEvent
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onArrowLoose (ArrowLooseEvent event) {
|
|
|
|
public void onArrowLoose(ArrowLooseEvent event) {
|
|
|
|
Entity attacker = event.entityLiving;
|
|
|
|
Entity attacker = event.entityLiving;
|
|
|
|
if (attacker instanceof EntityPlayerMP player) {
|
|
|
|
if (attacker instanceof EntityPlayerMP player) {
|
|
|
|
ItemStack bow = player.getHeldItem();
|
|
|
|
ItemStack bow = player.getHeldItem();
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Arrow Loose Event"));
|
|
|
|
|
|
|
|
if (bow != null && bow.isItemStackDamageable() && (bow.getItem() instanceof LOTRItemBow || bow.getItem() instanceof ItemBow)) {
|
|
|
|
if (bow != null && bow.isItemStackDamageable() && (bow.getItem() instanceof LOTRItemBow || bow.getItem() instanceof ItemBow)) {
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
double[] probabilities = {1.02, 1.05, 1.1};
|
|
|
|
double[] probabilities = {0.02, 0.05, 0.1}; // Corrected probabilities
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Semi Complete"));
|
|
|
|
|
|
|
|
float durabilityPercent = (float) (bow.getMaxDamage() - bow.getItemDamage() / bow.getMaxDamage());
|
|
|
|
// Corrected durabilityPercent calculation
|
|
|
|
|
|
|
|
float durabilityPercent = (float) (bow.getMaxDamage() - bow.getItemDamage()) / bow.getMaxDamage();
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < durabilityThresholds.length; j++) {
|
|
|
|
for (int j = 0; j < durabilityThresholds.length; j++) {
|
|
|
|
if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) {
|
|
|
|
if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) {
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Complete"));
|
|
|
|
|
|
|
|
addNegativeModifier(bow, player, "bow");
|
|
|
|
addNegativeModifier(bow, player, "bow");
|
|
|
|
break; // Exit loop once a modifier is added
|
|
|
|
break; // Exit loop once a modifier is added
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -69,17 +69,16 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
|
|
|
|
|
|
|
|
if (attacker instanceof EntityPlayerMP player) {
|
|
|
|
if (attacker instanceof EntityPlayerMP player) {
|
|
|
|
ItemStack weapon = player.getHeldItem();
|
|
|
|
ItemStack weapon = player.getHeldItem();
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Attack Event"));
|
|
|
|
|
|
|
|
// smithing rework for melee
|
|
|
|
// smithing rework for melee
|
|
|
|
if (weapon !=null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) {
|
|
|
|
if (weapon != null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) {
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
double[] probabilities = {1.02, 1.05, 1.1};
|
|
|
|
double[] probabilities = {0.02, 0.05, 0.1}; // Corrected probabilities
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Semi Attack Event Complete"));
|
|
|
|
|
|
|
|
if (weapon.isItemStackDamageable()) {
|
|
|
|
if (weapon.isItemStackDamageable()) {
|
|
|
|
float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage() / weapon.getMaxDamage());
|
|
|
|
// Corrected durabilityPercent calculation
|
|
|
|
|
|
|
|
float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage()) / weapon.getMaxDamage();
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < durabilityThresholds.length; j++) {
|
|
|
|
for (int j = 0; j < durabilityThresholds.length; j++) {
|
|
|
|
if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) {
|
|
|
|
if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) {
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Attack Event Complete"));
|
|
|
|
|
|
|
|
addNegativeModifier(weapon, player, "weapon");
|
|
|
|
addNegativeModifier(weapon, player, "weapon");
|
|
|
|
break; // Exit loop once a modifier is added
|
|
|
|
break; // Exit loop once a modifier is added
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -166,7 +165,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
// smithing rework for melee
|
|
|
|
// smithing rework for melee
|
|
|
|
if (weapon !=null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) {
|
|
|
|
if (weapon !=null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) {
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
double[] probabilities = {1.02, 1.05, 1.1};
|
|
|
|
double[] probabilities = {0.02, 0.05, 0.1};
|
|
|
|
|
|
|
|
|
|
|
|
if (weapon.isItemStackDamageable()) {
|
|
|
|
if (weapon.isItemStackDamageable()) {
|
|
|
|
float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage() / weapon.getMaxDamage());
|
|
|
|
float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage() / weapon.getMaxDamage());
|
|
|
|
@ -183,7 +182,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
|
|
|
|
|
|
|
|
// Durability thresholds and corresponding probabilities for adding a negative modifier
|
|
|
|
// Durability thresholds and corresponding probabilities for adding a negative modifier
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
float[] durabilityThresholds = {0.6f, 0.5f, 0.4f};
|
|
|
|
double[] probabilities = {1.02, 1.05, 1.1};
|
|
|
|
double[] probabilities = {0.02, 0.05, 0.1};
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
ItemStack armor = player.getEquipmentInSlot(i + 1);
|
|
|
|
ItemStack armor = player.getEquipmentInSlot(i + 1);
|
|
|
|
@ -200,8 +199,12 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void sendNegativeModifierMessage(EntityPlayerMP player) {
|
|
|
|
private void sendNegativeModifierMessage(EntityPlayerMP player, String type) {
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Your armor has received a negative modifier!"));
|
|
|
|
player.addChatMessage(new ChatComponentText(
|
|
|
|
|
|
|
|
EnumChatFormatting.RED + "Your " +
|
|
|
|
|
|
|
|
EnumChatFormatting.GOLD + type +
|
|
|
|
|
|
|
|
EnumChatFormatting.RED + " has received a negative modifier!"
|
|
|
|
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void playNegativeModifierSound(World world, double x, double y, double z) {
|
|
|
|
private void playNegativeModifierSound(World world, double x, double y, double z) {
|
|
|
|
world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F);
|
|
|
|
world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F);
|
|
|
|
@ -236,7 +239,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
protectWeakUpgraded = true;
|
|
|
|
protectWeakUpgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Armor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "protectRangedWeak1" -> {
|
|
|
|
case "protectRangedWeak1" -> {
|
|
|
|
enchList.removeTag(i);
|
|
|
|
enchList.removeTag(i);
|
|
|
|
@ -244,7 +247,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
protectRangedWeakUpgraded = true;
|
|
|
|
protectRangedWeakUpgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Armor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "protectWeak2" -> protectWeakUpgraded = true;
|
|
|
|
case "protectWeak2" -> protectWeakUpgraded = true;
|
|
|
|
case "protectRangedWeak2" -> protectRangedWeakUpgraded = true;
|
|
|
|
case "protectRangedWeak2" -> protectRangedWeakUpgraded = true;
|
|
|
|
@ -266,7 +269,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
enchList.appendTag(new NBTTagString("protectRangedWeak1"));
|
|
|
|
enchList.appendTag(new NBTTagString("protectRangedWeak1"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Armor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tag.setTag("LOTREnch", enchList);
|
|
|
|
tag.setTag("LOTREnch", enchList);
|
|
|
|
@ -280,7 +283,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
upgraded = true;
|
|
|
|
upgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Bow");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "rangedWeak2" -> {
|
|
|
|
case "rangedWeak2" -> {
|
|
|
|
enchList.removeTag(i);
|
|
|
|
enchList.removeTag(i);
|
|
|
|
@ -288,7 +291,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
upgraded = true;
|
|
|
|
upgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Bow");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "rangedWeak3" -> upgraded = true;
|
|
|
|
case "rangedWeak3" -> upgraded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -299,7 +302,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
String newModifier = possibleModifiers[random.nextInt(possibleModifiers.length)];
|
|
|
|
String newModifier = possibleModifiers[random.nextInt(possibleModifiers.length)];
|
|
|
|
enchList.appendTag(new NBTTagString(newModifier));
|
|
|
|
enchList.appendTag(new NBTTagString(newModifier));
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Weapon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (type.equals("weapon")) {
|
|
|
|
} else if (type.equals("weapon")) {
|
|
|
|
// First, iterate and upgrade if necessary
|
|
|
|
// First, iterate and upgrade if necessary
|
|
|
|
@ -312,7 +315,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
upgraded = true;
|
|
|
|
upgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Weapon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "weak3" -> {
|
|
|
|
case "weak3" -> {
|
|
|
|
enchList.removeTag(i);
|
|
|
|
enchList.removeTag(i);
|
|
|
|
@ -320,7 +323,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
upgraded = true;
|
|
|
|
upgraded = true;
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
i--; // Adjust index after removal
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Weapon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "weak4" -> upgraded = true;
|
|
|
|
case "weak4" -> upgraded = true;
|
|
|
|
case "meleeSlow1" -> meleeSwift = true;
|
|
|
|
case "meleeSlow1" -> meleeSwift = true;
|
|
|
|
@ -349,7 +352,7 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ);
|
|
|
|
sendNegativeModifierMessage(player);
|
|
|
|
sendNegativeModifierMessage(player, "Weapon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|