mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 08:03:06 +00:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/main/java/noppes/npcs/controllers/AuctionController.java
This commit is contained in:
commit
e7b033ecf0
19 files changed
+242
-165
No files matched your search
+3
-3
@@ -14,7 +14,7 @@ public class AbilityPotionEffect {
|
||||
private EnumPotionType type = EnumPotionType.None;
|
||||
private int manualPotionId = 0;
|
||||
private int durationTicks = 60;
|
||||
private int amplifier = 0; // 0-10
|
||||
private int amplifier = 0; // 0-255 (Manual), 0-10 (preset)
|
||||
|
||||
public AbilityPotionEffect() {
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class AbilityPotionEffect {
|
||||
public AbilityPotionEffect(EnumPotionType type, int durationTicks, int amplifier) {
|
||||
this.type = type;
|
||||
this.durationTicks = Math.max(1, durationTicks);
|
||||
this.amplifier = Math.max(0, Math.min(10, amplifier));
|
||||
this.amplifier = Math.max(0, Math.min(255, amplifier));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ public class AbilityPotionEffect {
|
||||
}
|
||||
|
||||
public void setAmplifier(int amplifier) {
|
||||
this.amplifier = Math.max(0, Math.min(10, amplifier));
|
||||
this.amplifier = Math.max(0, Math.min(255, amplifier));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,11 +112,22 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
widgetId++;
|
||||
|
||||
if (effect.getType() != EnumPotionType.Fire) {
|
||||
GuiNpcButton ampBtn = new GuiNpcButton(widgetId, colLLabel + 158, y, 40, 20, ampValues, effect.getAmplifier());
|
||||
sw.addButton(ampBtn);
|
||||
buttonFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 2});
|
||||
widgetId++;
|
||||
if (effect.getType() == EnumPotionType.Manual) {
|
||||
GuiNpcTextField ampField = new GuiNpcTextField(widgetId, parent, fontRenderer,
|
||||
colLLabel + 158, y, 40, 20, String.valueOf(effect.getAmplifier()));
|
||||
ampField.setIntegersOnly();
|
||||
ampField.setMinMaxDefault(0, 255, 0);
|
||||
sw.addTextField(ampField);
|
||||
textFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 2});
|
||||
widgetId++;
|
||||
} else {
|
||||
GuiNpcButton ampBtn = new GuiNpcButton(widgetId, colLLabel + 158, y, 40, 20, ampValues, effect.getAmplifier());
|
||||
sw.addButton(ampBtn);
|
||||
buttonFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 2});
|
||||
widgetId++;
|
||||
}
|
||||
} else {
|
||||
widgetId++;
|
||||
}
|
||||
@@ -367,8 +378,14 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
if (effects == null) return false;
|
||||
switch (action) {
|
||||
case 0:
|
||||
if (idx < effects.size())
|
||||
effects.get(idx).setType(EnumPotionType.fromIndexNoNone(((GuiNpcButton) button).getValue()));
|
||||
if (idx < effects.size()) {
|
||||
EnumPotionType oldType = effects.get(idx).getType();
|
||||
EnumPotionType newType = EnumPotionType.fromIndexNoNone(((GuiNpcButton) button).getValue());
|
||||
if (oldType == EnumPotionType.Manual && newType != EnumPotionType.Manual) {
|
||||
effects.get(idx).setAmplifier(0);
|
||||
}
|
||||
effects.get(idx).setType(newType);
|
||||
}
|
||||
return true;
|
||||
case 2:
|
||||
if (idx < effects.size())
|
||||
@@ -471,6 +488,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
List<AbilityPotionEffect> effects = (List<AbilityPotionEffect>) def.getValue();
|
||||
if (effects != null && idx < effects.size()) {
|
||||
if (action == 1) effects.get(idx).setDurationTicks(field.getInteger());
|
||||
else if (action == 2) effects.get(idx).setAmplifier(field.getInteger());
|
||||
else if (action == 5) effects.get(idx).setManualPotionId(field.getInteger());
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import kamkeel.npcs.network.enums.EnumDataPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
@@ -86,7 +87,7 @@ public final class AbilityCooldownSyncPacket extends AbstractPacket {
|
||||
perDurations.put(key, duration);
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
PlayerData data = ClientCacheHandler.playerData;
|
||||
if (data != null && data.abilityData != null) {
|
||||
data.abilityData.applyCooldownSync(globalEndTime, globalDuration, perEndTimes, perDurations);
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
@@ -53,7 +54,7 @@ public final class PlayerAbilitySyncPacket extends AbstractPacket {
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
if (nbt == null) return;
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
PlayerData data = ClientCacheHandler.playerData;
|
||||
if (data != null) {
|
||||
data.abilityData.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@@ -366,8 +366,9 @@ public class ManageAuctionPacket extends AbstractPacket {
|
||||
String result = controller.createGlobalListing(player, sellerName, item, startingPrice, buyoutPrice, durationHours);
|
||||
if (result != null) {
|
||||
// Failed create, return item (or drop to avoid loss).
|
||||
if (!player.inventory.addItemStackToInventory(item.copy())) {
|
||||
player.entityDropItem(item.copy(), 0.5f);
|
||||
// Use same reference so partial add mutates stackSize, then drop only the remainder.
|
||||
if (!player.inventory.addItemStackToInventory(item)) {
|
||||
player.entityDropItem(item, 0.5f);
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
|
||||
Reference in new issue
Block a user