mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Re-added the villager and tweaked some dungeon loot
This commit is contained in:
parent
a294ab4f7e
commit
52c8e92f33
8 changed files with 74 additions and 114 deletions
|
@ -11,13 +11,20 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
public final class InitVillager{
|
||||
|
||||
public static final String JAM_HOUSE_CHEST_NAME = ModUtil.MOD_ID+".jamHouseChest";
|
||||
public static VillagerProfession jamProfession;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Village Addons...");
|
||||
|
@ -31,19 +38,13 @@ public final class InitVillager{
|
|||
}
|
||||
|
||||
private static void initJamVillagePart(){
|
||||
//TODO Fix villager
|
||||
/*int jamID = ConfigIntValues.JAM_VILLAGER_ID.getValue();
|
||||
VillagerRegistry.INSTANCE().registerVillagerId(jamID);
|
||||
VillagerRegistry.INSTANCE().registerVillageTradeHandler(jamID, new JamVillagerTradeHandler());
|
||||
jamProfession = new VillagerProfession(ModUtil.MOD_ID+":jamGuy", ModUtil.MOD_ID+":textures/entity/villager/jamVillager.png", ModUtil.MOD_ID+":textures/entity/villager/jamVillagerZombie.png");
|
||||
VillagerRegistry.instance().register(jamProfession);
|
||||
|
||||
ChestGenHooks jamHouseChest = ChestGenHooks.getInfo(JAM_HOUSE_CHEST_NAME);
|
||||
jamHouseChest.setMin(5);
|
||||
jamHouseChest.setMax(10);
|
||||
for(int i = 0; i < TheJams.values().length; i++){
|
||||
ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(InitItems.itemJams, 1, i), 1, 1, 10));
|
||||
VillagerCareer career = new VillagerCareer(jamProfession, ModUtil.MOD_ID+".jammer");
|
||||
for(int i = 0; i < 3; i++){
|
||||
career.addTrade(i+1, new JamVillagerTradeList());
|
||||
}
|
||||
ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(Items.glass_bottle), 1, 2, 30));
|
||||
ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(Items.potionitem), 1, 1, 20));*/
|
||||
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler());
|
||||
MapGenStructureIO.registerStructureComponent(VillageComponentJamHouse.class, ModUtil.MOD_ID+":jamHouseStructure");
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* This file ("JamVillagerTradeHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class JamVillagerTradeHandler{
|
||||
|
||||
private final ArrayList<Trade> trades = new ArrayList<Trade>();
|
||||
|
||||
public JamVillagerTradeHandler(){
|
||||
this.addWants("ingotGold", 5, 7);
|
||||
this.addWants("cropWheat", 15, 25);
|
||||
this.addWants("dustRedstone", 25, 40);
|
||||
this.addWants(new ItemStack(Items.BUCKET), 5, 9);
|
||||
this.addWants(new ItemStack(Items.GLASS_BOTTLE), 12, 17);
|
||||
this.addWants(new ItemStack(Items.POTIONITEM), 1, 1);
|
||||
this.addWants("ingotIron", 10, 15);
|
||||
this.addWants("gemDiamond", 1, 2);
|
||||
this.addWants("dustGlowstone", 12, 22);
|
||||
}
|
||||
|
||||
public void addWants(String oredictName, int minSize, int maxSize){
|
||||
ArrayList<ItemStack> stacks = (ArrayList<ItemStack>)OreDictionary.getOres(oredictName, false);
|
||||
this.trades.add(new Trade(stacks, minSize, maxSize));
|
||||
}
|
||||
|
||||
public void addWants(ItemStack stack, int minSize, int maxSize){
|
||||
this.trades.add(new Trade(stack, minSize, maxSize));
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random rand){
|
||||
for(int trade = 0; trade < this.trades.size(); trade++){
|
||||
for(int want = 0; want < this.trades.get(trade).wants.size(); want++){
|
||||
ItemStack wantsOne = this.trades.get(trade).wants.get(want);
|
||||
wantsOne.stackSize = MathHelper.getRandomIntegerInRange(rand, this.trades.get(trade).minStackSize, this.trades.get(trade).maxStackSize);
|
||||
|
||||
ItemStack wantsTwo = null;
|
||||
if(rand.nextInt(3) == 0){
|
||||
int randomSecondTrade = rand.nextInt(this.trades.size());
|
||||
for(int randomSecondWant = 0; randomSecondWant < this.trades.get(randomSecondTrade).wants.size(); randomSecondWant++){
|
||||
wantsTwo = this.trades.get(randomSecondTrade).wants.get(randomSecondWant);
|
||||
wantsTwo.stackSize = MathHelper.getRandomIntegerInRange(rand, this.trades.get(randomSecondTrade).minStackSize, this.trades.get(randomSecondTrade).maxStackSize);
|
||||
}
|
||||
}
|
||||
if(wantsOne == wantsTwo){
|
||||
wantsTwo = null;
|
||||
}
|
||||
|
||||
for(int k = 0; k < TheJams.values().length; k++){
|
||||
recipeList.add(new MerchantRecipe(wantsOne, wantsTwo, new ItemStack(InitItems.itemJams, rand.nextInt(3)+1, k)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Trade{
|
||||
|
||||
public final ArrayList<ItemStack> wants = new ArrayList<ItemStack>();
|
||||
public final int minStackSize;
|
||||
public final int maxStackSize;
|
||||
|
||||
public Trade(ArrayList<ItemStack> wants, int minStackSize, int maxStackSize){
|
||||
this.wants.addAll(wants);
|
||||
this.minStackSize = minStackSize <= 0 ? 1 : minStackSize;
|
||||
this.maxStackSize = maxStackSize <= 0 ? 1 : maxStackSize;
|
||||
}
|
||||
|
||||
public Trade(ItemStack want, int minStackSize, int maxStackSize){
|
||||
this.wants.add(want);
|
||||
this.minStackSize = minStackSize <= 0 ? 1 : minStackSize;
|
||||
this.maxStackSize = maxStackSize <= 0 ? 1 : maxStackSize;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file ("GenericTrade.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
|
||||
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class JamVillagerTradeList implements ITradeList{
|
||||
|
||||
@Override
|
||||
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random){
|
||||
for(int i = 0; i < random.nextInt(3)+3; i++){
|
||||
ItemStack jam = new ItemStack(InitItems.itemJams, 1, random.nextInt(TheJams.values().length));
|
||||
ItemStack emerald = new ItemStack(Items.EMERALD);
|
||||
|
||||
if(random.nextFloat() >= 0.65F){
|
||||
//Jam as input
|
||||
jam.stackSize = random.nextInt(3)+1;
|
||||
emerald.stackSize = random.nextInt(2)+1;
|
||||
recipeList.add(new MerchantRecipe(jam, emerald));
|
||||
}
|
||||
else{
|
||||
//Emeralds as input
|
||||
jam.stackSize = random.nextInt(4)+2;
|
||||
emerald.stackSize = random.nextInt(6)+2;
|
||||
recipeList.add(new MerchantRecipe(emerald, jam));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
@ -195,4 +197,9 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{
|
|||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 2, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 6, sbb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof){
|
||||
return InitVillager.jamProfession;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DungeonLoot{
|
|||
|
||||
LootPool pool = event.getTable().getPool("main");
|
||||
if(pool == null){
|
||||
pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main");
|
||||
pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(3, 6), new RandomValueRange(0), "main");
|
||||
event.getTable().addPool(pool);
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ public class DungeonLoot{
|
|||
}
|
||||
else if(JAM_HOUSE.equals(event.getName())){
|
||||
LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length-1));
|
||||
LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(1, 8));
|
||||
LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(3, 5));
|
||||
pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[]{jamDamage, jamAmount}, noCondition, ModUtil.MOD_ID+":jams"));
|
||||
|
||||
LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(1, 5));
|
||||
LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(2));
|
||||
pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[]{glassAmount}, noCondition, ModUtil.MOD_ID+":bottles"));
|
||||
}
|
||||
else if(LUSH_CAVES.equals(event.getName())){
|
||||
|
@ -95,10 +95,10 @@ public class DungeonLoot{
|
|||
addBatWings = true;
|
||||
addCrystals = true;
|
||||
|
||||
pool.addEntry(new LootEntryItem(Items.BOOK, 90, 0, new LootFunction[0], noCondition, ModUtil.MOD_ID+":book"));
|
||||
pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ModUtil.MOD_ID+":book"));
|
||||
|
||||
LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12));
|
||||
pool.addEntry(new LootEntryItem(Items.BONE, 150, 0, new LootFunction[]{bonesAmount}, noCondition, ModUtil.MOD_ID+":bones"));
|
||||
pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[]{bonesAmount}, noCondition, ModUtil.MOD_ID+":bones"));
|
||||
|
||||
Item[] aiots = new Item[]{InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite};
|
||||
for(int i = 0; i < aiots.length; i++){
|
||||
|
@ -109,7 +109,7 @@ public class DungeonLoot{
|
|||
Item[] armor = new Item[]{Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS};
|
||||
for(int i = 0; i < armor.length; i++){
|
||||
LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.75F));
|
||||
pool.addEntry(new LootEntryItem(armor[i], 70, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i));
|
||||
pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ fluid.actuallyadditions.canolaoil=Canola Oil
|
|||
fluid.actuallyadditions.crystaloil=Crystallized Oil
|
||||
fluid.actuallyadditions.empoweredoil=Empowered Oil
|
||||
|
||||
#Entities
|
||||
entity.Villager.actuallyadditions.jammer=Jam Guy
|
||||
|
||||
#Banners
|
||||
item.banner.actuallyadditionsBook.black=Black Actually Additions Manual Pattern
|
||||
item.banner.actuallyadditionsBook.red=Red Actually Additions Manual Pattern
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in a new issue