Skip to content

Commit

Permalink
Hopefully match with JEIDsI now and can lead to a proper release of 1…
Browse files Browse the repository at this point in the history
….0.3

- Added support for Dimstack mod
- Added additional support for Extra Utils 2
- Added Gaia Dimension support
- Updated CreepingNether support
- Updated JourneyMap support
- Additional updates and changes

Thank you @sk2048 for the creation of JEIDsI and the help along the way with adding these additional changes and support for mods. Hopefully these next few commits will lead to the unification of both mods and hopefully better support for JEID
  • Loading branch information
ZombieHDGaming committed Aug 22, 2019
1 parent c87fb63 commit adc3704
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: java
jdk: oraclejdk8
jdk: openjdk8

if: tag IS blank
git:
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {
compileOnly "2683:667:TheBetweenlands-3.4.6-universal@jar"
compileOnly "2692:524:TofuCraftReload-0.0.2.1@jar"
compileOnly "2636:492:tropicraft-MC1.12.2-7.1.8.105@jar"
compileOnly "2724:738:gaiadimension-1.12.2-1.0.5@jar"
}

def travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER")
Expand Down
26 changes: 18 additions & 8 deletions src/main/java/org/dimdev/jeid/mixin/core/MixinChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import net.minecraft.world.chunk.Chunk;
import org.dimdev.jeid.INewChunk;
import org.dimdev.jeid.JEID;
import org.dimdev.jeid.Utils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Arrays;

Expand All @@ -35,18 +39,24 @@ public void setIntBiomeArray(int[] intBiomeArray) {

@Overwrite
public byte[] getBiomeArray() {
Utils.LOGGER.error("A mod is accessing the byte biome array, report to JEID!", new Throwable("Chunk#getBiomeArray"));
byte[] arr = new byte[256];
Arrays.fill(arr, errorBiomeID);
return arr;
}

@Overwrite
public Biome getBiome(BlockPos pos, BiomeProvider provider) {
int x = pos.getX() & 15;
int z = pos.getZ() & 15;
int index = z << 4 | x;
int biomeID = intBiomeArray[index];
Biome biome = Biome.getBiome(biomeID);
return biome == null ? Biomes.PLAINS : biome;
@Redirect(method = "getBiome", at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/Chunk;blockBiomeArray:[B", args = "array=get"))
private int getIntBiomeIdFromArray(byte[] array, int index) {
return this.intBiomeArray[index];
}

@Inject(method = "getBiome", at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/Chunk;blockBiomeArray:[B", args = "array=set"), locals = LocalCapture.CAPTURE_FAILHARD)
private void setIntBiomeIdInArray(BlockPos pos, BiomeProvider provider, CallbackInfoReturnable<Biome> cir, int i, int j, int k, Biome biome) {
this.intBiomeArray[j << 4 | i] = k;
}

@ModifyConstant(method = "getBiome", constant = @Constant(intValue = 0xFF))
private int getBiomeBitmask(int oldValue) {
return 0xFFFFFFFF;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public boolean getIsFullChunk(SPacketChunkData packet) {
return false;
}

/** @reason Disable adding biome byte array size. **/
@Redirect(method = "calculateChunkSize", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/SPacketChunkData;isFullChunk()Z", ordinal = 1))
public boolean getIsFullChunk1(SPacketChunkData packet) {
return false;
}

@Inject(method = "calculateChunkSize", at = @At(value = "RETURN"), cancellable = true)
public void onReturn(Chunk chunkIn, boolean p_189556_2_, int p_189556_3_, CallbackInfoReturnable<Integer> ci) {
if (this.isFullChunk()) {
int size = ci.getReturnValue();

// First, we subtract off the length added by Vanilla (the line 'i += chunkIn.getBiomeArray().length;')
size -= chunkIn.getBiomeArray().length;

// Now, we add on the actual length of the VarIntArray we're going to be writing in extractChunkData
size += this.getVarIntArraySize(((INewChunk) chunkIn).getIntBiomeArray());
ci.setReturnValue(size);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/dimdev/jeid/mixin/init/MixinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private void beforeConstructingMods(List<String> injectedModContainers, Callback
// Add and reload mixin configs
Mixins.addConfiguration("mixins.jeid.modsupport.json");
Mixins.addConfiguration("mixins.jeid.twilightforest.json");
Mixins.addConfiguration("mixins.jeid.dimstack.json");

Proxy mixinProxy = (Proxy) Launch.classLoader.getTransformers().stream().filter(transformer -> transformer instanceof Proxy).findFirst().get();
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
package org.dimdev.jeid.mixin.modsupport.creepingnether;

import com.cutievirus.creepingnether.Ref;
import com.cutievirus.creepingnether.entity.CorruptorAbstract;
import net.minecraft.init.Biomes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import org.dimdev.jeid.INewChunk;
import org.dimdev.jeid.network.BiomeChangeMessage;
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.Shadow;

@Pseudo
@Mixin(CorruptorAbstract.class)
public class MixinCorruptorAbstract {
@Shadow private static Biome toBiome;
public abstract class MixinCorruptorAbstract {
@Shadow public abstract Biome getBiome();

/**
* This should(?) fix Creeping Nether issues
*/
@Overwrite(remap = false)
public static void corruptBiome(World world, BlockPos pos) {
if (world.isBlockLoaded(pos)) {
Chunk chunk = world.getChunk(pos);
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = Biome.getIdForBiome(toBiome);
public void corruptBiome(World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) return;
Biome oldBiome = world.getBiome(pos);
if (oldBiome == this.getBiome() || oldBiome != Biomes.HELL && this.getBiome() != Ref.biomeCreepingNether) return;
Chunk chunk = world.getChunk(pos);
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = Biome.getIdForBiome(this.getBiome());
if (!world.isRemote) {
MessageManager.CHANNEL.sendToAllAround(
new BiomeChangeMessage(pos.getX(), pos.getZ(), Biome.getIdForBiome(this.getBiome())),
new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), 128.0D, pos.getZ(), 128.0D)
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.dimdev.jeid.mixin.modsupport.dimstack;

import net.minecraftforge.fml.common.Loader;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class DimstackPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String s) {

}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String s, String s1) {
if (Loader.isModLoaded("dimstack")) return true;
return false;
}

@Override
public void acceptTargets(Set<String> set, Set<String> set1) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {

}

@Override
public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {

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

import net.minecraft.block.state.IBlockState;
import net.minecraft.world.chunk.ChunkPrimer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = ChunkPrimer.class, priority = 500)
public class MixinChunkPrimer {
public IBlockState ingnoredBlock;

@Inject(method = "setBlockState", at = @At(value = "HEAD"), cancellable = true)
private void ignoreBlock(int x, int y, int z, IBlockState state, CallbackInfo ci) {
if (state != null && this.ingnoredBlock == state) ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.dimdev.jeid.mixin.modsupport.extrautils2;

import com.rwtema.extrautils2.dimensions.workhousedim.WorldProviderSpecialDim;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.ChunkProviderServer;
import org.dimdev.jeid.INewChunk;
import org.spongepowered.asm.mixin.Mixin;
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.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Arrays;

@Pseudo
@Mixin(WorldProviderSpecialDim.class)
public class MixinWorldProviderSpecialDim {
@Inject(method = "generate", at = @At(target = "Lnet/minecraft/world/chunk/Chunk;setTerrainPopulated(Z)V", value = "INVOKE"), locals = LocalCapture.CAPTURE_FAILSOFT)
private static void setChunkIntBiomeArray(int x, int z, ChunkProviderServer chunkProvider, Object generator, CallbackInfo ci, Chunk chunk, int idForBiome) {
Arrays.fill(((INewChunk) chunk).getIntBiomeArray(), idForBiome);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.dimdev.jeid.mixin.modsupport.gaiadimension;

import androsa.gaiadimension.world.layer.GenLayerGDRiverMix;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Pseudo
@Mixin(GenLayerGDRiverMix.class)
public class MixinGenLayerGDRiverMix {
@ModifyConstant(method = "func_75904_a", constant = @Constant(intValue = 255), remap = false)
private int getBitMask(int oldValue) {
return 0xFFFFFFFF;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import journeymap.client.model.ChunkMD;
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.INewChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Pseudo;
Expand All @@ -15,12 +15,30 @@
@Pseudo
@Mixin(ChunkMD.class)
public abstract class MixinChunkMD {
@Shadow public abstract World getWorld();

@Shadow public abstract Chunk getChunk();

/**
*
* @param pos
* @return
*/
@Overwrite(remap = false)
@Nullable
public Biome getBiome(final BlockPos pos) {
return getChunk().getBiome(pos, getWorld().getBiomeProvider());
public Biome getBiome(BlockPos pos) {
Chunk chunk = this.getChunk();
int[] biomeArray = ((INewChunk) chunk).getIntBiomeArray();
int biomeId = biomeArray[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF];
if (biomeId == 0xFFFFFFFF) {
Biome biome = chunk.getWorld().getBiomeProvider().getBiome(pos, null);

if (biome == null) {
return null;
}
biomeId = Biome.getIdForBiome(biome);
biomeArray[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = biomeId;
}

return Biome.getBiome(biomeId);
}
}
16 changes: 16 additions & 0 deletions src/main/resources/mixins.jeid.dimstack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"package": "org.dimdev.jeid.mixin.modsupport.dimstack",
"plugin": "org.dimdev.jeid.mixin.modsupport.dimstack.DimstackPlugin",
"required": true,
"refmap": "mixins.jeid.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.6",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinChunkPrimer"
],
"client": [],
"injectors": {
"maxShiftBy": 10
}
}
2 changes: 2 additions & 0 deletions src/main/resources/mixins.jeid.modsupport.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"creepingnether.MixinCorruptorAbstract",
"cyclopscore.MixinWorldHelpers",
"extrautils2.MixinBiomeManip",
"extrautils2.MixinWorldProviderSpecialDim",
"gaiadimension.MixinGenLayerGDRiverMix",
"geographicraft.MixinDimensionManager",
"journeymap.MixinChunkMD",
"mystcraft.MixinBiomeReplacer",
Expand Down

0 comments on commit adc3704

Please sign in to comment.