-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mod support for WorldEdit, Advanced Rocketry, Mystcraft, Journeym…
- Loading branch information
Showing
10 changed files
with
203 additions
and
6 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
2 changes: 1 addition & 1 deletion
2
...ev/jeid/mixin/core/MixinRenderGlobal.java → .../mixin/core/client/MixinRenderGlobal.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
24 changes: 24 additions & 0 deletions
24
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinBaseBlock.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,24 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
import com.sk89q.worldedit.blocks.BaseBlock; | ||
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(BaseBlock.class) | ||
public class MixinBaseBlock { | ||
@Shadow private short id; | ||
|
||
@Overwrite(remap = false) | ||
protected final void internalSetId(int id) { | ||
if (id > Short.MAX_VALUE) { | ||
throw new IllegalArgumentException("Can't have a block ID above 32767 (" + id + " given)"); | ||
} else if (id < 0) { | ||
throw new IllegalArgumentException("Can't have a block ID below 0"); | ||
} else { | ||
this.id = (short)id; | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinBiomeHandler.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,52 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
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 zmaster587.advancedRocketry.util.BiomeHandler; | ||
|
||
@Pseudo | ||
@Mixin(BiomeHandler.class) | ||
public class MixinBiomeHandler { | ||
@Overwrite(remap = false) | ||
public static void changeBiome(World world, int biomeId, BlockPos pos) { | ||
changeBiome(world, biomeId, world.getChunkFromBlockCoords(pos), pos); | ||
} | ||
|
||
@Overwrite(remap = false) | ||
public static void changeBiome(World world, int biomeId, Chunk chunk, BlockPos pos) { | ||
Biome biome = world.getBiome(pos); | ||
Biome biomeTo = Biome.getBiome(biomeId); | ||
|
||
if (biome == biomeTo) { | ||
return; | ||
} | ||
|
||
int x = pos.getX(); | ||
int z = pos.getZ(); | ||
|
||
if (biome.topBlock != biomeTo.topBlock) { | ||
int topBlockY = chunk.getHeightValue(x & 15, z & 15) - 1; | ||
|
||
while (!world.getBlockState(new BlockPos(x, topBlockY, z)).isOpaqueCube() && topBlockY > 0) topBlockY--; | ||
if (topBlockY == 0) return; | ||
|
||
if (chunk.getBlockState(x & 15, topBlockY, z & 15) == biome.topBlock) { | ||
chunk.setBlockState(new BlockPos(x & 15, topBlockY, z & 15), biomeTo.topBlock); | ||
} | ||
} | ||
|
||
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = biomeId; | ||
|
||
NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 300); | ||
MessageManager.CHANNEL.sendToAllAround(new BiomeChangeMessage(pos.getX(), pos.getY(), biomeId), point); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinBiomeReplacer.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,34 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
import com.xcompwiz.mystcraft.symbol.symbols.SymbolFloatingIslands; | ||
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.Shadow; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
@Mixin(SymbolFloatingIslands.BiomeReplacer.class) | ||
public class MixinBiomeReplacer { | ||
@Shadow private HashMap<List<Integer>, boolean[]> chunks; | ||
@Shadow private Biome biome; | ||
|
||
@Overwrite(remap = false) | ||
public void finalizeChunk(Chunk chunk, int chunkX, int chunkZ) { | ||
boolean[] modified = chunks.remove(Arrays.asList(chunkX, chunkZ)); | ||
|
||
if (modified != null) { | ||
int[] biomes = ((INewChunk) chunk).getIntBiomeArray(); | ||
|
||
for(int coords = 0; coords < modified.length; ++coords) { | ||
if (modified[coords]) { | ||
biomes[coords] = Biome.getIdForBiome(biome) & 255; | ||
} | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinChunkMD.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,24 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
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.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Mixin(ChunkMD.class) | ||
public abstract class MixinChunkMD { | ||
@Shadow public abstract World getWorld(); | ||
@Shadow public abstract Chunk getChunk(); | ||
|
||
@Overwrite(remap = false) | ||
@Nullable | ||
public Biome getBiome(final BlockPos pos) { | ||
return getChunk().getBiome(pos, getWorld().getBiomeProvider()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinDimensionManager.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,25 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
import climateControl.DimensionManager; | ||
import net.minecraft.init.Biomes; | ||
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; | ||
|
||
@Pseudo | ||
@Mixin(DimensionManager.class) | ||
public class MixinDimensionManager { | ||
@Overwrite(remap = false) | ||
private boolean hasOnlySea(Chunk tested) { | ||
for (int biome : ((INewChunk) tested).getIntBiomeArray()) { | ||
if (biome != 0 && biome != Biome.getIdForBiome(Biomes.DEEP_OCEAN)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/dimdev/jeid/mixin/modsupport/MixinEntityPortal.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,26 @@ | ||
package org.dimdev.jeid.mixin.modsupport; | ||
|
||
import com.cutievirus.creepingnether.entity.EntityPortal; | ||
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; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Pseudo | ||
@Mixin(EntityPortal.class) | ||
public class MixinEntityPortal { | ||
@Shadow private static Biome toBiome; | ||
|
||
@Overwrite(remap = false) | ||
public static void corruptBiome(World world, BlockPos pos) { | ||
if (world.isBlockLoaded(pos)) { | ||
Chunk chunk = world.getChunkFromBlockCoords(pos); | ||
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = Biome.getIdForBiome(toBiome); | ||
} | ||
} | ||
} |
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