Skip to content

Commit 16f79f5

Browse files
committed
revert: commit 8137f7d
1 parent 90d3a19 commit 16f79f5

File tree

3 files changed

+273
-228
lines changed

3 files changed

+273
-228
lines changed

src/main/java/micdoodle8/mods/galacticraft/core/GalacticraftCore.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Team Galacticraft
2+
* Copyright (c) 2023 Team Galacticraft
33
*
44
* Licensed under the MIT license.
55
* See LICENSE file in the project root for details.
@@ -126,6 +126,7 @@
126126
import micdoodle8.mods.galacticraft.core.entities.EntitySkeletonBoss;
127127
import micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket;
128128
import micdoodle8.mods.galacticraft.core.entities.player.GCCapabilities;
129+
import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerBaseMP;
129130
import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerHandler;
130131
import micdoodle8.mods.galacticraft.core.event.EventHandlerGC;
131132
import micdoodle8.mods.galacticraft.core.event.LootHandlerGC;
@@ -206,6 +207,8 @@
206207
import micdoodle8.mods.galacticraft.planets.mars.recipe.RecipeManagerMars;
207208
import micdoodle8.mods.galacticraft.planets.venus.recipe.RecipeManagerVenus;
208209

210+
import api.player.server.ServerPlayerAPI;
211+
209212
//@noformat
210213
@Mod(
211214
modid = Constants.MOD_ID_CORE,
@@ -311,6 +314,11 @@ public void preInit(FMLPreInitializationEvent event)
311314

312315
GCFluids.registerOilandFuel();
313316

317+
if (CompatibilityManager.PlayerAPILoaded)
318+
{
319+
ServerPlayerAPI.register(Constants.MOD_ID_CORE, GCPlayerBaseMP.class);
320+
}
321+
314322
GCBlocks.initBlocks();
315323
GCItems.initItems();
316324

@@ -618,9 +626,11 @@ private void handleConfigFilenameChange(FMLPreInitializationEvent event)
618626
{
619627
File oldCoreConfig = new File(event.getModConfigurationDirectory(), Constants.OLD_CONFIG_FILE);
620628
File oldPowerConfig = new File(event.getModConfigurationDirectory(), Constants.OLD_POWER_CONFIG_FILE);
629+
File oldChunkLoaderConfig = new File(event.getModConfigurationDirectory(), Constants.OLD_CHUNKLOADER_CONFIG_FILE);
621630

622631
File coreConfig = new File(event.getModConfigurationDirectory(), Constants.CONFIG_FILE);
623632
File powerConfig = new File(event.getModConfigurationDirectory(), Constants.POWER_CONFIG_FILE);
633+
File chunkLoaderConfig = new File(event.getModConfigurationDirectory(), Constants.CHUNKLOADER_CONFIG_FILE);
624634

625635
if (oldCoreConfig.exists())
626636
{
@@ -632,8 +642,14 @@ private void handleConfigFilenameChange(FMLPreInitializationEvent event)
632642
oldPowerConfig.renameTo(powerConfig);
633643
}
634644

645+
if (oldChunkLoaderConfig.exists())
646+
{
647+
oldChunkLoaderConfig.renameTo(chunkLoaderConfig);
648+
}
649+
635650
ConfigManagerCore.initialize(coreConfig);
636651
EnergyConfigHandler.setDefaultValues(powerConfig);
652+
ChunkLoadingCallback.loadConfig(chunkLoaderConfig);
637653
}
638654

639655
private void moveLegacyGCFileLocations(File worldFolder)

src/main/java/micdoodle8/mods/galacticraft/core/event/EventHandlerGC.java

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/*
2-
* Copyright (c) 2022 Team Galacticraft
2+
* Copyright (c) 2023 Team Galacticraft
33
*
44
* Licensed under the MIT license.
55
* See LICENSE file in the project root for details.
66
*/
77

88
package micdoodle8.mods.galacticraft.core.event;
99

10-
import java.lang.reflect.Field;
1110
import java.util.ArrayList;
1211
import java.util.Collections;
1312
import java.util.HashMap;
@@ -75,6 +74,9 @@
7574
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
7675
import net.minecraftforge.event.terraingen.TerrainGen;
7776
import net.minecraftforge.event.world.BlockEvent;
77+
import net.minecraftforge.event.world.ChunkDataEvent;
78+
import net.minecraftforge.event.world.ChunkEvent.Load;
79+
import net.minecraftforge.event.world.WorldEvent.Save;
7880
import net.minecraftforge.fml.client.FMLClientHandler;
7981
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
8082
import net.minecraftforge.fml.common.eventhandler.Event;
@@ -111,11 +113,13 @@
111113
import micdoodle8.mods.galacticraft.core.network.PacketSimple.EnumSimplePacket;
112114
import micdoodle8.mods.galacticraft.core.proxy.ClientProxyCore;
113115
import micdoodle8.mods.galacticraft.core.tick.TickHandlerServer;
116+
import micdoodle8.mods.galacticraft.core.util.ASMUtil;
114117
import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore;
115118
import micdoodle8.mods.galacticraft.core.util.DamageSourceGC;
116119
import micdoodle8.mods.galacticraft.core.util.GCCoreUtil;
117120
import micdoodle8.mods.galacticraft.core.util.OxygenUtil;
118121
import micdoodle8.mods.galacticraft.core.util.PlayerUtil;
122+
import micdoodle8.mods.galacticraft.core.world.ChunkLoadingCallback;
119123
import micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData;
120124
import micdoodle8.mods.galacticraft.planets.asteroids.AsteroidsModule;
121125
import micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars;
@@ -126,6 +130,27 @@ public class EventHandlerGC
126130
public static Map<Block, Item> bucketList = new HashMap<>(4, 1F);
127131
public static boolean bedActivated;
128132

133+
@SubscribeEvent
134+
public void onWorldSave(Save event)
135+
{
136+
ChunkLoadingCallback.save((WorldServer) event.getWorld());
137+
}
138+
139+
@SubscribeEvent
140+
public void onChunkDataLoad(ChunkDataEvent.Load event)
141+
{
142+
ChunkLoadingCallback.load((WorldServer) event.getWorld());
143+
}
144+
145+
@SubscribeEvent
146+
public void onWorldLoad(Load event)
147+
{
148+
if (!event.getWorld().isRemote)
149+
{
150+
ChunkLoadingCallback.load((WorldServer) event.getWorld());
151+
}
152+
}
153+
129154
@SubscribeEvent
130155
public void playerJoinWorld(EntityJoinWorldEvent event)
131156
{
@@ -882,9 +907,6 @@ public void overrideSkyColor(EntityViewRenderEvent.FogColors event)
882907

883908
private List<SoundPlayEntry> soundPlayList = new ArrayList<>();
884909

885-
private static Field volumeField;
886-
private static Field pitchField;
887-
888910
@SideOnly(Side.CLIENT)
889911
@SubscribeEvent
890912
public void onSoundPlayed(PlaySoundEvent event)
@@ -923,36 +945,10 @@ public void onSoundPlayed(PlaySoundEvent event)
923945
float volume = 1.0F;
924946
float pitch = 1.0F;
925947

926-
if (volumeField == null)
927-
{
928-
try
929-
{
930-
volumeField = PositionedSound.class.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "volume" : "field_147662_b"); // TODO
931-
// Obfuscated
932-
// environment
933-
// support
934-
volumeField.setAccessible(true);
935-
pitchField = PositionedSound.class.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "pitch" : "field_147663_c"); // TODO
936-
// Obfuscated
937-
// environment
938-
// support
939-
pitchField.setAccessible(true);
940-
} catch (Exception e)
941-
{
942-
e.printStackTrace();
943-
}
944-
}
945-
946-
if (volumeField != null && pitchField != null)
948+
if (event.getSound() instanceof PositionedSound)
947949
{
948-
try
949-
{
950-
volume = event.getSound() instanceof PositionedSound ? (float) volumeField.get(event.getSound()) : 1.0F;
951-
pitch = event.getSound() instanceof PositionedSound ? (float) pitchField.get(event.getSound()) : 1.0F;
952-
} catch (IllegalAccessException e)
953-
{
954-
e.printStackTrace();
955-
}
950+
volume = ASMUtil.getPrivateValue(PositionedSound.class, (PositionedSound) event.getSound(), "volume", "field_147662_b");
951+
pitch = ASMUtil.getPrivateValue(PositionedSound.class, (PositionedSound) event.getSound(), "pitch", "field_147663_c");
956952
}
957953

958954
// First check for duplicate firing of PlaySoundEvent17

0 commit comments

Comments
 (0)