Jump to content

Recommended Posts

Posted (edited)

Hi, I am kind of new in Minecraft modding. I was following a video on how to create a custom Axe and shield for minecraft 1.12. It worked great. But when I realized the latest version of minecraft is 1.15, it seems like the code in 1.12 is completely broken in 1.15. And there isn't a good documentation 

 

Below is the code that is working in 1.12, but not in 1.15

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

public class CustomAxe extends ItemAxe {

	public int power = 3;
	public String axeName = "my_axe";



	public CustomAxe(ToolMaterial material) {
		super(material, 1, 1);

		this.setUnlocalizedName(axeName);
		this.setRegistryName(axeName);
		this.setCreativeTab(CreativeTabs.COMBAT);
		this.setMaxDamage(power);
	}

	@Override
	public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
		if(!world.isRemote) {
			world.spawnEntity(createFireball(world, player, power));
		}

		return super.onItemRightClick(world, player, hand);
	}

	public static EntityLargeFireball createFireball(World world, EntityPlayer player, int power){
		EntityLargeFireball fireball =new EntityLargeFireball(world,player.posX,player.posY+2,player.posZ, player.getLookVec().x,player.getLookVec().y,player.getLookVec().z);
		fireball.explosionPower = power;
		fireball.shootingEntity = player;
		fireball.rotationPitch = player.rotationPitch;
		fireball.rotationYaw = player.rotationYaw;
		return fireball;
	}
}

 

Any idea how to convert above 1.12 code to 1.15?

Any 1.15 guide / documentation / tutorial?

Edited by gamas
Posted

I would try to make it work for 1.15.1 or .2, and also make sure your code is a working github repository. This will make it so if someone wants, they can clone your repository and build it themselves to help debug it if they have the time and/or inclination.

Then link to it here with errors you get that you cannot figure out, and post logs if it runs but crashes.

 

I did find the link that describes many of the changes that came after 1.12, so it may help.

https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a

Posted

I think I got it. This is how I create custom Axe which spit fireball in 1.15

package com.ayclogic.aycfirstmod.item;

import com.ayclogic.aycfirstmod.init.ModItemGroup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.FireballEntity;
import net.minecraft.item.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class AycAxe extends AxeItem {
    public static final Logger LOGGER = LogManager.getLogger(AycAxe.class);
    public int fireballStrength = 3;
    public AycAxe() {
        super(ItemTier.IRON, 6.0F, -3.1F, new Item.Properties().group(ModItemGroup.MOD_ITEM_GROUP));
    }
    public AycAxe(IItemTier tier, float attackDamageIn, float attackSpeedIn, Item.Properties builder) {
        super(tier, attackDamageIn, attackSpeedIn, builder);
    }

    public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand handIn) {

        FireballEntity fireballentity = new FireballEntity(world, player,player.getLookVec().x,player.getLookVec().y,player.getLookVec().z);
        fireballentity.explosionPower = fireballStrength;
        fireballentity.rotationPitch = player.rotationPitch;
        fireballentity.rotationYaw = player.rotationYaw;
        fireballentity.setPosition(player.getPosX(), player.getPosY()+2, player.getPosZ());
        world.addEntity(fireballentity);

        LOGGER.info("********** Magic Axe swing **************");
        return super.onItemRightClick(world, player, handIn);
    }
}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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