mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 06:25:11 +00:00
Support for Future DBC Addon
This commit is contained in:
1 parent
38cc396299
commit
a57bf10031
6 files changed
+106
-25
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
|
||||
public class AddonManager {
|
||||
@@ -17,5 +18,9 @@ public class AddonManager {
|
||||
// Gecko Addon Initialization
|
||||
new GeckoAddon();
|
||||
new GeckoAddonClient();
|
||||
|
||||
// DBC Addon
|
||||
new DBCAddon();
|
||||
new DBCClient();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DBCAddon {
|
||||
public static DBCAddon instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
*/
|
||||
public DBCAddon(){
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity){}
|
||||
|
||||
public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver){}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package kamkeel.addon.client;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.client.gui.mainmenu.GuiNpcStats;
|
||||
import noppes.npcs.client.gui.model.GuiCreationScreen;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DBCClient {
|
||||
public static DBCClient Instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
* The fewer classes modified by mixins the safer.
|
||||
* These are for mixins affecting only client-side classes.
|
||||
*/
|
||||
public DBCClient(){
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Stat Buttons
|
||||
public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity){}
|
||||
public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn){}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
@@ -11,7 +12,7 @@ public class EntityUtil {
|
||||
|
||||
public static void Copy(EntityLivingBase copied, EntityLivingBase entity){
|
||||
entity.worldObj = copied.worldObj;
|
||||
|
||||
|
||||
entity.deathTime = copied.deathTime;
|
||||
entity.distanceWalkedModified = copied.distanceWalkedModified;
|
||||
entity.prevDistanceWalkedModified = copied.distanceWalkedModified;
|
||||
@@ -20,18 +21,18 @@ public class EntityUtil {
|
||||
|
||||
entity.moveForward = copied.moveForward;
|
||||
entity.moveStrafing = copied.moveStrafing;
|
||||
|
||||
|
||||
entity.setPosition(copied.posX, copied.posY, copied.posZ);
|
||||
entity.boundingBox.setBB(copied.boundingBox);
|
||||
|
||||
|
||||
entity.prevPosX = copied.prevPosX;
|
||||
entity.prevPosY = copied.prevPosY;
|
||||
entity.prevPosZ = copied.prevPosZ;
|
||||
|
||||
|
||||
entity.motionX = copied.motionX;
|
||||
entity.motionY = copied.motionY;
|
||||
entity.motionZ = copied.motionZ;
|
||||
|
||||
|
||||
entity.rotationYaw = copied.rotationYaw;
|
||||
entity.rotationPitch = copied.rotationPitch;
|
||||
entity.prevRotationYaw = copied.prevRotationYaw;
|
||||
@@ -41,9 +42,9 @@ public class EntityUtil {
|
||||
entity.prevRenderYawOffset = copied.prevRenderYawOffset;
|
||||
entity.cameraPitch = copied.cameraPitch;
|
||||
entity.prevCameraPitch = copied.prevCameraPitch;
|
||||
|
||||
|
||||
entity.renderYawOffset = copied.renderYawOffset;
|
||||
|
||||
|
||||
entity.lastTickPosX = copied.lastTickPosX;
|
||||
entity.lastTickPosY = copied.lastTickPosY;
|
||||
entity.lastTickPosZ = copied.lastTickPosZ;
|
||||
@@ -56,9 +57,9 @@ public class EntityUtil {
|
||||
entity.prevSwingProgress = copied.prevSwingProgress;
|
||||
entity.isSwingInProgress = copied.isSwingInProgress;
|
||||
entity.swingProgressInt = copied.swingProgressInt;
|
||||
|
||||
|
||||
entity.ticksExisted = copied.ticksExisted;
|
||||
|
||||
|
||||
if(entity instanceof EntityPlayer && copied instanceof EntityPlayer){
|
||||
EntityPlayer ePlayer = (EntityPlayer) entity;
|
||||
EntityPlayer cPlayer = (EntityPlayer) copied;
|
||||
@@ -73,19 +74,20 @@ public class EntityUtil {
|
||||
ePlayer.field_71095_bQ = cPlayer.field_71095_bQ;
|
||||
ePlayer.field_71085_bR = cPlayer.field_71085_bR;
|
||||
}
|
||||
|
||||
|
||||
if(entity instanceof EntityDragon){
|
||||
entity.rotationYaw += 180;
|
||||
}
|
||||
if(entity instanceof EntityChicken){
|
||||
((EntityChicken)entity).destPos = copied.onGround?0:1;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < 5; i++){
|
||||
entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i));
|
||||
}
|
||||
|
||||
GeckoAddon.instance.geckoCopyData(copied, entity);
|
||||
DBCAddon.instance.dbcCopyData(copied, entity);
|
||||
|
||||
if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) copied;
|
||||
@@ -94,9 +96,9 @@ public class EntityUtil {
|
||||
target.textureLocation = npc.textureLocation;
|
||||
target.display = npc.display;
|
||||
target.inventory = npc.inventory;
|
||||
|
||||
|
||||
target.currentAnimation = npc.currentAnimation;
|
||||
|
||||
|
||||
target.setDataWatcher(npc.getDataWatcher());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.mainmenu;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -70,6 +72,8 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
||||
addLabel(new GuiNpcLabel(18,"stats.attackInvisible", guiLeft + 140, y + 5));
|
||||
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
|
||||
addButton(new GuiNpcButton(8,guiLeft + 358, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
|
||||
|
||||
DBCClient.Instance.showDBCStatButtons(this, npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,6 +138,10 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
||||
else if (button.id == 22) {
|
||||
stats.ignoreCobweb = (button.getValue() == 0);
|
||||
}
|
||||
|
||||
// Button 300
|
||||
if(guibutton instanceof GuiNpcButton)
|
||||
DBCClient.Instance.showDBCStatActionPerformed(this, (GuiNpcButton) guibutton);
|
||||
}
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.entity;
|
||||
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
@@ -232,41 +233,49 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityAsMob(Entity par1Entity){
|
||||
public boolean attackEntityAsMob(Entity receiver){
|
||||
float f = stats.getAttackStrength();
|
||||
|
||||
if (stats.attackSpeed < 10){
|
||||
par1Entity.hurtResistantTime = 0;
|
||||
receiver.hurtResistantTime = 0;
|
||||
}
|
||||
if(par1Entity instanceof EntityLivingBase && !isRemote()){
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)par1Entity);
|
||||
if(receiver instanceof EntityLivingBase && !isRemote()){
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)receiver);
|
||||
if(EventHooks.onNPCMeleeAttack(this, event))
|
||||
return false;
|
||||
f = event.getDamage();
|
||||
}
|
||||
|
||||
boolean var4 = par1Entity.attackEntityFrom(new NpcDamageSource("mob", this), f);
|
||||
boolean didAttack = false;
|
||||
if(DBCAddon.instance.canDBCAttack(this, f, receiver)){
|
||||
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), 1.0f);
|
||||
if(didAttack)
|
||||
DBCAddon.instance.doDBCDamage(this, f, receiver);
|
||||
}
|
||||
else
|
||||
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), f);
|
||||
|
||||
if (var4){
|
||||
|
||||
if (didAttack){
|
||||
if(getOwner() instanceof EntityPlayer)
|
||||
NPCEntityHelper.setRecentlyHit((EntityLivingBase)par1Entity);
|
||||
NPCEntityHelper.setRecentlyHit((EntityLivingBase)receiver);
|
||||
if (stats.knockback > 0){
|
||||
par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
|
||||
receiver.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
|
||||
this.motionX *= 0.6D;
|
||||
this.motionZ *= 0.6D;
|
||||
}
|
||||
if(advanced.role == EnumRoleType.Companion){
|
||||
((RoleCompanion)roleInterface).attackedEntity(par1Entity);
|
||||
((RoleCompanion)roleInterface).attackedEntity(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
if (stats.potionType != EnumPotionType.None){
|
||||
if (stats.potionType != EnumPotionType.Fire)
|
||||
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
|
||||
((EntityLivingBase)receiver).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
|
||||
else
|
||||
par1Entity.setFire(stats.potionDuration);
|
||||
receiver.setFire(stats.potionDuration);
|
||||
}
|
||||
return var4;
|
||||
return didAttack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user