Jump to content

BlockyPenguin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by BlockyPenguin

  1. Okay, so this is kind of a follow-up to this post, so, I've now made a potion, and in the creative inventory, it appears. So do the Lingering and Splash variants. I do not want this. In the aforementioned post, diesieben07 mentioned using an IBrewingRecipe to do this. I have tried creating one for my potion, but I ended up deleting it in favour of BrewingRecipeRegistry.addRecipe(). However, my recipe doesn't work (I can't even insert my custom item that I want to use as an ingredient into a brewing stand), and I've no idea where in an IBrewingRecipe I''d disable potion variants. I'm 100% new to potions, how would I do this? All help appreciated! [Merged from a comment and edited to fit the present] Okay, now, I've made a new IBrewingRecipe class called FlyingPotionRecipe, here's the code: package ... import ... public class FlyingPotionRecipe implements IBrewingRecipe { private ItemStack output = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), ModPotions.FLYING_POTION); @Override public boolean isInput(ItemStack input) { return input.getItem() == PotionUtils.addPotionToItemStack(input, Potions.WATER).getItem(); } @Override public boolean isIngredient(ItemStack ingredient) { return ingredient.getItem() == ModItems.GOLDEN_FEATHER; } @Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) { return PotionUtils.addPotionToItemStack(output, ModPotions.FLYING_POTION); } } So, I've tested that now, and all looks good, but where in here would I set the splash and lingering potions on/off? TIA!
  2. It works! thank you so much! Just a sidenote, other than using affectEntity, are there any special methods/classes that I'd need to use for an instant potion? EDIT: Also, how would I disable splash and lingering potion types for a potion, whilst keeping the standard drinkable potion?
  3. Ah okay! I was wondering about the Effect#applyAttributesModifiersToEntity and Effect#removeAttributesModifiersFromEntity methods, but I didn't think they were relevant. Thank you so much. Okay, I've tried that now, and the code gets called, and my NBT data gets updated (I did /data get @s, and I saw mayFly: 1b.), but... I still can't fly. What's gone wrong? package com.blockypenguin.labkit.effects; import com.blockypenguin.labkit.LabKit; import com.blockypenguin.labkit.util.list.ModEffects; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AbstractAttributeMap; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectType; import net.minecraft.potion.Effects; import net.minecraft.util.text.ITextComponent; public class FlyingEffect extends Effect { public FlyingEffect() { super(EffectType.BENEFICIAL, 0x87cefa); setRegistryName("flying"); } @Override public void removeAttributesModifiersFromEntity(LivingEntity entity, AbstractAttributeMap attributeMap, int amplifier) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; player.abilities.isFlying = false; player.abilities.allowFlying = false; }else { entity.removeActivePotionEffect(Effects.LEVITATION); } } @Override public void applyAttributesModifiersToEntity(LivingEntity entity, AbstractAttributeMap attributeMap, int amplifier) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; player.abilities.allowFlying = true; if(player.getActivePotionEffect(ModEffects.FLYING).getDuration() == 100) { player.sendStatusMessage(ITextComponent.Serializer.fromJson("You will stop flying in 5 seconds!"), true); } }else { entity.addPotionEffect(new EffectInstance(Effects.LEVITATION, 200, 3)); } } }
  4. Hey! I'd like to potion (which I already have, as well as the long variant, and the respective effect), where, when a player gets the effect, they can fly as if in creative. Here is my code as it stands: package com.blockypenguin.labkit.effects; import com.blockypenguin.labkit.util.list.ModEffects; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectType; import net.minecraft.potion.Effects; import net.minecraft.util.text.ITextComponent; public class FlyingEffect extends Effect { public FlyingEffect() { super(EffectType.BENEFICIAL, 0x87cefa); setRegistryName("flying"); } @Override public void affectEntity(Entity source, Entity indirectSource, LivingEntity entity, int amplifier, double health) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; player.abilities.allowFlying = true; player.abilities.isFlying = true; if(player.getActivePotionEffect(ModEffects.FLYING).getDuration() == 100) { player.sendStatusMessage(ITextComponent.Serializer.fromJson("You will stop flying in 5 seconds!"), true); } if(player.getActivePotionEffect(ModEffects.FLYING).getDuration() <= 1) { player.abilities.isFlying = false; player.abilities.allowFlying = false; } }else { entity.addPotionEffect(new EffectInstance(Effects.LEVITATION, 200, 3)); } super.affectEntity(source, indirectSource, entity, amplifier, health); } } But it doesn't do anything, as if the code never gets run. What have I done wrong? All help appreciated. Thanks!
  5. Hi, I'm wondering if it's possible to change the size of a player (or preferably any entity) in 1.14? I've been playing around with snippets of other mods' code from GitHub, and following old tutorials (and doing my best to update them), but I haven't found a solution. I'm looking to shrink and grow entities, changing the rendered player and the collision box, etc, like what the gulliver mod did, for example. Is it still possible? Thanks EDIT: I should probably mention that I'm trying to do this from a potion. 2nd EDIT: Forget that, I'd prefer a block to do it to whoever is in front of it, I can handle that, but not the size change... Help? Pls?
  6. Oh, I've done that too, forgot to mention it, sorry. How would I write it to the tile entity then?
  7. I created an EffectInstance and passed some CompoundNBT in the .write method.
  8. Okay, so I've added this code to my block's constructor: CompoundNBT nbt = new CompoundNBT(); EffectInstance potion = new EffectInstance(Effects.LUCK, 6000); potion.write(nbt); but if I run "/data get block <x> <y> <z>" ingame, it doesn't give me any info on the potion, just the x, y, z and id, so I'm guessing it isn't writing properly. Nothing seems to be amiss in the logs. Please forgive me if I'm missing something important here, this is my first time working with TileEntities.
  9. Cool, thx.
  10. So, I'm looking to make a block that, when right-clicked with a potion, will store that potion's data (effect and length) in some blockdata, then when the player right clicks again with an empty hand, it gives them the correct effect for the correct amount of time. If that sounds too op, don't worry, it only has three uses Edit: Or maybe I could use a String if that's possible? labkit:potiondispensary[potion="speed",time="8:00",level=3]
  11. Hi, I'm fairly new to modding, and I'd like to know if it's possible to store a potion's effect (e.g. slowness, invisibility, strength, etc) inside of some blockdata. If not, how else could I do this?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.