Dome, Panel Settings

This commit is contained in:
Kam committed 2026-02-20 18:16:52 -05:00
1 parent 14545818bd
commit f620e820e8
16 files changed
+752 -146

No files matched your search

@@ -430,6 +430,7 @@ public class CustomNpcs {
}
kamkeel.npcs.entity.EntityEnergyProjectile.clearAllProjectiles();
kamkeel.npcs.entity.EntityEnergyBarrier.clearAllBarriers();
if (FMLCommonHandler.instance().getSide().isClient())
clientJaninoCompiler = null;
@@ -30,6 +30,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import kamkeel.npcs.entity.EntityEnergyBarrier;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
@@ -151,6 +152,52 @@ public class ServerEventsHandler {
}
}
@SubscribeEvent
public void barrierDamageProtection(LivingAttackEvent event) {
if (event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving.worldObj.isRemote)
return;
EntityEnergyBarrier barrier = EntityEnergyBarrier.getProtectingBarrier(event.entityLiving);
if (barrier != null && barrier.isDamageFromOutside(event.source)) {
// Redirect the damage to the barrier instead of preventing it
barrier.absorbDamage(event.ammount);
event.setCanceled(true);
}
}
@SubscribeEvent
public void domeItemBlacklist(PlayerInteractEvent event) {
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return;
EntityPlayer player = event.entityPlayer;
if (player == null || player.worldObj == null || player.worldObj.isRemote) return;
ItemStack held = player.getHeldItem();
if (held == null) return;
String itemId = net.minecraft.item.Item.itemRegistry.getNameForObject(held.getItem());
if (itemId == null) return;
String[] blacklist = noppes.npcs.config.ConfigEnergy.DomeItemBlacklist;
if (blacklist == null) return;
boolean blacklisted = false;
for (String banned : blacklist) {
if (banned.equals(itemId)) {
blacklisted = true;
break;
}
}
if (!blacklisted) return;
List<EntityEnergyBarrier> barriers = EntityEnergyBarrier.getActiveBarriers(player.worldObj);
for (EntityEnergyBarrier barrier : barriers) {
if (barrier instanceof kamkeel.npcs.entity.EntityEnergyDome && barrier.isEntityInside(player)) {
event.setCanceled(true);
return;
}
}
}
@SubscribeEvent
public void partyDamagedEvent(LivingAttackEvent event) {
if (!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient())
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;
import kamkeel.npcs.client.renderer.lightning.LightningBolt;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
@@ -203,6 +204,40 @@ public class ClientTickHandler {
}
}
/**
* Enforce ability lock motion constraints right before entity update.
* The Phase.END zeroing in onClientTick can be overwritten by other mods'
* ClientTickEvent Phase.START handlers (e.g. flight mods re-applying gravity).
* PlayerTickEvent fires after all ClientTickEvent handlers but before
* player.onUpdate(), making this the definitive point to enforce motion locks.
*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.phase != Phase.START || event.side != Side.CLIENT)
return;
Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer == null || mc.currentScreen != null)
return;
if (!ClientAbilityState.shouldSuppressMovementInput())
return;
if (!ClientAbilityState.hasAbilityMovement) {
mc.thePlayer.motionX = 0;
mc.thePlayer.motionZ = 0;
}
if ((ClientAbilityState.movementLocked || ClientAbilityState.positionLocked)
&& !ClientAbilityState.hasAbilityMovement) {
if (ClientAbilityState.wasFlyingAtLock) {
mc.thePlayer.motionY = 0;
} else {
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY, 0);
}
}
}
@SubscribeEvent
public void onMouse(InputEvent.MouseInputEvent event) {
if (Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0)
@@ -0,0 +1,37 @@
package noppes.npcs.config;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level;
import java.io.File;
public class ConfigEnergy {
public static Configuration config;
public final static String DOMES = "Domes";
public static String[] DomeItemBlacklist;
public static void init(File configFile) {
config = new Configuration(configFile);
try {
config.load();
DomeItemBlacklist = config.getStringList(
"Item Blacklist", DOMES,
new String[]{"minecraft:ender_pearl"},
"Items that cannot be used while inside an Energy Dome.\n"
+ "Format: modid:itemname (e.g., minecraft:ender_pearl)"
);
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "CustomNPC+ has had a problem loading its energy configuration");
} finally {
if (config.hasChanged()) {
config.save();
}
}
}
}
@@ -10,6 +10,7 @@ public class LoadConfiguration {
public static File clientConfigFile;
public static File experimentalConfigFile;
public static File marketConfigFile;
public static File energyConfigFile;
public static void init(String configpath) {
mainConfigFile = new File(configpath + "main.cfg");
@@ -19,6 +20,7 @@ public class LoadConfiguration {
debugConfigFile = new File(configpath + "debug.cfg");
experimentalConfigFile = new File(configpath + "experimental.cfg");
marketConfigFile = new File(configpath + "market.cfg");
energyConfigFile = new File(configpath + "energy.cfg");
ConfigMain.init(mainConfigFile);
ConfigItem.init(itemConfigFile);
@@ -27,5 +29,6 @@ public class LoadConfiguration {
ConfigDebug.init(debugConfigFile);
ConfigExperimental.init(experimentalConfigFile);
ConfigMarket.init(marketConfigFile);
ConfigEnergy.init(energyConfigFile);
}
}