Biome structure loot, texture fixes
|
@ -5,18 +5,28 @@ import net.fabricmc.fabric.api.loot.v1.FabricLootSupplierBuilder;
|
||||||
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
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.predicates.LootItemRandomChanceCondition;
|
||||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||||
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
|
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
|
||||||
|
import ru.bclib.api.biomes.BiomeAPI;
|
||||||
|
import ru.bclib.complexmaterials.WoodenComplexMaterial;
|
||||||
|
import ru.bclib.world.biomes.BCLBiome;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
|
import ru.betterend.registry.EndBiomes;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class LootTableUtil {
|
public class LootTableUtil {
|
||||||
private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure");
|
private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure");
|
||||||
public static final ResourceLocation COMMON = BetterEnd.makeID("chests/common");
|
private static final ResourceLocation COMMON = BetterEnd.makeID("chests/common");
|
||||||
|
private static final ResourceLocation FOGGY_MUSHROOMLAND = BetterEnd.makeID("chests/foggy_mushroomland");
|
||||||
|
private static final ResourceLocation CHORUS_FOREST = BetterEnd.makeID("chests/chorus_forest");
|
||||||
|
private static final ResourceLocation SHADOW_FOREST = BetterEnd.makeID("chests/shadow_forest");
|
||||||
|
private static final ResourceLocation LANTERN_WOODS = BetterEnd.makeID("chests/lantern_woods");
|
||||||
|
private static final ResourceLocation UMBRELLA_JUNGLE = BetterEnd.makeID("chests/umbrella_jungle");
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
|
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
|
||||||
|
@ -35,13 +45,73 @@ public class LootTableUtil {
|
||||||
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA).build());
|
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA).build());
|
||||||
table.withPool(builder);
|
table.withPool(builder);
|
||||||
}
|
}
|
||||||
|
else if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
|
||||||
else if (COMMON.equals(id)) {
|
|
||||||
addCommonItems(table);
|
addCommonItems(table);
|
||||||
|
if (FOGGY_MUSHROOMLAND.equals(id)) {
|
||||||
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
|
builder.setRolls(UniformGenerator.between(4, 8));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.MOSSY_GLOWSHROOM.getBlock(WoodenComplexMaterial.BLOCK_PLANKS)).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.MOSSY_GLOWSHROOM_SAPLING).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.BLUE_VINE_SEED).build());
|
||||||
|
table.withPool(builder);
|
||||||
|
}
|
||||||
|
else if (CHORUS_FOREST.equals(id)) {
|
||||||
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
|
builder.setRolls(UniformGenerator.between(4, 8));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.PYTHADENDRON.getBlock(WoodenComplexMaterial.BLOCK_PLANKS)).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.PYTHADENDRON_SAPLING).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.CHORUS_MUSHROOM).build());
|
||||||
|
table.withPool(builder);
|
||||||
|
}
|
||||||
|
else if (SHADOW_FOREST.equals(id)) {
|
||||||
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
|
builder.setRolls(UniformGenerator.between(4, 8));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.DRAGON_TREE.getBlock(WoodenComplexMaterial.BLOCK_PLANKS)).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.DRAGON_TREE_SAPLING).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.SHADOW_BERRY).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndItems.SHADOW_BERRY_RAW).build());
|
||||||
|
table.withPool(builder);
|
||||||
|
}
|
||||||
|
else if (LANTERN_WOODS.equals(id)) {
|
||||||
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
|
builder.setRolls(UniformGenerator.between(4, 8));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.LUCERNIA.getBlock(WoodenComplexMaterial.BLOCK_PLANKS)).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.LUCERNIA_SAPLING).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.BOLUX_MUSHROOM).build());
|
||||||
|
table.withPool(builder);
|
||||||
|
}
|
||||||
|
else if (UMBRELLA_JUNGLE.equals(id)) {
|
||||||
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
|
builder.setRolls(UniformGenerator.between(4, 8));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.UMBRELLA_TREE.getBlock(WoodenComplexMaterial.BLOCK_PLANKS)).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.UMBRELLA_TREE_SAPLING).build());
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.SMALL_JELLYSHROOM).build());
|
||||||
|
table.withPool(builder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation getTable(Biome biome) {
|
||||||
|
BCLBiome bclBiome = BiomeAPI.getBiome(biome);
|
||||||
|
if (bclBiome == EndBiomes.FOGGY_MUSHROOMLAND) {
|
||||||
|
return FOGGY_MUSHROOMLAND;
|
||||||
|
}
|
||||||
|
else if (bclBiome == EndBiomes.CHORUS_FOREST) {
|
||||||
|
return CHORUS_FOREST;
|
||||||
|
}
|
||||||
|
else if (bclBiome == EndBiomes.SHADOW_FOREST) {
|
||||||
|
return SHADOW_FOREST;
|
||||||
|
}
|
||||||
|
else if (bclBiome == EndBiomes.LANTERN_WOODS) {
|
||||||
|
return LANTERN_WOODS;
|
||||||
|
}
|
||||||
|
else if (bclBiome == EndBiomes.UMBRELLA_JUNGLE) {
|
||||||
|
return UMBRELLA_JUNGLE;
|
||||||
|
}
|
||||||
|
return COMMON;
|
||||||
|
}
|
||||||
|
|
||||||
private static void addCommonItems(FabricLootSupplierBuilder table) {
|
private static void addCommonItems(FabricLootSupplierBuilder table) {
|
||||||
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
|
||||||
builder.setRolls(UniformGenerator.between(0, 2));
|
builder.setRolls(UniformGenerator.between(0, 2));
|
||||||
|
@ -74,6 +144,7 @@ public class LootTableUtil {
|
||||||
|
|
||||||
builder = FabricLootPoolBuilder.builder();
|
builder = FabricLootPoolBuilder.builder();
|
||||||
builder.setRolls(UniformGenerator.between(0, 4));
|
builder.setRolls(UniformGenerator.between(0, 4));
|
||||||
|
builder.withEntry(LootItem.lootTableItem(EndBlocks.FLAVOLITE_RUNED).build());
|
||||||
builder.withEntry(LootItem.lootTableItem(EndItems.AETERNIUM_INGOT).build());
|
builder.withEntry(LootItem.lootTableItem(EndItems.AETERNIUM_INGOT).build());
|
||||||
builder.withEntry(LootItem.lootTableItem(EndItems.AMBER_GEM).build());
|
builder.withEntry(LootItem.lootTableItem(EndItems.AMBER_GEM).build());
|
||||||
builder.withEntry(LootItem.lootTableItem(Items.END_CRYSTAL).build());
|
builder.withEntry(LootItem.lootTableItem(Items.END_CRYSTAL).build());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ru.betterend.world.features;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
|
@ -41,7 +42,12 @@ public class BuildingListFeature extends ListFeature {
|
||||||
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);
|
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);
|
||||||
levelReader.getChunk(chestPos).setBlockEntity(entity);
|
levelReader.getChunk(chestPos).setBlockEntity(entity);
|
||||||
RandomizableContainerBlockEntity chestEntity = RandomizableContainerBlockEntity.class.cast(entity);
|
RandomizableContainerBlockEntity chestEntity = RandomizableContainerBlockEntity.class.cast(entity);
|
||||||
chestEntity.setLootTable(LootTableUtil.COMMON, random.nextLong());
|
Biome biome = levelReader.getNoiseBiome(
|
||||||
|
chestPos.getX() >> 2,
|
||||||
|
chestPos.getY() >> 2,
|
||||||
|
chestPos.getZ() >> 2
|
||||||
|
);
|
||||||
|
chestEntity.setLootTable(LootTableUtil.getTable(biome), random.nextLong());
|
||||||
chestEntity.setChanged();
|
chestEntity.setChanged();
|
||||||
System.out.println("Set loot at " + chestPos);
|
System.out.println("Set loot at " + chestPos);
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 969 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 1,020 B After Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 977 B |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 976 B |
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 239 B |
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:chest",
|
||||||
|
"pools": []
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:chest",
|
||||||
|
"pools": []
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:chest",
|
||||||
|
"pools": []
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:chest",
|
||||||
|
"pools": []
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:chest",
|
||||||
|
"pools": []
|
||||||
|
}
|