Move to 1.10

This commit is contained in:
Vincent Lee committed 2016-07-20 20:55:20 -05:00
1 parent 87172ea3f2
commit a0d0fefe8d
20 files changed
+25 -260

No files matched your search

@@ -85,17 +85,12 @@ public class MultiblockBlockAccess implements IBlockAccess {
@Nonnull
@Override
public Biome getBiomeGenForCoords(@Nonnull BlockPos pos) {
public Biome getBiome(@Nonnull BlockPos pos) {
if(hasBlockAccess)
return originalBlockAccess.getBiomeGenForCoords(pos);
return originalBlockAccess.getBiome(pos);
return null;
}
@Override
public boolean extendedLevelsInChunkCache() {
return hasBlockAccess && originalBlockAccess.extendedLevelsInChunkCache();
}
@Override
public boolean isSideSolid(@Nonnull BlockPos pos, @Nonnull EnumFacing side, boolean _default) {
if(hasBlockAccess)
@@ -26,7 +26,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.client.model.animation.AnimationTESR;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@@ -337,7 +336,7 @@ public class ClientProxy extends CommonProxy {
BotaniaPlayerController controller = new BotaniaPlayerController(mc, net);
boolean isFlying = player.capabilities.isFlying;
boolean allowFlying = player.capabilities.allowFlying;
Botania.crossVersionProxy.copyGameType(mc.playerController, controller);
controller.setGameType(mc.playerController.getCurrentGameType());
player.capabilities.isFlying = isFlying;
player.capabilities.allowFlying = allowFlying;
mc.playerController = controller;
@@ -146,13 +146,8 @@ public class PlatformModel implements IBakedModel {
@Nonnull
@Override
public Biome getBiomeGenForCoords(@Nonnull BlockPos pos) {
return compose.getBiomeGenForCoords(pos);
}
@Override
public boolean extendedLevelsInChunkCache() {
return compose.extendedLevelsInChunkCache();
public Biome getBiome(@Nonnull BlockPos pos) {
return compose.getBiome(pos);
}
@Override
@@ -20,6 +20,7 @@ import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.monster.SkeletonType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumFacing;
@@ -62,7 +63,7 @@ public class RenderTileGaiaHead extends TileEntitySkullRenderer {
profile = ((EntityPlayer) mc.getRenderViewEntity()).getGameProfile();
} else if (view instanceof EntitySkeleton) {
skullType = 0;
if(Botania.crossVersionProxy.getSkeletonTypeInt((EntitySkeleton) view) == 1)
if (((EntitySkeleton) view).getSkeletonType() == SkeletonType.WITHER)
skullType = 1;
} else if(view instanceof EntityWither)
skullType = 1;
@@ -10,15 +10,11 @@
*/
package vazkii.botania.common;
import com.google.common.collect.ImmutableMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
@@ -40,11 +36,8 @@ import org.apache.logging.log4j.Logger;
import vazkii.botania.common.core.handler.IMCHandler;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.core.proxy.ICrossVersionProxy;
import vazkii.botania.common.lib.LibMisc;
import java.util.Map;
@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES,
guiFactory = LibMisc.GUI_FACTORY, acceptedMinecraftVersions = LibMisc.MC_VERSIONS, updateJSON = LibMisc.UPDATE_JSON)
public class Botania {
@@ -66,33 +59,10 @@ public class Botania {
@SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT)
public static CommonProxy proxy;
public static ICrossVersionProxy crossVersionProxy;
public static final Logger LOGGER = LogManager.getLogger(LibMisc.MOD_ID);
private static final Map<String, String> PROXY_MAP = ImmutableMap.of(
"1.9.4", "vazkii.botania.common.core.proxy.CrossVersionProxy_19",
"1.10", "vazkii.botania.common.core.proxy.CrossVersionProxy_110",
"1.10.2", "vazkii.botania.common.core.proxy.CrossVersionProxy_110"
);
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
try {
// The constant is inlined at compile time, we want the real value.
String mcVersion = (String) Loader.class.getDeclaredField("MC_VERSION").get(null);
if(!PROXY_MAP.containsKey(mcVersion))
throw new IllegalStateException("Botania couldn't find a cross version proxy!");
Class clazz = Class.forName(PROXY_MAP.get(mcVersion));
crossVersionProxy = (ICrossVersionProxy) clazz.newInstance();
Botania.LOGGER.info("Enabling proxy for Minecraft {}", mcVersion);
} catch (NoSuchFieldException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
throw new IllegalStateException("Botania couldn't find a cross version proxy!", ex);
}
gardenOfGlassLoaded = Loader.isModLoaded("GardenOfGlass");
thaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
@@ -75,7 +75,7 @@ public class SubTileMarimorphosis extends SubTileFunctional {
}
public ItemStack getStoneToPut(BlockPos coords) {
List<Type> types = Arrays.asList(BiomeDictionary.getTypesForBiome(supertile.getWorld().getBiomeGenForCoords(coords)));
List<Type> types = Arrays.asList(BiomeDictionary.getTypesForBiome(supertile.getWorld().getBiome(coords)));
TIntArrayList values = new TIntArrayList();
for(int i = 0; i < 8; i++) {
@@ -59,7 +59,7 @@ public class SubTileDaybloom extends SubTilePassiveGenerating {
@Override
public boolean canGeneratePassively() {
boolean rain = supertile.getWorld().getBiomeGenForCoords(supertile.getPos()).getRainfall() > 0 && (supertile.getWorld().isRaining() || supertile.getWorld().isThundering());
boolean rain = supertile.getWorld().getBiome(supertile.getPos()).getRainfall() > 0 && (supertile.getWorld().isRaining() || supertile.getWorld().isThundering());
return supertile.getWorld().isDaytime() && !rain && supertile.getWorld().canBlockSeeSky(supertile.getPos().up());
}
@@ -180,7 +180,7 @@ public class SubTileHydroangeas extends SubTilePassiveGenerating {
@Override
public int getDelayBetweenPassiveGeneration() {
boolean rain = supertile.getWorld().getBiomeGenForCoords(supertile.getPos()).getRainfall() > 0 && (supertile.getWorld().isRaining() || supertile.getWorld().isThundering());
boolean rain = supertile.getWorld().getBiome(supertile.getPos()).getRainfall() > 0 && (supertile.getWorld().isRaining() || supertile.getWorld().isThundering());
return rain ? 1 : 2;
}
@@ -34,8 +34,8 @@ public class BiomeDecorationHandler {
boolean flowers = true;
if(event.getWorld().provider instanceof IFlowerlessWorld)
flowers = ((IFlowerlessWorld) event.getWorld().provider).generateFlowers(event.getWorld());
else if(event.getWorld().getBiomeGenForCoords(event.getPos()) instanceof IFlowerlessBiome)
flowers = ((IFlowerlessBiome) event.getWorld().getBiomeGenForCoords(event.getPos())).canGenerateFlowers(event.getWorld(), event.getPos().getX(), event.getPos().getZ());
else if(event.getWorld().getBiome(event.getPos()) instanceof IFlowerlessBiome)
flowers = ((IFlowerlessBiome) event.getWorld().getBiome(event.getPos())).canGenerateFlowers(event.getWorld(), event.getPos().getX(), event.getPos().getZ());
if(!flowers)
return;
@@ -1,82 +0,0 @@
package vazkii.botania.common.core.proxy;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.client.core.handler.BotaniaPlayerController;
import vazkii.botania.common.Botania;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class CrossVersionProxy_110 implements ICrossVersionProxy {
@Override
public TileEntity createTeFromCompound(World world, NBTTagCompound compound) {
Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_190200_a", "a" }, World.class, NBTTagCompound.class);
try {
return (TileEntity) m.invoke(null, world, compound);
} catch (IllegalAccessException | InvocationTargetException e) {
Botania.LOGGER.error("Couldn't create TE in 1.10 crossversion proxy");
return null;
}
}
@SideOnly(Side.CLIENT)
@Override
public void copyGameType(PlayerControllerMP from, BotaniaPlayerController to) {
try {
Class<?> gameTypeClazz = Class.forName("net.minecraft.world.GameType");
Method m = ReflectionHelper.findMethod(PlayerControllerMP.class, null, new String[]{ "getCurrentGameType", "func_178889_l", "l" });
Object gameType = m.invoke(from);
m = ReflectionHelper.findMethod(PlayerControllerMP.class, null, new String[]{ "setGameType", "func_78746_a", "a" }, gameTypeClazz);
m.invoke(to, gameType);
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException ignored) {
Botania.LOGGER.error("Couldn't copy gametype in 1.10 crossversion proxy");
}
}
@Override
public int getSkeletonTypeInt(EntitySkeleton skeleton) {
try {
Method m = ReflectionHelper.findMethod(EntitySkeleton.class, null, new String[] { "func_189771_df", "df" });
Enum e = (Enum) m.invoke(skeleton);
return e.ordinal();
} catch (IllegalAccessException | InvocationTargetException e1) {
Botania.LOGGER.error("Couldn't get skeleton type in 1.10 crossversion proxy");
return 0;
}
}
@Override
public void setSkeletonTypeInt(EntitySkeleton skeleton, int type) {
try {
Class skeletonTypeClazz = Class.forName("net.minecraft.entity.monster.SkeletonType");
Object typeToSet = skeletonTypeClazz.getEnumConstants()[type];
Method m = ReflectionHelper.findMethod(EntitySkeleton.class, null, new String[] { "func_189768_a", "a" }, skeletonTypeClazz);
m.invoke(skeleton, typeToSet);
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
Botania.LOGGER.error("Couldn't set skeleton type in 1.10 crossversion proxy");
}
}
@Override
public boolean isSurvivalOrAdventure(EntityPlayerMP playerMP) {
try {
Class gameTypeClazz = Class.forName("net.minecraft.world.GameType");
Method m = ReflectionHelper.findMethod(PlayerInteractionManager.class, null, new String[] { "getGameType", "func_73081_b", "b" });
Object gameType = m.invoke(playerMP.interactionManager);
m = ReflectionHelper.findMethod(gameTypeClazz, null, new String[] { "isSurvivalOrAdventure", "func_77144_e", "e" });
return (Boolean) m.invoke(gameType);
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException ignored) {
Botania.LOGGER.error("Couldn't determine survival or adventure in 1.10 crossversion proxy");
return true;
}
}
}
@@ -1,79 +0,0 @@
package vazkii.botania.common.core.proxy;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.client.core.handler.BotaniaPlayerController;
import vazkii.botania.common.Botania;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class CrossVersionProxy_19 implements ICrossVersionProxy {
@Override
public TileEntity createTeFromCompound(World world, NBTTagCompound compound) {
Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_189514_c", "c" }, NBTTagCompound.class);
try {
return (TileEntity) m.invoke(null, compound);
} catch (IllegalAccessException | InvocationTargetException e) {
Botania.LOGGER.error("Couldn't create TE in 1.9 crossversion proxy");
return null;
}
}
@SideOnly(Side.CLIENT)
@Override
public void copyGameType(PlayerControllerMP from, BotaniaPlayerController to) {
try {
Class<?> gameTypeClazz = Class.forName("net.minecraft.world.WorldSettings$GameType");
Method m = ReflectionHelper.findMethod(PlayerControllerMP.class, null, new String[]{ "getCurrentGameType", "func_178889_l", "l" });
Object gameType = m.invoke(from);
m = ReflectionHelper.findMethod(PlayerControllerMP.class, null, new String[]{ "setGameType", "func_78746_a", "a" }, gameTypeClazz);
m.invoke(to, gameType);
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException ignored) {
Botania.LOGGER.error("Couldn't copy game type in 1.9 crossversion proxy");
}
}
@Override
public int getSkeletonTypeInt(EntitySkeleton skeleton) {
try {
Method m = ReflectionHelper.findMethod(EntitySkeleton.class, null, new String[]{ "getSkeletonType", "func_82202_m", "db" });
return (int) m.invoke(skeleton);
} catch (IllegalAccessException | InvocationTargetException e) {
Botania.LOGGER.error("Couldn't get skeleton type in 1.9 crossversion proxy");
return 0;
}
}
@Override
public void setSkeletonTypeInt(EntitySkeleton skeleton, int type) {
try {
Method m = ReflectionHelper.findMethod(EntitySkeleton.class, null, new String[]{ "setSkeletonType", "func_82201_a", "a" }, int.class);
m.invoke(skeleton, type);
} catch (IllegalAccessException | InvocationTargetException e) {
Botania.LOGGER.error("Couldn't set skeleton type in 1.9 crossversion proxy");
}
}
@Override
public boolean isSurvivalOrAdventure(EntityPlayerMP playerMP) {
try {
Class gameTypeClazz = Class.forName("net.minecraft.world.WorldSettings$GameType");
Method m = ReflectionHelper.findMethod(PlayerInteractionManager.class, null, new String[] { "getGameType", "func_73081_b", "b" });
Object gameType = m.invoke(playerMP.interactionManager);
m = ReflectionHelper.findMethod(gameTypeClazz, null, new String[] { "isSurvivalOrAdventure", "func_77144_e", "e" });
return (Boolean) m.invoke(gameType);
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException ignored) {
Botania.LOGGER.error("Couldn't determine survival or adventure in 1.9 crossversion proxy");
return true;
}
}
}
@@ -1,28 +0,0 @@
package vazkii.botania.common.core.proxy;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.client.core.handler.BotaniaPlayerController;
// horrible hax to try to run 1.9/10 from the same jar :D
// Taking this as an example is heavily discouraged
public interface ICrossVersionProxy {
TileEntity createTeFromCompound(World world, NBTTagCompound compound);
@SideOnly(Side.CLIENT)
void copyGameType(PlayerControllerMP from, BotaniaPlayerController to);
int getSkeletonTypeInt(EntitySkeleton skeleton);
void setSkeletonTypeInt(EntitySkeleton skeleton, int type);
boolean isSurvivalOrAdventure(EntityPlayerMP playerMP);
}
@@ -27,6 +27,7 @@ import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.monster.SkeletonType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
@@ -669,7 +670,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBoss {
entity = new EntitySkeleton(worldObj);
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
if(worldObj.rand.nextInt(8) == 0) {
Botania.crossVersionProxy.setSkeletonTypeInt((EntitySkeleton) entity, 1);
((EntitySkeleton) entity).setSkeletonType(SkeletonType.WITHER);
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(hard ? ModItems.elementiumSword : Items.STONE_SWORD));
}
break;
@@ -251,7 +251,7 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
TileEntity tile = null;
NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false);
if(tilecmp.hasKey("id"))
tile = Botania.crossVersionProxy.createTeFromCompound(entity.worldObj, tilecmp);
tile = TileEntity.create(entity.worldObj, tilecmp);
entity.worldObj.setBlockState(pos, block.getStateFromMeta(meta), 1 | 2);
entity.worldObj.playEvent(2001, pos, Block.getStateId(block.getStateFromMeta(meta)));
@@ -195,7 +195,7 @@ public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem {
void onFire(ItemStack bow, EntityLivingBase living, boolean infinity, EntityArrow arrow) {
if(living instanceof EntityPlayerMP) {
ToolCommons.damageItem(bow, 1, living, MANA_PER_DAMAGE);
if(Botania.crossVersionProxy.isSurvivalOrAdventure((EntityPlayerMP) living))
if(((EntityPlayerMP) living).interactionManager.getGameType().isSurvivalOrAdventure())
PlayerHelper.consumeAmmo(((EntityPlayerMP) living), AMMO_FUNC);
}
}
@@ -42,7 +42,7 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, weapon);
if(event.getEntityLiving() instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting)
addDrop(event, new ItemStack(Items.SKULL, 1, Botania.crossVersionProxy.getSkeletonTypeInt((EntitySkeleton) event.getEntityLiving())));
addDrop(event, new ItemStack(Items.SKULL, 1, ((EntitySkeleton) event.getEntityLiving()).getSkeletonType().ordinal()));
else if(event.getEntityLiving() instanceof EntityZombie && !(event.getEntityLiving() instanceof EntityPigZombie) && rand.nextInt(26) <= 2 + 2 * looting)
addDrop(event, new ItemStack(Items.SKULL, 1, 2));
else if(event.getEntityLiving() instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting)
@@ -17,8 +17,8 @@ public final class LibMisc {
public static final String MOD_NAME = MOD_ID;
public static final String BUILD = "GRADLE:BUILD";
public static final String VERSION = "GRADLE:VERSION-" + BUILD;
public static final String DEPENDENCIES = "required-after:Forge@[12.17.0.1965,];required-after:Baubles;after:Thaumcraft";
public static final String MC_VERSIONS = "[1.9.4,1.10.2]";
public static final String DEPENDENCIES = "required-after:Forge@[12.18.1.2014,];required-after:Baubles;after:Thaumcraft";
public static final String MC_VERSIONS = "[1.10.2]";
public static final String UPDATE_JSON = "https://raw.githubusercontent.com/williewillus/Botania/HEAD/version/update.json";
// Network Contants