mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
parent
976a21b257
commit
b7cd8e5cdd
2 changed files with 7 additions and 7 deletions
|
@ -19,6 +19,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends Container
|
|||
|
||||
public final PipeTileEntity tile;
|
||||
public final T module;
|
||||
public final int moduleIndex;
|
||||
public final ItemStack moduleStack;
|
||||
|
||||
public AbstractPipeContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos, int moduleIndex) {
|
||||
|
@ -26,6 +27,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends Container
|
|||
this.tile = Utility.getTileEntity(PipeTileEntity.class, player.world, pos);
|
||||
this.moduleStack = moduleIndex < 0 ? null : this.tile.modules.getStackInSlot(moduleIndex);
|
||||
this.module = moduleIndex < 0 ? null : (T) this.moduleStack.getItem();
|
||||
this.moduleIndex = moduleIndex;
|
||||
|
||||
// needs to be done here so transferStackInSlot works correctly, bleh
|
||||
this.addSlots();
|
||||
|
|
|
@ -99,27 +99,25 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
|
||||
private void initTabs() {
|
||||
this.tabs.clear();
|
||||
this.tabs.add(new Tab(new ItemStack(Registry.pipeBlock), null, 0, -1));
|
||||
this.tabs.add(new Tab(new ItemStack(Registry.pipeBlock), 0, -1));
|
||||
for (int i = 0; i < this.container.tile.modules.getSlots(); i++) {
|
||||
ItemStack stack = this.container.tile.modules.getStackInSlot(i);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
IModule module = (IModule) stack.getItem();
|
||||
if (module.hasContainer(stack, this.container.tile))
|
||||
this.tabs.add(new Tab(stack, module, this.tabs.size(), i));
|
||||
this.tabs.add(new Tab(stack, this.tabs.size(), i));
|
||||
}
|
||||
}
|
||||
|
||||
private class Tab {
|
||||
private final ItemStack moduleStack;
|
||||
private final IModule module;
|
||||
private final int index;
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
public Tab(ItemStack moduleStack, IModule module, int tabIndex, int index) {
|
||||
public Tab(ItemStack moduleStack, int tabIndex, int index) {
|
||||
this.moduleStack = moduleStack;
|
||||
this.module = module;
|
||||
this.index = index;
|
||||
this.x = AbstractPipeGui.this.guiLeft + 5 + tabIndex * 28;
|
||||
this.y = AbstractPipeGui.this.guiTop;
|
||||
|
@ -130,7 +128,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
int v = 0;
|
||||
int height = 30;
|
||||
int itemOffset = 9;
|
||||
if (this.module == AbstractPipeGui.this.container.module) {
|
||||
if (this.index == AbstractPipeGui.this.container.moduleIndex) {
|
||||
y = 0;
|
||||
v = 30;
|
||||
height = 32;
|
||||
|
@ -149,7 +147,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
}
|
||||
|
||||
private boolean onClicked(double mouseX, double mouseY, int button) {
|
||||
if (this.module == AbstractPipeGui.this.container.module)
|
||||
if (this.index == AbstractPipeGui.this.container.moduleIndex)
|
||||
return false;
|
||||
if (button != 0)
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue