adding villager trading system
This commit is contained in:
parent
d6c306c78a
commit
b62ca03fa4
|
@ -15,62 +15,56 @@
|
||||||
|白萝卜|√|||||||
|
|白萝卜|√|||||||
|
||||||
|薄荷|||||一次性|||
|
|薄荷|||||一次性|||
|
||||||
|鱼肉||原版可食用鱼肉||||||
|
|鱼肉||原版可食用鱼肉||||||
|
||||||
|胡椒|||屠夫|||||
|
|胡椒|||屠夫3|||||
|
||||||
|番茄|√|||||||
|
|番茄|√|||||||
|
||||||
|面粉||||√||||
|
|面粉||||√||||
|
||||||
|甜甜花|||||一次性|||
|
|甜甜花|||||一次性|||
|
||||||
|洋葱|√|||||||
|
|洋葱|√|||||||
|
||||||
|熏禽肉|||屠夫|||||
|
|熏禽肉|||屠夫3,用鸡肉处理|||||
|
||||||
|卷心菜|√|||||||
|
|卷心菜|√|||||||
|
||||||
|树莓|||||可反复|||
|
|树莓|||||可反复|||
|
||||||
|土豆||√||||||
|
|土豆||√||||||
|
||||||
|牛奶||√||||||
|
|牛奶||√||||||
|
||||||
|糖||√||||||
|
|糖||√||||||
|
||||||
|杏仁|||农民|||||
|
|杏仁|||农民3|||||
|
||||||
|金鱼草|||||一次性,沼泽|||
|
|金鱼草|||||一次性,沼泽|||
|
||||||
|豆腐|||农民|||||
|
|豆腐|||农民3|||||
|
||||||
|莲蓬||荷叶||||||
|
|莲蓬||荷叶||||||
|
||||||
|松茸|||||一次性|||
|
|松茸|||||一次性|||
|
||||||
|稻米|√|||||||
|
|稻米|√|||||||
|
||||||
|虾仁|||渔夫|||||
|
|虾仁|||渔夫4|||||
|
||||||
|胡萝卜||√||||||
|
|胡萝卜||√||||||
|
||||||
|奶油||||√||||
|
|奶油||||√||||
|
||||||
|螃蟹|||渔夫|||||
|
|螃蟹|||渔夫4|||||
|
||||||
|奶酪||||√||||
|
|奶酪||||√||||
|
||||||
|松果|||||云杉树叶掉落|||
|
|松果|||||云杉树叶掉落|||
|
||||||
|果酱||||√||||
|
|果酱||||√||||
|
||||||
|盐|||屠夫|||||
|
|盐|||屠夫3|||||
|
||||||
|黄油||||√||||
|
|黄油||||√||||
|
||||||
|火腿||||√||||
|
|火腿||||√||||
|
||||||
|培根||||√||||
|
|培根||||√||||
|
||||||
|香肠||||√||||
|
|香肠||||√||||
|
||||||
|青蛙|||渔夫|||||
|
|青蛙|||牧师3|||||
|
||||||
|电气水晶||||||√||
|
|电气水晶||||||高山||
|
||||||
|蜥蜴尾巴|||牧师|||||
|
|蜥蜴尾巴|||牧师3|||||
|
||||||
|冰雾花花朵|||||||√|
|
|冰雾花花朵|||牧师4|||||
|
||||||
|烈焰花花蕊|||||||√|
|
|烈焰花花蕊|||牧师4|||||
|
||||||
|蝴蝶翅膀|||牧师|||||
|
|蝴蝶翅膀|||牧师3|||||
|
||||||
|晶核|||牧师|||||
|
|晶核|||牧师3|||||
|
||||||
|铁块||||||√||
|
|铁块||||||√||
|
||||||
|白铁块||||||√||
|
|白铁块||||||√||
|
||||||
|水晶块||||||√||
|
|水晶块||||||√||
|
||||||
|蟹黄||||√||||
|
|蟹黄||||√||||
|
||||||
|小麦||√||||||
|
|小麦||√||||||
|
||||||
|魔晶块||||||√||
|
|魔晶块||||||√||
|
||||||
|鳅鳅宝玉|||牧师|||||
|
|鳅鳅宝玉|||牧师5|||||
|
||||||
|竹笋|||||||√|
|
|竹笋|||农民5,用竹子处理|||||
|
||||||
|发光髓|||||||√|
|
|发光髓|||牧师3|||||
|
||||||
|「冷鲜肉」|||||||√|
|
|「冷鲜肉」||||√,更改为冰块+猪肉||||
|
||||||
|星银矿石||||||高山||
|
|星银矿石||||||高山||
|
||||||
|奇异的「牙齿」|||||||√|
|
|奇异的「牙齿」|||||||√|
|
||||||
|汲取了生命力的龙牙|||||||√|
|
|汲取了生命力的龙牙|||||||√|
|
||||||
|马尾|||||一次性,沼泽|||
|
|马尾|||||一次性,沼泽|||
|
||||||
|嬗变之尘|||||||√|
|
|
||||||
|北陆单手剑原胚|||||||√|
|
|
||||||
|北陆双手剑原胚|||||||√|
|
|
||||||
|北陆长柄武器原胚|||||||√|
|
|
||||||
|北陆弓原胚|||||||√|
|
|
||||||
|北陆法器原胚|||||||√|
|
|
||||||
|苹果||√||||||
|
|苹果||√||||||
|
||||||
|日落果|||||白桦树叶掉落|||
|
|日落果|||||白桦树叶掉落|||
|
||||||
|塞西莉亚花|||||一次性,高山|||
|
|塞西莉亚花|||||一次性,高山|||
|
||||||
|
@ -82,7 +76,7 @@
|
||||||
|风车菊|||||一次性|||
|
|风车菊|||||一次性|||
|
||||||
|钩钩果|||||可反复|||
|
|钩钩果|||||可反复|||
|
||||||
|清心|||||一次性,高山|||
|
|清心|||||一次性,高山|||
|
||||||
|星螺|||牧师|||||
|
|星螺|||牧师5|||||
|
||||||
|
|
||||||
* 所有可种植物品,加入农民一级收购列表,尝试将这些作物设为农民可接受的作物,就像原版作物一样,如果不行就将作物种子设定为流浪商人贩卖
|
* 所有可种植物品,加入农民一级收购列表,尝试将这些作物设为农民可接受的作物,就像原版作物一样,如果不行就将作物种子设定为流浪商人贩卖
|
||||||
* 野外采集的,一次性表示类似于花的处理方式,采完就没了,可用刷花机量产。可反复表示类似于浆果丛的处理方式,可以反复采摘,但是只能在原地采摘,不能重新集中化种植。树叶掉落的,按照类似橡木树叶掉落苹果的方式处理掉落。
|
* 野外采集的,一次性表示类似于花的处理方式,采完就没了,可用刷花机量产。可反复表示类似于浆果丛的处理方式,可以反复采摘,但是只能在原地采摘,不能重新集中化种植。树叶掉落的,按照类似橡木树叶掉落苹果的方式处理掉落。
|
||||||
|
|
|
@ -117,12 +117,12 @@ public class TerrainsManager {
|
||||||
.configure((new RandomPatchFeatureConfig.Builder(
|
.configure((new RandomPatchFeatureConfig.Builder(
|
||||||
(BlockStateProvider)provider,
|
(BlockStateProvider)provider,
|
||||||
(BlockPlacer)SimpleBlockPlacer.INSTANCE))
|
(BlockPlacer)SimpleBlockPlacer.INSTANCE))
|
||||||
.tries(64)
|
.tries(8)
|
||||||
.whitelist((Set<Block>)ImmutableSet.of(Blocks.GRASS_BLOCK.getDefaultState().getBlock()))
|
.whitelist((Set<Block>)ImmutableSet.of(Blocks.GRASS_BLOCK.getDefaultState().getBlock()))
|
||||||
.cannotProject()
|
//.cannotProject()
|
||||||
.build())
|
.build())
|
||||||
.decorate(Decorators.SQUARE_HEIGHTMAP_SPREAD_DOUBLE)
|
.decorate(Decorators.SQUARE_HEIGHTMAP_SPREAD_DOUBLE)
|
||||||
.applyChance(24);
|
.applyChance(48);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ biome register
|
// ================ biome register
|
||||||
|
|
|
@ -3,8 +3,12 @@ package net.yyc12345.teyvatcraft.init;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.village.VillagerProfession;
|
||||||
import net.yyc12345.teyvatcraft.mixin.VillagerAccess;
|
import net.yyc12345.teyvatcraft.mixin.VillagerAccess;
|
||||||
|
import net.yyc12345.teyvatcraft.trading.VillagerTradingBuilder;
|
||||||
|
|
||||||
public class VillagerManager {
|
public class VillagerManager {
|
||||||
|
|
||||||
|
@ -27,5 +31,59 @@ public class VillagerManager {
|
||||||
villagerGatherables.add(ItemsManager.RADISH);
|
villagerGatherables.add(ItemsManager.RADISH);
|
||||||
VillagerAccess.setGatherableItems(villagerGatherables.build());
|
VillagerAccess.setGatherableItems(villagerGatherables.build());
|
||||||
|
|
||||||
|
// register trading
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 1, (factories -> {
|
||||||
|
// crops
|
||||||
|
VillagerTradingBuilder.VillagerBuyVanilla(factories, 1, ItemsManager.RADISH, 26, 1);
|
||||||
|
VillagerTradingBuilder.VillagerBuyVanilla(factories, 1, ItemsManager.TOMATO, 26, 1);
|
||||||
|
VillagerTradingBuilder.VillagerBuyVanilla(factories, 1, ItemsManager.ONION, 26, 1);
|
||||||
|
VillagerTradingBuilder.VillagerBuyVanilla(factories, 1, ItemsManager.CABBAGE, 26, 1);
|
||||||
|
VillagerTradingBuilder.VillagerBuyVanilla(factories, 1, ItemsManager.RICE, 26, 1);
|
||||||
|
}));
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 3, (factories -> {
|
||||||
|
// sold items
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.ALMOND, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.TOFU, 1, 6);
|
||||||
|
}));
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 5, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerProcessVanilla(factories, 5, Items.BAMBOO, ItemsManager.BAMBOO_SHOOT, 2);
|
||||||
|
}));
|
||||||
|
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.BUTCHER, 3, (factories -> {
|
||||||
|
// soled items
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.PEPPER, 1, 1);
|
||||||
|
VillagerTradingBuilder.VillagerProcessVanilla(factories, 3, Items.CHICKEN, ItemsManager.SMOKED_FOWL, 2);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.SALT, 1, 1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.FISHERMAN, 4, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 4, ItemsManager.SHRIMP_MEAT, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 4, ItemsManager.CRAB, 1, 6);
|
||||||
|
}));
|
||||||
|
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.CLERIC, 3, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.FROG, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.LIZARD_TAIL, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.BUTTERFLY_WINGS, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.CRYSTAL_CORE, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 3, ItemsManager.LUMINESCENT_SPINE, 1, 6);
|
||||||
|
}));
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.CLERIC, 4, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 4, ItemsManager.MIST_FLOWER_COROLLA, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 4, ItemsManager.FLAMING_FLOWER_STAMEN, 1, 6);
|
||||||
|
}));
|
||||||
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.CLERIC, 5, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.LOACH_PEARL, 1, 6);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.STARCONCH, 1, 6);
|
||||||
|
}));
|
||||||
|
|
||||||
|
// register wandering trading
|
||||||
|
TradeOfferHelper.registerWanderingTraderOffers(2, (factories -> {
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.RICE_SEED, 1, 2);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.RADISH, 1, 2);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.TOMATO, 1, 2);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.ONION, 1, 2);
|
||||||
|
VillagerTradingBuilder.VillagerSellVanilla(factories, 5, ItemsManager.CABBAGE, 1, 2);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,11 @@ package net.yyc12345.teyvatcraft.mixin;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -24,6 +26,7 @@ import net.minecraft.world.gen.feature.FlowerFeature;
|
||||||
|
|
||||||
@Mixin(GrassBlock.class)
|
@Mixin(GrassBlock.class)
|
||||||
public class GrassBlockFixer {
|
public class GrassBlockFixer {
|
||||||
|
|
||||||
@Inject(method = "grow", at = @At("HEAD"))
|
@Inject(method = "grow", at = @At("HEAD"))
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) {
|
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) {
|
||||||
BlockPos blockPos = pos.up();
|
BlockPos blockPos = pos.up();
|
||||||
|
@ -35,7 +38,7 @@ public class GrassBlockFixer {
|
||||||
// random walk
|
// random walk
|
||||||
for (int j = 0; j < i / 16; ) {
|
for (int j = 0; j < i / 16; ) {
|
||||||
blockPos2 = blockPos2.add(random.nextInt(3) - 1, (random.nextInt(3) - 1) * random.nextInt(3) / 2, random.nextInt(3) - 1);
|
blockPos2 = blockPos2.add(random.nextInt(3) - 1, (random.nextInt(3) - 1) * random.nextInt(3) / 2, random.nextInt(3) - 1);
|
||||||
if (world.getBlockState(blockPos2.down()).isOf(world.getBlockState(pos).getBlock()/* this */)) {
|
if (world.getBlockState(blockPos2.down()).isOf(world.getBlockState(pos).getBlock())) {
|
||||||
if (world.getBlockState(blockPos2).isFullCube((BlockView)world, blockPos2))
|
if (world.getBlockState(blockPos2).isFullCube((BlockView)world, blockPos2))
|
||||||
continue label32;
|
continue label32;
|
||||||
j++;
|
j++;
|
||||||
|
@ -61,4 +64,5 @@ public class GrassBlockFixer {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package net.yyc12345.teyvatcraft.trading;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.village.TradeOffers;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.village.TradeOffer;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
|
||||||
|
public class VillagerTradingBuilder {
|
||||||
|
public VillagerTradingBuilder() {}
|
||||||
|
|
||||||
|
public static final int basicRewardedExp = 5;
|
||||||
|
//public static final int basicMaxUses = 12;
|
||||||
|
public static final float basicPriceMultiplier = 0.05f;
|
||||||
|
|
||||||
|
public static int GetRewardedExpWithLevel(int level) {
|
||||||
|
return 5 * level;
|
||||||
|
}
|
||||||
|
public static int GetMaxUsesWithLevel(int level) {
|
||||||
|
if (level <= 3) return 12;
|
||||||
|
else return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void VillagerBuyVanilla(List<TradeOffers.Factory> factories, int level, Item item, int itemCount, int emeraldCount) {
|
||||||
|
factories.add((entity, random) -> new TradeOffer(new ItemStack(item, itemCount), new ItemStack(Items.EMERALD, emeraldCount), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void VillagerSellVanilla(List<TradeOffers.Factory> factories, int level, Item item, int itemCount, int emeraldCount) {
|
||||||
|
factories.add((entity, random) -> new TradeOffer(new ItemStack(Items.EMERALD, emeraldCount), new ItemStack(item, itemCount), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void VillagerProcessVanilla(List<TradeOffers.Factory> factories, int level, Item originalItem, Item resultItem, int emeraldCount) {
|
||||||
|
factories.add((entity, random) -> new TradeOffer(new ItemStack(originalItem, 1), new ItemStack(Items.EMERALD, emeraldCount), new ItemStack(resultItem, 1), GetMaxUsesWithLevel(level), GetRewardedExpWithLevel(level), basicPriceMultiplier));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user