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()); }
/** * 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"); } } }
public static void setVillagerCareer(EntityVillager merchant, int c) { ObfuscationReflectionHelper.setPrivateValue(EntityVillager.class, merchant, c, "careerId", "field_175563_bv"); }
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; }
protected void initBlockState() { BlockStateContainer stateContainer = createStateContainer(); ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer setDefaultState(stateContainer.getBaseState()); }
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; }
public NBTList(NBTTagList nbtList) { this.nbtList = nbtList; backingList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtList, 1); }
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) {} } }
protected void initBlockState() { BlockStateContainer stateContainer = createStateContainer(); ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer setDefaultState(stateContainer.getBaseState()); }
public String getName(){ return ObfuscationReflectionHelper.remapFieldNames(this.clazz.getName(), this.name)[0]; }
private static List<SoundEvent> getInstruments() { if (instruments == null) { instruments = ObfuscationReflectionHelper.getPrivateValue(BlockNote.class, null, "field_176434_a"); } return instruments; }
@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 } } }
@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(); } } } }
public static long[] getLongArray(NBTBase nbt) { if (!(nbt instanceof NBTTagLongArray)) { return new long[0]; } return ObfuscationReflectionHelper.getPrivateValue(NBTTagLongArray.class, (NBTTagLongArray) nbt, 0); }
ObfuscationReflectionHelper.setPrivateValue(NetHandlerPlayServer.class, ((EntityPlayerMP) entity).connection, 0, "field_147365_f"); } catch (RuntimeException ignored) {
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 {
private static int[][][] getMatrix() { if (matrix == null) { matrix = ObfuscationReflectionHelper.getPrivateValue(EntityMinecart.class, null, "field_70500_g"); } return matrix; }
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 } }
private static boolean isEntityInPortal(Entity entity) { return ObfuscationReflectionHelper.getPrivateValue(Entity.class, entity, inPortalFieldNames); } }
@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)); } }