Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for SRP, WoN, Advanced Rocketry #57

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/dimdev/jeid/JEID.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class JEID {
public static final String NAME = Tags.MOD_NAME;
public static final String VERSION = Tags.VERSION;
public static final String DEPENDENCIES = "required:mixinbooter@[8.0,);"
+ "after:srparasites;"
+ "after:abyssalcraft;"
+ "after:advancedrocketry;"
+ "after:atum;"
Expand All @@ -38,6 +37,7 @@ public class JEID {
+ "after:journeymap;"
+ "after:moreplanets;"
+ "after:mystcraft;"
+ "after:srparasites;"
+ "after:thaumcraft;"
+ "after:thebetweenlands;"
+ "after:tofucraft;"
Expand Down
30 changes: 9 additions & 21 deletions src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.dimdev.jeid.core;

import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import zone.rong.mixinbooter.ILateMixinLoader;

import java.util.ArrayList;
import java.util.List;

import net.minecraftforge.fml.common.Loader;

import zone.rong.mixinbooter.ILateMixinLoader;

public class JEIDMixinLoader implements ILateMixinLoader {
public List<String> getMixinConfigs() {
Expand All @@ -17,19 +16,11 @@ public List<String> getMixinConfigs() {
configs.add("mixins.jeid.advancedrocketry.client.json");
}
}
if (Loader.isModLoaded("srparasites")) {
configs.add("mixins.jeid.srparasites.json");
}
if (Loader.isModLoaded("abyssalcraft")) {
configs.add("mixins.jeid.abyssalcraft.json");
}
if (Loader.isModLoaded("advancedrocketry")) {
String version = Loader.instance().getIndexedModList().get("advancedrocketry").getVersion();
if (version.split("-")[1].contains(".") && Integer.parseInt(version.split("-")[1].split("\\.")[0]) >= 2) {
configs.add("mixins.jeid.advancedrocketry.v2_0_0.json");
} else {
configs.add("mixins.jeid.advancedrocketry.v1_7_0.json");
}
configs.add("mixins.jeid.advancedrocketry.json");
}
if (Loader.isModLoaded("atum")) {
configs.add("mixins.jeid.atum.json");
Expand Down Expand Up @@ -88,6 +79,9 @@ public List<String> getMixinConfigs() {
if (Loader.isModLoaded("rtg")) {
configs.add("mixins.jeid.rtg.json");
}
if (Loader.isModLoaded("srparasites")) {
configs.add("mixins.jeid.srparasites.json");
}
if (Loader.isModLoaded("thaumcraft")) {
configs.add("mixins.jeid.thaumcraft.json");
}
Expand All @@ -106,15 +100,9 @@ public List<String> getMixinConfigs() {
if (Loader.isModLoaded("worldedit")) {
configs.add("mixins.jeid.worldedit.json");
}

// Checks if the mod is within the version that has the legacy Biome Spread code
if (Loader.isModLoaded("wyrmsofnyrus"))
//TODO: Doesn't work since this code runs before anything is actually loaded, so we'll need to find another way before v0.6 comes out.
// Loader.instance().getCustomModProperties("wyrmsofnyrus").get("version").matches("0.5.[1-9][0-9]{1,3}") )
// this checks any version between v0.5.10 (introduced the system) and v0.5.9999 (Impossible number of versions for a LTS version, but let's futureproof it to be safe.)
if (Loader.isModLoaded("wyrmsofnyrus")) {
configs.add("mixins.jeid.wyrmsofnyrus.json");


}
return configs;
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
package org.dimdev.jeid.mixin.modsupport.advancedrocketry.v1_7_0;
package org.dimdev.jeid.mixin.modsupport.advancedrocketry;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import org.dimdev.jeid.ducks.INewChunk;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import zmaster587.advancedRocketry.util.BiomeHandler;

/**
* Mixin for Advanced Rocketry 1.7.0
*/
@SuppressWarnings("target")
@Mixin(value = BiomeHandler.class, remap = false)
public class MixinBiomeHandler {
@Dynamic("Only present with AR 1.7.0")
@Shadow
public static void changeBiome(World world, int biomeId, BlockPos pos) {
}
// Do not use @Local sugar for these injectors, it doesn't handle invalid targets well!

@Dynamic("Use int biome array for AR 1.7.0")
@Inject(method = "changeBiome(Lnet/minecraft/world/World;ILnet/minecraft/util/math/BlockPos;)V", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/network/PacketHandler;sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V"), require = 0)
private static void reid$toIntBiomeArray1_7_0(World world, int biomeId, BlockPos pos, CallbackInfo ci, @Local Chunk chunk) {
@Group(name = "versionAgnosticAR", min = 1, max = 2)
@Inject(method = "changeBiome(Lnet/minecraft/world/World;ILnet/minecraft/util/math/BlockPos;)V", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/network/PacketHandler;sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V"), locals = LocalCapture.CAPTURE_FAILHARD, require = 0)
private static void reid$toIntBiomeArray1_7_0(World world, int biomeId, BlockPos pos, CallbackInfo ci, Chunk chunk) {
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = biomeId;
chunk.markDirty();
// Method sends packet
}

@Dynamic("Overload for AR 1.7.0")
@Group(name = "versionAgnosticAR", min = 1, max = 2)
@Inject(method = "changeBiome(Lnet/minecraft/world/World;ILnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "HEAD"), cancellable = true, require = 0)
private static void reid$toIntBiomeArray1_7_0Chunk(World world, int biomeId, Chunk chunk, BlockPos pos, CallbackInfo ci) {
changeBiome(world, biomeId, pos);
BiomeHandler.changeBiome(world, biomeId, pos);
ci.cancel();
}

@Dynamic("Use int biome array for AR 2.0.0")
@Group(name = "versionAgnosticAR", min = 1, max = 2)
@Inject(method = "changeBiome(Lnet/minecraft/world/World;Lnet/minecraft/world/biome/Biome;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/network/PacketHandler;sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V"), locals = LocalCapture.CAPTURE_FAILHARD, require = 0)
private static void reid$toIntBiomeArray2_0_0(World world, Biome biomeId, BlockPos pos, CallbackInfo ci, Chunk chunk) {
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biomeId);
chunk.markDirty();
// Method sends packet
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,66 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import org.dimdev.jeid.INewChunk;
import net.minecraft.world.chunk.Chunk;

import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;

import com.llamalad7.mixinextras.sugar.Local;
import org.dimdev.jeid.ducks.INewChunk;
import org.dimdev.jeid.network.MessageManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Pseudo
@Mixin(ParasiteEventWorld.class)
public abstract class MixinSpreadBiome {
@Mixin(value = ParasiteEventWorld.class, remap = false)
public class MixinSpreadBiome {
/**
* @reason Use REID message to immediately re-render changes on client
*/
@Redirect(method = "SpreadBiome", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V"))
private static void reid$sendSpreadBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, World worldIn, BlockPos pos,
@Local(ordinal = 1) BlockPos convertPos) {
MessageManager.sendClientsBiomePosChange(worldIn, convertPos, Biome.getIdForBiome(SRPBiomes.biomeInfested));
}

// Overwriting the biome chaning code for SRP.
// This is just a mixin to force it to refer to REID's biome array.
/**
* @author roguetictac
* @reason Make Scape and Run: Parasites compatible with REID. Refer to new chunk duck interface for mixin reasons.
* @reason Use REID message to immediately re-render changes on client
*/
@Overwrite(remap=false)
public static void positionToParasiteBiome(World worldIn, BlockPos pos) {
int inChunkX = pos.getX() & 15;
int inChunkZ = pos.getZ() & 15;
((INewChunk)worldIn.getChunk(pos)).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(SRPBiomes.biomeInfested);
@Redirect(method = "killBiome", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V"))
private static void reid$sendKillBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, World worldIn, BlockPos pos,
@Local(ordinal = 1) BlockPos convertPos) {
Biome original = worldIn.getBiomeProvider().getBiome(pos, Biomes.PLAINS);
MessageManager.sendClientsBiomePosChange(worldIn, convertPos, Biome.getIdForBiome(original));
}

/**
* @author roguetictac
* @reason Make Scape and Run: Parasites compatible with REID. Refer to new chunk duck interface for mixin reasons.
* @author roguetictac, jchung01
* @reason Support int biome id for spreading infected biome.
*/
@Overwrite(remap=false)
public static void positionToBiome(World worldIn, BlockPos pos) {
int inChunkX = pos.getX() & 15;
int inChunkZ = pos.getZ() & 15;
((INewChunk)worldIn.getChunk(pos)).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(Biomes.PLAINS);
@Inject(method = "positionToParasiteBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), cancellable = true)
private static void reid$parasiteToIntBiomeArray(World worldIn, BlockPos pos, CallbackInfo ci,
@Local(ordinal = 0) int inChunkX, @Local(ordinal = 1) int inChunkZ) {
Chunk chunk = worldIn.getChunk(pos);
chunk.markDirty();
((INewChunk) chunk).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(SRPBiomes.biomeInfested);
ci.cancel();
}

/**
* @author roguetictac, jchung01
* @reason Support int biome id for resetting infected biome.
*/
@Inject(method = "positionToBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), cancellable = true)
private static void reid$plainsToIntBiomeArray(World worldIn, BlockPos pos, CallbackInfo ci,
@Local(ordinal = 0) int inChunkX, @Local(ordinal = 1) int inChunkZ) {
// Get the originally generated biome.
Biome original = worldIn.getBiomeProvider().getBiome(pos, Biomes.PLAINS);
Chunk chunk = worldIn.getChunk(pos);
chunk.markDirty();
((INewChunk) chunk).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(original);
ci.cancel();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;

import com.llamalad7.mixinextras.sugar.Local;
import com.vetpetmon.wyrmsofnyrus.invasion.HiveCreepSpreadFurther;
import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry;
import org.dimdev.jeid.network.MessageManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = HiveCreepSpreadFurther.class, remap = false)
public class MixinHiveCreepSpreadFurther {
/**
* @reason Use REID message to immediately re-render changes on client
*/
@Redirect(method = "decay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V"))
private static void reid$sendSpreadBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, BlockPos pos, World world,
@Local(ordinal = 2) BlockPos spreadPos) {
MessageManager.sendClientsBiomePosChange(world, spreadPos, Biome.getIdForBiome(BiomeRegistry.CREEPLANDS));
}
}
Loading
Loading