Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Fix server crash
Browse files Browse the repository at this point in the history
  • Loading branch information
lazynessmind committed Mar 22, 2020
1 parent 906a8eb commit bdff2e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/lazy/baubles/Baubles.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class Registration {
public static List<ContainerType<?>> CONTAINERS = new ArrayList<>();

@ObjectHolder("baubles:player_baubles")
public static ContainerType<PlayerExpandedContainer> PLAYER_BAUBLES = createContainer("player_baubles", PlayerExpandedContainer::new);
public static ContainerType<PlayerExpandedContainer> PLAYER_BAUBLES = createContainer("player_baubles", (id, inv, data) -> new PlayerExpandedContainer(id, inv, !inv.player.world.isRemote));

private static <T extends Container> ContainerType<T> createContainer(String name, IContainerFactory<T> factory) {
ContainerType<T> containerType = IForgeContainerType.create(factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public ITextComponent getDisplayName() {
@Nullable
@Override
public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) {
return new PlayerExpandedContainer(id, playerInventory, !playerEntity.world.isRemote, playerEntity);
return new PlayerExpandedContainer(id, playerInventory, !playerEntity.world.isRemote);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,12 @@ public class PlayerExpandedContainer extends Container {

public IBaublesItemHandler baubles;

public PlayerExpandedContainer(int id, PlayerInventory inventory, PacketBuffer buffer) {
this(id, inventory, !Minecraft.getInstance().world.isRemote, Minecraft.getInstance().player);
}

public PlayerExpandedContainer(int id, PlayerInventory playerInventory, boolean localWorld, PlayerEntity playerIn) {
public PlayerExpandedContainer(int id, PlayerInventory playerInventory, boolean localWorld) {
super(Baubles.Registration.PLAYER_BAUBLES, id);
this.isLocalWorld = localWorld;
this.player = playerIn;
this.player = playerInventory.player;

this.baubles = player.getCapability(BaublesCapabilities.BAUBLES).orElseThrow(NullPointerException::new);
this.baubles = this.player.getCapability(BaublesCapabilities.BAUBLES).orElseThrow(NullPointerException::new);

this.addSlot(new CraftingResultSlot(playerInventory.player, this.craftMatrix, this.craftResult, 0, 154, 28));

Expand Down

0 comments on commit bdff2e3

Please sign in to comment.