Java Code Examples for cpw.mods.fml.relauncher.ReflectionHelper#findField()
The following examples show how to use
cpw.mods.fml.relauncher.ReflectionHelper#findField() .
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: RabbitFoot.java From Et-Futurum with The Unlicense | 6 votes |
@SuppressWarnings("unchecked") public RabbitFoot() { setTextureName("rabbit_foot"); setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot")); setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null); if (EtFuturum.enableRabbit) try { Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l"); f.setAccessible(true); HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null); potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3"); Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m"); f2.setAccessible(true); HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null); potionAmplifiers.put(Potion.jump.getId(), "5"); Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N"); f3.setAccessible(true); f3.set(Potion.jump, 0x22FF4C); } catch (Exception e) { } }
Example 2
Source File: Mappings.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
public static boolean isMCP() { try { return ReflectionHelper.findField(Minecraft.class, new String[]{"theMinecraft"}) != null; } catch (Exception ex) { return false; } }
Example 3
Source File: EtFuturum.java From Et-Futurum with The Unlicense | 5 votes |
private void setFinalField(Class<?> cls, Object obj, Object newValue, String... fieldNames) { try { Field field = ReflectionHelper.findField(cls, fieldNames); field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(obj, newValue); } catch (Exception e) { e.printStackTrace(); } }
Example 4
Source File: AdvancedModEventHandler.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onCreeperSpawn(EntityJoinWorldEvent event){ if(event.entity instanceof EntityCreeper) { ((EntityCreeper)event.entity).explosionRadius = 0; try { Field field = ReflectionHelper.findField(EntityCreeper.class, "field_82225_f", "fuseTime"); field.set(event.entity, 80); } catch(Throwable e) { Log.warn("Reflection on Creeper fuseTime failed!"); e.printStackTrace(); } } }
Example 5
Source File: BlockLogTainted.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public BlockLogTainted() { super(); setCreativeTab(Forbidden.tab); setStepSound(ConfigBlocks.blockTaint.stepSound); try { Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J"); mat.set(this, Config.taintMaterial); } catch (Exception e){ e.printStackTrace(); } this.setHarvestLevel("axe", 0); }
Example 6
Source File: BlockLeavesTainted.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public BlockLeavesTainted() { super(); setCreativeTab(Forbidden.tab); setLightOpacity(0); setHardness(0.2F); setStepSound(ConfigBlocks.blockTaint.stepSound); try { Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J"); mat.set(this, Config.taintMaterial); } catch (Exception e){ e.printStackTrace(); } }
Example 7
Source File: BlockSaplingTainted.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public BlockSaplingTainted() { super(); setCreativeTab(Forbidden.tab); setStepSound(ConfigBlocks.blockTaint.stepSound); try { Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J"); mat.set(this, Config.taintMaterial); } catch (Exception e){ e.printStackTrace(); } }
Example 8
Source File: HackableWitch.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean afterHackTick(Entity entity){ if(attackTimer == null) attackTimer = ReflectionHelper.findField(EntityWitch.class, "field_82200_e", "witchAttackTimer"); try { attackTimer.set(entity, 20); ((EntityWitch)entity).setAggressive(true); return true; } catch(Exception e) { Log.warning("Reflection failed on HackableWitch:"); e.printStackTrace(); return false; } }
Example 9
Source File: FakePlayerItemInWorldManager.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public boolean isDigging(){ if(isDigging == null) isDigging = ReflectionHelper.findField(ItemInWorldManager.class, "field_73088_d", "isDestroyingBlock"); try { return isDigging.getBoolean(this); } catch(Exception e) { Log.error("Drone FakePlayerItemInWorldManager failed with reflection (Digging)!"); e.printStackTrace(); return true; } }
Example 10
Source File: FakePlayerItemInWorldManager.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public boolean isAcknowledged(){ if(acknowledged == null) acknowledged = ReflectionHelper.findField(ItemInWorldManager.class, "field_73097_j", "receivedFinishDiggingPacket"); try { return acknowledged.getBoolean(this); } catch(Exception e) { Log.error("Drone FakePlayerItemInWorldManager failed with reflection (Acknowledge get)!"); e.printStackTrace(); return true; } }
Example 11
Source File: Injector.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public static Field findField(Class clazz, String... names) { return ReflectionHelper.findField(clazz, names); }
Example 12
Source File: PrismarineIcon.java From Et-Futurum with The Unlicense | 4 votes |
public PrismarineIcon(String name) { super(name); fanimationMetadata = ReflectionHelper.findField(TextureAtlasSprite.class, "animationMetadata", "field_110982_k"); fanimationMetadata.setAccessible(true); }
Example 13
Source File: HackableLivingDisarm.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void onHackFinished(Entity entity, EntityPlayer player){ if(!entity.worldObj.isRemote) { Random rand = new Random(); if(fieldDropChance == null) { fieldDropChance = ReflectionHelper.findField(EntityLiving.class, "field_82174_bp", "equipmentDropChances"); } try { float[] equipmentDropChances = (float[])fieldDropChance.get(entity); for(int i = 0; i < ((EntityLiving)entity).getLastActiveItems().length; i++) { ItemStack stack = ((EntityLiving)entity).getLastActiveItems()[i]; float equipmentDropChance = equipmentDropChances[i]; boolean flag1 = equipmentDropChance > 1.0F; if(stack != null && rand.nextFloat() < equipmentDropChance) { if(!flag1 && stack.isItemStackDamageable()) { int k = Math.max(stack.getMaxDamage() - 25, 1); int l = stack.getMaxDamage() - rand.nextInt(rand.nextInt(k) + 1); if(l > k) { l = k; } if(l < 1) { l = 1; } stack.setItemDamage(l); } entity.entityDropItem(stack, 0.0F); } ((EntityLiving)entity).setCurrentItemOrArmor(i, null); } ((EntityLiving)entity).setCanPickUpLoot(false); } catch(Exception e) { Log.error("Reflection failed on HackableLivingDisarm"); e.printStackTrace(); } } }