Compatibility Helper DBC

This commit is contained in:
Kam committed 2023-07-19 11:17:11 -04:00
1 parent 3d40e2dfd1
commit da313f6d0a
14 files changed
+184 -9

No files matched your search

@@ -22,6 +22,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.LoadConfiguration;
import noppes.npcs.config.legacy.LegacyConfig;
@@ -17,7 +17,7 @@ import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.event.ForgeEvent;
@@ -10,7 +10,7 @@ import noppes.npcs.constants.EnumCompanionJobs;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobGuard;
import noppes.npcs.roles.RoleCompanion;
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.*;
import java.lang.reflect.Method;
@@ -9,7 +9,7 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.client.model.ModelMPM;
import noppes.npcs.client.model.util.ModelRenderPassHelper;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
@@ -0,0 +1,107 @@
package noppes.npcs.compat;
import cpw.mods.fml.common.Loader;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner;
import org.apache.logging.log4j.LogManager;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class DBCHelper {
public static boolean Enabled = false;
private static Method StatusEffectsMethod = null;
private static Method PlyrSkillsMethod = null;
private static Method TransPwrModAtr = null;
private static Method statMethod = null;
public static void load(){
Enabled = Loader.isModLoaded("jinryuujrmcore");
if(!Enabled)
return;
try{
Class<?> c = Class.forName("JinRyuu.JRMCore.JRMCoreH");
StatusEffectsMethod = c.getMethod("StusEfcts",int.class, String.class);
PlyrSkillsMethod = c.getMethod("PlyrSkills", EntityPlayer.class);
TransPwrModAtr = c.getMethod("TransPwrModAtr", int[].class, int.class, int.class, int.class, int.class, String.class, int.class, int.class, boolean.class, boolean.class, boolean.class, boolean.class, int.class, String[].class, boolean.class);
statMethod = c.getMethod("stat", int.class, int.class, int.class, int.class, int.class, float.class);
}
catch(Exception e){
LogWriter.except(e);
}
}
public static boolean StatusEffects(int id, String effect){
try {
Object returnValue = StatusEffectsMethod.invoke(null, id, effect);
return (Boolean) returnValue;
} catch (Exception e) {
LogManager.getLogger().error("StatusEffects", e);
}
return false;
}
public static String[] PlayerSkills(EntityPlayer p){
try {
Object returnValue = PlyrSkillsMethod.invoke(null, p);
if (returnValue instanceof String[]) {
return (String[]) returnValue; // Cast and return the String[] value
} else {
return new String[]{};
}
} catch (Exception e) {
LogManager.getLogger().error("PlayerSkills", e);
}
return new String[]{};
}
public static int TransPwrMod(int[] currAttributes, int attribute, int st, int st2, int race, String SklX, int currRelease, int arcRel, boolean legendOn, boolean majinOn, boolean mysticOn, boolean uiOn, int powerType, String[] Skls, boolean isFused){
try {
Object returnValue = TransPwrModAtr.invoke(null, currAttributes, attribute, st, st2, race, SklX, currRelease, arcRel, legendOn, majinOn, mysticOn, uiOn, powerType, Skls, isFused);
if (returnValue instanceof Integer) {
return (int) returnValue;
} else {
return -1;
}
} catch (Exception e) {
LogManager.getLogger().error("TransPwrModAtr", e);
}
return -1;
}
public static int StatMethod(int g, int s, int a, int r, int c, float b){
try {
Object returnValue = statMethod.invoke(null, g, s, a, r, c, b);
if (returnValue instanceof Integer) {
return (int) returnValue;
} else {
return -1;
}
} catch (Exception e) {
LogManager.getLogger().error("statMethod", e);
}
return -1;
}
}
@@ -1,4 +1,4 @@
package noppes.npcs.controllers;
package noppes.npcs.compat;
import cpw.mods.fml.common.Loader;
import net.minecraft.client.Minecraft;
@@ -3,7 +3,7 @@ package noppes.npcs.entity.data;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.EntityNPCInterface;
public class ModelData extends ModelDataShared{
@@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.EntityNPCInterface;
import org.apache.commons.lang3.RandomStringUtils;
@@ -45,6 +45,7 @@ import noppes.npcs.api.handler.data.IFramePart;
import noppes.npcs.api.handler.data.ISound;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.overlay.ICustomOverlay;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.containers.ContainerNpcInterface;
@@ -4,7 +4,7 @@ import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.IPixelmonPlayerData;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.scripted.entity.ScriptPixelmon;
public class ScriptPixelmonPlayerData implements IPixelmonPlayerData {
@@ -1,11 +1,13 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.entity.IDBCPlayer;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.compat.DBCHelper;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
@@ -786,4 +788,67 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
return "";
}
public int calcDexResistance(int damage, int percentPierce){
if(!DBCHelper.Enabled){
return 0;
}
NBTTagCompound nbt = player.getEntityData().getCompoundTag("PlayerPersisted");
if(nbt != null){
byte st = nbt.getByte("jrmcState");
byte st2 = nbt.getByte("jrmcState2");
byte rc = nbt.getByte("jrmcRace");
byte cls = nbt.getByte("jrmcClass");
String sklx = nbt.getString("jrmcSSltX");
byte rls = nbt.getByte("jrmcRelease");
int resrv = nbt.getInteger("jrmcArcRsrv");
String statusEffects = nbt.getString("jrmcStatusEff");
boolean mj = DBCHelper.StatusEffects(12 ,statusEffects);
boolean mc = DBCHelper.StatusEffects(13 ,statusEffects);
boolean lg = DBCHelper.StatusEffects(14 ,statusEffects);
boolean mn = DBCHelper.StatusEffects(19 ,statusEffects);
byte pwr = nbt.getByte("jrmcPwrtyp");
String[] ps = DBCHelper.PlayerSkills(player);
boolean c = DBCHelper.StatusEffects(10 ,statusEffects) || DBCHelper.StatusEffects(11 ,statusEffects);
int dex = DBCHelper.TransPwrMod(getStats(player), 1, st, st2, rc, sklx, rls, resrv, lg, mj, mc, mn, pwr, ps, c);
int def = (int) (DBCHelper.StatMethod(1, 1, dex, rc, cls, 0.0F) * rls * 0.01D * JRMCoreH.weightPerc(1, player));
boolean block = ExtendedPlayer.get(player).getBlocking() != 0;
if (!block) {
def /= (100 / JRMCoreConfig.cStatPasDef);
}
int dmg = damage - def;
if (dmg <= 0) {
dmg = (int) (damage * percentPierce);
}
int hp = nbt.getInteger("jrmcBdy") - (dmg / 2);
if (hp < 0) {
hp = 0;
}
nbt.setInteger("jrmcBdy", hp);
}
}
private int[] getStats(EntityPlayer player) {
NBTTagCompound nbt = player.getEntityData().getCompoundTag("PlayerPersisted");
int[] stats = new int[6];
String[] attr = { "jrmcStrI", "jrmcDexI", "jrmcCnsI", "jrmcWilI", "jrmcIntI", "jrmcCncI" };
for (int i = 0; i < attr.length; i++) {
stats[i] = nbt.getInteger(attr[i]);
}
return stats;
}
}
@@ -3,7 +3,7 @@ package noppes.npcs.scripted.entity;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.entity.IPixelmon;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.util.ValueUtil;
public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> implements IPixelmon {
@@ -25,6 +25,7 @@ import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.api.handler.data.ISound;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.overlay.ICustomOverlay;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat;