Updated to Minecraft 1.19.4. Forge 45.2.8.
- Removed recipe system with ability to disable totems via config. - Optimized imports. - Redid generated data. - Updated creative mode tab.
This commit is contained in:
@ -8,7 +8,7 @@ name = Micle's Totem of Reviving
|
|||||||
author = Micle
|
author = Micle
|
||||||
|
|
||||||
buildVersion = 2.0.0
|
buildVersion = 2.0.0
|
||||||
mcVersion = 1.19.2
|
mcVersion = 1.19.4
|
||||||
forgeVersion = 43.1.47
|
forgeVersion = 45.2.8
|
||||||
|
|
||||||
jeiVersion = 11.+
|
#jeiVersion = 11.+
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:charge_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"D": {
|
"D": {
|
||||||
"item": "minecraft:diamond"
|
"item": "minecraft:diamond"
|
||||||
@ -21,5 +22,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:diamond_charge"
|
"item": "totemofreviving:diamond_charge"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:totem_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"D": {
|
"D": {
|
||||||
"item": "minecraft:diamond"
|
"item": "minecraft:diamond"
|
||||||
@ -18,5 +19,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:diamond_totem"
|
"item": "totemofreviving:diamond_totem"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:charge_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"E": {
|
"E": {
|
||||||
"item": "minecraft:emerald"
|
"item": "minecraft:emerald"
|
||||||
@ -18,5 +19,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:iron_charge"
|
"item": "totemofreviving:iron_charge"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:totem_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"B": {
|
"B": {
|
||||||
"item": "minecraft:iron_block"
|
"item": "minecraft:iron_block"
|
||||||
@ -18,5 +19,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:iron_totem"
|
"item": "totemofreviving:iron_totem"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:charge_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"C": {
|
"C": {
|
||||||
"item": "totemofreviving:diamond_charge"
|
"item": "totemofreviving:diamond_charge"
|
||||||
@ -18,5 +19,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:netherite_charge"
|
"item": "totemofreviving:netherite_charge"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:totem_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"B": {
|
"B": {
|
||||||
"item": "minecraft:nether_brick"
|
"item": "minecraft:nether_brick"
|
||||||
@ -21,5 +22,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:netherite_totem"
|
"item": "totemofreviving:netherite_totem"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:charge_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"E": {
|
"E": {
|
||||||
"item": "minecraft:emerald"
|
"item": "minecraft:emerald"
|
||||||
@ -18,5 +19,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:straw_charge"
|
"item": "totemofreviving:straw_charge"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "totemofreviving:totem_recipe",
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "equipment",
|
||||||
"key": {
|
"key": {
|
||||||
"N": {
|
"N": {
|
||||||
"item": "minecraft:iron_nugget"
|
"item": "minecraft:iron_nugget"
|
||||||
@ -21,5 +22,6 @@
|
|||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
"item": "totemofreviving:straw_totem"
|
"item": "totemofreviving:straw_totem"
|
||||||
}
|
},
|
||||||
|
"show_notification": true
|
||||||
}
|
}
|
@ -1,12 +1,10 @@
|
|||||||
package dev.micle.totemofreviving;
|
package dev.micle.totemofreviving;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.proxy.IProxy;
|
|
||||||
import dev.micle.totemofreviving.proxy.IProxy;
|
import dev.micle.totemofreviving.proxy.IProxy;
|
||||||
import dev.micle.totemofreviving.proxy.Proxy;
|
import dev.micle.totemofreviving.proxy.Proxy;
|
||||||
import dev.micle.totemofreviving.setup.ModItems;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.CreativeModeTabs;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.ModContainer;
|
import net.minecraftforge.fml.ModContainer;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
@ -17,12 +15,7 @@ import java.util.Optional;
|
|||||||
@Mod(TotemOfReviving.MOD_ID)
|
@Mod(TotemOfReviving.MOD_ID)
|
||||||
public final class TotemOfReviving {
|
public final class TotemOfReviving {
|
||||||
public static final String MOD_ID = "totemofreviving";
|
public static final String MOD_ID = "totemofreviving";
|
||||||
public static final CreativeModeTab ITEM_GROUP = new CreativeModeTab(MOD_ID) {
|
public static CreativeModeTab CREATIVE_TAB = CreativeModeTabs.getDefaultTab();
|
||||||
@Override
|
|
||||||
public ItemStack makeIcon() {
|
|
||||||
return new ItemStack(ModItems.STRAW_TOTEM.get());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static IProxy proxy;
|
private static IProxy proxy;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package dev.micle.totemofreviving.data;
|
package dev.micle.totemofreviving.data;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.item.crafting.ExtendedShapedRecipeBuilder;
|
|
||||||
import dev.micle.totemofreviving.setup.ModItems;
|
import dev.micle.totemofreviving.setup.ModItems;
|
||||||
import dev.micle.totemofreviving.setup.ModRecipes;
|
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraft.data.recipes.FinishedRecipe;
|
import net.minecraft.data.recipes.FinishedRecipe;
|
||||||
|
import net.minecraft.data.recipes.RecipeCategory;
|
||||||
import net.minecraft.data.recipes.RecipeProvider;
|
import net.minecraft.data.recipes.RecipeProvider;
|
||||||
|
import net.minecraft.data.recipes.ShapedRecipeBuilder;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
@ -13,13 +13,13 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class ModRecipeProvider extends RecipeProvider {
|
public class ModRecipeProvider extends RecipeProvider {
|
||||||
public ModRecipeProvider(DataGenerator generator) {
|
public ModRecipeProvider(DataGenerator generator) {
|
||||||
super(generator);
|
super(generator.getPackOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
|
protected void buildRecipes(Consumer<FinishedRecipe> consumer) {
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.STRAW_TOTEM.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.STRAW_TOTEM.get())
|
||||||
.define('W', Items.WHEAT)
|
.define('W', Items.WHEAT)
|
||||||
.define('|', Items.STICK)
|
.define('|', Items.STICK)
|
||||||
.define('S', Items.STRING)
|
.define('S', Items.STRING)
|
||||||
@ -29,7 +29,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("N|N")
|
.pattern("N|N")
|
||||||
.unlockedBy("has_item", has(Items.WHEAT))
|
.unlockedBy("has_item", has(Items.WHEAT))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.IRON_TOTEM.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.IRON_TOTEM.get())
|
||||||
.define('B', Items.IRON_BLOCK)
|
.define('B', Items.IRON_BLOCK)
|
||||||
.define('E', Items.EMERALD)
|
.define('E', Items.EMERALD)
|
||||||
.define('I', Items.IRON_INGOT)
|
.define('I', Items.IRON_INGOT)
|
||||||
@ -38,7 +38,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern(" I ")
|
.pattern(" I ")
|
||||||
.unlockedBy("has_item", has(Items.EMERALD))
|
.unlockedBy("has_item", has(Items.EMERALD))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.DIAMOND_TOTEM.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.DIAMOND_TOTEM.get())
|
||||||
.define('T', Items.TOTEM_OF_UNDYING)
|
.define('T', Items.TOTEM_OF_UNDYING)
|
||||||
.define('D', Items.DIAMOND)
|
.define('D', Items.DIAMOND)
|
||||||
.define('E', Items.ENDER_PEARL)
|
.define('E', Items.ENDER_PEARL)
|
||||||
@ -47,7 +47,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("EDE")
|
.pattern("EDE")
|
||||||
.unlockedBy("has_item", has(Items.TOTEM_OF_UNDYING))
|
.unlockedBy("has_item", has(Items.TOTEM_OF_UNDYING))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.NETHERITE_TOTEM.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.NETHERITE_TOTEM.get())
|
||||||
.define('T', ModItems.DIAMOND_TOTEM.get())
|
.define('T', ModItems.DIAMOND_TOTEM.get())
|
||||||
.define('N', Items.NETHERITE_SCRAP)
|
.define('N', Items.NETHERITE_SCRAP)
|
||||||
.define('G', Items.GOLD_INGOT)
|
.define('G', Items.GOLD_INGOT)
|
||||||
@ -57,8 +57,8 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("BGB")
|
.pattern("BGB")
|
||||||
.unlockedBy("has_item", has(Items.NETHERITE_SCRAP))
|
.unlockedBy("has_item", has(Items.NETHERITE_SCRAP))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
|
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.STRAW_CHARGE.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.STRAW_CHARGE.get())
|
||||||
.define('E', Items.EMERALD)
|
.define('E', Items.EMERALD)
|
||||||
.define('W', Items.WHEAT)
|
.define('W', Items.WHEAT)
|
||||||
.define('N', Items.IRON_NUGGET)
|
.define('N', Items.IRON_NUGGET)
|
||||||
@ -67,7 +67,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("NWN")
|
.pattern("NWN")
|
||||||
.unlockedBy("has_item", has(ModItems.STRAW_TOTEM.get()))
|
.unlockedBy("has_item", has(ModItems.STRAW_TOTEM.get()))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.IRON_CHARGE.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.IRON_CHARGE.get())
|
||||||
.define('E', Items.EMERALD)
|
.define('E', Items.EMERALD)
|
||||||
.define('I', Items.IRON_INGOT)
|
.define('I', Items.IRON_INGOT)
|
||||||
.define('N', Items.IRON_NUGGET)
|
.define('N', Items.IRON_NUGGET)
|
||||||
@ -76,7 +76,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("NIN")
|
.pattern("NIN")
|
||||||
.unlockedBy("has_item", has(ModItems.IRON_TOTEM.get()))
|
.unlockedBy("has_item", has(ModItems.IRON_TOTEM.get()))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.DIAMOND_CHARGE.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.DIAMOND_CHARGE.get())
|
||||||
.define('E', Items.EMERALD)
|
.define('E', Items.EMERALD)
|
||||||
.define('D', Items.DIAMOND)
|
.define('D', Items.DIAMOND)
|
||||||
.define('I', Items.IRON_INGOT)
|
.define('I', Items.IRON_INGOT)
|
||||||
@ -86,7 +86,7 @@ public class ModRecipeProvider extends RecipeProvider {
|
|||||||
.pattern("IDI")
|
.pattern("IDI")
|
||||||
.unlockedBy("has_item", has(ModItems.DIAMOND_TOTEM.get()))
|
.unlockedBy("has_item", has(ModItems.DIAMOND_TOTEM.get()))
|
||||||
.save(consumer);
|
.save(consumer);
|
||||||
ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.NETHERITE_CHARGE.get())
|
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.NETHERITE_CHARGE.get())
|
||||||
.define('C', ModItems.DIAMOND_CHARGE.get())
|
.define('C', ModItems.DIAMOND_CHARGE.get())
|
||||||
.define('N', Items.NETHERITE_SCRAP)
|
.define('N', Items.NETHERITE_SCRAP)
|
||||||
.define('G', Items.GOLD_INGOT)
|
.define('G', Items.GOLD_INGOT)
|
||||||
|
@ -17,7 +17,7 @@ import net.minecraftforge.common.data.ExistingFileHelper;
|
|||||||
|
|
||||||
public class ModItemModelProvider extends ItemModelProvider {
|
public class ModItemModelProvider extends ItemModelProvider {
|
||||||
public ModItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
public ModItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
||||||
super(generator, TotemOfReviving.MOD_ID, existingFileHelper);
|
super(generator.getPackOutput(), TotemOfReviving.MOD_ID, existingFileHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package dev.micle.totemofreviving.event.common;
|
||||||
|
|
||||||
|
import dev.micle.totemofreviving.TotemOfReviving;
|
||||||
|
import dev.micle.totemofreviving.setup.ModItems;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = TotemOfReviving.MOD_ID)
|
||||||
|
public class OnCreativeModeTabRegisterEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void creativeModeTabRegisterEvent(CreativeModeTabEvent.Register event) {
|
||||||
|
System.out.println("HERE!");
|
||||||
|
TotemOfReviving.CREATIVE_TAB = event.registerCreativeModeTab(
|
||||||
|
TotemOfReviving.createResourceLocation("creative_mode_tab_main"), builder -> builder
|
||||||
|
.icon(() -> new ItemStack(ModItems.STRAW_TOTEM.get()))
|
||||||
|
.title(Component.translatable(String.format("tabs.%s.main_tab", TotemOfReviving.MOD_ID)))
|
||||||
|
.displayItems((featureFlags, output) -> {
|
||||||
|
output.accept(ModItems.STRAW_TOTEM.get());
|
||||||
|
output.accept(ModItems.IRON_TOTEM.get());
|
||||||
|
output.accept(ModItems.DIAMOND_TOTEM.get());
|
||||||
|
output.accept(ModItems.NETHERITE_TOTEM.get());
|
||||||
|
|
||||||
|
output.accept(ModItems.STRAW_CHARGE.get());
|
||||||
|
output.accept(ModItems.IRON_CHARGE.get());
|
||||||
|
output.accept(ModItems.DIAMOND_CHARGE.get());
|
||||||
|
output.accept(ModItems.NETHERITE_CHARGE.get());
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package dev.micle.totemofreviving.item.charge;
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.TotemOfReviving;
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@ -22,27 +21,14 @@ public class ChargeItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChargeItem(Rarity rarity) {
|
public ChargeItem(Rarity rarity) {
|
||||||
super(new Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(64).rarity(rarity));
|
super(new Properties().stacksTo(64).rarity(rarity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag tooltipFlag) {
|
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag tooltipFlag) {
|
||||||
if (isEnabled(stack)) {
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
|
|
||||||
} else {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.RED + "Totem is disabled!"));
|
|
||||||
}
|
|
||||||
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(ItemStack stack) {
|
|
||||||
Item item = stack.getItem();
|
|
||||||
if (item instanceof StrawChargeItem) { return Config.Server.getStrawTotemConfig().getIsEnabled(); }
|
|
||||||
if (item instanceof IronChargeItem) { return Config.Server.getIronTotemConfig().getIsEnabled(); }
|
|
||||||
if (item instanceof DiamondChargeItem) { return Config.Server.getDiamondTotemConfig().getIsEnabled(); }
|
|
||||||
if (item instanceof NetheriteChargeItem) { return Config.Server.getNetheriteTotemConfig().getIsEnabled(); }
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.item.crafting;
|
|
||||||
|
|
||||||
import dev.micle.totemofreviving.item.charge.ChargeItem;
|
|
||||||
import dev.micle.totemofreviving.setup.ModRecipes;
|
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
public class ChargeRecipe extends ExtendedShapedRecipe {
|
|
||||||
public ChargeRecipe(ShapedRecipe recipe) {
|
|
||||||
super(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeSerializer<?> getSerializer() {
|
|
||||||
return ModRecipes.CHARGE_RECIPE.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(CraftingContainer inventory, Level world) {
|
|
||||||
if (!ChargeItem.isEnabled(getResultItem())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return getBaseRecipe().matches(inventory, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack assemble(CraftingContainer inventory) {
|
|
||||||
return getBaseRecipe().getResultItem().copy();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.item.crafting;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public abstract class ExtendedShapedRecipe extends ShapedRecipe {
|
|
||||||
private static final RecipeSerializer<ShapedRecipe> BASE_SERIALIZER = RecipeSerializer.SHAPED_RECIPE;
|
|
||||||
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ExtendedShapedRecipe(ShapedRecipe recipe) {
|
|
||||||
super(recipe.getId(), recipe.getGroup(), recipe.getRecipeWidth(), recipe.getRecipeHeight(), recipe.getIngredients(), recipe.getResultItem());
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShapedRecipe getBaseRecipe() {
|
|
||||||
return this.recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract RecipeSerializer<?> getSerializer();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean matches(CraftingContainer inventory, Level world);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract ItemStack assemble(CraftingContainer inventory);
|
|
||||||
|
|
||||||
public static class Serializer<T extends ExtendedShapedRecipe> implements RecipeSerializer<T> {
|
|
||||||
private final Function<ShapedRecipe, T> recipeFactory;
|
|
||||||
@Nullable private final BiConsumer<JsonObject, T> readJson;
|
|
||||||
@Nullable private final BiConsumer<FriendlyByteBuf, T> readBuffer;
|
|
||||||
@Nullable private final BiConsumer<FriendlyByteBuf, T> writeBuffer;
|
|
||||||
|
|
||||||
public Serializer(Function<ShapedRecipe, T> recipeFactory,
|
|
||||||
@Nullable BiConsumer<JsonObject, T> readJson,
|
|
||||||
@Nullable BiConsumer<FriendlyByteBuf, T> readBuffer,
|
|
||||||
@Nullable BiConsumer<FriendlyByteBuf, T> writeBuffer) {
|
|
||||||
this.recipeFactory = recipeFactory;
|
|
||||||
this.readJson = readJson;
|
|
||||||
this.readBuffer = readBuffer;
|
|
||||||
this.writeBuffer = writeBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <S extends ExtendedShapedRecipe> Serializer<S> basic(Function<ShapedRecipe, S> recipeFactory) {
|
|
||||||
return new Serializer<>(recipeFactory, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T fromJson(ResourceLocation recipeId, JsonObject json) {
|
|
||||||
ShapedRecipe recipe = BASE_SERIALIZER.fromJson(recipeId, json);
|
|
||||||
T result = this.recipeFactory.apply(recipe);
|
|
||||||
if (this.readJson != null) {
|
|
||||||
this.readJson.accept(json, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
|
||||||
ShapedRecipe recipe = BASE_SERIALIZER.fromNetwork(recipeId, buffer);
|
|
||||||
T result = this.recipeFactory.apply(recipe);
|
|
||||||
if (this.readBuffer != null) {
|
|
||||||
this.readBuffer.accept(buffer, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toNetwork(FriendlyByteBuf buffer, T recipe) {
|
|
||||||
BASE_SERIALIZER.toNetwork(buffer, recipe.getBaseRecipe());
|
|
||||||
if (this.writeBuffer != null) {
|
|
||||||
this.writeBuffer.accept(buffer, recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.item.crafting;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.advancements.Advancement;
|
|
||||||
import net.minecraft.advancements.AdvancementRewards;
|
|
||||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
|
||||||
import net.minecraft.advancements.RequirementsStrategy;
|
|
||||||
import net.minecraft.advancements.critereon.EntityPredicate;
|
|
||||||
import net.minecraft.advancements.critereon.RecipeUnlockedTrigger;
|
|
||||||
import net.minecraft.data.recipes.FinishedRecipe;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class ExtendedShapedRecipeBuilder {
|
|
||||||
private final RecipeSerializer<?> serializer;
|
|
||||||
private final Item result;
|
|
||||||
private final int count;
|
|
||||||
private final List<String> pattern = new ArrayList<>();
|
|
||||||
private final Map<Character, Ingredient> key = new LinkedHashMap<>();
|
|
||||||
private final Advancement.Builder advancementBuilder = Advancement.Builder.advancement();
|
|
||||||
private boolean hasAdvancementCriterion = false;
|
|
||||||
private String group = "";
|
|
||||||
|
|
||||||
private ExtendedShapedRecipeBuilder(RecipeSerializer<?> serializer, ItemLike result, int count) {
|
|
||||||
this.serializer = serializer;
|
|
||||||
this.result = result.asItem();
|
|
||||||
this.count = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExtendedShapedRecipeBuilder shaped(RecipeSerializer<?> serializer, ItemLike result) {
|
|
||||||
return shaped(serializer, result, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExtendedShapedRecipeBuilder shaped(RecipeSerializer<?> serializer, ItemLike result, int count) {
|
|
||||||
return new ExtendedShapedRecipeBuilder(serializer, result, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder define(Character symbol, TagKey<Item> tagIn) {
|
|
||||||
return this.define(symbol, Ingredient.of(tagIn));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder define(Character symbol, ItemLike itemIn) {
|
|
||||||
return this.define(symbol, Ingredient.of(itemIn));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder define(Character symbol, Ingredient ingredientIn) {
|
|
||||||
if (this.key.containsKey(symbol)) {
|
|
||||||
throw new IllegalArgumentException("Symbol '" + symbol + "' is already defined!");
|
|
||||||
} else if (symbol == ' ') {
|
|
||||||
throw new IllegalArgumentException("Symbol ' ' (whitespace) is reserved and cannot be defined");
|
|
||||||
} else {
|
|
||||||
this.key.put(symbol, ingredientIn);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder pattern(String patternIn) {
|
|
||||||
if (!this.pattern.isEmpty() && patternIn.length() != this.pattern.get(0).length()) {
|
|
||||||
throw new IllegalArgumentException("Pattern must be the same width on every line!");
|
|
||||||
} else {
|
|
||||||
this.pattern.add(patternIn);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder unlockedBy(String name, CriterionTriggerInstance criterionIn) {
|
|
||||||
this.advancementBuilder.addCriterion(name, criterionIn);
|
|
||||||
this.hasAdvancementCriterion = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedShapedRecipeBuilder group(String groupIn) {
|
|
||||||
this.group = groupIn;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(Consumer<FinishedRecipe> consumer) {
|
|
||||||
save(consumer, ForgeRegistries.ITEMS.getKey(this.result.asItem()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(Consumer<FinishedRecipe> consumer, ResourceLocation id) {
|
|
||||||
this.validate(id);
|
|
||||||
if (this.hasAdvancementCriterion && !this.advancementBuilder.getCriteria().isEmpty()) {
|
|
||||||
this.advancementBuilder.parent(new ResourceLocation("recipes/root"))
|
|
||||||
.addCriterion("has_the_recipe", new RecipeUnlockedTrigger.TriggerInstance(EntityPredicate.Composite.ANY, id))
|
|
||||||
.rewards(AdvancementRewards.Builder.recipe(id))
|
|
||||||
.requirements(RequirementsStrategy.OR);
|
|
||||||
}
|
|
||||||
ResourceLocation advancementId = new ResourceLocation(id.getNamespace(), "recipes/" + this.result.getItemCategory().getRecipeFolderName() + "/" + id.getPath());
|
|
||||||
consumer.accept(new Result(id, this, advancementId));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validate(ResourceLocation id) {
|
|
||||||
if (this.pattern.isEmpty()) {
|
|
||||||
throw new IllegalStateException("No pattern is defined for shaped recipe " + id + "!");
|
|
||||||
} else {
|
|
||||||
Set<Character> set = Sets.newHashSet(this.key.keySet());
|
|
||||||
set.remove(' ');
|
|
||||||
|
|
||||||
for (String s : this.pattern) {
|
|
||||||
for (int i = 0; i < s.length(); ++i) {
|
|
||||||
char c0 = s.charAt(i);
|
|
||||||
if (!this.key.containsKey(c0) && c0 != ' ') {
|
|
||||||
throw new IllegalStateException("Pattern in recipe " + id + " uses undefined symbol '" + c0 + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
set.remove(c0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!set.isEmpty()) {
|
|
||||||
throw new IllegalStateException("Ingredients are defined but not used in pattern for recipe " + id);
|
|
||||||
} else if (this.pattern.size() == 1 && this.pattern.get(0).length() == 1) {
|
|
||||||
throw new IllegalStateException("Shaped recipe " + id + " only takes in a single item - should it be a shapeless recipe instead?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Result implements FinishedRecipe {
|
|
||||||
private final ResourceLocation id;
|
|
||||||
private final ExtendedShapedRecipeBuilder builder;
|
|
||||||
private final ResourceLocation advancementId;
|
|
||||||
|
|
||||||
public Result(ResourceLocation id, ExtendedShapedRecipeBuilder builder, ResourceLocation advancementId) {
|
|
||||||
this.id = id;
|
|
||||||
this.builder = builder;
|
|
||||||
this.advancementId = advancementId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serializeRecipeData(JsonObject json) {
|
|
||||||
if (!builder.group.isEmpty()) {
|
|
||||||
json.addProperty("group", builder.group);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonArray pattern = new JsonArray();
|
|
||||||
builder.pattern.forEach(pattern::add);
|
|
||||||
json.add("pattern", pattern);
|
|
||||||
|
|
||||||
JsonObject key = new JsonObject();
|
|
||||||
builder.key.forEach((c, ingredient) -> key.add(String.valueOf(c), ingredient.toJson()));
|
|
||||||
json.add("key", key);
|
|
||||||
|
|
||||||
JsonObject result = new JsonObject();
|
|
||||||
result.addProperty("item", ForgeRegistries.ITEMS.getKey(builder.result.asItem()).toString());
|
|
||||||
if (builder.count > 1) {
|
|
||||||
result.addProperty("count", builder.count);
|
|
||||||
}
|
|
||||||
json.add("result", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeSerializer<?> getType() {
|
|
||||||
return builder.serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public JsonObject serializeAdvancement() {
|
|
||||||
return builder.hasAdvancementCriterion ? builder.advancementBuilder.serializeToJson() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getAdvancementId() {
|
|
||||||
return builder.hasAdvancementCriterion ? advancementId : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.item.crafting;
|
|
||||||
|
|
||||||
import dev.micle.totemofreviving.item.totem.TotemItem;
|
|
||||||
import dev.micle.totemofreviving.setup.ModRecipes;
|
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
public class TotemRecipe extends ExtendedShapedRecipe {
|
|
||||||
public TotemRecipe(ShapedRecipe recipe) {
|
|
||||||
super(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeSerializer<?> getSerializer() {
|
|
||||||
return ModRecipes.TOTEM_RECIPE.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(CraftingContainer inventory, Level world) {
|
|
||||||
if (!TotemItem.isEnabled(getResultItem())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return getBaseRecipe().matches(inventory, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack assemble(CraftingContainer inventory) {
|
|
||||||
return getBaseRecipe().getResultItem().copy();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package dev.micle.totemofreviving.item.totem;
|
package dev.micle.totemofreviving.item.totem;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.item.charge.DiamondChargeItem;
|
import dev.micle.totemofreviving.item.charge.DiamondChargeItem;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.micle.totemofreviving.item.totem;
|
package dev.micle.totemofreviving.item.totem;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.item.charge.IronChargeItem;
|
import dev.micle.totemofreviving.item.charge.IronChargeItem;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
public class IronTotemItem extends TotemItem {
|
public class IronTotemItem extends TotemItem {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.micle.totemofreviving.item.totem;
|
package dev.micle.totemofreviving.item.totem;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.item.charge.NetheriteChargeItem;
|
import dev.micle.totemofreviving.item.charge.NetheriteChargeItem;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.micle.totemofreviving.item.totem;
|
package dev.micle.totemofreviving.item.totem;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.item.charge.StrawChargeItem;
|
import dev.micle.totemofreviving.item.charge.StrawChargeItem;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package dev.micle.totemofreviving.item.totem;
|
package dev.micle.totemofreviving.item.totem;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.TotemOfReviving;
|
import dev.micle.totemofreviving.network.NetworkManager;
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.network.client.ChangeTargetPacket;
|
import dev.micle.totemofreviving.network.client.ChangeTargetPacket;
|
||||||
import dev.micle.totemofreviving.network.client.ChargeTotemPacket;
|
import dev.micle.totemofreviving.network.client.ChargeTotemPacket;
|
||||||
import dev.micle.totemofreviving.network.NetworkManager;
|
|
||||||
import dev.micle.totemofreviving.network.client.ReviveTargetPacket;
|
import dev.micle.totemofreviving.network.client.ReviveTargetPacket;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import dev.micle.totemofreviving.setup.ModKeyMappings;
|
import dev.micle.totemofreviving.setup.ModKeyMappings;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@ -39,9 +38,9 @@ public abstract class TotemItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TotemItem(Rarity rarity, int durability) {
|
public TotemItem(Rarity rarity, int durability) {
|
||||||
super(new Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(1).rarity(rarity).defaultDurability(durability));
|
super(new Properties().stacksTo(1).rarity(rarity).defaultDurability(durability));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isCharge(ItemStack stack);
|
public abstract boolean isCharge(ItemStack stack);
|
||||||
|
|
||||||
public static int getTargetIndex(ItemStack stack) {
|
public static int getTargetIndex(ItemStack stack) {
|
||||||
@ -146,11 +145,6 @@ public abstract class TotemItem extends Item {
|
|||||||
return getConfig(stack).getCanReviveMoreExpensiveTargets();
|
return getConfig(stack).getCanReviveMoreExpensiveTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(ItemStack stack) {
|
|
||||||
if (!isTotem(stack)) { return false; }
|
|
||||||
return getConfig(stack).getIsEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@ -163,41 +157,37 @@ public abstract class TotemItem extends Item {
|
|||||||
int charge = getCharge(stack);
|
int charge = getCharge(stack);
|
||||||
int maxCharge = getMaxCharge(stack);
|
int maxCharge = getMaxCharge(stack);
|
||||||
double multiplier = getConfig(stack).getChargeCostMultiplier();
|
double multiplier = getConfig(stack).getChargeCostMultiplier();
|
||||||
|
|
||||||
if (getConfig(stack).getIsEnabled()) {
|
if (targetUUID == null) {
|
||||||
if (targetUUID == null) {
|
tooltip.add(Component.literal(ChatFormatting.RED + "Target: " + ChatFormatting.DARK_RED + "NONE"));
|
||||||
tooltip.add(Component.literal(ChatFormatting.RED + "Target: " + ChatFormatting.DARK_RED + "NONE"));
|
|
||||||
} else {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Target: " + ChatFormatting.GRAY + targetName));
|
|
||||||
}
|
|
||||||
tooltip.add(Component.literal(""));
|
|
||||||
if (!canTotemAffordTarget(stack)) {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.RED + "Charges: " + ChatFormatting.DARK_RED + "(" + charge + "/" + targetCost + ") " +
|
|
||||||
ChatFormatting.RED + "[Max: " + ChatFormatting.DARK_RED + maxCharge + ChatFormatting.RED + "] [Multi: " + ChatFormatting.DARK_RED + multiplier + ChatFormatting.RED + "]"));
|
|
||||||
} else {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Charges: " + ChatFormatting.GRAY + "(" + charge + "/" + targetCost + ") " +
|
|
||||||
ChatFormatting.WHITE + "[Max: " + ChatFormatting.GRAY + maxCharge + ChatFormatting.WHITE + "] [Multi: " + ChatFormatting.GRAY + multiplier + ChatFormatting.WHITE + "]"));
|
|
||||||
}
|
|
||||||
if (canReviveMoreExpensiveTargets(stack)) {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive more expensive targets."));
|
|
||||||
}
|
|
||||||
if (canReviveAcrossDimensions(stack)) {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive targets across dimensions."));
|
|
||||||
}
|
|
||||||
tooltip.add(Component.literal(""));
|
|
||||||
if (ModKeyMappings.ADVANCED_TOOLTIP.isDown()) {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Showing advanced tooltip."));
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "R-CLICK" + ChatFormatting.WHITE + "]"));
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is empty: revive target."));
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is holding a reviving charge: charge totem."));
|
|
||||||
tooltip.add(Component.literal(""));
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "L-SHIFT + R-CLICK" + ChatFormatting.WHITE + "]"));
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Change target."));
|
|
||||||
} else {
|
|
||||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Hold [" + ChatFormatting.DARK_GRAY + "L-SHIFT" + ChatFormatting.GRAY + "] for advanced tooltip."));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tooltip.add(Component.literal(ChatFormatting.RED + "Totem is disabled!"));
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Target: " + ChatFormatting.GRAY + targetName));
|
||||||
|
}
|
||||||
|
tooltip.add(Component.literal(""));
|
||||||
|
if (!canTotemAffordTarget(stack)) {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.RED + "Charges: " + ChatFormatting.DARK_RED + "(" + charge + "/" + targetCost + ") " +
|
||||||
|
ChatFormatting.RED + "[Max: " + ChatFormatting.DARK_RED + maxCharge + ChatFormatting.RED + "] [Multi: " + ChatFormatting.DARK_RED + multiplier + ChatFormatting.RED + "]"));
|
||||||
|
} else {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Charges: " + ChatFormatting.GRAY + "(" + charge + "/" + targetCost + ") " +
|
||||||
|
ChatFormatting.WHITE + "[Max: " + ChatFormatting.GRAY + maxCharge + ChatFormatting.WHITE + "] [Multi: " + ChatFormatting.GRAY + multiplier + ChatFormatting.WHITE + "]"));
|
||||||
|
}
|
||||||
|
if (canReviveMoreExpensiveTargets(stack)) {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive more expensive targets."));
|
||||||
|
}
|
||||||
|
if (canReviveAcrossDimensions(stack)) {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive targets across dimensions."));
|
||||||
|
}
|
||||||
|
tooltip.add(Component.literal(""));
|
||||||
|
if (ModKeyMappings.ADVANCED_TOOLTIP.isDown()) {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Showing advanced tooltip."));
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "R-CLICK" + ChatFormatting.WHITE + "]"));
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is empty: revive target."));
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is holding a reviving charge: charge totem."));
|
||||||
|
tooltip.add(Component.literal(""));
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "L-SHIFT + R-CLICK" + ChatFormatting.WHITE + "]"));
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.WHITE + "Change target."));
|
||||||
|
} else {
|
||||||
|
tooltip.add(Component.literal(ChatFormatting.GRAY + "Hold [" + ChatFormatting.DARK_GRAY + "L-SHIFT" + ChatFormatting.GRAY + "] for advanced tooltip."));
|
||||||
}
|
}
|
||||||
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
||||||
}
|
}
|
||||||
@ -206,7 +196,7 @@ public abstract class TotemItem extends Item {
|
|||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
if (!getConfig(player.getItemInHand(hand)).getIsEnabled() || !world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
return super.use(world, player, hand);
|
return super.use(world, player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,14 +2,9 @@ package dev.micle.totemofreviving.network.client;
|
|||||||
|
|
||||||
import dev.micle.totemofreviving.TotemOfReviving;
|
import dev.micle.totemofreviving.TotemOfReviving;
|
||||||
import dev.micle.totemofreviving.item.totem.TotemItem;
|
import dev.micle.totemofreviving.item.totem.TotemItem;
|
||||||
import dev.micle.totemofreviving.network.NetworkManager;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.gui.components.ChatComponent;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
|
||||||
import net.minecraft.network.chat.OutgoingPlayerChatMessage;
|
|
||||||
import net.minecraft.network.chat.PlayerChatMessage;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.micle.totemofreviving.network.client;
|
package dev.micle.totemofreviving.network.client;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.item.totem.TotemItem;
|
import dev.micle.totemofreviving.item.totem.TotemItem;
|
||||||
import dev.micle.totemofreviving.network.NetworkManager;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package dev.micle.totemofreviving.proxy;
|
package dev.micle.totemofreviving.proxy;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
|
||||||
import dev.micle.totemofreviving.data.DataGenerators;
|
|
||||||
import dev.micle.totemofreviving.network.NetworkManager;
|
import dev.micle.totemofreviving.network.NetworkManager;
|
||||||
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import dev.micle.totemofreviving.setup.Registration;
|
import dev.micle.totemofreviving.setup.Registration;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@ -31,7 +30,6 @@ public class Proxy implements IProxy {
|
|||||||
|
|
||||||
// Register mod event bus listeners
|
// Register mod event bus listeners
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
modEventBus.addListener(DataGenerators::gatherData);
|
|
||||||
modEventBus.addListener(Proxy::setup);
|
modEventBus.addListener(Proxy::setup);
|
||||||
modEventBus.addListener(Proxy::imcEnqueue);
|
modEventBus.addListener(Proxy::imcEnqueue);
|
||||||
modEventBus.addListener(Proxy::imcProcess);
|
modEventBus.addListener(Proxy::imcProcess);
|
||||||
|
@ -26,13 +26,13 @@ public final class Config {
|
|||||||
|
|
||||||
builder.comment("WHEN MAKING CHANGES IT IS RECOMMENDED TO NOT BE IN A WORLD.\n" +
|
builder.comment("WHEN MAKING CHANGES IT IS RECOMMENDED TO NOT BE IN A WORLD.\n" +
|
||||||
"CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY.");
|
"CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY.");
|
||||||
STRAW_TOTEM_CONFIG = new TotemConfig(builder, StrawTotemItem.getName(), true, -1, 3,
|
STRAW_TOTEM_CONFIG = new TotemConfig(builder, StrawTotemItem.getName(), -1, 3,
|
||||||
1, false, false, 1);
|
1, false, false, 1);
|
||||||
IRON_TOTEM_CONFIG = new TotemConfig(builder, IronTotemItem.getName(), true, -1, 5,
|
IRON_TOTEM_CONFIG = new TotemConfig(builder, IronTotemItem.getName(), -1, 5,
|
||||||
0.75, false, false, 4);
|
0.75, false, false, 4);
|
||||||
DIAMOND_TOTEM_CONFIG = new TotemConfig(builder, DiamondTotemItem.getName(), true, -1, 10,
|
DIAMOND_TOTEM_CONFIG = new TotemConfig(builder, DiamondTotemItem.getName(), -1, 10,
|
||||||
0.5, false, false, 10);
|
0.5, false, false, 10);
|
||||||
NETHERITE_TOTEM_CONFIG = new TotemConfig(builder, NetheriteTotemItem.getName(), true, 1, 1,
|
NETHERITE_TOTEM_CONFIG = new TotemConfig(builder, NetheriteTotemItem.getName(), 1, 1,
|
||||||
1, true, true, 0);
|
1, true, true, 0);
|
||||||
|
|
||||||
SPEC = builder.build();
|
SPEC = builder.build();
|
||||||
@ -45,7 +45,6 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TotemConfig {
|
public static class TotemConfig {
|
||||||
private final ForgeConfigSpec.BooleanValue IS_ENABLED;
|
|
||||||
private final ForgeConfigSpec.IntValue CHARGE_COST;
|
private final ForgeConfigSpec.IntValue CHARGE_COST;
|
||||||
private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
|
private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT;
|
||||||
private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
|
private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER;
|
||||||
@ -53,13 +52,10 @@ public final class Config {
|
|||||||
private final ForgeConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS;
|
private final ForgeConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS;
|
||||||
private final ForgeConfigSpec.IntValue DURABILITY;
|
private final ForgeConfigSpec.IntValue DURABILITY;
|
||||||
|
|
||||||
public TotemConfig(ForgeConfigSpec.Builder builder, String name, boolean isEnabled, int chargeCost,
|
public TotemConfig(ForgeConfigSpec.Builder builder, String name, int chargeCost,
|
||||||
int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
|
int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets,
|
||||||
boolean canReviveAcrossDimensions, int durability) {
|
boolean canReviveAcrossDimensions, int durability) {
|
||||||
builder.push(name);
|
builder.push(name);
|
||||||
IS_ENABLED = builder
|
|
||||||
.comment("Is the " + name + " enabled?")
|
|
||||||
.define("isEnabled", isEnabled);
|
|
||||||
CHARGE_COST = builder
|
CHARGE_COST = builder
|
||||||
.comment("The charge cost to revive a player.\n" +
|
.comment("The charge cost to revive a player.\n" +
|
||||||
"-1 means the cost is dynamic (follows the amount of deaths the target has)\n" +
|
"-1 means the cost is dynamic (follows the amount of deaths the target has)\n" +
|
||||||
@ -83,8 +79,7 @@ public final class Config {
|
|||||||
.defineInRange("durability", durability, 0, Integer.MAX_VALUE);
|
.defineInRange("durability", durability, 0, Integer.MAX_VALUE);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsEnabled() { return IS_ENABLED.get(); }
|
|
||||||
public int getChargeCost() { return CHARGE_COST.get(); }
|
public int getChargeCost() { return CHARGE_COST.get(); }
|
||||||
public int getChargeCostLimit() { return CHARGE_COST_LIMIT.get(); }
|
public int getChargeCostLimit() { return CHARGE_COST_LIMIT.get(); }
|
||||||
public double getChargeCostMultiplier() { return CHARGE_COST_MULTIPLIER.get(); }
|
public double getChargeCostMultiplier() { return CHARGE_COST_MULTIPLIER.get(); }
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.setup;
|
|
||||||
|
|
||||||
import dev.micle.totemofreviving.item.crafting.ChargeRecipe;
|
|
||||||
import dev.micle.totemofreviving.item.crafting.ExtendedShapedRecipe;
|
|
||||||
import dev.micle.totemofreviving.item.crafting.TotemRecipe;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
|
|
||||||
public class ModRecipes {
|
|
||||||
public static final RegistryObject<RecipeSerializer<?>> TOTEM_RECIPE =
|
|
||||||
Registration.RECIPE_SERIALIZERS.register("totem_recipe", () -> ExtendedShapedRecipe.Serializer.basic(TotemRecipe::new));
|
|
||||||
public static final RegistryObject<RecipeSerializer<?>> CHARGE_RECIPE =
|
|
||||||
Registration.RECIPE_SERIALIZERS.register("charge_recipe", () -> ExtendedShapedRecipe.Serializer.basic(ChargeRecipe::new));
|
|
||||||
|
|
||||||
public static void register() {}
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
package dev.micle.totemofreviving.setup;
|
package dev.micle.totemofreviving.setup;
|
||||||
|
|
||||||
import dev.micle.totemofreviving.TotemOfReviving;
|
import dev.micle.totemofreviving.TotemOfReviving;
|
||||||
|
import dev.micle.totemofreviving.event.common.OnCreativeModeTabRegisterEventHandler;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
@ -12,16 +12,13 @@ public class Registration {
|
|||||||
// Initialize variables
|
// Initialize variables
|
||||||
public static final DeferredRegister<Item> ITEMS =
|
public static final DeferredRegister<Item> ITEMS =
|
||||||
DeferredRegister.create(ForgeRegistries.ITEMS, TotemOfReviving.MOD_ID);
|
DeferredRegister.create(ForgeRegistries.ITEMS, TotemOfReviving.MOD_ID);
|
||||||
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS =
|
|
||||||
DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, TotemOfReviving.MOD_ID);
|
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
ITEMS.register(modEventBus);
|
ITEMS.register(modEventBus);
|
||||||
ModItems.register();
|
ModItems.register();
|
||||||
|
|
||||||
RECIPE_SERIALIZERS.register(modEventBus);
|
modEventBus.register(OnCreativeModeTabRegisterEventHandler.class);
|
||||||
ModRecipes.register();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
modLoader = "javafml" #mandatory
|
modLoader = "javafml" #mandatory
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
loaderVersion = "[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
loaderVersion = "[45,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||||
license = "All Rights Reserved"
|
license = "All Rights Reserved"
|
||||||
@ -43,7 +43,7 @@ Mod for reviving players in a hardcore world.
|
|||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory = true #mandatory
|
mandatory = true #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange = "[43,)" #mandatory
|
versionRange = "[45,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
@ -53,6 +53,6 @@ Mod for reviving players in a hardcore world.
|
|||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange = "[1.19.2,1.20)"
|
versionRange = "[1.19.4,1.20)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"itemGroup.totemofreviving": "Micle's Totem of Reviving",
|
"tabs.totemofreviving.main_tab": "Micle's Totem of Reviving",
|
||||||
"item.totemofreviving.straw_totem": "Straw totem of reviving",
|
"item.totemofreviving.straw_totem": "Straw totem of reviving",
|
||||||
"item.totemofreviving.iron_totem": "Iron totem of reviving",
|
"item.totemofreviving.iron_totem": "Iron totem of reviving",
|
||||||
"item.totemofreviving.diamond_totem": "Diamond totem of reviving",
|
"item.totemofreviving.diamond_totem": "Diamond totem of reviving",
|
||||||
|
Reference in New Issue
Block a user