2020-04-04 02:32:34 +00:00
|
|
|
package com.thebrokenrail.reliccraft;
|
|
|
|
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.ActivateTeleportationBeaconCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.ActivateTeleportationRestrictorCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.DilateTimeCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.DuplicateTimeDilaterCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.RevealRelicCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.UseTargetedEnderPearlCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.advancement.UseTeleportationBeaconCriterion;
|
|
|
|
import com.thebrokenrail.reliccraft.block.DragonEggHolderBlockEntity;
|
|
|
|
import com.thebrokenrail.reliccraft.block.TeleportationBeaconBlock;
|
|
|
|
import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
|
|
|
|
import com.thebrokenrail.reliccraft.entity.RelicEntity;
|
|
|
|
import com.thebrokenrail.reliccraft.item.TargetedEnderPearlItem;
|
|
|
|
import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
|
|
|
|
import com.thebrokenrail.reliccraft.item.RelicItem;
|
2020-04-05 22:17:42 +00:00
|
|
|
import com.thebrokenrail.reliccraft.loot.RelicLootTableFunction;
|
2020-04-04 02:32:34 +00:00
|
|
|
import com.thebrokenrail.reliccraft.mixin.CriteriaRegistryHook;
|
|
|
|
import com.thebrokenrail.reliccraft.recipe.RevealRelicRecipe;
|
|
|
|
import com.thebrokenrail.reliccraft.recipe.TimeDilaterRecipe;
|
|
|
|
import com.thebrokenrail.reliccraft.structure.TimeTempleFeature;
|
|
|
|
import com.thebrokenrail.reliccraft.structure.TimeTempleGenerator;
|
|
|
|
import net.fabricmc.api.ModInitializer;
|
|
|
|
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
|
|
|
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
|
|
|
|
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
|
|
|
import net.fabricmc.fabric.api.tag.TagRegistry;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
|
|
import net.minecraft.entity.EntityCategory;
|
|
|
|
import net.minecraft.entity.EntityDimensions;
|
|
|
|
import net.minecraft.entity.EntityType;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.item.BlockItem;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
import net.minecraft.loot.BinomialLootTableRange;
|
|
|
|
import net.minecraft.loot.LootTables;
|
|
|
|
import net.minecraft.loot.entry.ItemEntry;
|
|
|
|
import net.minecraft.recipe.SpecialRecipeSerializer;
|
|
|
|
import net.minecraft.sound.SoundCategory;
|
|
|
|
import net.minecraft.sound.SoundEvent;
|
|
|
|
import net.minecraft.sound.SoundEvents;
|
|
|
|
import net.minecraft.structure.StructurePieceType;
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import net.minecraft.util.Rarity;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.biome.Biome;
|
|
|
|
import net.minecraft.world.gen.GenerationStep;
|
|
|
|
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
|
|
|
|
import net.minecraft.world.gen.decorator.Decorator;
|
|
|
|
import net.minecraft.world.gen.decorator.DecoratorConfig;
|
|
|
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
|
|
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
|
|
|
import net.minecraft.world.gen.feature.Feature;
|
|
|
|
import net.minecraft.world.gen.feature.FeatureConfig;
|
|
|
|
import net.minecraft.world.gen.feature.StructureFeature;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
public class RelicCraft implements ModInitializer {
|
|
|
|
public static final String NAMESPACE = "reliccraft";
|
|
|
|
|
|
|
|
public static Item ORB_ITEM;
|
|
|
|
public static Item STAFF_ITEM;
|
|
|
|
public static Item TIME_DILATER_ITEM;
|
|
|
|
|
|
|
|
public static Item TARGETED_ENDER_PEARL_ITEM;
|
|
|
|
|
|
|
|
public static EntityType<RelicEntity> RELIC_ENTITY;
|
|
|
|
|
|
|
|
public static SpecialRecipeSerializer<RevealRelicRecipe> REVEAL_RELIC_RECIPE;
|
|
|
|
public static SpecialRecipeSerializer<TimeDilaterRecipe> TIME_DILATER_RECIPE;
|
|
|
|
|
|
|
|
public static Block TELEPORTATION_RESTRICTOR_BLOCK;
|
|
|
|
public static Block TELEPORTATION_BEACON_BLOCK;
|
|
|
|
public static BlockEntityType<DragonEggHolderBlockEntity> DRAGON_EGG_HOLDER_BLOCK_ENTITY;
|
|
|
|
|
|
|
|
public static final Identifier[] LOOT_TABLES = new Identifier[]{
|
|
|
|
LootTables.SIMPLE_DUNGEON_CHEST,
|
|
|
|
LootTables.END_CITY_TREASURE_CHEST,
|
|
|
|
LootTables.NETHER_BRIDGE_CHEST,
|
|
|
|
LootTables.ABANDONED_MINESHAFT_CHEST,
|
|
|
|
LootTables.SHIPWRECK_TREASURE_CHEST,
|
|
|
|
LootTables.DESERT_PYRAMID_CHEST,
|
|
|
|
LootTables.JUNGLE_TEMPLE_CHEST,
|
|
|
|
LootTables.STRONGHOLD_LIBRARY_CHEST,
|
|
|
|
LootTables.PILLAGER_OUTPOST_CHEST,
|
|
|
|
LootTables.WOODLAND_MANSION_CHEST,
|
|
|
|
LootTables.BURIED_TREASURE_CHEST,
|
|
|
|
LootTables.FISHING_TREASURE_GAMEPLAY
|
|
|
|
};
|
|
|
|
|
|
|
|
public static ActivateTeleportationRestrictorCriterion ACTIVATE_TELEPORTATION_RESTRICTOR_CRITERION;
|
|
|
|
public static RevealRelicCriterion REVEAL_RELIC_CRITERION;
|
|
|
|
public static DilateTimeCriterion DILATE_TIME_CRITERION;
|
|
|
|
public static DuplicateTimeDilaterCriterion DUPLICATE_TIME_DILATER_CRITERION;
|
|
|
|
public static ActivateTeleportationBeaconCriterion ACTIVATE_TELEPORTATION_BEACON_CRITERION;
|
|
|
|
public static UseTeleportationBeaconCriterion USE_TELEPORTATION_BEACON_CRITERION;
|
|
|
|
public static UseTargetedEnderPearlCriterion USE_TARGETED_ENDER_PEARL;
|
|
|
|
|
|
|
|
private boolean isSelectedLootTable(Identifier lootTable) {
|
|
|
|
for (Identifier id : LOOT_TABLES) {
|
|
|
|
if (id.equals(lootTable)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final SoundEvent RELIC_SOUND_EFFECT = SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE;
|
|
|
|
private static final SoundEvent INTERACT_TELEPORT_RESTRICTOR_SOUND_EFFECT = SoundEvents.BLOCK_END_PORTAL_FRAME_FILL;
|
|
|
|
|
|
|
|
public static void playRelicSound(PlayerEntity player) {
|
|
|
|
player.playSound(RELIC_SOUND_EFFECT, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void playInteractTeleportRestrictorSound(World world, BlockPos pos) {
|
|
|
|
world.playSound(null, pos, INTERACT_TELEPORT_RESTRICTOR_SOUND_EFFECT, SoundCategory.BLOCKS, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
2020-04-07 23:36:57 +00:00
|
|
|
public static StructureFeature<DefaultFeatureConfig> TIME_TEMPLE_STRUCTURE_FEATURE = new TimeTempleFeature(DefaultFeatureConfig::deserialize);
|
|
|
|
public static StructurePieceType TIME_TEMPLE_STRUCTURE_PIECE = TimeTempleGenerator.Piece::new;
|
2020-04-04 02:32:34 +00:00
|
|
|
public static final String TIME_TEMPLE_ID = "RelicCraft Time Temple";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInitialize() {
|
|
|
|
ORB_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "orb"), new RelicItem());
|
|
|
|
STAFF_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "staff"), new RelicItem());
|
|
|
|
TIME_DILATER_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "time_dilater"), new TimeDilaterItem());
|
|
|
|
|
|
|
|
TARGETED_ENDER_PEARL_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "targeted_ender_pearl"), new TargetedEnderPearlItem());
|
|
|
|
|
|
|
|
RELIC_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<RelicEntity>) RelicEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
|
|
|
|
|
|
|
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
|
|
|
|
if (isSelectedLootTable(id)) {
|
|
|
|
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
|
|
|
|
.withRolls(new BinomialLootTableRange(2, 0.5f))
|
|
|
|
.withEntry(ItemEntry.builder(ORB_ITEM))
|
|
|
|
.withEntry(ItemEntry.builder(STAFF_ITEM))
|
|
|
|
.withFunction(new RelicLootTableFunction.Builder());
|
|
|
|
|
|
|
|
supplier.withPool(poolBuilder);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
REVEAL_RELIC_RECIPE = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "reveal_relic"), new SpecialRecipeSerializer<>(RevealRelicRecipe::new));
|
|
|
|
TIME_DILATER_RECIPE = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "time_dilater"), new SpecialRecipeSerializer<>(TimeDilaterRecipe::new));
|
|
|
|
|
|
|
|
TELEPORTATION_RESTRICTOR_BLOCK = Registry.register(Registry.BLOCK, new Identifier(NAMESPACE, "teleportation_restrictor"), new TeleportationRestrictorBlock());
|
|
|
|
TELEPORTATION_BEACON_BLOCK = Registry.register(Registry.BLOCK, new Identifier(NAMESPACE, "teleportation_beacon"), new TeleportationBeaconBlock());
|
|
|
|
DRAGON_EGG_HOLDER_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(NAMESPACE, "dragon_egg_holder"), BlockEntityType.Builder.create(DragonEggHolderBlockEntity::new, TELEPORTATION_RESTRICTOR_BLOCK, TELEPORTATION_BEACON_BLOCK).build(null));
|
|
|
|
|
|
|
|
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "teleportation_restrictor"), new BlockItem(TELEPORTATION_RESTRICTOR_BLOCK, new Item.Settings().group(ItemGroup.MISC).rarity(Rarity.UNCOMMON)));
|
|
|
|
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "teleportation_beacon"), new BlockItem(TELEPORTATION_BEACON_BLOCK, new Item.Settings().group(ItemGroup.MISC).rarity(Rarity.UNCOMMON)));
|
|
|
|
|
|
|
|
ACTIVATE_TELEPORTATION_RESTRICTOR_CRITERION = CriteriaRegistryHook.callRegister(new ActivateTeleportationRestrictorCriterion());
|
|
|
|
REVEAL_RELIC_CRITERION = CriteriaRegistryHook.callRegister(new RevealRelicCriterion());
|
|
|
|
DILATE_TIME_CRITERION = CriteriaRegistryHook.callRegister(new DilateTimeCriterion());
|
|
|
|
DUPLICATE_TIME_DILATER_CRITERION = CriteriaRegistryHook.callRegister(new DuplicateTimeDilaterCriterion());
|
|
|
|
ACTIVATE_TELEPORTATION_BEACON_CRITERION = CriteriaRegistryHook.callRegister(new ActivateTeleportationBeaconCriterion());
|
|
|
|
USE_TELEPORTATION_BEACON_CRITERION = CriteriaRegistryHook.callRegister(new UseTeleportationBeaconCriterion());
|
|
|
|
USE_TARGETED_ENDER_PEARL = CriteriaRegistryHook.callRegister(new UseTargetedEnderPearlCriterion());
|
|
|
|
|
|
|
|
//noinspection ResultOfMethodCallIgnored
|
|
|
|
TagRegistry.item(new Identifier(NAMESPACE, "relics"));
|
2020-04-04 14:05:41 +00:00
|
|
|
//noinspection ResultOfMethodCallIgnored
|
|
|
|
TagRegistry.item(new Identifier(NAMESPACE, "items"));
|
2020-04-04 02:32:34 +00:00
|
|
|
|
2020-04-07 23:36:57 +00:00
|
|
|
Registry.register(Registry.STRUCTURE_PIECE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_PIECE);
|
|
|
|
Registry.register(Registry.FEATURE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_FEATURE);
|
2020-04-04 02:32:34 +00:00
|
|
|
Registry.register(Registry.STRUCTURE_FEATURE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_FEATURE);
|
|
|
|
|
|
|
|
Feature.STRUCTURES.put(TIME_TEMPLE_ID.toLowerCase(Locale.ROOT), TIME_TEMPLE_STRUCTURE_FEATURE);
|
|
|
|
|
2020-04-07 23:36:57 +00:00
|
|
|
ConfiguredFeature<?, ?> configuredFeature = getConfiguredFeature(TIME_TEMPLE_STRUCTURE_FEATURE);
|
2020-04-04 02:32:34 +00:00
|
|
|
|
|
|
|
for (Biome biome : Registry.BIOME) {
|
|
|
|
if (biome.getCategory() == Biome.Category.PLAINS) {
|
|
|
|
biome.addStructureFeature(TIME_TEMPLE_STRUCTURE_FEATURE.configure(FeatureConfig.DEFAULT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FlatChunkGeneratorConfig.FEATURE_TO_GENERATION_STEP.put(configuredFeature, GenerationStep.Feature.SURFACE_STRUCTURES);
|
|
|
|
FlatChunkGeneratorConfig.FEATURE_TO_FEATURE_CONFIG.put(configuredFeature, FeatureConfig.DEFAULT);
|
|
|
|
FlatChunkGeneratorConfig.STRUCTURE_TO_FEATURES.put(NAMESPACE + "_time_temple", new ConfiguredFeature[]{configuredFeature});
|
|
|
|
}
|
2020-04-07 23:36:57 +00:00
|
|
|
|
|
|
|
public static ConfiguredFeature<?, ?> getConfiguredFeature(StructureFeature<DefaultFeatureConfig> feature) {
|
|
|
|
return feature.configure(FeatureConfig.DEFAULT).createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT));
|
|
|
|
}
|
2020-04-04 02:32:34 +00:00
|
|
|
}
|