Jump to content

[SOLVED][1.15.2] Custom Chest Loot Tables


peter1745

Recommended Posts

I'm currently working on creating my own loot table.

I don't want to inject into an already existing table, I want to load my own but I haven't found any resources on it and I'm unable to figure out how to do it by looking through the code.

Does anyone know how to do it? Thank you.

Link to comment
Share on other sites

Create json file

Add json file to data/modid/loot_tables

Done

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

18 hours ago, Draco18s said:

Create json file

Add json file to data/modid/loot_tables

Done

Don't you have to register it? I want to assign the loot table to a chest in my structure generation code, it's not for a block or entity.

 

I want to do something like this:

protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand, MutableBoundingBox sbb) {
         if ("chest".equals(function)) {
            worldIn.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.WATERLOGGED, Boolean.valueOf(worldIn.getFluidState(pos).isTagged(FluidTags.WATER))), 2);
            TileEntity tileentity = worldIn.getTileEntity(pos);
            if (tileentity instanceof ChestTileEntity) {
               ((ChestTileEntity)tileentity).setLootTable(this.isLarge ? LootTables.CHESTS_UNDERWATER_RUIN_BIG : LootTables.CHESTS_UNDERWATER_RUIN_SMALL, rand.nextLong());
            }
         }
}

That code is taken from the Ocean Ruin Structure, as you can see they load a loot table, register it and then access it from the Ocean Ruin Structure.

Link to comment
Share on other sites

1 minute ago, peter1745 said:

Don't you have to register it? I want to assign the loot table to a chest in my structure generation code, it's not for a block or entity.

 

I want to do something like this:


protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand, MutableBoundingBox sbb) {
         if ("chest".equals(function)) {
            worldIn.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.WATERLOGGED, Boolean.valueOf(worldIn.getFluidState(pos).isTagged(FluidTags.WATER))), 2);
            TileEntity tileentity = worldIn.getTileEntity(pos);
            if (tileentity instanceof ChestTileEntity) {
               ((ChestTileEntity)tileentity).setLootTable(this.isLarge ? LootTables.CHESTS_UNDERWATER_RUIN_BIG : LootTables.CHESTS_UNDERWATER_RUIN_SMALL, rand.nextLong());
            }
         }
}

That code is taken from the Ocean Ruin Structure, as you can see they load a loot table, register it and then access it from the Ocean Ruin Structure.

Never mind. I just realized that it's not an actual loot table but it's actually just a Resource Location... Sorry...

Link to comment
Share on other sites

  • peter1745 changed the title to [SOLVED][1.15.2] Custom Chest Loot Tables

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, i want to add an item to player's inventory when specific event is fired, but i don't know how to do that
    • Try searching for the Shapeless Recipe in your workspace program's external libraries, which should have been downloaded along with the assets when you set up gradle for Forge. Looking at that file will show you how Minecraft sets it up and you can tinker with it in a custom file of your own from there. Additionally, take a look at how the crafting table handles the matching up of ingredients for shapeless recipes. You can also look at my two-slot fuel free furnace type that uses shapeless recipes. I did exactly as described above to design my custom recipe class and then built my entity class. https://github.com/toadie-odie/TodeCoins/blob/1.3.2/src/main/java/net/warrentode/todecoins/recipe/CoinPressRecipe.java https://github.com/toadie-odie/TodeCoins/blob/1.3.2/src/main/java/net/warrentode/todecoins/block/entity/CoinPressBlockEntity.java An alternative recipe check method can be looked at here:  https://github.com/toadie-odie/TodeVillagers/blob/master_03/src/main/java/net/warrentode/todevillagers/blocks/entity/GlassKilnBlockEntity.java I think maybe that the Glass Kiln one would be easier for you starting out, it was for me. In your case the points of interest are at lines 164 and 215.
    • I copied the Totem of Undying event for my coin charm, and as you can see in line 113 it has the method removeAllEffects in there, so if you're building a similar event, simply don't add the method to prevent it from removing effects. https://github.com/toadie-odie/TodeCoins/blob/1.3.2/src/main/java/net/warrentode/todecoins/event/ModEvents.java
    • Okay I got on the discord server and followed there steps and got it to start working, however the log is constantly being filled with this error code. It is creating additional copies of the config file, up to 5 copies.
    • I would like to force the pose of a living entity to a standing position (i.e. Pose.STANDING) when it is riding a certain vehicle. I have tried to call Entity#setPose every tick via LivingTickEvent, but the living entity remains in a sitting position. Here is my code: // I made it a low-priority event because I was wondering if the code should be executed at the end of each tick. @SubscribeEvent(priority = EventPriority.LOWEST) public static void livingTickEvent(LivingEvent.LivingTickEvent event) { LivingEntity livingEntity = event.getEntity(); if (!livingEntity.level.isClientSide && livingEntity.getVehicle() instanceof TheVehicle) { livingEntity.setPose(Pose.STANDING); } }   By the way, I am aware there is a setForcedPose method, but it's only for the Player class.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.