• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi I am a bit new in Minecraft. I want to make an axe that can spit lighting when I right click on my mouse. When I execute below code, I was hoping it would strike a cow that is front of my character, but all it did was produced the lightning sound, but I don't see any lightning anywhere. I thought my code, would produce a lighting 20 steps in front of me.   I think what I was missing in my code was a way to get a reference to the animal (cow) in front of me. I feel if I can get a reference of cow in front of me, I can set the my LightningBoltEntity to that animal position. But this is just a guess package com.ayclogic.aycfirstmod.item; import com.ayclogic.aycfirstmod.init.ModItemGroup; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class AycLightningAxe extends AxeItem { public static final Logger LOGGER = LogManager.getLogger(AycFireballAxe.class); public AycLightningAxe() { super(ItemTier.IRON, 6.0F, -3.1F, new Item.Properties().group(ModItemGroup.MOD_ITEM_GROUP)); } public AycLightningAxe(IItemTier tier, float attackDamageIn, float attackSpeedIn, Item.Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand handIn) { if (!world.isRemote) { Vec3d vec3d = player.getEyePosition(1.0F); Vec3d vec3d1 = player.getLook(1.0F); Vec3d vec3d2 = vec3d.add(20, 0, 0); BlockPos blockPos = new BlockPos(vec3d2); LightningBoltEntity lightning = new LightningBoltEntity(world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), false); ItemStack itemStack = player.getHeldItem(handIn); itemStack.damageItem(1, player, (p_220040_1_) -> { p_220040_1_.sendBreakAnimation(handIn); }); world.addEntity(lightning); } LOGGER.info("********** Abigail Lighting swing **************"); return super.onItemRightClick(world, player, handIn); } //AycLightningAxe }   Any assistance would be greatly appreciated.
    • You’ll want your own recipe.   Someone’s done this for 1.15, https://github.com/jacktheminecraftmodder/AllTheThings https://github.com/jacktheminecraftmodder/AllTheThings/blob/master/src/main/resources/data/allm/recipes/_factories.json https://github.com/jacktheminecraftmodder/AllTheThings/blob/master/src/main/resources/data/allm/recipes/test_item.json  
    • When you launch the game are those mods loaded (i.e. are the mods in your libs/mods folder)?
    • You can use a lambda for this Also, use @Override https://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why   Your subscription looks right, place a breakpoint to make sure it gets called though. 
    • http://tutorials.jenkov.com/java/ternary-operator.html
  • Topics

  • Who's Online (See full list)