Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I tried the following:

    @Override
    public boolean onBlockActivated(BlockState state, World world, BlockPos pos,
            PlayerEntity player, Hand hand, BlockRayTraceResult result) {
        player.openContainer(state.getContainer(world, pos));
        return true;
    }

    @Override
    public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos) {
        return new SimpleNamedContainerProvider((i, playerInventory, playerEntity)
                -> new WorkbenchContainer(0, playerInventory), TEXT_COMPONENT);
    }

This opens a crafting GUI, but does some mess in the inventory when opening - some items disappear, some get moved to other slot or duplicated, and everything returns back after leaving the GUI and clicking on any item in the inventory. What am I doing wrong?

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

  • Author

Since I need my own implementation of crafting container, I should be able to set which items can be used in crafting with this block, right?
I tried to initiate the crafting matrix like this (the only difference between this and the vanilla class is the slot class name):

        for (i = 0; i < 3; ++i) {
            for (j = 0; j < 3; ++j) {
                this.addSlot(new FoodSlot(this.inventory, j + i * 3,
                        30 + j * 18, 17 + i * 18));
            }
        }

But the game actually doesn't reject any item even if the FoodSlot class looks like this:

package ...

import ...

public class FoodSlot extends Slot {
    public FoodSlot(IInventory inventory, int p1, int p2, int p3) {
        super(inventory, p1, p2, p3);
    }

    @Override
    public boolean isItemValid(ItemStack item) {
        return false;
    }
}

Instead, it moves the entire content of the matrix back to the inventory after several clicks.

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

  • Author

Block:
https://pastebin.com/uHCFPFVq

Container:
https://pastebin.com/PBNvPkbR

Edited by Xander402

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.