1.0.18
All checks were successful
RelicCraft/pipeline/head This commit looks good

Give RelicCraft its own Item Group
Give Targeted Ender Pearls a Cooldown
Add Creative Relic Generator
This commit is contained in:
TheBrokenRail 2020-04-15 18:19:40 -04:00
parent 61732c4cd6
commit ca24f0a997
12 changed files with 124 additions and 24 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
**1.0.18**
* Give RelicCraft its own Item Group
* Give Targeted Ender Pearls a Cooldown
* Add Creative Relic Generator
**1.0.17** **1.0.17**
* The Teleportation Restrictor now blocks Portal Teleportation * The Teleportation Restrictor now blocks Portal Teleportation

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.7.10+build.191 fabric_loader_version = 0.7.10+build.191
# Mod Properties # Mod Properties
mod_version = 1.0.17 mod_version = 1.0.18
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = reliccraft archives_base_name = reliccraft

View File

@ -12,6 +12,7 @@ import com.thebrokenrail.reliccraft.block.TeleportationBeaconBlock;
import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock; import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
import com.thebrokenrail.reliccraft.entity.RelicEntity; import com.thebrokenrail.reliccraft.entity.RelicEntity;
import com.thebrokenrail.reliccraft.item.DragonEggHolderBlockItem; import com.thebrokenrail.reliccraft.item.DragonEggHolderBlockItem;
import com.thebrokenrail.reliccraft.item.GenerateRelicItem;
import com.thebrokenrail.reliccraft.item.TargetedEnderPearlItem; import com.thebrokenrail.reliccraft.item.TargetedEnderPearlItem;
import com.thebrokenrail.reliccraft.item.TimeDilaterItem; import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
import com.thebrokenrail.reliccraft.item.RelicItem; import com.thebrokenrail.reliccraft.item.RelicItem;
@ -22,6 +23,7 @@ import com.thebrokenrail.reliccraft.recipe.TimeDilaterRecipe;
import com.thebrokenrail.reliccraft.structure.TimeTempleFeature; import com.thebrokenrail.reliccraft.structure.TimeTempleFeature;
import com.thebrokenrail.reliccraft.structure.TimeTempleGenerator; import com.thebrokenrail.reliccraft.structure.TimeTempleGenerator;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder; import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder; import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
@ -33,6 +35,9 @@ import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.BinomialLootTableRange; import net.minecraft.loot.BinomialLootTableRange;
import net.minecraft.loot.LootTables; import net.minecraft.loot.LootTables;
import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.entry.ItemEntry;
@ -65,8 +70,8 @@ public class RelicCraft implements ModInitializer {
public static Item ORB_ITEM; public static Item ORB_ITEM;
public static Item STAFF_ITEM; public static Item STAFF_ITEM;
public static Item TIME_DILATER_ITEM; public static Item TIME_DILATER_ITEM;
public static Item TARGETED_ENDER_PEARL_ITEM; public static Item TARGETED_ENDER_PEARL_ITEM;
public static Item GENERATE_RELIC_ITEM;
public static EntityType<RelicEntity> RELIC_ENTITY; public static EntityType<RelicEntity> RELIC_ENTITY;
@ -124,13 +129,17 @@ public class RelicCraft implements ModInitializer {
public static StructurePieceType TIME_TEMPLE_STRUCTURE_PIECE = TimeTempleGenerator.Piece::new; public static StructurePieceType TIME_TEMPLE_STRUCTURE_PIECE = TimeTempleGenerator.Piece::new;
public static final String TIME_TEMPLE_ID = "RelicCraft Time Temple"; public static final String TIME_TEMPLE_ID = "RelicCraft Time Temple";
public static ItemGroup ITEM_GROUP;
@Override @Override
public void onInitialize() { public void onInitialize() {
ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(Items.ENDER_CHEST));
ORB_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "orb"), new RelicItem()); ORB_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "orb"), new RelicItem());
STAFF_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "staff"), 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()); 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()); TARGETED_ENDER_PEARL_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "targeted_ender_pearl"), new TargetedEnderPearlItem());
GENERATE_RELIC_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "generate_relic"), new GenerateRelicItem());
RELIC_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<RelicEntity>) RelicEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build(); RELIC_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<RelicEntity>) RelicEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
@ -168,7 +177,7 @@ public class RelicCraft implements ModInitializer {
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
TagRegistry.item(new Identifier(NAMESPACE, "relics")); TagRegistry.item(new Identifier(NAMESPACE, "relics"));
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
TagRegistry.item(new Identifier(NAMESPACE, "items")); TagRegistry.item(new Identifier(NAMESPACE, "advancement_trigger_items"));
Registry.register(Registry.STRUCTURE_PIECE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_PIECE); 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); Registry.register(Registry.FEATURE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_FEATURE);

View File

@ -45,26 +45,30 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
} }
@Override @Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity user, Hand hand, BlockHitResult hit) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof Inventory) { if (blockEntity instanceof Inventory) {
Inventory inventory = (Inventory) blockEntity; Inventory inventory = (Inventory) blockEntity;
ItemStack stack = player.getStackInHand(hand); ItemStack stack = user.getStackInHand(hand);
if (!stack.isEmpty()) {
if (inventory.isValidInvStack(0, stack) && inventory.getInvStack(0).isEmpty()) { if (inventory.isValidInvStack(0, stack) && inventory.getInvStack(0).isEmpty()) {
if (user.isCreative()) {
inventory.setInvStack(0, stack.copy().split(1));
} else {
inventory.setInvStack(0, stack.split(1)); inventory.setInvStack(0, stack.split(1));
}
if (!world.isClient()) { if (!world.isClient()) {
grantAdvancement(player); grantAdvancement(user);
} }
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}
} else { } else {
if (!inventory.getInvStack(0).isEmpty()) { if (!inventory.getInvStack(0).isEmpty()) {
player.inventory.offerOrDrop(world, inventory.getInvStack(0)); if (!user.isCreative()) {
user.inventory.offerOrDrop(world, inventory.getInvStack(0));
}
inventory.removeInvStack(0); inventory.removeInvStack(0);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {

View File

@ -4,7 +4,6 @@ import com.thebrokenrail.reliccraft.RelicCraft;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.inventory.Inventories; import net.minecraft.inventory.Inventories;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.DefaultedList; import net.minecraft.util.DefaultedList;
@ -13,7 +12,7 @@ import net.minecraft.util.Rarity;
public class DragonEggHolderBlockItem extends BlockItem { public class DragonEggHolderBlockItem extends BlockItem {
public DragonEggHolderBlockItem(Block block) { public DragonEggHolderBlockItem(Block block) {
super(block, new Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.MISC)); super(block, new Settings().rarity(Rarity.UNCOMMON).group(RelicCraft.ITEM_GROUP));
addPropertyGetter(new Identifier(RelicCraft.NAMESPACE, "active"), (stack, world, entity) -> { addPropertyGetter(new Identifier(RelicCraft.NAMESPACE, "active"), (stack, world, entity) -> {
CompoundTag tag = stack.getSubTag("BlockEntityTag"); CompoundTag tag = stack.getSubTag("BlockEntityTag");
if (tag != null) { if (tag != null) {

View File

@ -0,0 +1,69 @@
package com.thebrokenrail.reliccraft.item;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import com.thebrokenrail.reliccraft.RelicCraft;
import com.thebrokenrail.reliccraft.data.RelicData;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import java.util.List;
public class GenerateRelicItem extends Item {
public GenerateRelicItem() {
super(new Settings().maxCount(1).group(RelicCraft.ITEM_GROUP).rarity(Rarity.UNCOMMON));
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack stack = user.getStackInHand(hand);
if (!world.isClient()) {
RelicCraft.playRelicSound(user);
ItemStack newStack;
if (RANDOM.nextBoolean()) {
newStack = new ItemStack(RelicCraft.ORB_ITEM);
} else {
newStack = new ItemStack(RelicCraft.STAFF_ITEM);
}
CompoundTag tag = new CompoundTag();
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<RelicData> jsonAdapter = moshi.adapter(RelicData.class);
tag.putString("RelicData", jsonAdapter.toJson(RelicData.generate(RANDOM)));
newStack.setTag(tag);
if (!user.isCreative()) {
stack.decrement(1);
}
if (!user.inventory.insertStack(newStack.copy())) {
user.dropItem(newStack, false);
}
}
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
@Override
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {
tooltip.add(new TranslatableText("item." + RelicCraft.NAMESPACE + ".generate_relic.tooltip").formatted(Formatting.GRAY));
}
@Override
public boolean hasEnchantmentGlint(ItemStack stack) {
return true;
}
}

View File

@ -9,12 +9,12 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -34,7 +34,7 @@ import java.util.List;
public class TargetedEnderPearlItem extends Item { public class TargetedEnderPearlItem extends Item {
public TargetedEnderPearlItem() { public TargetedEnderPearlItem() {
super(new Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.MISC).maxCount(16)); super(new Settings().rarity(Rarity.UNCOMMON).group(RelicCraft.ITEM_GROUP).maxCount(16));
} }
@Override @Override
@ -46,6 +46,9 @@ public class TargetedEnderPearlItem extends Item {
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack stack = user.getStackInHand(hand); ItemStack stack = user.getStackInHand(hand);
user.getItemCooldownManager().set(this, 20);
user.incrementStat(Stats.USED.getOrCreateStat(this));
if (!world.isClient()) { if (!world.isClient()) {
CompoundTag tag = stack.getTag(); CompoundTag tag = stack.getTag();
if (tag == null) { if (tag == null) {

View File

@ -7,10 +7,10 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
@ -36,12 +36,15 @@ public class TimeDilaterItem extends Item {
} }
public TimeDilaterItem() { public TimeDilaterItem() {
super(new Settings().group(ItemGroup.MISC).maxDamage(9).rarity(Rarity.UNCOMMON)); super(new Settings().group(RelicCraft.ITEM_GROUP).maxDamage(9).rarity(Rarity.UNCOMMON));
} }
@Override @Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack stack = user.getStackInHand(hand); ItemStack stack = user.getStackInHand(hand);
user.incrementStat(Stats.USED.getOrCreateStat(this));
if (!world.isClient()) { if (!world.isClient()) {
DilatedWorld dilatedWorld = (DilatedWorld) world; DilatedWorld dilatedWorld = (DilatedWorld) world;
switch (dilatedWorld.getTimeSpeed()) { switch (dilatedWorld.getTimeSpeed()) {
@ -65,6 +68,7 @@ public class TimeDilaterItem extends Item {
RelicCraft.playRelicSound(user); RelicCraft.playRelicSound(user);
stack.damage(1, user, e -> e.sendToolBreakStatus(hand)); stack.damage(1, user, e -> e.sendToolBreakStatus(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, stack); return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} }

View File

@ -36,6 +36,8 @@
"item.reliccraft.tooltip.targeted_ender_pearl.y": "Y: %s", "item.reliccraft.tooltip.targeted_ender_pearl.y": "Y: %s",
"item.reliccraft.tooltip.targeted_ender_pearl.z": "Z: %s", "item.reliccraft.tooltip.targeted_ender_pearl.z": "Z: %s",
"item.reliccraft.tooltip.targeted_ender_pearl.dimension": "Dimension: %s", "item.reliccraft.tooltip.targeted_ender_pearl.dimension": "Dimension: %s",
"item.reliccraft.generate_relic": "Creative Relic Generator",
"item.reliccraft.generate_relic.tooltip": "Use To Generate A Random Relic",
"text.reliccraft.relic.action.heal_action": "Heal", "text.reliccraft.relic.action.heal_action": "Heal",
"text.reliccraft.relic.action.bedrock_action": "Turn To Bedrock", "text.reliccraft.relic.action.bedrock_action": "Turn To Bedrock",
"text.reliccraft.relic.action.gold_action": "Turn Coal To Gold", "text.reliccraft.relic.action.gold_action": "Turn Coal To Gold",
@ -69,5 +71,6 @@
"advancements.reliccraft.duplicate_time_dilater.description": "Duplicate a Time Dilater", "advancements.reliccraft.duplicate_time_dilater.description": "Duplicate a Time Dilater",
"text.reliccraft.dimension.minecraft.overworld": "The Overworld", "text.reliccraft.dimension.minecraft.overworld": "The Overworld",
"text.reliccraft.dimension.minecraft.the_nether": "The Nether", "text.reliccraft.dimension.minecraft.the_nether": "The Nether",
"text.reliccraft.dimension.minecraft.the_end": "The End" "text.reliccraft.dimension.minecraft.the_end": "The End",
"itemGroup.reliccraft.item_group": "RelicCraft"
} }

View File

@ -0,0 +1,3 @@
{
"parent": "minecraft:item/blaze_rod"
}

View File

@ -21,7 +21,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"tag": "reliccraft:items" "tag": "reliccraft:advancement_trigger_items"
} }
] ]
} }

View File

@ -5,6 +5,7 @@
"reliccraft:time_dilater", "reliccraft:time_dilater",
"reliccraft:teleportation_restrictor", "reliccraft:teleportation_restrictor",
"reliccraft:teleportation_beacon", "reliccraft:teleportation_beacon",
"reliccraft:targeted_ender_pearl" "reliccraft:targeted_ender_pearl",
"minecraft:dragon_egg"
] ]
} }