Codota Logo
ObfuscationReflectionHelper
Code IndexAdd Codota to your IDE (free)

How to use
ObfuscationReflectionHelper
in
net.minecraftforge.fml.common

Best Java code snippets using net.minecraftforge.fml.common.ObfuscationReflectionHelper (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: SlimeKnights/TinkersConstruct

public TableRecipeWrapper(TableRecipe recipe) {
 this.recipe = recipe;
 for(Object input : this.recipe.getIngredients()) {
  if(input instanceof ItemStack) {
   ItemStack itemStack = (ItemStack) input;
   if(itemStack.getCount() != 1) {
    itemStack.setCount(1);
   }
  }
 }
 this.width = ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, this.recipe, "width");
 this.height = ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, this.recipe, "height");
 // sort the output entries into lists of items
 ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
 for(ItemStack stack : recipe.ingredients.getMatchingStacks()) {
  BlockTable block = (BlockTable) BlockTable.getBlockFromItem(recipe.getRecipeOutput().getItem());
  Block legBlock = Block.getBlockFromItem(stack.getItem());
  if(stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
   for(ItemStack sub : JEIPlugin.jeiHelpers.getStackHelper().getSubtypes(stack)) {
    builder.add(BlockTable.createItemstack(block, recipe.getRecipeOutput().getItemDamage(), legBlock, sub.getItemDamage()));
   }
  }
  else {
   builder.add(BlockTable.createItemstack(block, recipe.getRecipeOutput().getItemDamage(), legBlock, stack.getItemDamage()));
  }
 }
 outputs = ImmutableList.of(builder.build());
}
origin: Zyin055/zyinhud

/**
 * Disables the potion effects from rendering by telling the Gui that the player has no potion effects applied.
 * Uses reflection to grab the class's private variable.
 * @param guiScreen the screen the player is looking at which extends InventoryEffectRenderer
 */
public static void DisableInventoryPotionEffects(InventoryEffectRenderer guiScreen)
{
  if(PotionTimers.Enabled && HidePotionEffectsInInventory)
  {
    //Note for future Forge versions: field "field_147045_u" will probably be renamed to something like "playerHasPotionEffects"
    boolean playerHasPotionEffects = ObfuscationReflectionHelper.getPrivateValue(InventoryEffectRenderer.class, (InventoryEffectRenderer)guiScreen, "field_147045_u");
    
    if(playerHasPotionEffects)
    {
      int guiLeftPx = (guiScreen.width - 176) / 2;
      
      ObfuscationReflectionHelper.setPrivateValue(GuiContainer.class, (GuiContainer)guiScreen, guiLeftPx, "field_147003_i","guiLeft");
      ObfuscationReflectionHelper.setPrivateValue(InventoryEffectRenderer.class, (InventoryEffectRenderer)guiScreen, false, "field_147045_u");
    }
  }
}

origin: PrinceOfAmber/Cyclic

public static void setVillagerCareer(EntityVillager merchant, int c) {
 ObfuscationReflectionHelper.setPrivateValue(EntityVillager.class, merchant, c, "careerId", "field_175563_bv");
}
origin: Alex-the-666/Ice_and_Fire

private DataParameter<Integer> PROFFESSION() {
  Field field = ReflectionHelper.findField(EntityVillager.class, ObfuscationReflectionHelper.remapFieldNames(EntityVillager.class.getName(), new String[]{"PROFESSION", "field_184752_bw"}));
  try {
    Field modifier = Field.class.getDeclaredField("modifiers");
    modifier.setAccessible(true);
    modifier.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    DataParameter<Integer> prof = (DataParameter<Integer>) field.get(this);
    return prof;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}
origin: GregTechCE/GregTech

protected void initBlockState() {
  BlockStateContainer stateContainer = createStateContainer();
  ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer
  setDefaultState(stateContainer.getBaseState());
}
origin: Alex-the-666/Ice_and_Fire

private DataParameter<Boolean> BABY() {
  Field field = ReflectionHelper.findField(EntityAgeable.class, ObfuscationReflectionHelper.remapFieldNames(EntityAgeable.class.getName(), new String[]{"BABY", "field_184751_bv"}));
  try {
    Field modifier = Field.class.getDeclaredField("modifiers");
    modifier.setAccessible(true);
    modifier.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    DataParameter<Boolean> bay = (DataParameter<Boolean>) field.get(this);
    return bay;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}
origin: ForestryMC/ForestryMC

public NBTList(NBTTagList nbtList) {
  this.nbtList = nbtList;
  backingList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtList, 1);
}
origin: PrinceOfAmber/Cyclic

 private void startConverting(EntityZombieVillager v, int t) {
  //      v.conversionTime = t;
  ObfuscationReflectionHelper.setPrivateValue(EntityZombieVillager.class, v, t, "conversionTime", "field_82234_d");
  v.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, t, Math.min(v.world.getDifficulty().getId() - 1, 0)));
  v.world.setEntityState(v, (byte) 16);
  try {
   //       v.getDataManager().set(CONVERTING, Boolean.valueOf(true));
   DataParameter<Boolean> CONVERTING = ObfuscationReflectionHelper.getPrivateValue(EntityZombieVillager.class, v, "CONVERTING", "field_184739_bx");
   v.getDataManager().set(CONVERTING, Boolean.valueOf(true));
  }
  catch (Exception e) {}
 }
}
origin: GregTechCE/GregTech

protected void initBlockState() {
  BlockStateContainer stateContainer = createStateContainer();
  ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer
  setDefaultState(stateContainer.getBaseState());
}
origin: superckl/BiomeTweaker

public String getName(){
  return ObfuscationReflectionHelper.remapFieldNames(this.clazz.getName(), this.name)[0];
}
origin: SquidDev-CC/plethora

private static List<SoundEvent> getInstruments() {
  if (instruments == null) {
    instruments = ObfuscationReflectionHelper.getPrivateValue(BlockNote.class, null, "field_176434_a");
  }
  return instruments;
}
origin: SleepyTrousers/EnderIO

@SideOnly(Side.CLIENT)
private void onInput(@Nonnull EntityPlayerSP player) {
 MovementInput input = player.movementInput;
 BlockPos target = TravelController.instance.selectedCoord;
 if (target == null) {
  return;
 }
 TileEntity te = player.world.getTileEntity(target);
 if (te instanceof ITravelAccessable) {
  ITravelAccessable ta = (ITravelAccessable) te;
  if (ta.getRequiresPassword(player)) {
   PacketOpenAuthGui p = new PacketOpenAuthGui(target);
   PacketHandler.INSTANCE.sendToServer(p);
   return;
  }
 }
 if (travelToSelectedTarget(player, Prep.getEmpty(), EnumHand.MAIN_HAND, TravelSource.BLOCK, false)) {
  input.jump = false;
  try {
   ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, (EntityPlayer) player, 0, "flyToggleTimer", "field_71101_bC");
  } catch (Exception e) {
   // ignore
  }
 }
}
origin: Alex-the-666/Ice_and_Fire

  @SubscribeEvent
  public void openMainMenu(GuiOpenEvent event) {
    if (event.getGui() instanceof GuiMainMenu && IceAndFire.CONFIG.customMainMenu) {
      GuiMainMenu mainMenu = (GuiMainMenu) event.getGui();
      Field field = ReflectionHelper.findField(GuiMainMenu.class, ObfuscationReflectionHelper.remapFieldNames(GuiMainMenu.class.getName(), new String[]{"TITLE_PANORAMA_PATHS", "field_73978_o"}));
      try {
        Field modifier = Field.class.getDeclaredField("modifiers");
        modifier.setAccessible(true);
        modifier.setInt(field, field.getModifiers() & ~Modifier.FINAL);
        field.set(mainMenu, panorama);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
}
origin: ForestryMC/ForestryMC

public static long[] getLongArray(NBTBase nbt) {
  if (!(nbt instanceof NBTTagLongArray)) {
    return new long[0];
  }
  return ObfuscationReflectionHelper.getPrivateValue(NBTTagLongArray.class, (NBTTagLongArray) nbt, 0);
}
origin: SquidDev-CC/plethora

  ObfuscationReflectionHelper.setPrivateValue(NetHandlerPlayServer.class,
    ((EntityPlayerMP) entity).connection, 0, "field_147365_f");
} catch (RuntimeException ignored) {
origin: Alex-the-666/Ice_and_Fire

Field renderingRegistryField = ReflectionHelper.findField(RenderingRegistry.class, ObfuscationReflectionHelper.remapFieldNames(RenderingRegistry.class.getName(), new String[]{"INSTANCE", "INSTANCE"}));
Field entityRendersField = ReflectionHelper.findField(RenderingRegistry.class, ObfuscationReflectionHelper.remapFieldNames(RenderingRegistry.class.getName(), new String[]{"entityRenderers", "entityRenderers"}));
Field entityRendersOldField = ReflectionHelper.findField(RenderingRegistry.class, ObfuscationReflectionHelper.remapFieldNames(RenderingRegistry.class.getName(), new String[]{"entityRenderersOld", "entityRenderersOld"}));
RenderingRegistry registry = null;
try {
origin: SquidDev-CC/plethora

private static int[][][] getMatrix() {
  if (matrix == null) {
    matrix = ObfuscationReflectionHelper.getPrivateValue(EntityMinecart.class, null, "field_70500_g");
  }
  return matrix;
}
origin: PrinceOfAmber/Cyclic

public void onSleepSuccess(World world, EnumHand hand, ItemStack stack, EntityPlayerMP player, final IPlayerExtendedProperties sleep) {
 sleep.setSleeping(true);
 if (doPotions) {
  player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, seconds * Const.TICKS_PER_SEC, Const.Potions.I));
  player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, seconds * Const.TICKS_PER_SEC, Const.Potions.I));
 }
 this.onUse(stack, player, world, hand);
 //hack because vanilla/forge has that java.lang.IllegalArgumentException: Cannot get property PropertyDirection error with assuming its a bed when its blocks.air
 ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, player, true, "sleeping", "field_71083_bS");
 ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, player, 0, "sleepTimer", "field_71076_b");
 UtilChat.sendStatusMessage(player, this.getTranslationKey() + ".trying");
 //first set bed location
 player.bedLocation = player.getPosition();
 ModCyclic.network.sendTo(new PacketSleepClient(player.bedLocation), player);
 //then stop player in place
 player.motionX = player.motionZ = player.motionY = 0;
 world.updateAllPlayersSleepingFlag();
 //then trigger vanilla sleep event(s)
 //                world.setBlockState(player.getPosition(), Blocks.BED.getDefaultState());
 SPacketUseBed sleepPacket = new SPacketUseBed(player, player.getPosition());
 player.getServerWorld().getEntityTracker().sendToTracking(player, sleepPacket);
 player.connection.sendPacket(sleepPacket);
 if (this.isOn(stack)) {
  player.setSpawnPoint(player.getPosition(), true);//true means it wont check for bed block
 }
}
origin: AntiqueAtlasTeam/AntiqueAtlas

  private static boolean isEntityInPortal(Entity entity) {
    return ObfuscationReflectionHelper.getPrivateValue(Entity.class, entity, inPortalFieldNames);
  }
}
origin: P3pp3rF1y/AncientWarfare2

@Override
public void setCollisionBoundingBox(EntityGate gate) {
  if (gate.pos1 == null || gate.pos2 == null) {
    return;
  }
  BlockPos min = BlockTools.getMin(gate.pos1, gate.pos2);
  BlockPos max = BlockTools.getMax(gate.pos1, gate.pos2);
  if (!(gate.getEntityBoundingBox() instanceof DualBoundingBox)) {
    try {
      ObfuscationReflectionHelper.setPrivateValue(Entity.class, gate, new DualBoundingBox(min, max), "boundingBox", "field_70121_D");
    }
    catch (Exception ignored) {
      //ignored
    }
  }
  if (gate.edgePosition > 0) {
    gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), max.getY() + 0.5d, min.getZ(), max.getX() + 1, max.getY() + 1, max.getZ() + 1));
  } else {
    gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX() + 1, max.getY() + 1, max.getZ() + 1));
  }
}
net.minecraftforge.fml.commonObfuscationReflectionHelper

Most used methods

  • getPrivateValue
  • setPrivateValue
  • remapFieldNames

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now