Java Code Examples for cpw.mods.fml.relauncher.ReflectionHelper#setPrivateValue()
The following examples show how to use
cpw.mods.fml.relauncher.ReflectionHelper#setPrivateValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Nan0EventRegistar.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
public static void register(EventBus bus, Object target) { ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners"); Map<Object, ModContainer> listenerOwners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listenerOwners"); if (listeners.containsKey(target)) { return; } ModContainer activeModContainer = Loader.instance().getMinecraftModContainer(); listenerOwners.put(target, activeModContainer); ReflectionHelper.setPrivateValue(EventBus.class, bus, listenerOwners, "listenerOwners"); Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); for (Method method : target.getClass().getMethods()) { for (Class<?> cls : supers) { try { Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (real.isAnnotationPresent(SubscribeEvent.class)) { Class<?>[] parameterTypes = method.getParameterTypes(); Class<?> eventType = parameterTypes[0]; register(bus, eventType, target, method, activeModContainer); break; } } catch (NoSuchMethodException ignored) { } } } }
Example 2
Source File: Nan0EventRegistar.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
private static void register(EventBus bus, Class<?> eventType, Object target, Method method, ModContainer owner) { try { int busID = ReflectionHelper.getPrivateValue(EventBus.class, bus, "busID"); ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners"); Constructor<?> ctr = eventType.getConstructor(); ctr.setAccessible(true); Event event = (Event) ctr.newInstance(); ASMEventHandler listener = new ASMEventHandler(target, method, owner); event.getListenerList().register(busID, listener.getPriority(), listener); ArrayList<IEventListener> others = listeners.get(target); if (others == null) { others = new ArrayList<>(); listeners.put(target, others); ReflectionHelper.setPrivateValue(EventBus.class, bus, listeners, "listeners"); } others.add(listener); } catch (Exception e) { } }
Example 3
Source File: EntityRabbit.java From Et-Futurum with The Unlicense | 6 votes |
public EntityRabbit(World world) { super(world); moveType = EntityRabbit.EnumMoveType.HOP; carrotTicks = 0; setSize(0.4F, 0.5F); ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitJumpHelper(this), "jumpHelper", "field_70767_i"); ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitMoveHelper(), "moveHelper", "field_70765_h"); getNavigator().setAvoidsWater(true); // navigator.func_179678_a(2.5F); tasks.addTask(1, new EntityAISwimming(this)); tasks.addTask(1, new EntityRabbit.AIPanic(1.33D)); tasks.addTask(2, new EntityAIMate(this, 0.8D)); tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.carrot, false)); tasks.addTask(5, new EntityRabbit.AIRaidFarm()); tasks.addTask(5, new EntityAIWander(this, 0.6D)); tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F)); tasks.addTask(4, new EntityAIAvoidEntity(this, EntityWolf.class, 16.0F, 1.33D, 1.33D)); tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 0.8D, 1.33D)); setMovementSpeed(0.0D); }
Example 4
Source File: GuiAnvil.java From Et-Futurum with The Unlicense | 5 votes |
public GuiAnvil(EntityPlayer player, World world, int x, int y, int z) { super(player.inventory, world, x, y, z); ContainerAnvil container = new ContainerAnvil(player, world, x, y, z); ReflectionHelper.setPrivateValue(GuiRepair.class, this, container, "field_147092_v"); inventorySlots = container; }
Example 5
Source File: ClientProxy.java From Et-Futurum with The Unlicense | 5 votes |
@SuppressWarnings("unchecked") private void registerEntityRenderers() { if (EtFuturum.enableArmourStand) RenderingRegistry.registerEntityRenderingHandler(EntityArmourStand.class, new ArmourStandRenderer()); if (EtFuturum.enableEndermite) RenderingRegistry.registerEntityRenderingHandler(EntityEndermite.class, new EndermiteRenderer()); if (EtFuturum.enableRabbit) RenderingRegistry.registerEntityRenderingHandler(EntityRabbit.class, new RabbitRenderer()); if (EtFuturum.enableLingeringPotions) { RenderingRegistry.registerEntityRenderingHandler(EntityLingeringPotion.class, new LingeringPotionRenderer()); RenderingRegistry.registerEntityRenderingHandler(EntityLingeringEffect.class, new LingeringEffectRenderer()); } if (EtFuturum.enableVillagerZombies) RenderingRegistry.registerEntityRenderingHandler(EntityZombieVillager.class, new VillagerZombieRenderer()); if (EtFuturum.enableDragonRespawn) RenderingRegistry.registerEntityRenderingHandler(EntityPlacedEndCrystal.class, new PlacedEndCrystalRenderer()); if (EtFuturum.enablePlayerSkinOverlay) { TextureManager texManager = Minecraft.getMinecraft().renderEngine; File fileAssets = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "fileAssets", "field_110446_Y", " field_110607_c"); File skinFolder = new File(fileAssets, "skins"); MinecraftSessionService sessionService = Minecraft.getMinecraft().func_152347_ac(); ReflectionHelper.setPrivateValue(Minecraft.class, Minecraft.getMinecraft(), new NewSkinManager(Minecraft.getMinecraft().func_152342_ad(), texManager, skinFolder, sessionService), "field_152350_aA"); RenderManager.instance.entityRenderMap.put(EntityPlayer.class, new NewRenderPlayer()); } if (EtFuturum.enableShearableGolems) RenderingRegistry.registerEntityRenderingHandler(EntityNewSnowGolem.class, new NewSnowGolemRenderer()); }
Example 6
Source File: EntityDrone.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public EntityDrone(World world){ super(world); setSize(0.7F, 0.35F); ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityPathNavigateDrone(this, world), "navigator", "field_70699_by"); ReflectionHelper.setPrivateValue(EntityLiving.class, this, new DroneMoveHelper(this), "moveHelper", "field_70765_h"); tasks.addTask(1, chargeAI = new DroneGoToChargingStation(this)); }
Example 7
Source File: NoWeb.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@Override public void onTicks() { ReflectionHelper.setPrivateValue(Entity.class, Wrapper.INSTANCE.player(), false, new String[]{Mappings.isInWeb}); }
Example 8
Source File: WorldEventHandler.java From TickDynamic with MIT License | 4 votes |
private void setCustomProfiler(World world, Profiler profiler) throws Exception { ReflectionHelper.setPrivateValue(World.class, world, profiler, "theProfiler", "field_72984_F"); }