
ANtonYL
Members-
Posts
8 -
Joined
-
Last visited
Everything posted by ANtonYL
-
Hi, guys, is there any way to auto-grant a root advancement whenever the player logs in? I've tried using minecraft:tick and InventoryChangeTrigger, but the first one doesn't work, and the second one doesn't guarantee a log-in-grant. I'm using 1.20.1 public class ModAdvancementGenerator implements ForgeAdvancementProvider.AdvancementGenerator { @Override public void generate(HolderLookup.Provider registries, Consumer<Advancement> saver, ExistingFileHelper existingFileHelper) { // Define a root advancement. Advancement root = Advancement.Builder.advancement() .display( ModItems.COMPRESSED_DIAMOND.get(), // Icon Component.literal("Compressed"), // Title Component.literal("Explore Compressed tools and armor!"), // Description new ResourceLocation("compressed","textures/block/compressed_diamond_block.png"), // Background image (null if not used) FrameType.TASK, // Frame type (TASK, GOAL, or CHALLENGE) true, // Show toast? true, // Announce in chat? false // Hidden? ) /* .addCriterion("tick", new InventoryChangeTrigger.TriggerInstance()); ????????????????????????????????????????????????????? */ // Notice we now pass the advancement ID as a string (the path part) plus the existingFileHelper. .save(saver, new ResourceLocation("compressed","compressed_root_advancement"), existingFileHelper); } }
-
Hi, I'm trying to add a chance for the LootTableIdCondition. I've tried to manipulate the AddItemModifier class, but it still doesn't work: public class AddItemModifier extends LootModifier { public static final Supplier<Codec<AddItemModifier>> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst).and(ForgeRegistries.ITEMS.getCodec() .fieldOf("item").forGetter(m -> m.item)) .and(Codec.FLOAT.fieldOf("chance").forGetter(m -> m.chance)) .apply(inst, AddItemModifier::new))); private final Item item; public AddItemModifier(LootItemCondition[] conditionsIn, Item item) { super(conditionsIn); this.item = item; } @Override protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) { if(context.getRandom().nextFloat() < chance) { generatedLoot.add(new ItemStack(this.item)); } for(LootItemCondition condition : this.conditions) { if(!condition.test(context)) { return generatedLoot; } } generatedLoot.add(new ItemStack(this.item)); return generatedLoot; } @Override public Codec<? extends IGlobalLootModifier> codec() { return CODEC.get(); } } the only problem is the two "chance" are not defined, but when I add a private final Float chance, the AddItemModifier::new is in red underline, and there's an error. Is there a way to solve this, or is there another better way to add a chance to chest loot modifiers?
-
Thank you so much. Also, is it possible to make the name of the sword constantly changing colors and show "+infinity attack damage "?
-
How can I add drops when killing an entity? Now there are no drops. How can I add an @override to change the attack speed to 1.6 and show "when in main hand...attack damage,...attack speed"? also, how can I make the item enchantable?
-
Ok. Thanks. by the way, will this crash in any circumstances? public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { if (entity instanceof LivingEntity){ LivingEntity victim = (LivingEntity) entity; if(!victim.isDeadOrDying() && victim.getHealth()>0){ victim.setHealth(0); return true; } } return false; }
-
Hi, can anybody tell me what's wrong? public class SoulDrinkerItem extends Item { public SoulDrinkerItem(Properties pProperties) { super(pProperties); } @Override public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { if (entity instanceof Player){ Player victim = (Player) entity; if(!victim.isDeadOrDying() && victim.getHealth()>0){ victim.setHealth(0); return true; } } return false; } @Override public void setDamage(ItemStack stack, int damage) { super.setDamage(stack, 0); } } The code above is the custom item class. I'm trying to make a Sword-of-the-Cosmos-like item that basically does .setHealth(0) for every single entity it hits. When I go into the game, the attack damage is just 1.
-
Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error: Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?