Создаю мод для minecraft в eclipse. Хочу изменить положение рук.

Версия Minecraft
1.12.2
Создаю мод на супер героев. Работаю над тором. Хочу сделать что бы его правая рука была поднята в верх если игрок приседает и зажимает правую кнопку мыши (если у него в руках топор тора(уже сделанный)), но не я не профи. Прошу помочь вас. Если вы скинете уже готовый код, то я буду вам благодарен.


КОД ТОПОРА ТОРА:
Java:
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraft.world.World;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.EnumAction;
import net.minecraft.init.Items;
import net.minecraft.init.Enchantments;
import net.minecraft.init.Blocks;
import net.minecraft.entity.projectile.EntityTippedArrow;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.Block;

import java.util.Random;
import java.util.HashMap;

public class mcreator_axeThor {

    public mcreator_axeThor() {
    }

    public static Item block;
    public static Object instance;

    public void load(FMLInitializationEvent event) {
        if (event.getSide() == Side.CLIENT) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                    .register(block, 0, new ModelResourceLocation("testenvironmentmod:axethor", "inventory"));
        }
    }

    @SideOnly(Side.CLIENT)
    public void registerRenderers() {
        RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(),
                new ItemStack(Blocks.AIR).getItem(), Minecraft.getMinecraft().getRenderItem()));
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
        EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:entitybulletaxethor"), EntityArrowCustom.class, "entitybulletaxethor",
                2, instance, 64, 1, true);
        ForgeRegistries.ITEMS.register(block);
    }

    static {
        block = (new ItemgGUN());
    }

    static class ItemgGUN extends Item {

        public ItemgGUN() {
            super();
            setMaxDamage(10000);
            maxStackSize = 1;
            setFull3D();
            setUnlocalizedName("axethor");
            setRegistryName("axethor");
            setCreativeTab(mcreator_coreTab.tab);
        }

        @Override
        public int getMaxItemUseDuration(ItemStack par1ItemStack) {
            return 72000;
        }

        @Override
        public ActionResult<ItemStack> onItemRightClick(World par2World, final EntityPlayer par3EntityPlayer, EnumHand hand) {
            ItemStack par1ItemStack = par3EntityPlayer.getHeldItem(hand);
            boolean flag = par3EntityPlayer.capabilities.isCreativeMode
                    || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, par1ItemStack) > 0;
            if (flag || par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.BLAZE_ROD))) {
                float f = 10.0F;
                EntityArrowCustom entityarrow = new EntityArrowCustom(par2World, par3EntityPlayer);
                entityarrow.shoot(par3EntityPlayer.getLookVec().x, par3EntityPlayer.getLookVec().y, par3EntityPlayer.getLookVec().z, f * 2.0F, 0);
                entityarrow.setIsCritical(false);
                entityarrow.setDamage(16.0);
                entityarrow.setKnockbackStrength(1);
                if (true) {
                    entityarrow.setFire(100);
                }
                par1ItemStack.damageItem(1, par3EntityPlayer);
                int i = (int) par3EntityPlayer.posX;
                int j = (int) par3EntityPlayer.posY;
                int k = (int) par3EntityPlayer.posZ;
                par2World.playSound((EntityPlayer) null, (double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D,
                        (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
                                ("entity.lightning.thunder"))), SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
                if (flag) {
                    entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                } else {
                    par3EntityPlayer.inventory.clearMatchingItems(new ItemStack(Items.BLAZE_ROD).getItem(), -1, 1, null);
                }
                if (!par2World.isRemote) {
                    par2World.spawnEntity(entityarrow);
                }
                World world = par2World;
                EntityPlayer entity = par3EntityPlayer;
                ItemStack itemstack = par1ItemStack;
            }
            return new ActionResult(EnumActionResult.SUCCESS, par1ItemStack);
        }

        @Override
        public EnumAction getItemUseAction(ItemStack par1ItemStack) {
            return EnumAction.BOW;
        }
    }

    public static class EntityArrowCustom extends EntityTippedArrow {

        public EntityArrowCustom(World a) {
            super(a);
        }

        public EntityArrowCustom(World worldIn, double x, double y, double z) {
            super(worldIn, x, y, z);
        }

        public EntityArrowCustom(World worldIn, EntityLivingBase shooter) {
            super(worldIn, shooter);
        }

        @Override
        public void onCollideWithPlayer(EntityPlayer entity) {
            super.onCollideWithPlayer(entity);
            int i = MathHelper.floor(this.getEntityBoundingBox().minX + 0.001D);
            int j = MathHelper.floor(this.getEntityBoundingBox().minY + 0.001D);
            int k = MathHelper.floor(this.getEntityBoundingBox().minZ + 0.001D);
            World world = this.world;
            java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
            dependencies.put("x", i);
            dependencies.put("y", j);
            dependencies.put("z", k);
            dependencies.put("world", world);
            dependencies.put("entity", entity);
            mcreator_axeThorProcedure.executeProcedure(dependencies);
        }

        @Override
        public void onUpdate() {
            super.onUpdate();
            int i = MathHelper.floor(this.getEntityBoundingBox().minX + 0.001D);
            int j = MathHelper.floor(this.getEntityBoundingBox().minY + 0.001D);
            int k = MathHelper.floor(this.getEntityBoundingBox().minZ + 0.001D);
            World world = this.world;
            Entity entity = (Entity) shootingEntity;
            {
            }
            if (getBlock(this.world, i, j, k) != Blocks.AIR || getBlock(this.world, i, j - 1, k) != Blocks.AIR
                    || getBlock(this.world, i, j + 1, k) != Blocks.AIR || getBlock(this.world, i + 1, j, k) != Blocks.AIR
                    || getBlock(this.world, i - 1, j, k) != Blocks.AIR || getBlock(this.world, i, j, k + 1) != Blocks.AIR
                    || getBlock(this.world, i, j, k - 1) != Blocks.AIR) {
                java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
                dependencies.put("x", i);
                dependencies.put("y", j);
                dependencies.put("z", k);
                dependencies.put("world", world);
                dependencies.put("entity", entity);
                mcreator_axeThorProcedure.executeProcedure(dependencies);
                this.world.removeEntity(this);
            }
        }

        public Block getBlock(World par1World, int i, int j, int k) {
            return par1World.getBlockState(new BlockPos(i, j, k)).getBlock();
        }
    }
}
 
Последнее редактирование модератором:
Решение
Код на 1.7.10, но думаю подойдёт. В рендеринге не шарю, тем более на 12.2, так что другие подскажут.
P.S. Это в предмет.
Java:
    public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
        if(player.isSneaking()) {
            //Рендеришь и добавляешь действие.
        }
        return is;
    }
Я тебе уже объяснял в той теме про код. Это в правилах прописано, прочитай. И да... MCreator выруби.
1,357
110
233
Код на 1.7.10, но думаю подойдёт. В рендеринге не шарю, тем более на 12.2, так что другие подскажут.
P.S. Это в предмет.
Java:
    public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
        if(player.isSneaking()) {
            //Рендеришь и добавляешь действие.
        }
        return is;
    }
Я тебе уже объяснял в той теме про код. Это в правилах прописано, прочитай. И да... MCreator выруби.
 
Последнее редактирование:
Сверху