BiomeUndergroundDecorator

This commit is contained in:
FalsePattern committed 2022-03-22 11:30:49 +01:00
1 parent 6967fc26fe
commit 99fde997de
4 files changed
+55 -49

No files matched your search

@@ -3,7 +3,6 @@ package com.falsepattern.endlessids.asm;
import java.util.HashMap;
import com.falsepattern.endlessids.asm.transformer.WorldEditBaseBlock;
import com.falsepattern.endlessids.asm.transformer.MFQM;
import com.falsepattern.endlessids.asm.transformer.UndergroundBiomesBiomeUndergroundDecorator;
import com.falsepattern.endlessids.asm.transformer.CofhBlockHelper;
import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
import java.util.Map;
@@ -29,7 +28,7 @@ public enum ClassEdit
FmlRegistry(new FmlRegistry(), new String[] { "cpw.mods.fml.common.registry.GameData", "cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry" }),
CofhBlockHelper(new CofhBlockHelper(), new String[] { "cofh.lib.util.helpers.BlockHelper" }),
//UndergroundBiomesOreUBifier(new UndergroundBiomesOreUBifier(), new String[] { "exterminatorJeff.undergroundBiomes.worldGen.OreUBifier" }),
UndergroundBiomesBiomeUndergroundDecorator(new UndergroundBiomesBiomeUndergroundDecorator(), new String[] { "exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator" }),
//UndergroundBiomesBiomeUndergroundDecorator(new UndergroundBiomesBiomeUndergroundDecorator(), new String[] { "exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator" }),
MFQM(new MFQM(), new String[] { "MoreFunQuicksandMod.main.MFQM" }),
WorldEditBaseBlock(new WorldEditBaseBlock(), new String[] { "com.sk89q.worldedit.blocks.BaseBlock" });
@@ -1,46 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import java.util.ListIterator;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.MethodNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import com.falsepattern.endlessids.asm.Name;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class UndergroundBiomesBiomeUndergroundDecorator implements IClassNodeTransformer
{
public UndergroundBiomesBiomeUndergroundDecorator() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
MethodNode method = AsmUtil.findMethod(cn, Name.ub_bud_replaceChunkOres_world);
this.transformReplaceChunkOres(cn, method, obfuscated, 1);
method = AsmUtil.findMethod(cn, Name.ub_bud_replaceChunkOres_iChunkProvider);
this.transformReplaceChunkOres(cn, method, obfuscated, 0);
}
private void transformReplaceChunkOres(final ClassNode cn, final MethodNode method, final boolean obfuscated, final int varOffset) {
final InsnList code = method.instructions;
final ListIterator<AbstractInsnNode> iterator = (ListIterator<AbstractInsnNode>)code.iterator();
while (iterator.hasNext()) {
final AbstractInsnNode insn = (AbstractInsnNode)iterator.next();
if (insn.getOpcode() == 182 && Name.ebs_getBlockLSBArray.matches((MethodInsnNode)insn, obfuscated)) {
iterator.remove();
iterator.add((AbstractInsnNode)new VarInsnNode(21, 9 + varOffset));
iterator.add((AbstractInsnNode)new VarInsnNode(21, 18 + varOffset));
iterator.add((AbstractInsnNode)new VarInsnNode(21, 10 + varOffset));
iterator.add((AbstractInsnNode)Name.hooks_getBlockId.staticInvocation(obfuscated));
while (((AbstractInsnNode)iterator.next()).getOpcode() != 54) {
iterator.remove();
}
break;
}
}
}
}
@@ -0,0 +1,52 @@
package com.falsepattern.endlessids.mixin.mixins.common.ubc;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator;
import exterminatorJeff.undergroundBiomes.worldGen.OreUBifier;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = BiomeUndergroundDecorator.class, remap = false)
public abstract class BiomeUndergroundDecoratorMixin {
private static NibbleArray fakeArray;
private ThreadLocal<IExtendedBlockStorageMixin> ebs;
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;func_76658_g()[B"),
require = 2)
private byte[] returnMSBasLSB(ExtendedBlockStorage instance) {
if (ebs == null) ebs = new ThreadLocal<>();
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
ebs.set(iebs);
return iebs.getMSB();
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;func_76660_i()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 4)
private NibbleArray returnFakeArray(ExtendedBlockStorage instance) {
return fakeArray == null ? (fakeArray = new NibbleArray(4096, 4)) : fakeArray;
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/NibbleArray;func_76582_a(III)I"),
require = 2)
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
return ebs.get().getLSB()[y << 8 | z << 4 | x] & 0xFFFF;
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier;blockReplacer(I)LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier$BlockReplacer;"),
require = 2)
private OreUBifier.BlockReplacer reshuffleID(OreUBifier instance, int blockID) {
blockID = ((blockID & 0xFF) << 16) | ((blockID & 0xFFFF00) >>> 8);
return instance.blockReplacer(blockID);
}
}
@@ -40,7 +40,8 @@ public enum Mixin {
//END Minecraft
//BEGIN UBC
//BEGIN common
OreUBifierMixin(builder(Side.COMMON).target(TargetedMod.UBC).mixin("ubc.OreUBifierMixin"))
OreUBifierMixin(builder(Side.COMMON).target(TargetedMod.UBC).mixin("ubc.OreUBifierMixin")),
BiomeUndergroundDecoratorMixin(builder(Side.COMMON).target(TargetedMod.UBC).mixin("ubc.BiomeUndergroundDecoratorMixin"))
//END common
//END ubc
;