Jump to content

MineDen

Members
  • Posts

    47
  • Joined

Posts posted by MineDen

  1. 42 minutes ago, V0idWa1k3r said:

    Use IGuiHandler with EntityPlayer#openGui(Object mod, int modGuiId, World world, int x, int y, int z) for your custom GUIs. Your solution will open a gui/container pair of a vanilla furnace which is likely not what you want. If you do want that you can

    • Still use IGuiHandler. Just return vanilla's ContainerFurnace and GuiFurnace in corresponding methods.
    • Make sure that your TE implements IInteractionObject. I do not see Override annotations in your code(Code-style issue #2)

    Oh, I forgot that my TE doesn't extend TileEntityFurnace, and I also forgot to change checking in block code!

  2. 9 minutes ago, V0idWa1k3r said:

    If there are no overloads then you are using a forge version which doesn't have that introduced. In the newer version GameRegistry#registerTileEntity(Class<? extends TileEntity> tileEntityClass, String key) is deprecated with a comment that it'll be removed in 1.13. 

    Also I want to open furnace GUI but it doesn't open. Here is my code:

     

    Block:

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
            if (worldIn.isRemote) {
                return true;
            } else {
                TileEntity tileentity = worldIn.getTileEntity(pos);
    
                if (tileentity instanceof TileEntityFurnace) {
                    playerIn.displayGUIChest((TileEntityFurnace) tileentity);
                    playerIn.addStat(TestMod.CHEMICAL_LABORATORY_INTERACT);
                }
    
                return true;
            }
        }

     

    TileEntity:

    @Nonnull
        public String getGuiID() {
            return "minecraft:furnace";
        }
    
        @Nonnull
        public Container createContainer(@Nonnull InventoryPlayer playerInventory, @Nonnull EntityPlayer playerIn) {
            return new ContainerFurnace(playerInventory, this);
        }

     

  3. 5 minutes ago, V0idWa1k3r said:

    It's still GameRegistry#registerTileEntity. Use the overload which takes a ResourceLocation as the second argument though.

     

    Okay, I'll try this.
    UPD: there is no overloads, only string. Is this should be like "testmod:my_tileentity"?

  4. Today I copied and edited furnace tileentity and then started testing. But now I have "TileEntity is missing a mapping! This is a bug!" exception. In 1.9 I can fix it by registering TE with GameRegistry.registerTileEntity(...) but in 1.12 I should use RegistryEvents and here is described types of events, and there is no TileEntity! So how I can register my TE?

  5. Just now, Choonster said:

    Use Random#nextInt(int) to generate a random integer between 0 (inclusive) and the argument (exclusive) instead of the multiplication, subtraction and rounding you're doing now.

    Math.round(Math.random() * <count> - 1)

    is the JavaScript arrays way, and it's my favourite way, so shut up i will use this way.

  6. 10 minutes ago, Choonster said:

     

    It adds the items to the list that you pass as an argument.

    Is this code right? It works.

    public static CreativeTabs decoration = new CreativeTabs("mtest_decoration") {
            @Override
            public ItemStack getTabIconItem() {
                int index = (int) Math.round(Math.random() * (MBlocks.BLOCKS.size() - 1));
                Block block = MBlocks.BLOCKS.get(index);
                NonNullList<ItemStack> subBlocks = NonNullList.create();
                block.getSubBlocks(CreativeTabs.SEARCH, subBlocks);
                System.out.println(subBlocks);
                int meta = (int) Math.round(Math.random() * (subBlocks.size() - 1));
                ItemStack is = new ItemStack(block, 1, meta);
                return is;
            }
        };

     

  7. On 16.02.2018 at 8:42 PM, diesieben07 said:

    You create an empty NonNullList using NonNullList.create. Then you call getSubItems with that list and CreativeTabs.SEARCH. Afterwards you will have all sub items of that item in the list.

    Seriously, this is not hard.

    This method returns void, what I can do?

  8. 7 minutes ago, jabelar said:

    It's just a coding style thing. That was probably convenient to the person who needed that method in the first place since they were using it for making creative tabs. Like you could pass in an existing list for the creative tab and this method would add to it then you could get the list containing the subitems of multiple item types and if they are itemstacks that makes it super easy to put into the gui container inventory.

    Okay, I'll try this now.

  9. Hello, I need to get maximum meta value of block. I created a creative tab and returning random block as icon, but I have colored blocks. And I want to return random meta. But I don't know how to get maximum meta value of block. Now my creative tab code looks like this:

    public static CreativeTabs decoration = new CreativeTabs("mtest_decoration") {
            @Override
            public ItemStack getTabIconItem() {
                int index = (int) Math.round(Math.random() * (MBlocks.BLOCKS.size() - 1));
                Block block = MBlocks.BLOCKS.get(index);
                int meta = 0;
                ItemStack is = new ItemStack(block, 1, meta);
                return is;
            }
        };

     

  10. 2 hours ago, Draco18s said:

    In 1.12.1, method this.getState() not exist. What method i need to use?

  11. Just now, diesieben07 said:

    I don't want video. I want code that shows where you change the energy. You have shown no such code, as such I can only assume that the energy value never changes.

    Energy don't change, but after world restart it always maximum. I think, that this is storage creating or update() method problem.

  12. 16 minutes ago, diesieben07 said:

    You can do that. But you must also have a no-argument constructor and you must be aware that only the no-argument constructor will be used when reading your TileEntity from disk.

    I recrated zero-argument constructor and uploaded new code to GitHub.

×
×
  • Create New...

Important Information

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