Xander402 Posted December 17, 2019 Posted December 17, 2019 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? Quote 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++; }); } }
Xander402 Posted December 19, 2019 Author Posted December 19, 2019 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. Quote 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++; }); } }
Xander402 Posted December 19, 2019 Author Posted December 19, 2019 (edited) Block:https://pastebin.com/uHCFPFVq Container:https://pastebin.com/PBNvPkbR Edited December 19, 2019 by Xander402 Quote 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++; }); } }
Recommended Posts
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.