mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
79fa879eb6
13 files changed
+109
-45
No files matched your search
+5
-2
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.ability.conditions;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.UserType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -7,7 +9,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.gui.advanced.SubGuiCustomEffectSelect;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
|
||||
@@ -33,11 +34,12 @@ public class ConditionHasEffect extends AbilityCondition {
|
||||
return CustomEffectController.getInstance().hasEffect(player, effectId, effectIndex);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getConditionDefinitions(List<FieldDef> defs) {
|
||||
defs.add(FieldDef.subGuiField("condition.select_effect",
|
||||
() -> new SubGuiCustomEffectSelect(effectId, effectIndex),
|
||||
(SubGuiInterface gui) -> {
|
||||
gui -> {
|
||||
SubGuiCustomEffectSelect sel = (SubGuiCustomEffectSelect) gui;
|
||||
if (sel.getSelectedEffectId() >= 0) {
|
||||
effectId = sel.getSelectedEffectId();
|
||||
@@ -55,6 +57,7 @@ public class ConditionHasEffect extends AbilityCondition {
|
||||
}));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.ability.conditions;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -52,12 +54,14 @@ public class ConditionHitCount extends AbilityCondition {
|
||||
this.withinTicks = Math.max(0, withinTicks);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getConditionDefinitions(List<FieldDef> defs) {
|
||||
defs.add(FieldDef.intField("condition.required_hits", this::getRequiredHits, this::setRequiredHits).min(1));
|
||||
defs.add(FieldDef.intField("condition.within_ticks", this::getWithinTicks, this::setWithinTicks).min(0));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.ability.conditions;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -127,6 +129,7 @@ public class ConditionItem extends AbilityCondition {
|
||||
return itemName.equals(registryName);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getConditionDefinitions(List<FieldDef> defs) {
|
||||
defs.add(FieldDef.enumField("condition.usage_type", UsageType.class,
|
||||
@@ -150,6 +153,7 @@ public class ConditionItem extends AbilityCondition {
|
||||
// .hover("condition.hover.required_count"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
|
||||
+5
-2
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.ability.conditions;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.UserType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -7,7 +9,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.select.GuiQuestSelection;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
@@ -32,11 +33,12 @@ public class ConditionQuestCompleted extends AbilityCondition {
|
||||
return PlayerData.get(player).questData.hasFinishedQuest(questId);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getConditionDefinitions(List<FieldDef> defs) {
|
||||
defs.add(FieldDef.subGuiField("condition.select_quest",
|
||||
() -> new GuiQuestSelection(questId),
|
||||
(SubGuiInterface gui) -> {
|
||||
gui -> {
|
||||
GuiQuestSelection sel = (GuiQuestSelection) gui;
|
||||
if (sel.selectedQuest != null) {
|
||||
questId = sel.selectedQuest.id;
|
||||
@@ -50,6 +52,7 @@ public class ConditionQuestCompleted extends AbilityCondition {
|
||||
.clearable(() -> questId = -1));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.ability.conditions;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -95,6 +97,7 @@ public abstract class ConditionThreshold extends AbilityCondition {
|
||||
return thresholdType.test(value, threshold);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getConditionDefinitions(List<FieldDef> defs) {
|
||||
defs.add(FieldDef.floatField("condition.threshold_flat", this::getThresholdFlat, this::setThresholdFlat)
|
||||
@@ -122,6 +125,7 @@ public abstract class ConditionThreshold extends AbilityCondition {
|
||||
thresholdType = ThresholdType.fromOrdinal(nbt.getInteger("thresholdType"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
|
||||
@@ -8,6 +8,7 @@ import kamkeel.npcs.controllers.data.ability.data.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.util.AnchorPointHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -172,18 +173,6 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
|
||||
EntityLivingBase livingOwner = (EntityLivingBase) owner;
|
||||
|
||||
// Update origin from anchor point
|
||||
if (anchorData != null) {
|
||||
Vec3 pos = AnchorPointHelper.calculateAnchorPosition(livingOwner, anchorData);
|
||||
startX = pos.xCoord;
|
||||
startY = pos.yCoord;
|
||||
startZ = pos.zCoord;
|
||||
} else {
|
||||
startX = owner.posX;
|
||||
startY = owner.posY + owner.height * 0.7;
|
||||
startZ = owner.posZ;
|
||||
}
|
||||
|
||||
// Update direction from owner's current rotation
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
if (lockVerticalDirection) {
|
||||
@@ -199,6 +188,25 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
}
|
||||
|
||||
// Update origin: for player casters, snap to look vector so laser aligns with crosshair.
|
||||
// For NPCs, use the configured anchor point.
|
||||
if (owner instanceof EntityPlayer) {
|
||||
double eyeY = owner.posY + owner.getEyeHeight();
|
||||
float frontDist = Math.max(0.5f, laserWidth * 0.5f);
|
||||
startX = owner.posX + dirX * frontDist;
|
||||
startY = eyeY + dirY * frontDist;
|
||||
startZ = owner.posZ + dirZ * frontDist;
|
||||
} else if (anchorData != null) {
|
||||
Vec3 pos = AnchorPointHelper.calculateAnchorPosition(livingOwner, anchorData);
|
||||
startX = pos.xCoord;
|
||||
startY = pos.yCoord;
|
||||
startZ = pos.zCoord;
|
||||
} else {
|
||||
startX = owner.posX;
|
||||
startY = owner.posY + owner.height * 0.7;
|
||||
startZ = owner.posZ;
|
||||
}
|
||||
|
||||
// Keep entity positioned at origin
|
||||
prevPosX = startX;
|
||||
prevPosY = startY;
|
||||
@@ -209,12 +217,6 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
public void startMoving(EntityLivingBase target) {
|
||||
setCharging(false);
|
||||
|
||||
// Initialize from current anchor position
|
||||
// updateLaserOriginAndDirection() will keep these updated each tick
|
||||
startX = posX;
|
||||
startY = posY;
|
||||
startZ = posZ;
|
||||
|
||||
// Set initial direction from owner's rotation
|
||||
Entity owner = getOwnerEntity();
|
||||
if (owner != null) {
|
||||
@@ -224,9 +226,9 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
this.dirY = -Math.sin(pitch);
|
||||
this.dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
} else if (target != null) {
|
||||
double dx = target.posX - startX;
|
||||
double dy = (target.posY + target.getEyeHeight() - 0.4) - startY;
|
||||
double dz = target.posZ - startZ;
|
||||
double dx = target.posX - posX;
|
||||
double dy = (target.posY + target.getEyeHeight() - 0.4) - posY;
|
||||
double dz = target.posZ - posZ;
|
||||
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
if (len > 0) {
|
||||
this.dirX = dx / len;
|
||||
@@ -235,6 +237,24 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
}
|
||||
}
|
||||
|
||||
// For player casters, snap origin to look vector so laser aligns with crosshair.
|
||||
// For NPCs, use current anchor position.
|
||||
if (owner instanceof EntityPlayer) {
|
||||
double eyeY = owner.posY + owner.getEyeHeight();
|
||||
float frontDist = Math.max(0.5f, laserWidth * 0.5f);
|
||||
startX = owner.posX + dirX * frontDist;
|
||||
startY = eyeY + dirY * frontDist;
|
||||
startZ = owner.posZ + dirZ * frontDist;
|
||||
setPosition(startX, startY, startZ);
|
||||
prevPosX = startX;
|
||||
prevPosY = startY;
|
||||
prevPosZ = startZ;
|
||||
} else {
|
||||
startX = posX;
|
||||
startY = posY;
|
||||
startZ = posZ;
|
||||
}
|
||||
|
||||
// Initialize end point at start (will expand from here)
|
||||
this.endX = startX;
|
||||
this.endY = startY;
|
||||
|
||||
@@ -132,6 +132,7 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
public EntityEnergyProjectile(World world) {
|
||||
super(world);
|
||||
this.setSize(0.5f, 0.5f);
|
||||
this.yOffset = this.height / 2.0f;
|
||||
this.noClip = false;
|
||||
}
|
||||
|
||||
@@ -363,6 +364,20 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
|
||||
@Override
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements) {
|
||||
// If position changed significantly (e.g. snap from anchor to look vector),
|
||||
// skip interpolation and jump directly to prevent visual offset from crosshair
|
||||
double dx = x - this.posX;
|
||||
double dy = y - this.posY;
|
||||
double dz = z - this.posZ;
|
||||
if (dx * dx + dy * dy + dz * dz > 1.0) {
|
||||
this.setPosition(x, y, z);
|
||||
this.prevPosX = x;
|
||||
this.prevPosY = y;
|
||||
this.prevPosZ = z;
|
||||
this.interpSteps = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
this.interpTargetX = x;
|
||||
this.interpTargetY = y;
|
||||
this.interpTargetZ = z;
|
||||
|
||||
@@ -28,9 +28,17 @@ public class RequestProperSpawnData extends AbstractPacket {
|
||||
private static final int BATCH_LIMIT = 5;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static final Set<Integer> entitiesToFix = new HashSet<>();
|
||||
private static Set<Integer> entitiesToFix;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static long lastBatchAttemptMillis = 0;
|
||||
private static long lastBatchAttemptMillis;
|
||||
|
||||
static {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
entitiesToFix = new HashSet<>();
|
||||
lastBatchAttemptMillis = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int entityId;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta6")
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta6.1")
|
||||
public class CustomNpcs {
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
|
||||
@@ -118,10 +118,11 @@ public class FieldDef {
|
||||
return def;
|
||||
}
|
||||
|
||||
public static FieldDef subGuiField(String label, Supplier<SubGuiInterface> factory, Consumer<SubGuiInterface> resultHandler) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> FieldDef subGuiField(String label, Supplier<T> factory, Consumer<T> resultHandler) {
|
||||
FieldDef def = new FieldDef(label, FieldType.SUB_GUI);
|
||||
def.subGuiFactory = factory;
|
||||
def.subGuiResultHandler = resultHandler;
|
||||
def.subGuiFactory = (Supplier<SubGuiInterface>) (Supplier<?>) factory;
|
||||
def.subGuiResultHandler = (Consumer<SubGuiInterface>) (Consumer<?>) resultHandler;
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,15 +62,16 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
} else if (heightOffGround > this.ais.flyHeightLimit) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
if (aboveLimit && this.ais.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
if (aboveLimit && this.ais.hasFlyLimit) {
|
||||
this.flyLimitAllow = false;
|
||||
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
||||
if (this.motionY > 0) {
|
||||
this.motionY = 0;
|
||||
} else {
|
||||
setNpcFlyingState(false);
|
||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||
return;
|
||||
}
|
||||
} else if (heightOffGround < Math.ceil(this.height) && this.motionY == 0) {
|
||||
this.flyLimitAllow = false;
|
||||
setNpcFlyingState(false);
|
||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||
return;
|
||||
}
|
||||
this.flyLimitAllow = true;
|
||||
setNpcFlyingState(true);
|
||||
@@ -120,15 +121,16 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
} else if (heightOffGround > this.ais.flyHeightLimit) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
if (aboveLimit && this.ais.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
if (aboveLimit && this.ais.hasFlyLimit) {
|
||||
this.flyLimitAllow = false;
|
||||
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
||||
if (this.motionY > 0) {
|
||||
this.motionY = 0;
|
||||
} else {
|
||||
setNpcFlyingState(false);
|
||||
super.performMountedMovement(strafe, forward, moveSpeed);
|
||||
return;
|
||||
}
|
||||
} else if (heightOffGround < Math.ceil(this.height) && this.motionY == 0) {
|
||||
this.flyLimitAllow = false;
|
||||
setNpcFlyingState(false);
|
||||
super.performMountedMovement(strafe, forward, moveSpeed);
|
||||
return;
|
||||
}
|
||||
this.flyLimitAllow = true;
|
||||
setNpcFlyingState(true);
|
||||
|
||||
@@ -789,7 +789,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
|
||||
}
|
||||
|
||||
public void setRace(byte race) {
|
||||
if (race < 0 || race > 1)
|
||||
if (race < 0 || race > 5)
|
||||
return;
|
||||
|
||||
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRace", race);
|
||||
|
||||
Reference in new issue
Block a user