Created
August 17, 2015 16:55
-
-
Save Skepfyr/b7cfaf8d715d5bdbe361 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Flardians { | |
public static final ItemType[] SELL_TYPES = new ItemType[] {ItemTypes.SLIME_BALL, ItemTypes.HARDENED_CLAY, ItemTypes.BLAZE_ROD, ItemTypes.APPLE, | |
ItemTypes.GHAST_TEAR, ItemTypes.COBBLESTONE, ItemTypes.STICK, ItemTypes.EMERALD,}; | |
public static final List<ItemType> BUYING_TYPES = ImmutableList.of(ItemTypes.ACACIA_DOOR, ItemTypes.LEAVES2, ItemTypes.BOOKSHELF, ItemTypes.COAL, | |
ItemTypes.COBBLESTONE, ItemTypes.ANVIL, ItemTypes.IRON_ORE, ItemTypes.APPLE, | |
ItemTypes.WHEAT_SEEDS, ItemTypes.DIRT); | |
public static final Text FLARDARIAN = Texts.of(TextColors.DARK_AQUA, TextStyles.BOLD, TextStyles.ITALIC, "Flardarian"); | |
public static final Text ITEM_DISPLAY = Texts.of(TextColors.YELLOW, TextStyles.BOLD, "[", TextColors.GREEN, TextStyles.ITALIC, "FLARD", | |
TextStyles.RESET, TextColors.YELLOW, TextStyles.BOLD, "]"); | |
public static final Text LORE_FIRST = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "This is indeed a glorious day!"); | |
public static final Text LORE_SECOND = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "Shining sun makes the clouds flee"); | |
public static final Text LORE_THIRD = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "With State of ", TextColors.YELLOW, "Sponge", | |
TextColors.BLUE, " again today"); | |
public static final Text LORE_FOURTH = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "Granting delights for you and me"); | |
public static final Text LORE_FIFTH = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "For ", TextColors.YELLOW, "Sponge", TextColors.BLUE, | |
" is in a State of play"); | |
public static final Text LORE_SIXTH = Texts.of(TextColors.BLUE, TextStyles.ITALIC, "Today, be happy as can be!"); | |
public static final Random RANDOM = new Random(); | |
@Inject private Game game; | |
@Subscribe | |
public void onSpawn(EntitySpawnEvent event) { | |
if (event.getEntity().getType() == EntityTypes.VILLAGER && Math.random() > 0.7) { | |
final Villager entity = (Villager) event.getEntity(); | |
entity.setCareer(Careers.CLERIC); | |
entity.setDisplayName(FLARDARIAN); | |
entity.setShowsDisplayName(true); | |
entity.setInvulnerability(10000D); | |
entity.setTradeOffer(generateTradeOffer()); | |
} | |
} | |
private TradeOffer generateTradeOffer() { | |
final int rand = RANDOM.nextInt(7); | |
final int itemRand = RANDOM.nextInt(BUYING_TYPES.size()); | |
// Set up the lore data. | |
final List<Text> lore = new List(); | |
lore.addAll(ImmutableList.of(LORE_FIRST, LORE_SECOND, LORE_THIRD, LORE_FOURTH, LORE_FIFTH, LORE_SIXTH)); | |
// Create the selling item | |
final ItemStack selling = game.getRegistry().getItemBuilder() | |
.itemType(BUYING_TYPES.get(itemRand)) | |
.setItemName(ITEM_DISPLAY) | |
.setLore(lore) | |
.quantity(1) | |
.build(); | |
// Create the buying item | |
final ItemStack buying = game.getRegistry().getItemBuilder() | |
.itemType(SELL_TYPES[rand]) | |
.quantity(1) | |
.build(); | |
final TradeOfferBuilder builder = game.getRegistry().getTradeOfferBuilder(); | |
return builder.firstBuyingItem(buying).maxUses(10000).sellingItem(selling).build()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment