Skip to content

Commit

Permalink
Updated MekaSuit Helmet
Browse files Browse the repository at this point in the history
Use DE's Gui to configure the MekaSuit Helmet
  • Loading branch information
sddsd2332 committed Nov 29, 2024
1 parent f01d141 commit d9cd322
Show file tree
Hide file tree
Showing 8 changed files with 376 additions and 88 deletions.
61 changes: 29 additions & 32 deletions src/main/java/mekanism/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public class ClientTickHandler {
public static Set<IClientTicker> tickingSet = new ReferenceOpenHashSet<>();
public static Map<EntityPlayer, TeleportData> portableTeleports = new Object2ObjectOpenHashMap<>();
public static int wheelStatus = 0;
public static boolean visionEnhancement = false;
public boolean initHoliday = false;
public boolean shouldReset = false;
public static boolean visionEnhancement = false;

public static void killDeadNetworks() {
tickingSet.removeIf(iClientTicker -> !iClientTicker.needsTicks());
Expand Down Expand Up @@ -166,17 +166,6 @@ public static void portableTeleport(EntityPlayer player, EnumHand hand, Frequenc
}
}

@SubscribeEvent
public void renderEntityPre(RenderPlayerEvent.Pre evt) {
setModelVisibility(evt.getEntityPlayer(), evt.getRenderer(), false);
}


@SubscribeEvent
public void renderEntityPost(RenderPlayerEvent.Post evt) {
setModelVisibility(evt.getEntityPlayer(), evt.getRenderer(), true);
}

private static void setModelVisibility(EntityPlayer entity, Render<?> entityModel, boolean showModel) {
if (entityModel instanceof RenderPlayer renderPlayer) {
if (entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem() instanceof ItemMekaSuitArmor) {
Expand Down Expand Up @@ -204,14 +193,27 @@ private static void setModelVisibility(EntityPlayer entity, Render<?> entityMode
}
}

public static boolean isVisionEnhancementOn(EntityPlayer player) {
ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
return !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour armour && UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.VisionEnhancementUnit) && armour.isVision;
}

@SubscribeEvent
public void renderEntityPre(RenderPlayerEvent.Pre evt) {
setModelVisibility(evt.getEntityPlayer(), evt.getRenderer(), false);
}

@SubscribeEvent
public void renderEntityPost(RenderPlayerEvent.Post evt) {
setModelVisibility(evt.getEntityPlayer(), evt.getRenderer(), true);
}

//Maybe it works
@SubscribeEvent
public void remove(WorldEvent.Unload event) {
portableTeleports.remove(mc.player);
}


@SubscribeEvent
public void onTick(ClientTickEvent event) {
if (event.phase == Phase.START) {
Expand Down Expand Up @@ -451,19 +453,6 @@ public void onMouseEvent(MouseEvent event) {
}
}

private static class TeleportData {

private EnumHand hand;
private Frequency freq;
private long teleportTime;

public TeleportData(EnumHand h, Frequency f, long t) {
hand = h;
freq = f;
teleportTime = t;
}
}

@SubscribeEvent
public void GuiScreenEvent(GuiOpenEvent event) {
if (event.getGui() instanceof GuiGameOver) {
Expand All @@ -472,18 +461,13 @@ public void GuiScreenEvent(GuiOpenEvent event) {
}
if (mc.player instanceof EntityPlayerSP) {
ItemStack head = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!mc.player.isEntityAlive() && !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour && UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE)) {
if (!mc.player.isEntityAlive() && !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour armour && ((UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE) && armour.getEmergency(head)) || (UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT) && armour.getInterception(head)))) {
event.setCanceled(true);
}
}
}
}

public static boolean isVisionEnhancementOn(EntityPlayer player) {
ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
return !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour armour&& UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.VisionEnhancementUnit) && armour.isVision;
}

@SubscribeEvent
public void onFogLighting(EntityViewRenderEvent.FogColors event) {
if (visionEnhancement) {
Expand Down Expand Up @@ -511,4 +495,17 @@ public void onFog(EntityViewRenderEvent.RenderFogEvent event) {
}
}

private static class TeleportData {

private EnumHand hand;
private Frequency freq;
private long teleportTime;

public TeleportData(EnumHand h, Frequency f, long t) {
hand = h;
freq = f;
teleportTime = t;
}
}

}
24 changes: 13 additions & 11 deletions src/main/java/mekanism/common/CommonPlayerTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public void isMekAsuitArmorFlying(EntityPlayer player) {
}



@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event) {
EntityLivingBase entity = event.getEntityLiving();
Expand Down Expand Up @@ -401,18 +400,16 @@ public void getBreakSpeed(PlayerEvent.BreakSpeed event) {
event.setNewSpeed(speed);
}

@Desugar
private record FallEnergyInfo(ItemStack stack, float damageRatio, float energyCost) {
}

//When the player dies
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {
if (event.getEntityLiving() instanceof EntityPlayer player) {
ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour && UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE)) {
if (!head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour armour &&
((UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE) && armour.getEmergency(head)) ||
(UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT) && armour.getInterception(head)))) {
event.setCanceled(true);
if (!UpgradeHelper.isUpgradeInstalled(head,moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT)){
if (!UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT)) {
int installed = UpgradeHelper.getUpgradeLevel(head, moduleUpgrade.EMERGENCY_RESCUE);
int toAdd = Math.max(installed - 1, 0);
UpgradeHelper.setUpgradeLevel(head, moduleUpgrade.EMERGENCY_RESCUE, toAdd);
Expand All @@ -429,15 +426,16 @@ public void onDeath(LivingDeathEvent event) {
}
}


@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
//If the player is affected by setHealth
//What? Why do you want to go straight to setHealth?
if (MekanismConfig.current().mekce.MekAsuitOverloadProtection.val()){
if (MekanismConfig.current().mekce.MekAsuitOverloadProtection.val()) {
if (event.getEntityLiving() instanceof EntityPlayer player) {
ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!player.isEntityAlive() && !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour && UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE)) {
if (!player.isEntityAlive() && !head.isEmpty() && head.getItem() instanceof ItemMekAsuitHeadArmour armour &&
((UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.EMERGENCY_RESCUE) && armour.getEmergency(head)) ||
(UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT) && armour.getInterception(head)))) {
player.hurtResistantTime = 20;
player.deathTime = 0;
player.isDead = false;
Expand All @@ -448,7 +446,7 @@ public void onLivingUpdate(LivingUpdateEvent event) {
player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 2));
player.setAir(300);
player.getFoodStats().addStats(20, 20);
if (!UpgradeHelper.isUpgradeInstalled(head,moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT)){
if (!UpgradeHelper.isUpgradeInstalled(head, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT)) {
int installed = UpgradeHelper.getUpgradeLevel(head, moduleUpgrade.EMERGENCY_RESCUE);
int toAdd = Math.max(installed - 1, 0);
UpgradeHelper.setUpgradeLevel(head, moduleUpgrade.EMERGENCY_RESCUE, toAdd);
Expand All @@ -457,4 +455,8 @@ public void onLivingUpdate(LivingUpdateEvent event) {
}
}
}

@Desugar
private record FallEnergyInfo(ItemStack stack, float damageRatio, float energyCost) {
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mekanism.common.item.armor;

import com.brandon3055.draconicevolution.api.itemconfig.ItemConfigFieldRegistry;
import com.google.common.collect.Multimap;
import mekanism.api.EnumColor;
import mekanism.api.gas.Gas;
Expand Down Expand Up @@ -253,12 +254,16 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if (!world.isRemote) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
ItemStack headStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
boolean isHealth = false;
if (headStack.getItem() instanceof ItemMekAsuitHeadArmour armour){
isHealth = UpgradeHelper.isUpgradeInstalled(headStack, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT) && armour.getInterception(headStack);
}
if (chestStack.getItem() instanceof ItemMekAsuitBodyArmour) {
if (UpgradeHelper.isUpgradeInstalled(chestStack, moduleUpgrade.CHARGE_DISTRIBUTION_UNIT)) {
chargeSuit(player);
}
if (UpgradeHelper.isUpgradeInstalled(chestStack, moduleUpgrade.HEALTH_REGENERATION)) {
if (!UpgradeHelper.isUpgradeInstalled(headStack, moduleUpgrade.ADVANCED_INTERCEPTION_SYSTEM_UNIT)) {
if (isHealth) {
ArmourTick++;
if (player.getHealth() < player.getMaxHealth() && ArmourTick % 20 == 0) {
player.heal(UpgradeHelper.getUpgradeLevel(chestStack, moduleUpgrade.HEALTH_REGENERATION));
Expand Down
Loading

0 comments on commit d9cd322

Please sign in to comment.