Skip to content

Commit

Permalink
Biome structure loot, texture fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulevsGitch committed Dec 30, 2021
1 parent 57641fe commit 2c5f428
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 4 deletions.
77 changes: 74 additions & 3 deletions src/main/java/ru/betterend/util/LootTableUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@
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.biome.Biome;
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.bclib.api.biomes.BiomeAPI;
import ru.bclib.complexmaterials.WoodenComplexMaterial;
import ru.bclib.world.biomes.BCLBiome;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndBiomes;
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");
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() {
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
Expand All @@ -35,13 +45,73 @@ public static void init() {
builder.withEntry(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA).build());
table.withPool(builder);
}

else if (COMMON.equals(id)) {
else if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
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) {
FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder();
builder.setRolls(UniformGenerator.between(0, 2));
Expand Down Expand Up @@ -74,6 +144,7 @@ private static void addCommonItems(FabricLootSupplierBuilder table) {

builder = FabricLootPoolBuilder.builder();
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.AMBER_GEM).build());
builder.withEntry(LootItem.lootTableItem(Items.END_CRYSTAL).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.BlockPos;
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.entity.BlockEntity;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
Expand Down Expand Up @@ -41,7 +42,12 @@ public StructureTemplate.StructureBlockInfo processBlock(LevelReader levelReader
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);
levelReader.getChunk(chestPos).setBlockEntity(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();
System.out.println("Set loot at " + chestPos);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/betterend/textures/block/jungle_grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minecraft:chest",
"pools": []
}

0 comments on commit 2c5f428

Please sign in to comment.