Skip to content

Commit 88a29e1

Browse files
Zorbatronbrachy84
authored andcommitted
Add a second constructor to PosGuiData that takes a BlockPos (CleanroomMC#178)
* Add second constructor to PosGuiData that takes a BlockPos * Add nullability annotations to GuiData parameters and getter methods (cherry picked from commit db36219)
1 parent b5d3997 commit 88a29e1

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/main/java/com/cleanroommc/modularui/factory/GuiData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import net.minecraft.item.ItemStack;
77
import net.minecraft.world.World;
88

9+
import org.jetbrains.annotations.NotNull;
10+
911
import java.util.Objects;
1012

1113
/**
@@ -20,10 +22,11 @@ public class GuiData {
2022

2123
private final EntityPlayer player;
2224

23-
public GuiData(EntityPlayer player) {
25+
public GuiData(@NotNull EntityPlayer player) {
2426
this.player = Objects.requireNonNull(player);
2527
}
2628

29+
@NotNull
2730
public EntityPlayer getPlayer() {
2831
return this.player;
2932
}

src/main/java/com/cleanroommc/modularui/factory/PlayerInventoryGuiData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
import net.minecraft.entity.player.EntityPlayer;
66
import net.minecraft.item.ItemStack;
77

8+
import org.jetbrains.annotations.NotNull;
9+
810
public class PlayerInventoryGuiData extends GuiData {
911

1012
private final InventoryType inventoryType;
1113
private final int slotIndex;
1214

13-
public PlayerInventoryGuiData(EntityPlayer player, InventoryType inventoryType, int slotIndex) {
15+
public PlayerInventoryGuiData(@NotNull EntityPlayer player, @NotNull InventoryType inventoryType, int slotIndex) {
1416
super(player);
1517
this.inventoryType = inventoryType;
1618
this.slotIndex = slotIndex;
1719
}
1820

21+
@NotNull
1922
public InventoryType getInventoryType() {
2023
return inventoryType;
2124
}

src/main/java/com/cleanroommc/modularui/factory/PosGuiData.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@
55
import net.minecraft.tileentity.TileEntity;
66
import net.minecraft.world.World;
77

8+
import org.jetbrains.annotations.NotNull;
9+
10+
import java.util.Objects;
11+
812
/**
913
* See {@link GuiData} for an explanation for what this is for.
1014
*/
1115
public class PosGuiData extends GuiData {
1216

1317
private final int x, y, z;
1418

15-
public PosGuiData(EntityPlayer player, int x, int y, int z) {
19+
public PosGuiData(@NotNull EntityPlayer player, int x, int y, int z) {
1620
super(player);
1721
this.x = x;
1822
this.y = y;
1923
this.z = z;
2024
}
2125

26+
public PosGuiData(@NotNull EntityPlayer player, @NotNull BlockPos pos) {
27+
super(player);
28+
Objects.requireNonNull(pos);
29+
this.x = pos.getX();
30+
this.y = pos.getY();
31+
this.z = pos.getZ();
32+
}
33+
2234
public int getX() {
2335
return this.x;
2436
}

src/main/java/com/cleanroommc/modularui/factory/SidedPosGuiData.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
import net.minecraft.entity.player.EntityPlayer;
44
import net.minecraftforge.common.util.ForgeDirection;
55

6+
import org.jetbrains.annotations.NotNull;
7+
8+
import java.util.Objects;
9+
610
/**
711
* See {@link GuiData} for an explanation for what this is for.
812
*/
913
public class SidedPosGuiData extends PosGuiData {
1014

1115
private final ForgeDirection side;
1216

13-
public SidedPosGuiData(EntityPlayer player, int x, int y, int z, ForgeDirection side) {
17+
public SidedPosGuiData(@NotNull EntityPlayer player, int x, int y, int z, @NotNull ForgeDirection side) {
1418
super(player, x, y, z);
15-
this.side = side;
19+
this.side = Objects.requireNonNull(side);
1620
}
1721

22+
@NotNull
1823
public ForgeDirection getSide() {
1924
return this.side;
2025
}

0 commit comments

Comments
 (0)