-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/net/romvoid95/gctweaks/base/core/TickHandlerClientOverride.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.romvoid95.gctweaks.base.core; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; | ||
import micdoodle8.mods.galacticraft.core.client.gui.overlay.OverlayOxygenWarning; | ||
import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient; | ||
import micdoodle8.mods.galacticraft.core.tick.TickHandlerClient; | ||
import micdoodle8.mods.galacticraft.core.util.PlayerUtil; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.EntityPlayerSP; | ||
import net.minecraftforge.fml.client.FMLClientHandler; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent; | ||
|
||
public class TickHandlerClientOverride { | ||
|
||
@SubscribeEvent | ||
public void onRenderTick(RenderTickEvent event) { | ||
long tickCount = 0; | ||
try { | ||
Field tick = TickHandlerClient.class.getDeclaredField("tickCount"); | ||
tick.setAccessible(true); | ||
tickCount = tick.getLong(null); | ||
} catch (Exception e) { | ||
|
||
} | ||
final Minecraft minecraft = FMLClientHandler.instance().getClient(); | ||
final EntityPlayerSP player = minecraft.player; | ||
final EntityPlayerSP playerBaseClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false); | ||
|
||
if (player == null || playerBaseClient == null) { | ||
return; | ||
} | ||
|
||
GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerBaseClient); | ||
|
||
if (event.phase == Phase.END) { | ||
if (playerBaseClient != null && player.world.provider instanceof IGalacticraftWorldProvider | ||
&& !stats.isOxygenSetupValid()) { | ||
if (minecraft.currentScreen == null && !minecraft.gameSettings.hideGUI | ||
&& !(playerBaseClient.isCreative() || playerBaseClient.isSpectator())) { | ||
OverlayOxygenWarning.renderOxygenWarningOverlay(minecraft, tickCount); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
9 changes: 6 additions & 3 deletions
9
src/main/java/net/romvoid95/gctweaks/base/core/proxy/ClientProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/main/java/net/romvoid95/gctweaks/gc/features/breathable/OxygenPlanets.java
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
src/main/java/net/romvoid95/gctweaks/gc/features/oxytoggle/OxygenToggle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package net.romvoid95.gctweaks.gc.features.oxytoggle; | ||
|
||
import micdoodle8.mods.galacticraft.api.event.oxygen.GCCoreOxygenSuffocationEvent; | ||
import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; | ||
import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; | ||
import micdoodle8.mods.galacticraft.core.util.DamageSourceGC; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.entity.living.LivingEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.romvoid95.gctweaks.base.Feature; | ||
import net.romvoid95.gctweaks.base.core.TickHandlerClientOverride; | ||
|
||
public class OxygenToggle extends Feature { | ||
|
||
private static boolean oxygenToggle; | ||
private int[] setDimsBreatheable; | ||
private int[] setDimsNonBreatheable; | ||
private TickHandlerClientOverride clientHandler; | ||
|
||
@Override | ||
public String comment() { | ||
return "Define which planets will be breatheable or not"; | ||
} | ||
|
||
@Override | ||
public String category() { | ||
return "oxygenToggle"; | ||
} | ||
|
||
@Override | ||
public void syncConfig(String category) { | ||
oxygenToggle = set(category, "enableFeature", false); | ||
setDimsBreatheable = set(category, "breathableDims", | ||
"Data consisting of which Dimensions Players can breahte in", new int[] { -29, -31 }); | ||
setDimsNonBreatheable = set(category, "nonBreathableDims", | ||
"Data consisting of which Dimensions Players can NOT breahte in", new int[] { -1030 }); | ||
} | ||
|
||
@Override | ||
public boolean usesEvents() { | ||
return true; | ||
} | ||
|
||
@SubscribeEvent | ||
public void GCCoreOxygenSuffocationEvent(GCCoreOxygenSuffocationEvent.Pre event) { | ||
if (oxygenToggle) { | ||
EntityPlayer player = (EntityPlayer) event.getEntityLiving(); | ||
|
||
for (int dimId : setDimsBreatheable) { | ||
if (setDimsBreatheable.length == 0) { | ||
return; | ||
} | ||
if (player.world.provider.getDimensionType().getId() == dimId) { | ||
event.setCanceled(true); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void entityLivingEvent(LivingEvent.LivingUpdateEvent event) { | ||
if (oxygenToggle) { | ||
if (setDimsNonBreatheable.length == 0) { | ||
return; | ||
} | ||
final EntityLivingBase entityLiving = event.getEntityLiving(); | ||
if (entityLiving instanceof EntityPlayer && entityLiving.ticksExisted % ConfigManagerCore.suffocationCooldown == 0) { | ||
IGalacticraftWorldProvider galacticraftWorldProvider = (IGalacticraftWorldProvider) entityLiving.world.provider; | ||
if (galacticraftWorldProvider.hasBreathableAtmosphere()) { | ||
for (int dimId : setDimsNonBreatheable) { | ||
if (entityLiving.world.provider.getDimensionType().getId() == dimId) { | ||
GCCoreOxygenSuffocationEvent suffocationEvent = new GCCoreOxygenSuffocationEvent.Pre( | ||
entityLiving); | ||
MinecraftForge.EVENT_BUS.post(suffocationEvent); | ||
|
||
entityLiving.attackEntityFrom(DamageSourceGC.oxygenSuffocation, | ||
Math.max(ConfigManagerCore.suffocationDamage / 2, 1)); | ||
|
||
GCCoreOxygenSuffocationEvent suffocationEventPost = new GCCoreOxygenSuffocationEvent.Post( | ||
entityLiving); | ||
MinecraftForge.EVENT_BUS.post(suffocationEventPost); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |