Java Code Examples for net.minecraft.entity.passive.EntityVillager#ITradeList

The following examples show how to use net.minecraft.entity.passive.EntityVillager#ITradeList . 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: VillagerTradeHelper.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Inserts one or more trades to the defaul villager trade table using dark magic (aka java reflection).
 * @param professionID Villager profession ID (0-4)
 * @param careerID Villager career ID (1-3)
 * @param tradeLevel Level of trade (1+)
 * @param trades Trades to add to the given level
 * @throws NoSuchFieldException Thrown if java reflection has been disabled for security reasons
 * @throws IllegalAccessException Thrown if java reflection has been disabled for security reasons
 */
public static void insertTrades(int professionID, int careerID, int tradeLevel, EntityVillager.ITradeList... trades) throws NoSuchFieldException, IllegalAccessException {
	ResourceLocation profession = professionList[professionID];
	insertTrades(profession,careerID,tradeLevel,trades);
	/*
	FMLLog.info("%s: injecting villager trades %s into default trade array table at position [%s][%s][%s][*]", BaseMetals.MODID, Arrays.toString(trades), professionID, careerID-1, tradeLevel-1);
	Field vanillaTradeField = getTradeArrayFromClass(EntityVillager.class);
	unlockPrivateFinalField(vanillaTradeField);
	Object tradeTable = vanillaTradeField.get(null); // is static
	appendToMultidimensionalArray(trades,tradeTable,professionID,Math.max(0,careerID-1),Math.max(0,tradeLevel-1));
	*/
}
 
Example 2
Source File: VillagerTradeHelper.java    From BaseMetals with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Inserts one or more trades to the defaul villager trade table using dark magic (aka java reflection).
 * @param profession Villager profession
 * @param careerID Villager career ID (1-3)
 * @param tradeLevel Level of trade (1+)
 * @param trades Trades to add to the given level
 */
public static void insertTrades(ResourceLocation profession, int careerID, int tradeLevel, EntityVillager.ITradeList... trades) {
	for(EntityVillager.ITradeList trade : trades) {
		VillagerRegistry.instance().getRegistry().getValue(profession).getCareer(careerID-1).addTrade(tradeLevel, trade);
	}
}