Модели

Версия Minecraft
1.11+
Как менять модель предмета относительно с предметом который находиться в предмете

Java:
package com.superheroes.superheroesmod.gui;

import javax.annotation.Nullable;

import com.superheroes.superheroesmod.SuperheroesMain;
import com.superheroes.superheroesmod.items.StoneSoul;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.superheroes.superheroesmod.items.StoneSoul;

import static com.superheroes.superheroesmod.items.ItemsRegister.*;

public class StandartSlot extends Slot {

    //Это по сути копитя обычного ванильного слота

    private final EntityPlayer thePlayer;
    private int removeCount;

    public StandartSlot(EntityPlayer player, IInventory inventoryIn, int slotIndex, int xPosition, int yPosition){

        super(inventoryIn, slotIndex, xPosition, yPosition);
        this.thePlayer = player;
    }

    /*    Может ли даный стак быть положен в этот слот. Здесь могут быть проверки, например если вы хотите
        чтоб в слот нельзя было положить яблоко, проверяете равен ли предмет в стаке яблоку, если да, то
        возвращаем false

    */


    @Override
    public boolean isItemValid(ItemStack itemStack) {
        if (this.getSlotIndex() == 0 && itemStack.getItem() == PowerStone) {
            return true;
        }
       else if (this.getSlotIndex() == 1 && itemStack.getItem() == MindStone) {
            return true;
        }
       else if (this.getSlotIndex() == 2 && itemStack.getItem() == SoulStone) {
            return true;
        }
       else if (this.getSlotIndex() == 3 && itemStack.getItem() == TimeStone) {
            return true;
        }
       else if (this.getSlotIndex() == 4 && itemStack.getItem() == RealityStone) {
            return true;
        }
       else if (this.getSlotIndex() == 5 && itemStack.getItem() == SpaceStone) {
            return true;
        }
        else {
            return false;
        }
    }

    public ItemStack decrStackSize(int amount){

        if (this.getHasStack()){
            this.removeCount += Math.min(amount, this.getStack().getCount());
        }

        return super.decrStackSize(amount);
    }

    //Что происходит, если забрать предмет из слота
    public ItemStack onTake(EntityPlayer player, ItemStack stack){


        this.onCrafting(stack);
        super.onTake(player, stack);
        return stack;
    }

    protected void onCrafting(ItemStack stack, int amount){

        this.removeCount += amount;
        this.onCrafting(stack);
    }

    protected void onCrafting(ItemStack stack){

        stack.onCrafting(this.thePlayer.world, this.thePlayer, this.removeCount);
        this.removeCount = 0;
    }
}
Java:
package com.superheroes.superheroesmod.items;

import com.superheroes.superheroesmod.SuperheroesMain;
import com.superheroes.superheroesmod.gui.NetworkHandler;
import com.superheroes.superheroesmod.gui.OpenInventoryMessage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import com.superheroes.superheroesmod.key.KeyHandler;


public class GauntletThanos extends Item {

    public GauntletThanos(String name, int maxStackSize)
    {
        this.setRegistryName(name);
        this.setUnlocalizedName(name);
        this.setCreativeTab(SuperheroesMain.SuperheroTab);
        this.setMaxStackSize(1);
    }



    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
        if(worldIn.isRemote){
            NetworkHandler.network.sendToServer(new OpenInventoryMessage());
        }
        return new ActionResult(EnumActionResult.SUCCESS , playerIn.getHeldItem(handIn));

    }
}
 
Как менять модель предмета относительно с предметом который находиться в предмете
Чот я не понял. Типа, есть предмет А с определенной моделью. И если в одном инвентаре есть предмет Б, то модель предмета А, трисовывающуюся в инвентаре, нужно изменить?
 
Назад
Сверху