Skip to content

Commit eb23b52

Browse files
committed
Done
1 parent 103013f commit eb23b52

8 files changed

Lines changed: 145 additions & 34 deletions

File tree

dependencies.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66
transitive = false
77
}
88
compileOnly "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
9-
compileOnly('com.github.GTNewHorizons:TC4Tweaks:1.4.26:dev') {
9+
compileOnly('curse.maven:tc4tweaks-431297:7441877') {
1010
transitive = false
1111
}
1212
compileOnly "curse.maven:chunkpregen-267193:3756388"
@@ -36,6 +36,8 @@ dependencies {
3636
compileOnly(deobfMaven(curseMaven, "curse.maven:ars-magica-2-67313:2280862"))
3737
compileOnly(deobfMaven(curseMaven, "curse.maven:waystones-245755:2559125"))
3838
runtimeOnly(deobf("https://github.com/makamys/CoreTweaks/releases/download/0.3.3.2/CoreTweaks-1.7.10-0.3.3.2+nomixin.jar"))
39+
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.8.1:dev")
40+
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.7.1:dev")
3941

4042
if(!Boolean.valueOf(project.properties["archaicFix.noRuntimeExtras"] ?: "false")) {
4143
runtimeOnly(deobfMaven(curseMaven, "curse.maven:xaerosminimap-263420:3876755"))

src/main/java/org/embeddedt/archaicfix/ArchaicFix.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.embeddedt.archaicfix;
22

3+
import com.falsepattern.chunk.api.DataRegistry;
34
import cpw.mods.fml.common.FMLCommonHandler;
45
import cpw.mods.fml.common.Loader;
56
import cpw.mods.fml.common.SidedProxy;
@@ -16,6 +17,9 @@
1617
import net.minecraft.network.NetHandlerPlayServer;
1718
import net.minecraftforge.common.MinecraftForge;
1819
import org.embeddedt.archaicfix.asm.EarlyStringPool;
20+
import org.embeddedt.archaicfix.asm.TargetedMod;
21+
import org.embeddedt.archaicfix.chunkapi.ChunkAPICompat;
22+
import org.embeddedt.archaicfix.chunkapi.ChunkLightingDataManager;
1923
import org.embeddedt.archaicfix.config.ArchaicConfig;
2024
import org.embeddedt.archaicfix.ducks.IAcceleratedRecipe;
2125
import org.embeddedt.archaicfix.proxy.CommonProxy;
@@ -24,7 +28,7 @@
2428

2529
import java.util.*;
2630

27-
@Mod(modid = ArchaicFix.MODID, version = ArchaicFix.VERSION, dependencies = "required-after:gtnhmixins@[2.0.0,);required-after:unimixins@[0.1.16,);", guiFactory = "org.embeddedt.archaicfix.config.ArchaicGuiConfigFactory")
31+
@Mod(modid = ArchaicFix.MODID, version = ArchaicFix.VERSION, dependencies = "required-after:gtnhmixins@[2.0.0,);required-after:unimixins@[0.1.16,);after:chunkapi", guiFactory = "org.embeddedt.archaicfix.config.ArchaicGuiConfigFactory")
2832
public class ArchaicFix
2933
{
3034
public static final String MODID = "archaicfix";
@@ -72,6 +76,10 @@ public void preinit(FMLPreInitializationEvent event)
7276

7377
@EventHandler
7478
public void init(FMLInitializationEvent event) {
79+
if (Loader.isModLoaded(TargetedMod.CHUNKAPI.ModID()))
80+
{
81+
ChunkAPICompat.init(); // This must be a call to the class because otherwise the JVM will try to load DataManager.
82+
}
7583
EarlyStringPool.clear();
7684
}
7785

src/main/java/org/embeddedt/archaicfix/asm/Mixin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
44
import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder;
5+
import cpw.mods.fml.common.Loader;
56
import lombok.Getter;
67
import lombok.RequiredArgsConstructor;
78
import org.embeddedt.archaicfix.config.ArchaicConfig;
@@ -83,6 +84,10 @@ public enum Mixin implements IMixins {
8384
"lighting.MixinMinecraft",
8485
"lighting.MixinWorld",
8586
"lighting.MixinChunkCache")),
87+
PHOSPHOR_NO_CHUNKAPI(new ArchaicBuilder()
88+
.setPhase(Phase.LATE)
89+
.setApplyIf(() -> ArchaicConfig.enablePhosphor && !Loader.isModLoaded(TargetedMod.CHUNKAPI.ModID()))
90+
.addCommonMixins("lighting.base.MixinAnvilChunkLoaderBase")),
8691
PHOSPHOR_FASTCRAFT(new ArchaicBuilder()
8792
.setPhase(Phase.EARLY)
8893
.setApplyIf(() -> ArchaicConfig.enablePhosphor)
@@ -91,7 +96,6 @@ public enum Mixin implements IMixins {
9196
"lighting.fastcraft.MixinChunk",
9297
"lighting.fastcraft.MixinChunkProviderServer",
9398
"lighting.fastcraft.MixinWorld")),
94-
9599
GREGTECH6(new ArchaicBuilder()
96100
.setPhase(Phase.LATE)
97101
.addRequiredMod(TargetedMod.GREGTECH6)

src/main/java/org/embeddedt/archaicfix/asm/TargetedMod.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum TargetedMod implements ITargetMod {
1313
ARS_MAGICA_2("arsmagica2"),
1414
BOTANIA("Botania"),
1515
CHICKENCHUNKS("ChickenChunks"),
16+
CHUNKAPI("chunkapi"),
1617
CHUNK_PREGENERATOR("chunkpregenerator"),
1718
COFHCORE("cofh.asm.LoadingPlugin", "CoFHCore"),
1819
DIVERSITY("diversity"),
@@ -35,12 +36,19 @@ public enum TargetedMod implements ITargetMod {
3536
WAYSTONES("waystones");
3637

3738
private final TargetModBuilder builder;
38-
39+
private final String ID;
40+
3941
TargetedMod(String modId) {
4042
this(null, modId);
4143
}
4244

4345
TargetedMod(String coremodClass, String modId) {
4446
this.builder = new TargetModBuilder().setCoreModClass(coremodClass).setModId(modId);
47+
this.ID = modId;
48+
}
49+
50+
public String ModID()
51+
{
52+
return ID;
4553
}
4654
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.embeddedt.archaicfix.chunkapi;
2+
3+
import com.falsepattern.chunk.api.DataRegistry;
4+
5+
public class ChunkAPICompat
6+
{
7+
public static void init()
8+
{
9+
DataRegistry.registerDataManager(new ChunkLightingDataManager(), 1000);
10+
}
11+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.embeddedt.archaicfix.chunkapi;
2+
3+
import com.falsepattern.chunk.api.DataManager;
4+
import net.minecraft.nbt.NBTTagCompound;
5+
import net.minecraft.world.chunk.Chunk;
6+
import org.embeddedt.archaicfix.lighting.api.IChunkLightingData;
7+
import org.embeddedt.archaicfix.lighting.world.lighting.LightingHooks;
8+
9+
public class ChunkLightingDataManager implements DataManager.ChunkDataManager
10+
{
11+
@Override
12+
public String domain() {
13+
return "archaicfix";
14+
}
15+
16+
@Override
17+
public String id() {
18+
return "lighting";
19+
}
20+
21+
@Override
22+
public void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt)
23+
{
24+
LightingHooks.writeNeighborLightChecksToNBT(chunk, nbt);
25+
nbt.setBoolean("LightPopulated", ((IChunkLightingData) chunk).isLightInitialized());
26+
}
27+
28+
@Override
29+
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt)
30+
{
31+
LightingHooks.readNeighborLightChecksFromNBT(chunk, nbt);
32+
((IChunkLightingData) chunk).setLightInitialized(nbt.getBoolean("LightPopulated"));
33+
}
34+
35+
@Override
36+
public void cloneChunk(Chunk from, Chunk to) {
37+
((IChunkLightingData) to).setNeighborLightChecks(((IChunkLightingData) from).getNeighborLightChecks());
38+
((IChunkLightingData) to).setLightInitialized(((IChunkLightingData) from).isLightInitialized());
39+
}
40+
41+
@Override
42+
public String version() {
43+
return "1.0";
44+
}
45+
46+
@Override
47+
public String newInstallDescription() {
48+
return "Migrating the Light Initialization checks to a DataManager when ChunkAPI is installed.";
49+
}
50+
51+
@Override
52+
public String uninstallMessage() {
53+
return "Removing Light Inititialization checks from a Datamanager. Shouldn't break anything.";
54+
}
55+
56+
@Override
57+
public String versionChangeMessage(String priorVersion)
58+
{
59+
return null;
60+
}
61+
62+
@Override
63+
public boolean chunkPrivilegedAccess() {
64+
return true;
65+
}
66+
}
Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package org.embeddedt.archaicfix.mixins.common.lighting;
22

3-
import net.minecraft.nbt.NBTTagCompound;
43
import net.minecraft.world.World;
54
import net.minecraft.world.chunk.Chunk;
65
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
7-
import org.embeddedt.archaicfix.lighting.api.IChunkLightingData;
86
import org.embeddedt.archaicfix.lighting.api.ILightingEngineProvider;
9-
import org.embeddedt.archaicfix.lighting.world.lighting.LightingHooks;
107
import org.spongepowered.asm.mixin.Mixin;
118
import org.spongepowered.asm.mixin.injection.At;
129
import org.spongepowered.asm.mixin.injection.Inject;
1310
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1511

1612
@Mixin(AnvilChunkLoader.class)
1713
public abstract class MixinAnvilChunkLoader {
@@ -24,30 +20,4 @@ public abstract class MixinAnvilChunkLoader {
2420
private void onConstructed(World world, Chunk chunkIn, CallbackInfo callbackInfo) {
2521
((ILightingEngineProvider) world).getLightingEngine().processLightUpdates();
2622
}
27-
28-
/**
29-
* Injects the deserialization logic for chunk data on load so we can extract whether or not we've populated light yet.
30-
*
31-
* @author Angeline
32-
*/
33-
@Inject(method = "readChunkFromNBT", at = @At("RETURN"))
34-
private void onReadChunkFromNBT(World world, NBTTagCompound compound, CallbackInfoReturnable<Chunk> cir) {
35-
Chunk chunk = cir.getReturnValue();
36-
37-
LightingHooks.readNeighborLightChecksFromNBT(chunk, compound);
38-
39-
((IChunkLightingData) chunk).setLightInitialized(compound.getBoolean("LightPopulated"));
40-
41-
}
42-
43-
/**
44-
* Injects the serialization logic for chunk data on save so we can store whether or not we've populated light yet.
45-
* @author Angeline
46-
*/
47-
@Inject(method = "writeChunkToNBT", at = @At("RETURN"))
48-
private void onWriteChunkToNBT(Chunk chunk, World world, NBTTagCompound compound, CallbackInfo ci) {
49-
LightingHooks.writeNeighborLightChecksToNBT(chunk, compound);
50-
51-
compound.setBoolean("LightPopulated", ((IChunkLightingData) chunk).isLightInitialized());
52-
}
5323
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.embeddedt.archaicfix.mixins.common.lighting.base;
2+
3+
import net.minecraft.nbt.NBTTagCompound;
4+
import net.minecraft.world.World;
5+
import net.minecraft.world.chunk.Chunk;
6+
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
7+
import org.embeddedt.archaicfix.lighting.api.IChunkLightingData;
8+
import org.embeddedt.archaicfix.lighting.world.lighting.LightingHooks;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14+
15+
@Mixin(AnvilChunkLoader.class)
16+
public abstract class MixinAnvilChunkLoaderBase {
17+
/**
18+
* Injects the deserialization logic for chunk data on load so we can extract whether or not we've populated light yet.
19+
*
20+
* @author Angeline
21+
*/
22+
@Inject(method = "readChunkFromNBT", at = @At("RETURN"))
23+
private void onReadChunkFromNBT(World world, NBTTagCompound compound, CallbackInfoReturnable<Chunk> cir) {
24+
Chunk chunk = cir.getReturnValue();
25+
26+
LightingHooks.readNeighborLightChecksFromNBT(chunk, compound);
27+
28+
((IChunkLightingData) chunk).setLightInitialized(compound.getBoolean("LightPopulated"));
29+
30+
}
31+
32+
/**
33+
* Injects the serialization logic for chunk data on save so we can store whether or not we've populated light yet.
34+
* @author Angeline
35+
*/
36+
@Inject(method = "writeChunkToNBT", at = @At("RETURN"))
37+
private void onWriteChunkToNBT(Chunk chunk, World world, NBTTagCompound compound, CallbackInfo ci) {
38+
LightingHooks.writeNeighborLightChecksToNBT(chunk, compound);
39+
40+
compound.setBoolean("LightPopulated", ((IChunkLightingData) chunk).isLightInitialized());
41+
}
42+
}

0 commit comments

Comments
 (0)