Structures loot, Umbrella Jungle features rebalance

This commit is contained in:
paulevsGitch 2021-12-30 05:31:42 +03:00
parent 789f1ccabd
commit 57641fe02c
4 changed files with 126 additions and 19 deletions

View file

@ -24,11 +24,9 @@ import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.api.features.BCLCommonFeatures;
import ru.bclib.api.features.BCLFeatureBuilder;
import ru.bclib.util.JsonFactory;
import ru.bclib.util.StructureHelper;
import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.features.BCLFeature;
import ru.bclib.world.features.DefaultFeature;
import ru.bclib.world.features.ListFeature;
import ru.bclib.world.features.ListFeature.StructureInfo;
import ru.bclib.world.features.NBTStructureFeature.TerrainMerge;
import ru.betterend.BetterEnd;
@ -38,6 +36,7 @@ import ru.betterend.world.biome.cave.EndCaveBiome;
import ru.betterend.world.biome.land.UmbraValleyBiome;
import ru.betterend.world.features.BiomeIslandFeature;
import ru.betterend.world.features.BlueVineFeature;
import ru.betterend.world.features.BuildingListFeature;
import ru.betterend.world.features.CavePumpkinFeature;
import ru.betterend.world.features.CharniaFeature;
import ru.betterend.world.features.CrashedShipFeature;
@ -107,8 +106,8 @@ public class EndFeatures {
public static final BCLFeature DRAGON_TREE = redisterVegetation("dragon_tree", new DragonTreeFeature(), 2);
public static final BCLFeature TENANEA = redisterVegetation("tenanea", new TenaneaFeature(), 2);
public static final BCLFeature HELIX_TREE = redisterVegetation("helix_tree", new HelixTreeFeature(), 1);
public static final BCLFeature UMBRELLA_TREE = redisterVegetation("umbrella_tree", new UmbrellaTreeFeature(), 4);
public static final BCLFeature JELLYSHROOM = redisterVegetation("jellyshroom", new JellyshroomFeature(), 3);
public static final BCLFeature UMBRELLA_TREE = redisterVegetation("umbrella_tree", new UmbrellaTreeFeature(), 2);
public static final BCLFeature JELLYSHROOM = redisterVegetation("jellyshroom", new JellyshroomFeature(), 2);
public static final BCLFeature GIGANTIC_AMARANITA = redisterVegetation("gigantic_amaranita", new GiganticAmaranitaFeature(), 1);
public static final BCLFeature LUCERNIA = redisterVegetation("lucernia", new LucerniaFeature(), 3);
@ -137,9 +136,9 @@ public class EndFeatures {
public static final BCLFeature AMBER_GRASS = redisterVegetation("amber_grass", new SinglePlantFeature(EndBlocks.AMBER_GRASS, 6), 7);
public static final BCLFeature LANCELEAF = redisterVegetation("lanceleaf", new LanceleafFeature(), 2);
public static final BCLFeature GLOW_PILLAR = redisterVegetation("glow_pillar", new GlowPillarFeature(), 1);
public static final BCLFeature TWISTED_UMBRELLA_MOSS = redisterVegetation("twisted_umbrella_moss", new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 5);
public static final BCLFeature JUNGLE_GRASS = redisterVegetation("jungle_grass", new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 8);
public static final BCLFeature SMALL_JELLYSHROOM_FLOOR = redisterVegetation("small_jellyshroom_floor", new SinglePlantFeature(EndBlocks.SMALL_JELLYSHROOM, 5, 5), 4);
public static final BCLFeature TWISTED_UMBRELLA_MOSS = redisterVegetation("twisted_umbrella_moss", new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 3);
public static final BCLFeature JUNGLE_GRASS = redisterVegetation("jungle_grass", new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 6);
public static final BCLFeature SMALL_JELLYSHROOM_FLOOR = redisterVegetation("small_jellyshroom_floor", new SinglePlantFeature(EndBlocks.SMALL_JELLYSHROOM, 5, 5), 2);
public static final BCLFeature BLOSSOM_BERRY = redisterVegetation("blossom_berry", new SinglePlantFeature(EndBlocks.BLOSSOM_BERRY, 3, 3), 2);
public static final BCLFeature BLOOMING_COOKSONIA = redisterVegetation("blooming_cooksonia", new SinglePlantFeature(EndBlocks.BLOOMING_COOKSONIA, 5), 5);
public static final BCLFeature SALTEAGO = redisterVegetation("salteago", new SinglePlantFeature(EndBlocks.SALTEAGO, 5), 5);
@ -350,13 +349,13 @@ public class EndFeatures {
}
String path = "/data/" + ns + "/structures/biome/" + nm + "/";
InputStream inputstream = StructureHelper.class.getResourceAsStream(path + "structures.json");
InputStream inputstream = EndFeatures.class.getResourceAsStream(path + "structures.json");
if (inputstream != null) {
JsonObject obj = JsonFactory.getJsonObject(inputstream);
JsonArray enties = obj.getAsJsonArray("structures");
if (enties != null) {
JsonArray structures = obj.getAsJsonArray("structures");
if (structures != null) {
List<StructureInfo> list = Lists.newArrayList();
enties.forEach((entry) -> {
structures.forEach((entry) -> {
JsonObject e = entry.getAsJsonObject();
String structure = path + e.get("nbt").getAsString() + ".nbt";
TerrainMerge terrainMerge = TerrainMerge.getFromString(e.get("terrainMerge").getAsString());
@ -367,7 +366,7 @@ public class EndFeatures {
return BCLCommonFeatures.makeChancedFeature(
new ResourceLocation(ns, nm + "_structures"),
Decoration.SURFACE_STRUCTURES,
new ListFeature(list, Blocks.END_STONE.defaultBlockState()),
new BuildingListFeature(list, Blocks.END_STONE.defaultBlockState()),
10
);
}

View file

@ -1,35 +1,83 @@
package ru.betterend.util;
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplierBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public class LootTableUtil {
private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure");
public static final ResourceLocation COMMON = BetterEnd.makeID("chests/common");
public static void init() {
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
if (END_CITY_TREASURE_ID.equals(id)) {
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(0, 5));
builder.withCondition(LootItemRandomChanceCondition.randomChance(0.5f).build());
builder.setRolls(ConstantValue.exactly(1));
builder.withCondition(LootItemRandomChanceCondition.randomChance(0.2f).build());
builder.withEntry(LootItem.lootTableItem(Items.GHAST_TEAR).build());
supplier.withPool(builder);
table.withPool(builder);
builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(0, 5));
builder.withCondition(LootItemRandomChanceCondition.randomChance(0.1f).build());
builder.setRolls(UniformGenerator.between(0, 3));
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_STRANGE_AND_ALIEN).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_GRASPING_AT_STARS).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_ENDSEEKER).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA).build());
supplier.withPool(builder);
table.withPool(builder);
}
else if (COMMON.equals(id)) {
addCommonItems(table);
}
});
}
private static void addCommonItems(FabricLootSupplierBuilder table) {
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(0, 2));
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_STRANGE_AND_ALIEN).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_GRASPING_AT_STARS).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_ENDSEEKER).build());
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA).build());
table.withPool(builder);
builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(4, 8));
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.ingot).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.rawOre).build());
builder.withEntry(LootItem.lootTableItem(Items.ENDER_PEARL).build());
table.withPool(builder);
builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(2, 4));
builder.withEntry(LootItem.lootTableItem(EndBlocks.TERMINITE.ingot).build());
builder.withEntry(LootItem.lootTableItem(EndItems.ENDER_SHARD).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.AURORA_CRYSTAL).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.axe).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.pickaxe).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.hoe).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.sword).build());
builder.withEntry(LootItem.lootTableItem(EndBlocks.THALLASIUM.shovel).build());
builder.withEntry(LootItem.lootTableItem(Items.ENDER_EYE).build());
builder.withEntry(LootItem.lootTableItem(Blocks.OBSIDIAN).build());
table.withPool(builder);
builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(0, 4));
builder.withEntry(LootItem.lootTableItem(EndItems.AETERNIUM_INGOT).build());
builder.withEntry(LootItem.lootTableItem(EndItems.AMBER_GEM).build());
builder.withEntry(LootItem.lootTableItem(Items.END_CRYSTAL).build());
builder.withEntry(LootItem.lootTableItem(Items.GHAST_TEAR).build());
table.withPool(builder);
}
}

View file

@ -0,0 +1,56 @@
package ru.betterend.world.features;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import org.jetbrains.annotations.Nullable;
import ru.bclib.world.features.ListFeature;
import ru.betterend.util.LootTableUtil;
import java.util.List;
import java.util.Random;
public class BuildingListFeature extends ListFeature {
public BuildingListFeature(List<StructureInfo> list, BlockState defaultBlock) {
super(list, defaultBlock);
}
@Override
protected void addStructureData(StructurePlaceSettings data) {
super.addStructureData(data);
data.addProcessor(new ChestProcessor());
}
class ChestProcessor extends StructureProcessor {
@Nullable
@Override
public StructureTemplate.StructureBlockInfo processBlock(LevelReader levelReader, BlockPos blockPos, BlockPos blockPos2, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlaceSettings) {
BlockState blockState = structureBlockInfo2.state;
if (blockState.getBlock() instanceof ChestBlock) {
Random random = structurePlaceSettings.getRandom(structureBlockInfo2.pos);
BlockPos chestPos = structureBlockInfo2.pos;
ChestBlock chestBlock = ChestBlock.class.cast(blockState.getBlock());
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);
levelReader.getChunk(chestPos).setBlockEntity(entity);
RandomizableContainerBlockEntity chestEntity = RandomizableContainerBlockEntity.class.cast(entity);
chestEntity.setLootTable(LootTableUtil.COMMON, random.nextLong());
chestEntity.setChanged();
System.out.println("Set loot at " + chestPos);
}
return structureBlockInfo2;
}
@Override
protected StructureProcessorType<?> getType() {
return StructureProcessorType.NOP;
}
}
}

View file

@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}