mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 11:10:29 +00:00
Load treasure disks from various loot tables
This commit is contained in:
parent
697e9449cf
commit
9f87eda5de
1
src/generated/resources/data/computercraft/loot_tables/treasure_disk.json
generated
Normal file
1
src/generated/resources/data/computercraft/loot_tables/treasure_disk.json
generated
Normal file
@ -0,0 +1 @@
|
||||
{}
|
@ -116,7 +116,7 @@ public final class ClientRegistry
|
||||
|
||||
event.getItemColors().register(
|
||||
( stack, layer ) -> layer == 1 ? ((ItemDisk) stack.getItem()).getColour( stack ) : 0xFFFFFF,
|
||||
ComputerCraft.Items.disk
|
||||
ComputerCraft.Items.disk, ComputerCraft.Items.treasureDisk
|
||||
);
|
||||
|
||||
event.getItemColors().register( ( stack, layer ) -> {
|
||||
|
@ -9,6 +9,7 @@ package dan200.computercraft.data;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -41,6 +42,11 @@ public class LootTables extends LootTableProvider
|
||||
computerDrop( add, ComputerCraft.Blocks.computerAdvanced );
|
||||
computerDrop( add, ComputerCraft.Blocks.turtleNormal );
|
||||
computerDrop( add, ComputerCraft.Blocks.turtleAdvanced );
|
||||
|
||||
add.accept( ComputerCraftProxyCommon.ForgeHandlers.LOOT_TREASURE_DISK, LootTable
|
||||
.builder()
|
||||
.setParameterSet( LootParameterSets.GENERIC )
|
||||
.build() );
|
||||
}
|
||||
|
||||
private static void basicDrop( BiConsumer<ResourceLocation, LootTable> add, Block block )
|
||||
|
@ -31,7 +31,12 @@ import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.tileentity.CommandBlockTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.ConstantRange;
|
||||
import net.minecraft.world.storage.loot.LootPool;
|
||||
import net.minecraft.world.storage.loot.LootTables;
|
||||
import net.minecraft.world.storage.loot.TableLootEntry;
|
||||
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
|
||||
import net.minecraftforge.event.LootTableLoadEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@ -41,6 +46,10 @@ import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||
public final class ComputerCraftProxyCommon
|
||||
{
|
||||
@ -167,5 +176,33 @@ public final class ComputerCraftProxyCommon
|
||||
WirelessNetwork.resetNetworks();
|
||||
Tracking.reset();
|
||||
}
|
||||
|
||||
public static final ResourceLocation LOOT_TREASURE_DISK = new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" );
|
||||
|
||||
private static final Set<ResourceLocation> TABLES = new HashSet<>( Arrays.asList(
|
||||
LootTables.CHESTS_SIMPLE_DUNGEON,
|
||||
LootTables.CHESTS_ABANDONED_MINESHAFT,
|
||||
LootTables.CHESTS_STRONGHOLD_CORRIDOR,
|
||||
LootTables.CHESTS_STRONGHOLD_CROSSING,
|
||||
LootTables.CHESTS_STRONGHOLD_LIBRARY,
|
||||
LootTables.CHESTS_DESERT_PYRAMID,
|
||||
LootTables.CHESTS_JUNGLE_TEMPLE,
|
||||
LootTables.CHESTS_IGLOO_CHEST,
|
||||
LootTables.CHESTS_WOODLAND_MANSION,
|
||||
LootTables.CHESTS_VILLAGE_VILLAGE_CARTOGRAPHER
|
||||
) );
|
||||
|
||||
@SubscribeEvent
|
||||
public static void lootLoad( LootTableLoadEvent event )
|
||||
{
|
||||
ResourceLocation name = event.getName();
|
||||
if( !name.getNamespace().equals( "minecraft" ) || !TABLES.contains( name ) ) return;
|
||||
|
||||
event.getTable().addPool( LootPool.builder()
|
||||
.addEntry( TableLootEntry.builder( LOOT_TREASURE_DISK ) )
|
||||
.rolls( ConstantRange.of( 1 ) )
|
||||
.name( "computercraft_treasure" )
|
||||
.build() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user