Jump to content

Recommended Posts

Posted

I call it from onKeyPressed() event. Now i can see my GUI and items, but I can't edit it.  Items just go back in their slots when I try to take them. Is it GUI problem or I need to fully setup my messages and message handlers first? I have class GUICustomPlayerInventory extends GuiContainer and separate inventory stored in extendedProperties of player. I want to fully replace standart player inventory with mine. What's simplier: to overriding player.inventory or using my current method?

Posted

I made message and message handler, but I can't open inventory again. Server receives message (it logs it) and then executes EntityPlayer.openGui method

@Override

    public IMessage onMessage(CustomPlayerOpenInventoryMessage message, MessageContext ctx) {

        if (ctx.side == Side.SERVER) {

            System.out.println("Received message from " + ctx.getServerHandler().playerEntity.getCommandSenderName());

            ((EntityPlayer) ctx.getServerHandler().playerEntity).openGui(TESItems.instance, 0, ((EntityPlayer) ctx.getServerHandler().playerEntity).worldObj, 0, 0, 0);

        }

        return null;

    }

 

Here's message class:

 

public class CustomPlayerOpenInventoryMessage implements IMessage {

 

    public CustomPlayerOpenInventoryMessage() {}

 

    @Override

    public void fromBytes(ByteBuf buf) {

    }

 

    @Override

    public void toBytes(ByteBuf buf) {

    }

}

 

 

Posted

full handler class:

 

public class CustomPlayerOpenInventoryHandler implements IMessageHandler<CustomPlayerOpenInventoryMessage, IMessage> {

 

    public CustomPlayerOpenInventoryHandler() {}

 

    @Override

    public IMessage onMessage(CustomPlayerOpenInventoryMessage message, MessageContext ctx) {

        if (ctx.side == Side.SERVER) {

            System.out.println("Received message from " + ctx.getServerHandler().playerEntity.getCommandSenderName());

            ((EntityPlayer) ctx.getServerHandler().playerEntity).openGui(TESItems.instance, 0, ((EntityPlayer) ctx.getServerHandler().playerEntity).worldObj, 0, 0, 0);

        }

        return null;

    }

}

 

 

 

Posted

Here's GUI handler:

 

public class CustomPlayerGUIHandler implements IGuiHandler {

    @Override

    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

        return new CustomPlayerContainer(player, player.inventory, ((CustomPlayer)player.getExtendedProperties("CustomPlayer")).inventory);

    }

    @Override

    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {

        return new GUICustomPlayerInventory(player, player.inventory, ((CustomPlayer)player.getExtendedProperties("CustomPlayer")).inventory);

    }

}

 

,

message handler:

 

public class CustomPlayerOpenInventoryHandler implements IMessageHandler<CustomPlayerOpenInventoryMessage, IMessage> {

    public CustomPlayerOpenInventoryHandler() {}

    @Override

    public IMessage onMessage(CustomPlayerOpenInventoryMessage message, MessageContext ctx) {

        if (ctx.side == Side.SERVER) {

            System.out.println("Received message from " + ctx.getServerHandler().playerEntity.getCommandSenderName());

            ctx.getServerHandler().playerEntity.openGui(TESItems.instance, 0, ctx.getServerHandler().playerEntity.worldObj, 0, 0, 0);

        }

        return null;

    }

}

 

 

 

Registration of handlers:

 

networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("customPlayerChannel");

networkWrapper.registerMessage(CustomPlayerOpenInventoryHandler.class, CustomPlayerOpenInventoryMessage.class, 1, Side.SERVER);

NetworkRegistry.INSTANCE.registerGuiHandler(this, new CustomPlayerGUIHandler());

 

It receives message, but GUI doesn't work

Posted

Here's key listener:

 

 

@SubscribeEvent

    public void onKeyInput(InputEvent.KeyInputEvent event) {

        if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) {

            int kb = Keyboard.getEventKey();

            boolean isDown = Keyboard.getEventKeyState();

            if (kb == keys[CUSTOM_INV].getKeyCode()) {

                TESItems.networkWrapper.sendToServer(new CustomPlayerOpenInventoryMessage());

            }

        }

    }

 

 

I don't close GUI, and problem is not in it, because it was working earlier.

 

GUI:

public class GUICustomPlayerInventory extends GuiContainer {

    private int xSize = 218, ySize = 300;

    private final CustomPlayerInventory inventory;

    ResourceLocation resourceLocation = new ResourceLocation("tesitems:textures/gui/custom_inventory.png");

 

    public GUICustomPlayerInventory(EntityPlayer player, InventoryPlayer inventoryPlayer, CustomPlayerInventory inventoryCustom) {

        super(new CustomPlayerContainer(player, inventoryPlayer, inventoryCustom));

        this.inventory = inventoryCustom;

        this.guiLeft = (this.width - this.xSize) / 2;

        this.guiTop = (this.height - this.ySize) / 2;

    }

 

    @Override

    protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {

        GL11.glColor4f(0,0,0,100);

        Minecraft.getMinecraft().renderEngine.bindTexture(resourceLocation);

        GL11.glEnable(GL11.GL_BLEND);

        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        Tessellator t = Tessellator.instance;

        t.startDrawingQuads();

        t.addVertexWithUV(guiLeft, guiTop, 0, 0, 0);

        t.addVertexWithUV(guiLeft, guiTop + ySize, 0, 0, 1);

        t.addVertexWithUV(guiLeft + xSize, guiTop + ySize, 0, 1, 1);

        t.addVertexWithUV(guiLeft + xSize, guiTop, 0, 1, 0);

        t.draw();

        GL11.glDisable(GL11.GL_BLEND);

    }

 

    @Override

    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {

    }

}

 

 

Posted

Only thing I can see is you are sending the message twice - once when the key is pressed, and again when it is released. You should add ' && isDown' to your condition.

 

You're not getting any error messages at all in your console log?

 

Show your Container class, then, since that is the only other thing that has been added since it stopped working.

Posted

Container:

 

public class CustomPlayerContainer extends Container {

    private static final int ARMOR_START = 0, ARMOR_END = 3, HANDS_START = 4, HANDS_END = 5, INV_START = 6;

    private static int INV_END;

 

    InventoryPlayer inventoryPlayer;

    CustomPlayerInventory customPlayerInventory;

 

    @Override

    public boolean canInteractWith(EntityPlayer player) {

        return true;

    }

 

    private int size;

 

    public CustomPlayerContainer(EntityPlayer player, InventoryPlayer inventoryPlayer, CustomPlayerInventory customPlayerInventory) {

        this.inventoryPlayer = inventoryPlayer;

        this.customPlayerInventory = customPlayerInventory;

        size = customPlayerInventory.getSizeInventory();

        INV_END = size-1;

        addSlotToContainer(new ArmorSlot(player, customPlayerInventory, 0, 10, 10, 0));//helmet

        addSlotToContainer(new ArmorSlot(player, customPlayerInventory, 1, 10, 29, 1));//chestplate

        addSlotToContainer(new ArmorSlot(player, customPlayerInventory, 2, 10, 48, 2));//leggings

        addSlotToContainer(new ArmorSlot(player, customPlayerInventory, 3, 10, 67, 3));//boots

        addSlotToContainer(new Slot(customPlayerInventory, 4, 29, 29));//hand 1

        addSlotToContainer(new Slot(customPlayerInventory, 5, 48, 29));//hand 2

        for (int i = 0; i < size; i++) {

            addSlotToContainer(new Slot(customPlayerInventory, 6 + i, 29 + i * 19, 10));

        }

    }

 

    public void updateSlots() {

        if (customPlayerInventory.getSizeInventory() > size) {

            for (int i = size; i < customPlayerInventory.getSizeInventory(); i++) {

                addSlotToContainer(new Slot(customPlayerInventory, 6 + size, 29 + i * 19, 10));

            }

        }

    }

 

    @Override

    public ItemStack transferStackInSlot(EntityPlayer player, int par2)

    {

        ItemStack itemstack = null;

        Slot slot = (Slot) this.inventorySlots.get(par2);

        if (slot != null && slot.getHasStack()) {

            ItemStack itemstack1 = slot.getStack();

            itemstack = itemstack1.copy();

            if (par2 < HANDS_START) {

                if (!this.mergeItemStack(itemstack1, HANDS_START, INV_END + 1, true)) {

                    return null;

                }

                slot.onSlotChange(itemstack1, itemstack);

            } else {

                if (itemstack1.getItem() instanceof ItemArmor) {

                    int type = ((ItemArmor) itemstack1.getItem()).armorType;

                    if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) {

                        return null;

                    }

                } else if (par2 >= INV_START) {

                    if (!this.mergeItemStack(itemstack1, HANDS_START, HANDS_END + 1, false)) {

                        return null;

                    }

                } else if (par2 >= HANDS_START && par2 < HANDS_END + 1) {

                    if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) {

                        return null;

                    }

                }

            }

            if (itemstack1.stackSize == 0) {

                slot.putStack((ItemStack) null);

            } else {

                slot.onSlotChanged();

            }

            if (itemstack1.stackSize == itemstack.stackSize) {

                return null;

            }

            slot.onPickupFromSlot(player, itemstack1);

        }

        return itemstack;

    }

 

 

    public class ArmorSlot extends Slot {

        final int armorType;

        final EntityPlayer player;

 

        public ArmorSlot(EntityPlayer player, IInventory inventory, int slot, int x, int y, int armorType) {

            super(inventory, slot, x, y);

            this.player = player;

            this.armorType = armorType;

        }

 

        public int getSlotStackLimit()

        {

            return 1;

        }

 

        public boolean isItemValid(ItemStack itemstack)

        {

            Item item = (itemstack == null ? null : itemstack.getItem());

            return item != null && item.isValidArmor(itemstack, armorType, player);

        }

 

        @SideOnly(Side.CLIENT)

        public IIcon getBackgroundIconIndex()

        {

            return ItemArmor.func_94602_b(this.armorType);

        }

    }

}

 

 

 

All I get when press key is

 

[19:25:22] [server thread/INFO] [sTDOUT]: [ru.iammaxim.tesitems.Player.CustomPlayerOpenInventoryHandler:onMessage:21]: Received message from Player72

 

Posted

I register it from

@EventHandler

public void preInit(FMLInitializationEvent event)

with NetworkRegistry.INSTANCE.registerGuiHandler(this, new CustomPlayerGUIHandler());

Posted

I register it from

@EventHandler

public void preInit(FMLInitializationEvent event)

with NetworkRegistry.INSTANCE.registerGuiHandler(this, new CustomPlayerGUIHandler());

Why is your FMLInitializationEvent handled in a method named 'preInit'? Is that an accident?

 

Anyway, can you show your entire Main class? Something in there is not right.

Posted

Main class:

 

@Mod(modid = TESItems.MODID, version = TESItems.VERSION)

public class TESItems

{

    public static SimpleNetworkWrapper networkWrapper;

    public static TESItems instance = new TESItems();

 

    private static int modGuiIndex = 0;

    public static final int customInventoryGUIIndex = modGuiIndex++;

 

    public static final String MODID = "tesitems";

    public static final String VERSION = "1.0";

 

    public static Material dwarven_material;

 

    //Damage modifiers

    public static final float daggerDamageModifier = 1.0f,

            swordDamageModifier = 1.5f,

            waraxeDamageModifier = 2.2f,

            greadswordDamageModifier = 2.0f,

            maceDamageModifier = 1.8f,

            axeDamageModifier = 1.7f;

 

    public static int dungeon_generator_mode = 0,

        room_width = 10,

        room_height = 10,

        room_length = 10;

 

    public static DungeonGeneratorItem dungeon_generator_item;

 

    public static GenericBlock dungeon_generator_block,

            dwarven_block_01,

            dungeon_bricks_01,

            dungeon_bricks_02,

            dungeon_bricks_03,

            dungeon_bricks_04,

            dungeon_bricks_05,

            dungeon_bricks_06,

            dungeon_bricks_07,

            dungeon_bricks_07_lamp,

            dungeon_bricks_08,

            dungeon_bricks_09,

            dungeon_bricks_09_lamp,

            dirt_01,

            dirt_02,

            planks_01,

            planks_02,

            grass_01_top,

            bark_01,

            bricks_block_01;

 

    public static DwarvenDoor dwarven_door;

    public static DwarvenDoorItem dwarven_door_item;

    public static dwarven_pipe_block dwarven_pipe;

    public static TableBlock table_block;

 

    //Clothes

    public static ItemArmor.ArmorMaterial clothMaterial = EnumHelper.addArmorMaterial("Cloth", 1000, new int[]{0,0,0,0}, 100);;

    /*public static ClothesItemArmor clothes01_helmet;

    public static ClothesItemArmor clothes01_chestplate;

    public static ClothesItemArmor clothes01_leggings;

    public static ClothesItemArmor clothes01_boots;*/

 

    //Armor

    public static ItemArmor.ArmorMaterial daedricArmorMaterial = EnumHelper.addArmorMaterial("Daedric", 37, new int[]{4,10,4,2}, 25);

    public static ItemArmor.ArmorMaterial ebonyArmorMaterial = EnumHelper.addArmorMaterial("Ebony", 37, new int[]{4,9,3,2}, 25);

    public static ItemArmor.ArmorMaterial dragonArmorMaterial = EnumHelper.addArmorMaterial("Dragon", 37, new int[]{4,8,3,3}, 25);

    public static ItemArmor.ArmorMaterial dwarvenArmorMaterial = EnumHelper.addArmorMaterial("Dwarven", 37, new int[]{3,8,3,2}, 25);

    public static ItemArmor.ArmorMaterial orcishArmorMaterial = EnumHelper.addArmorMaterial("Orcish", 37, new int[]{2,7,3,2}, 25);

    public static ItemArmor.ArmorMaterial glassArmorMaterial = EnumHelper.addArmorMaterial("Glass", 37, new int[]{2,7,3,2}, 25);

    public static ItemArmor.ArmorMaterial steelArmorMaterial = EnumHelper.addArmorMaterial("Steel", 37, new int[]{2,6,3,1}, 25);

    public static ItemArmor.ArmorMaterial elvenArmorMaterial = EnumHelper.addArmorMaterial("Elven", 37, new int[]{2,6,3,1}, 25);

    public static ItemArmor.ArmorMaterial ironArmorMaterial = EnumHelper.addArmorMaterial("Iron", 37, new int[]{2,5,2,1}, 25);

    public static ItemArmor.ArmorMaterial mithrilArmorMaterial = EnumHelper.addArmorMaterial("Mithril", 37, new int[]{2,5,2,1}, 25);

    public static ItemArmor.ArmorMaterial chainArmorMaterial = EnumHelper.addArmorMaterial("Chain", 37, new int[]{2,4,2,1}, 25);

    public static ItemArmor.ArmorMaterial hideArmorMaterial = EnumHelper.addArmorMaterial("Hide", 37, new int[]{1,1,1,1}, 25);

    public static ItemArmor.ArmorMaterial dawnguardArmorMaterial = EnumHelper.addArmorMaterial("Dawnguard", 37, new int[]{4,9,7,4}, 25);

 

    //Damage

    public static float daedricDamage = 5,

            dawnbreakerDamage = 5,

            dragonDamage = 4.5f,

            dwarvenDamage = 4,

            ebonyDamage = 4,

            elvenDamage = 4,

            emeraldDamage = 3.5f,

            falmerDamage = 3,

            forswornDamage = 3.5f,

            glassDamage = 4,

            headsmansDamage = 4,

            imperialDamage = 3,

            ironDamage = 2.5f,

            notchedDamage = 2,

            orcishDamage = 4.5f,

            silverDamage = 2,

            stalhrimDamage = 4,

            steelDamage = 3,

            wuuthradDamage = 2.5f;

 

    public static Item daedric_sword,

            daedric_mace,

            dawnbreaker,

            dragon_sword,

            dragon_waraxe,

            dwarven_axe,

            dwarven_sword,

            ebony_dagger,

            ebony_mace,

            ebony_waraxe,

            elven_sword,

            elven_waraxe,

            emerald_sword,

            falmer_axe,

            falmer_sword,

            forsworn_sword,

            glass_axe,

            glass_dagger,

            glass_sword,

            headsmans_axe,

            imperial_sword,

            iron_greatsword,

            notched_pickaxe,

            orcish_mace,

            orcish_sword,

            silver_sword,

            stalhrim_battleaxe,

            stalhrim_sword,

            steel_mace,

            steel_sword,

            steel_waraxe,

            wuuthrad;

 

    public static BlacksmithBlock blacksmith_block;

    public static Septim_coin septim_coin;

 

    //Material01

    public static final Item.ToolMaterial material01 = EnumHelper.addToolMaterial("material01", 3, 10, 15, 7, 100);

 

    @EventHandler

    public void serverStarting(FMLServerStartingEvent event)

    {

        event.registerServerCommand(new dungeonGeneratorCommands());

        event.registerServerCommand(new TestCommands());

    }

 

    @EventHandler

    public void Init(FMLInitializationEvent event)

    {

        networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("customPlayerChannel");

        networkWrapper.registerMessage(CustomPlayerMessageHandler.class, CustomPlayerMessage.class, 0, Side.SERVER);

        networkWrapper.registerMessage(CustomPlayerOpenInventoryHandler.class, CustomPlayerOpenInventoryMessage.class, 1, Side.SERVER);

        NetworkRegistry.INSTANCE.registerGuiHandler(this, new CustomPlayerGUIHandler());

        MinecraftForge.EVENT_BUS.register(new CustomPlayerHandler());

 

        dwarven_material = new Material(MapColor.yellowColor);

 

        GameRegistry.registerTileEntity(dwarven_pipe_tileEntity.class, "dwarven_pipe_tile_entity");

        GameRegistry.registerTileEntity(TableTileEntity.class, "table_tile_entity");

 

        //Register weapon

        GameRegistry.registerItem(daedric_sword =      new ItemSword(createToolMaterial("Daedric", 1500, daedricDamage * swordDamageModifier)).setUnlocalizedName("daedric_sword").setTextureName("tesitems:daedricsword").setCreativeTab(CreativeTabs.tabCombat), "daedric_sword");

        GameRegistry.registerItem(daedric_mace =        new ItemSword(createToolMaterial("Daedric", 1500, daedricDamage * maceDamageModifier)).setUnlocalizedName("daedric_mace").setTextureName("tesitems:daedricmace").setCreativeTab(CreativeTabs.tabCombat), "daedric_mace");

        GameRegistry.registerItem(dawnbreaker =        new ItemSword(createToolMaterial("Dawnbreaker", 1700, dawnbreakerDamage * swordDamageModifier)).setUnlocalizedName("dawnbreaker").setTextureName("tesitems:dawnbreaker").setCreativeTab(CreativeTabs.tabCombat), "dawnbreaker");

        GameRegistry.registerItem(dragon_sword =        new ItemSword(createToolMaterial("Dragon", 1700, dragonDamage * swordDamageModifier)).setUnlocalizedName("dragon_sword").setTextureName("tesitems:dragonsword").setCreativeTab(CreativeTabs.tabCombat), "dragon_sword");

        GameRegistry.registerItem(dragon_waraxe =      new ItemSword(createToolMaterial("Dragon", 1700, dragonDamage * waraxeDamageModifier)).setUnlocalizedName("dragon_waraxe").setTextureName("tesitems:dragonwaraxe").setCreativeTab(CreativeTabs.tabCombat), "dragon_waraxe");

        GameRegistry.registerItem(dwarven_axe =        new ItemSword(createToolMaterial("Dwarven", 1300, dwarvenDamage * axeDamageModifier)).setUnlocalizedName("dwarven_axe").setTextureName("tesitems:dwarvenaxe").setCreativeTab(CreativeTabs.tabCombat), "dwarven_axe");

        GameRegistry.registerItem(dwarven_sword =      new ItemSword(createToolMaterial("Dwarven", 1300,daedricDamage * swordDamageModifier)).setUnlocalizedName("dwarven_sword").setTextureName("tesitems:dwarvensword").setCreativeTab(CreativeTabs.tabCombat), "dwarven_sword");

        GameRegistry.registerItem(ebony_dagger =        new ItemSword(createToolMaterial("Ebony", 1200, ebonyDamage * daggerDamageModifier)).setUnlocalizedName("ebony_dagger").setTextureName("tesitems:ebonydagger").setCreativeTab(CreativeTabs.tabCombat), "ebony_dagger");

        GameRegistry.registerItem(ebony_mace =          new ItemSword(createToolMaterial("Ebony", 1200, ebonyDamage * maceDamageModifier)).setUnlocalizedName("ebony_mace").setTextureName("tesitems:ebonymace").setCreativeTab(CreativeTabs.tabCombat), "ebony_mace");

        GameRegistry.registerItem(ebony_waraxe =        new ItemSword(createToolMaterial("Ebony", 1200, ebonyDamage * waraxeDamageModifier)).setUnlocalizedName("ebony_waraxe").setTextureName("tesitems:ebonywaraxe").setCreativeTab(CreativeTabs.tabCombat), "ebony_waraxe");

        GameRegistry.registerItem(elven_sword =        new ItemSword(createToolMaterial("Elven", 1200, elvenDamage * swordDamageModifier)).setUnlocalizedName("elven_sword").setTextureName("tesitems:elvensword").setCreativeTab(CreativeTabs.tabCombat), "elven_sword");

        GameRegistry.registerItem(elven_waraxe =        new ItemSword(createToolMaterial("Elven", 1200, elvenDamage * waraxeDamageModifier)).setUnlocalizedName("elven_waraxe").setTextureName("tesitems:elvenwaraxe").setCreativeTab(CreativeTabs.tabCombat), "elven_waraxe");

        GameRegistry.registerItem(emerald_sword =      new ItemSword(createToolMaterial("Emerald", 1400, emeraldDamage * swordDamageModifier)).setUnlocalizedName("emerald_sword").setTextureName("tesitems:emeraldsword").setCreativeTab(CreativeTabs.tabCombat), "emerald_sword");

        GameRegistry.registerItem(falmer_axe =          new ItemSword(createToolMaterial("Falmer", 800, falmerDamage * axeDamageModifier)).setUnlocalizedName("falmer_axe").setTextureName("tesitems:falmeraxe").setCreativeTab(CreativeTabs.tabCombat), "falmer_axe");

        GameRegistry.registerItem(falmer_sword =        new ItemSword(createToolMaterial("Falmer", 800, falmerDamage * swordDamageModifier)).setUnlocalizedName("falmer_sword").setTextureName("tesitems:falmersword").setCreativeTab(CreativeTabs.tabCombat), "falmer_sword");

        GameRegistry.registerItem(forsworn_sword =      new ItemSword(createToolMaterial("Forsworn", 1500, forswornDamage * swordDamageModifier)).setUnlocalizedName("forsworn_sword").setTextureName("tesitems:forswornsword").setCreativeTab(CreativeTabs.tabCombat), "forsworn_sword");

        GameRegistry.registerItem(glass_axe =          new ItemSword(createToolMaterial("Glass", 1300, glassDamage * axeDamageModifier)).setUnlocalizedName("glass_axe").setTextureName("tesitems:glassaxe").setCreativeTab(CreativeTabs.tabCombat), "glass_axe");

        GameRegistry.registerItem(glass_dagger =        new ItemSword(createToolMaterial("Glass", 1300, glassDamage * daggerDamageModifier)).setUnlocalizedName("glass_dagger").setTextureName("tesitems:glassdagger").setCreativeTab(CreativeTabs.tabCombat), "glass_dagger");

        GameRegistry.registerItem(glass_sword =        new ItemSword(createToolMaterial("Glass", 1300, glassDamage * swordDamageModifier)).setUnlocalizedName("glass_sword").setTextureName("tesitems:glasssword").setCreativeTab(CreativeTabs.tabCombat), "glass_sword");

        GameRegistry.registerItem(headsmans_axe =      new ItemSword(createToolMaterial("Headsman", 1200, headsmansDamage * axeDamageModifier)).setUnlocalizedName("headsmans_axe").setTextureName("tesitems:headsmansaxe").setCreativeTab(CreativeTabs.tabCombat), "headsmans_axe");

        GameRegistry.registerItem(imperial_sword =      new ItemSword(createToolMaterial("Imperial", 800, imperialDamage * swordDamageModifier)).setUnlocalizedName("imperial_sword").setTextureName("tesitems:imperialsword").setCreativeTab(CreativeTabs.tabCombat), "imperial_sword");

        GameRegistry.registerItem(iron_greatsword =    new ItemSword(createToolMaterial("Iron", 800, ironDamage * greadswordDamageModifier)).setUnlocalizedName("iron_greatsword").setTextureName("tesitems:irongreatsword").setCreativeTab(CreativeTabs.tabCombat), "iron_greatsword");

        GameRegistry.registerItem(notched_pickaxe =    new ItemSword(createToolMaterial("Notched", 2, 600, 0, notchedDamage * axeDamageModifier, 20)).setUnlocalizedName("notched_pickaxe").setTextureName("tesitems:notchedpickaxe").setCreativeTab(CreativeTabs.tabCombat), "notched_pickaxe");

        GameRegistry.registerItem(orcish_mace =        new ItemSword(createToolMaterial("Orcish", 1500, orcishDamage * maceDamageModifier)).setUnlocalizedName("orcish_mace").setTextureName("tesitems:orcishmace").setCreativeTab(CreativeTabs.tabCombat), "orcish_mace");

        GameRegistry.registerItem(orcish_sword =        new ItemSword(createToolMaterial("Orcish", 1500, orcishDamage * swordDamageModifier)).setUnlocalizedName("orcish_sword").setTextureName("tesitems:orcishsword").setCreativeTab(CreativeTabs.tabCombat), "orcish_sword");

        GameRegistry.registerItem(silver_sword =        new ItemSword(createToolMaterial("Silver", 800, silverDamage * swordDamageModifier)).setUnlocalizedName("silver_sword").setTextureName("tesitems:silversword").setCreativeTab(CreativeTabs.tabCombat), "silver_sword");

        GameRegistry.registerItem(stalhrim_battleaxe =  new ItemSword(createToolMaterial("Stalhrim", 700, stalhrimDamage * waraxeDamageModifier)).setUnlocalizedName("stalhrim_battleaxe").setTextureName("tesitems:stalhrimbattleaxe").setCreativeTab(CreativeTabs.tabCombat), "stalhrim_battleaxe");

        GameRegistry.registerItem(stalhrim_sword =      new ItemSword(createToolMaterial("Stalhrim", 700, stalhrimDamage * swordDamageModifier)).setUnlocalizedName("stalhrim_sword").setTextureName("tesitems:stalhrimsword").setCreativeTab(CreativeTabs.tabCombat), "stalhrim_sword");

        GameRegistry.registerItem(steel_mace =          new ItemSword(createToolMaterial("Steel", 1000, steelDamage * maceDamageModifier)).setUnlocalizedName("steel_mace").setTextureName("tesitems:steelmace").setCreativeTab(CreativeTabs.tabCombat), "steel_mace");

        GameRegistry.registerItem(steel_sword =        new ItemSword(createToolMaterial("Steel", 1000, steelDamage * swordDamageModifier)).setUnlocalizedName("steel_sword").setTextureName("tesitems:steelsword").setCreativeTab(CreativeTabs.tabCombat), "steel_sword");

        GameRegistry.registerItem(steel_waraxe =        new ItemSword(createToolMaterial("Steel", 1000, steelDamage * waraxeDamageModifier)).setUnlocalizedName("steel_waraxe").setTextureName("tesitems:steelwaraxe").setCreativeTab(CreativeTabs.tabCombat), "steel_waraxe");

        GameRegistry.registerItem(wuuthrad =            new ItemSword(createToolMaterial("Wuutrad", 300, wuuthradDamage * waraxeDamageModifier)).setUnlocalizedName("wuuthrad").setTextureName("tesitems:wuuthrad").setCreativeTab(CreativeTabs.tabCombat), "wuuthrad");

 

 

        //Register dungeon generator

        dungeon_generator_item = new DungeonGeneratorItem();

        GameRegistry.registerItem(dungeon_generator_item, "dungeon_generator_item");

        GameRegistry.registerBlock(dungeon_generator_block = new GenericBlock(Material.iron, "dungeon_generator_block", "dungeon_generator_block", 1, Block.soundTypeMetal, CreativeTabs.tabMisc), dungeon_generator_block.getUnlocalizedName());

 

        //Register blocks

        GameRegistry.registerBlock(dwarven_door = new DwarvenDoor(dwarven_material), "dwarven_door");

        GameRegistry.registerBlock(dwarven_block_01 = new GenericBlock(Material.iron, "dwarven_block_01", "dwarven_block_01", 5, Block.soundTypeMetal, CreativeTabs.tabBlock), "dwarven_block_01");

        GameRegistry.registerBlock(dwarven_pipe = new dwarven_pipe_block(Material.iron), "dwarven_pipe");

        GameRegistry.registerBlock(dungeon_bricks_01 = new GenericBlock(Material.rock, "dungeon_bricks_01", "dungeon_bricks_01", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_01");

        GameRegistry.registerBlock(dungeon_bricks_02 = new GenericBlock(Material.rock, "dungeon_bricks_02", "dungeon_bricks_02", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_02");

        GameRegistry.registerBlock(dungeon_bricks_03 = new GenericBlock(Material.rock, "dungeon_bricks_03", "dungeon_bricks_03", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_03");

        GameRegistry.registerBlock(dungeon_bricks_04 = new GenericBlock(Material.rock, "dungeon_bricks_04", "dungeon_bricks_04", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_04");

        GameRegistry.registerBlock(dungeon_bricks_05 = new GenericBlock(Material.rock, "dungeon_bricks_05", "dungeon_bricks_05", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_05");

        GameRegistry.registerBlock(dungeon_bricks_06 = new GenericBlock(Material.rock, "dungeon_bricks_06", "dungeon_bricks_06", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_06");

        GameRegistry.registerBlock(dungeon_bricks_07 = new GenericBlock(Material.rock, "dungeon_bricks_07", "dungeon_bricks_07", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_07");

        GameRegistry.registerBlock(dungeon_bricks_07_lamp = (GenericBlock) new GenericBlock(Material.rock, "dungeon_bricks_07_lamp", "dungeon_bricks_07_lamp", 4, Block.soundTypeStone, CreativeTabs.tabBlock).setLightLevel(1), "dungeon_bricks_07_lamp");

        GameRegistry.registerBlock(dungeon_bricks_08 = new GenericBlock(Material.rock, "dungeon_bricks_08", "dungeon_bricks_08", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_08");

        GameRegistry.registerBlock(dungeon_bricks_09 = new GenericBlock(Material.rock, "dungeon_bricks_09", "dungeon_bricks_09", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "dungeon_bricks_09");

        GameRegistry.registerBlock(dungeon_bricks_09_lamp = (GenericBlock) new GenericBlock(Material.rock, "dungeon_bricks_09_lamp", "dungeon_bricks_09_lamp", 4, Block.soundTypeStone, CreativeTabs.tabBlock).setLightLevel(1), "dungeon_bricks_09_lamp");

        GameRegistry.registerBlock(bricks_block_01 = new GenericBlock(Material.rock, "bricks_block_01", "bricks_block_01", 4, Block.soundTypeStone, CreativeTabs.tabBlock), "bricks_block_01");

        GameRegistry.registerBlock(dirt_01 = new GenericBlock(Material.ground, "dirt_01", "dirt_01", 4, Block.soundTypeGravel, CreativeTabs.tabBlock), "dirt_01");

        GameRegistry.registerBlock(dirt_02 = new GenericBlock(Material.ground, "dirt_02", "dirt_02", 4, Block.soundTypeGravel, CreativeTabs.tabBlock), "dirt_02");

        GameRegistry.registerBlock(grass_01_top = new GenericBlock(Material.ground, "grass_01_top", "grass_01_top", 4, Block.soundTypeGrass, CreativeTabs.tabBlock), "grass_01_top");

        GameRegistry.registerBlock(planks_01 = new GenericBlock(Material.wood, "planks_01", "planks_01", 4, Block.soundTypeWood, CreativeTabs.tabBlock), "planks_01");

        GameRegistry.registerBlock(planks_02 = new GenericBlock(Material.wood, "planks_02", "planks_02", 4, Block.soundTypeWood, CreativeTabs.tabBlock), "planks_02");

        GameRegistry.registerBlock(bark_01 = new GenericBlock(Material.wood, "bark_01", "bark_01", 4, Block.soundTypeWood, CreativeTabs.tabBlock), "bark_01");

        GameRegistry.registerBlock(table_block = new TableBlock(Material.wood), "table_block");

        //GameRegistry.registerBlock(blacksmith_block = new BlacksmithBlock(Material.iron), "blacksmith_block");

 

        //Register items

        GameRegistry.registerItem(dwarven_door_item = new DwarvenDoorItem(dwarven_material), "dwarven_door_item");

        GameRegistry.registerItem(septim_coin = new Septim_coin(), "septim_coin");

 

 

        //Register clothes

        /*clothes01_helmet = new ClothesItemArmor("clothes_01", clothMaterial, "clothes_01", 0);

        GameRegistry.registerItem(clothes01_helmet, "clothes01_helmet");

        clothes01_chestplate = new ClothesItemArmor("clothes_01", clothMaterial, "clothes_01", 1);

        GameRegistry.registerItem(clothes01_chestplate, "clothes01_chestplate");

        clothes01_leggings = new ClothesItemArmor("clothes_01", clothMaterial, "clothes_01", 2);

        GameRegistry.registerItem(clothes01_leggings, "clothes01_leggings");

        clothes01_boots = new ClothesItemArmor("clothes_01", clothMaterial, "clothes_01", 3);

        GameRegistry.registerItem(clothes01_boots, "clothes01_boots");*/

 

        GameRegistry.registerItem(new ClothesItemArmor("clothes_helmet", clothMaterial, "clothes_01", 0), "clothes01_helmet");

        GameRegistry.registerItem(new ClothesItemArmor("clothes_chestplate", clothMaterial, "clothes_01", 1), "clothes01_chestplate");

        GameRegistry.registerItem(new ClothesItemArmor("clothes_leggings", clothMaterial, "clothes_01", 2), "clothes01_leggings");

        GameRegistry.registerItem(new ClothesItemArmor("clothes_boots", clothMaterial, "clothes_01", 3), "clothes01_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("daedric_helmet", daedricArmorMaterial, "daedric", 0), "daedric_helmet");

        GameRegistry.registerItem(new GenericItemArmor("daedric_chestplate", daedricArmorMaterial, "daedric", 1), "daedric_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("daedric_leggings", daedricArmorMaterial, "daedric", 2), "daedric_leggings");

        GameRegistry.registerItem(new GenericItemArmor("daedric_boots", daedricArmorMaterial, "daedric", 3), "daedric_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("dawnguard_helmet", dawnguardArmorMaterial, "dawnguard", 0), "dawnguard_helmet");

        GameRegistry.registerItem(new GenericItemArmor("dawnguard_chestplate", dawnguardArmorMaterial, "dawnguard", 1), "dawnguard_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("dawnguard_leggings", dawnguardArmorMaterial, "dawnguard", 2), "dawnguard_leggings");

        GameRegistry.registerItem(new GenericItemArmor("dawnguard_boots", dawnguardArmorMaterial, "dawnguard", 3), "dawnguard_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("dragon_helmet", dragonArmorMaterial, "dragon", 0), "dragon_helmet");

        GameRegistry.registerItem(new GenericItemArmor("dragon_chestplate", dragonArmorMaterial, "dragon", 1), "dragon_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("dragon_leggings", dragonArmorMaterial, "dragon", 2), "dragon_leggings");

        GameRegistry.registerItem(new GenericItemArmor("dragon_boots", dragonArmorMaterial, "dragon", 3), "dragon_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("dwarven_helmet", dwarvenArmorMaterial, "dwarven", 0), "dwarven_helmet");

        GameRegistry.registerItem(new GenericItemArmor("dwarven_chestplate", dwarvenArmorMaterial, "dwarven", 1), "dwarven_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("dwarven_leggings", dwarvenArmorMaterial, "dwarven", 2), "dwarven_leggings");

        GameRegistry.registerItem(new GenericItemArmor("dwarven_boots", dwarvenArmorMaterial, "dwarven", 3), "dwarven_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("elven_helmet", elvenArmorMaterial, "elven", 0), "elven_helmet");

        GameRegistry.registerItem(new GenericItemArmor("elven_chestplate", elvenArmorMaterial, "elven", 1), "elven_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("elven_leggings", elvenArmorMaterial, "elven", 2), "elven_leggings");

        GameRegistry.registerItem(new GenericItemArmor("elven_boots", elvenArmorMaterial, "elven", 3), "elven_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("hide_helmet", hideArmorMaterial, "hide", 0), "hide_helmet");

        GameRegistry.registerItem(new GenericItemArmor("hide_chestplate", hideArmorMaterial, "hide", 1), "hide_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("hide_leggings", hideArmorMaterial, "hide", 2), "hide_leggings");

        GameRegistry.registerItem(new GenericItemArmor("hide_boots", hideArmorMaterial, "hide", 3), "hide_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("iron_helmet", ironArmorMaterial, "iron", 0), "iron_helmet");

        GameRegistry.registerItem(new GenericItemArmor("iron_chestplate", ironArmorMaterial, "iron", 1), "iron_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("iron_leggings", ironArmorMaterial, "iron", 2), "iron_leggings");

        GameRegistry.registerItem(new GenericItemArmor("iron_boots", ironArmorMaterial, "iron", 3), "iron_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("glass_helmet", glassArmorMaterial, "glass", 0), "glass_helmet");

        GameRegistry.registerItem(new GenericItemArmor("glass_chestplate", glassArmorMaterial, "glass", 1), "glass_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("glass_leggings", glassArmorMaterial, "glass", 2), "glass_leggings");

        GameRegistry.registerItem(new GenericItemArmor("glass_boots", glassArmorMaterial, "glass", 3), "glass_boots");

 

        GameRegistry.registerItem(new GenericItemArmor("steel_helmet", steelArmorMaterial, "steel", 0), "steel_helmet");

        GameRegistry.registerItem(new GenericItemArmor("steel_chestplate", steelArmorMaterial, "steel", 1), "steel_chestplate");

        GameRegistry.registerItem(new GenericItemArmor("steel_leggings", steelArmorMaterial, "steel", 2), "steel_leggings");

        GameRegistry.registerItem(new GenericItemArmor("steel_boots", steelArmorMaterial, "steel", 3), "steel_boots");

    }

 

    @EventHandler

    @SideOnly(Side.CLIENT)

    public void Load(FMLInitializationEvent event) {

        ClientRegistry.bindTileEntitySpecialRenderer(dwarven_pipe_tileEntity.class, new dwarven_pipe_special_renderer());

        ClientRegistry.bindTileEntitySpecialRenderer(TableTileEntity.class, new TableSpecialRenderer());

        MinecraftForge.EVENT_BUS.register(new RenderHandler());

        FMLCommonHandler.instance().bus().register(new GUIEventHandler());

    }

 

    @EventHandler

    public void postInit(FMLInitializationEvent event) {

        Item.getItemFromBlock(Blocks.log).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.log2).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.stone).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.cobblestone).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.hardened_clay).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.clay).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.gravel).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.mossy_cobblestone).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.dirt).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.obsidian).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.sand).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.sandstone).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.brick_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.quartz_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.stonebrick).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.bookshelf).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.lapis_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.coal_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.diamond_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.gold_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.iron_block).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.netherrack).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.nether_brick).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.stone_slab).setMaxStackSize(2);

        Item.getItemFromBlock(Blocks.wooden_slab).setMaxStackSize(2);

        Item.getItemFromBlock(Blocks.stone_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.acacia_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.birch_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.brick_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.dark_oak_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.jungle_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.nether_brick_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.oak_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.quartz_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.sandstone_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.spruce_stairs).setMaxStackSize(1);

        Item.getItemFromBlock(Blocks.stone_brick_stairs).setMaxStackSize(1);

    }

}

 

 

Posted

Your mod instance is missing its annotation; it should be like this:

@Mod.Instance(TESItems.MODID,)
public static TESItems instance;

 

Also, you are handling the FMLInitializationEvent THREE times... you should only do so once. There are also FMLPreInitializationEvent and FMLPostInitializationEvent events which you can use.

 

Do NOT use @SideOnly in your Main class. Ever. Use the proxy system, which you do not have at all in your mod...

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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