mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-16 21:05:01 +00:00
Biome Wand compat
This commit is contained in:
8 files changed
+190
No files matched your search
@@ -2,6 +2,7 @@ package com.falsepattern.endlessids.asm;
|
||||
|
||||
import com.falsepattern.endlessids.asm.transformer.DragonAPIModList;
|
||||
import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
|
||||
import com.falsepattern.endlessids.asm.transformer.SpaceCoreModInfoGenerator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -9,6 +10,7 @@ import java.util.Map;
|
||||
public enum ClassEdit {
|
||||
FmlRegistry(new FmlRegistry(), new String[]{"cpw.mods.fml.common.registry.GameData",
|
||||
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"}),
|
||||
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), new String[]{"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator"}),
|
||||
DragonAPIModList(new DragonAPIModList(), new String[]{"Reika.DragonAPI.ModList"});
|
||||
|
||||
private static final Map<String, ClassEdit> editMap;
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import lombok.val;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
|
||||
public class SpaceCoreModInfoGenerator implements IClassNodeTransformer {
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
for (val method: cn.methods) {
|
||||
if (method.name.equals("generate")) {
|
||||
val iterator = method.instructions.iterator();
|
||||
iterator.add(new InsnNode(Opcodes.RETURN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.client.biomewand;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.spacechase0.minecraft.biomewand.BiomeWandMod;
|
||||
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
@Mixin(value = BiomeWandItem.class,
|
||||
remap = false)
|
||||
public abstract class BiomeWandItemMixin {
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@Overwrite
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
int biomeID = -1;
|
||||
if (tag != null && tag.hasKey("sampledBiomeS")) {
|
||||
biomeID = Short.toUnsignedInt(tag.getShort("sampledBiomeS"));
|
||||
}
|
||||
if (pass != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (biomeID < 0) {
|
||||
return 0;
|
||||
}
|
||||
val biome = BiomeGenBase.getBiomeGenArray()[biomeID];
|
||||
if (biome == null) {
|
||||
return 0;
|
||||
}
|
||||
return biome.color;
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biomewand;
|
||||
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.spacechase0.minecraft.biomewand.BiomeWandMod;
|
||||
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
|
||||
import com.spacechase0.minecraft.spacecore.util.TranslateUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = BiomeWandItem.class,
|
||||
remap = false)
|
||||
public abstract class BiomeWandItemMixin {
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, int side, float par8, float par9, float par10) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
boolean sample = true;
|
||||
if (tag != null) {
|
||||
if (tag.hasKey("sampledBiomeS")) {
|
||||
sample = false;
|
||||
}
|
||||
} else {
|
||||
tag = new NBTTagCompound();
|
||||
}
|
||||
|
||||
if (sample) {
|
||||
int relBlockX = blockX & 15;
|
||||
int relBlockZ = blockZ & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
short biome = ((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
|
||||
tag.setShort("sampledBiomeS", biome);
|
||||
} else {
|
||||
short biome = tag.getShort("sampledBiomeS");
|
||||
|
||||
for(int ix = blockX - 3; ix <= blockX + 3; ++ix) {
|
||||
for(int iz = blockZ - 3; iz <= blockZ + 3; ++iz) {
|
||||
int relBlockX = ix & 15;
|
||||
int relBlockZ = iz & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||
chunk.isModified = true;
|
||||
BiomeWandMod.proxy.updateRendererAt(ix, iz);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
tag.removeTag("sampledBiomeS");
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
|
||||
stack.setTagCompound(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@Overwrite
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
String str = TranslateUtils.translate("biomewand.tooltip.biome") + ": ";
|
||||
if (tag == null || !tag.hasKey("sampledBiomeS")) {
|
||||
str = str + TranslateUtils.translate("biomewand.tooltip.none");
|
||||
} else {
|
||||
BiomeGenBase b = BiomeGenBase.getBiomeGenArray()[Short.toUnsignedInt(tag.getShort("sampledBiomeS"))];
|
||||
if (b == null) {
|
||||
str = str + TranslateUtils.translate("biomewand.tooltip.unknown");
|
||||
} else {
|
||||
str = str + b.biomeName;
|
||||
}
|
||||
}
|
||||
|
||||
list.add(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@Overwrite
|
||||
public void getSubItems(Item item, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack((BiomeWandItem)(Object)this, 1));
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (biome != null && !(biome instanceof PlaceholderBiome)) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setShort("sampledBiomeS", (short) biome.biomeID);
|
||||
ItemStack wand = new ItemStack((BiomeWandItem)(Object)this, 1);
|
||||
wand.setTagCompound(compound);
|
||||
list.add(wand);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,14 @@ public enum Mixin implements IMixin {
|
||||
ATGChunkProviderMixin(Side.COMMON, require(TargetedMod.ATG), "atg.ATGChunkProviderMixin"),
|
||||
ATGWorldGenRocksMixin(Side.COMMON, require(TargetedMod.ATG), "atg.ATGWorldGenRocksMixin"),
|
||||
//endregion ATG->common
|
||||
//region Biome Wand
|
||||
//region Biome Wand->client
|
||||
BiomeWandItemClientMixin(Side.CLIENT, require(TargetedMod.BIOMEWAND), "biomewand.BiomeWandItemMixin"),
|
||||
//endregion Biome Wand->client
|
||||
//region Biome Wand->common
|
||||
BiomeWandItemMixin(Side.COMMON, require(TargetedMod.BIOMEWAND), "biomewand.BiomeWandItemMixin"),
|
||||
//endregion Biome Wand->common
|
||||
//endregion Biome Wand
|
||||
//region BoP->common
|
||||
BOPBiomeManagerMixin(Side.COMMON, require(TargetedMod.BOP), "bop.BOPBiomeManagerMixin"),
|
||||
ChunkProviderBOPEndMixin(Side.COMMON, require(TargetedMod.BOP), "bop.ChunkProviderBOPEndMixin"),
|
||||
|
||||
@@ -14,6 +14,7 @@ public enum TargetedMod implements ITargetedMod {
|
||||
ANTIIDCONFLICT("Anti ID Conflict", true, startsWith("antiidconflict")),
|
||||
ANTIQUEATLAS("Antique Atlas", true, startsWith("antiqueatlas")),
|
||||
ATG("Alternate Terrain Generation", true, startsWith("atg")),
|
||||
BIOMEWAND("Biome Wand", true, startsWith("1.7.10-biome-wand-").or(startsWith("biome-wand"))),
|
||||
BOP("Biomes O' Plenty", true, startsWith("biomesoplenty-")),
|
||||
COFHLIB("CoFH Lib", true, startsWith("cofhlib-")),
|
||||
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
|
||||
|
||||
Reference in new issue
Block a user