Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.thevoxelbox.voxelmap;
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
- import net.minecraftforge.client.event.RenderGameOverlayEvent.Post;
- import net.minecraftforge.common.MinecraftForge;
- import cpw.mods.fml.common.Mod;
- import cpw.mods.fml.common.Mod.EventHandler;
- import cpw.mods.fml.common.Mod.Instance;
- import cpw.mods.fml.common.event.FMLPostInitializationEvent;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- @Mod(
- modid = "voxelmapforceenabler",
- version = "1.7.2",
- name = "VoxelMapForceEnabler"
- )
- public class VoxelMapForceEnabler
- {
- @Instance("voxelmapforceenabler")
- public static VoxelMapForceEnabler instance;
- public static Object voxelMapMod_voxelMap = null;
- public static Method voxelMap_setPermissions = null;
- @EventHandler
- public void postInit(FMLPostInitializationEvent event)
- {
- MinecraftForge.EVENT_BUS.register(this);
- }
- @SubscribeEvent
- public void onRenderOverlay(Post event)
- {
- if (event.type == ElementType.ALL)
- {
- if (this.getVoxelMap())
- {
- if (voxelMap_setPermissions != null)
- {
- try
- {
- voxelMap_setPermissions.invoke(voxelMapMod_voxelMap, true, true);
- }
- catch (Throwable e) {}
- }
- }
- }
- }
- public boolean getVoxelMap()
- {
- try
- {
- if (voxelMap_setPermissions != null)
- {
- return true;
- }
- else
- {
- Class voxelMapClass = Class.forName("com.thevoxelbox.voxelmap.VoxelMapMod");
- Field voxelMapClass_instance = voxelMapClass.getDeclaredField("instance");
- Object voxelMapMod_instance = voxelMapClass_instance.get(null);
- Field voxelMapClass_proxy = voxelMapClass.getDeclaredField("proxy");
- Object voxelMapMod_proxy = voxelMapClass_proxy.get(voxelMapMod_instance);
- Field voxelMapClass_voxelMap = Class.forName("com.thevoxelbox.voxelmap.ClientProxy").getDeclaredField("voxelMap");
- voxelMapMod_voxelMap = voxelMapClass_voxelMap.get(voxelMapMod_proxy);
- voxelMap_setPermissions = Class.forName("com.thevoxelbox.voxelmap.VoxelMap").getDeclaredMethod("setPermissions", Boolean.TYPE, Boolean.TYPE);
- if (voxelMap_setPermissions != null)
- {
- return true;
- }
- }
- }
- catch (Throwable e) {}
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement