use of net.minecraft.screen.slot.Slot in project Rug by RubixDev.
the class PeekCommand method showEnderChest.
public static void showEnderChest(ServerPlayerEntity executingPlayer, ServerPlayerEntity targetPlayer) {
EnderChestInventory targetEnderChest = targetPlayer.getEnderChestInventory();
PlayerDataGui invScreen = new PlayerDataGui(ScreenHandlerType.GENERIC_9X3, executingPlayer, targetPlayer);
invScreen.setTitle(Text.of("EnderChest of " + targetPlayer.getDisplayName().asString()));
for (int slot = 0; slot < targetEnderChest.size(); slot++) {
invScreen.setSlotRedirect(slot, new Slot(targetEnderChest, slot, 0, 0));
}
invScreen.open();
}
use of net.minecraft.screen.slot.Slot in project WK by witches-kitchen.
the class ScreenHandlerBuilder method playerSetup.
public ScreenHandlerBuilder playerSetup(int posX, int posY) {
final int i = this.parent.slots.size();
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 9; ++k) {
this.parent.addSlot(new Slot(this.playerInventory, k + j * 9 + 9, posX + k * 18, posY + j * 18));
}
}
posY += 58;
for (int x = 0; x < 9; x++) {
this.parent.addSlot(new Slot(this.playerInventory, x, posX + x * 18, posY));
}
final int j = this.parent.slots.size() - 1;
this.parent.addPlayerRange(Range.between(i, j));
this.start = this.parent.slots.size();
return this;
}
use of net.minecraft.screen.slot.Slot in project WK by witches-kitchen.
the class WKScreenHandler method transferSlot.
@Override
public ItemStack transferSlot(final PlayerEntity player, final int index) {
ItemStack originalStack = ItemStack.EMPTY;
final Slot slot = this.getSlot(index);
if (slot != null && slot.hasStack()) {
final ItemStack stackInSlot = slot.getStack();
originalStack = stackInSlot.copy();
boolean shifted = false;
for (final Range<Integer> range : this.playerRanges) {
if (range.contains(index)) {
if (this.transferToBlockEntity(stackInSlot)) {
shifted = true;
}
break;
}
}
if (!shifted) {
for (final Range<Integer> range : this.blockEntityRanges) {
if (range.contains(index)) {
if (this.transferToPlayer(stackInSlot)) {
shifted = true;
}
break;
}
}
}
slot.onQuickTransfer(stackInSlot, originalStack);
if (stackInSlot.getCount() <= 0) {
slot.setStack(ItemStack.EMPTY);
} else {
slot.markDirty();
}
if (stackInSlot.getCount() == originalStack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTakeItem(player, stackInSlot);
}
return originalStack;
}
use of net.minecraft.screen.slot.Slot in project Skyblocker by LifeIsAParadox.
the class ContainerSolverManager method onDraw.
public void onDraw(MatrixStack matrices, List<Slot> slots) {
if (currentSolver == null)
return;
if (highlights == null)
highlights = currentSolver.getColors(groups, slotMap(slots));
RenderSystem.disableDepthTest();
RenderSystem.colorMask(true, true, true, false);
for (ColorHighlight highlight : highlights) {
Slot slot = slots.get(highlight.slot());
int color = highlight.color();
fillGradient(matrices, slot.x, slot.y, slot.x + 16, slot.y + 16, color, color);
}
RenderSystem.colorMask(true, true, true, true);
RenderSystem.enableDepthTest();
}
use of net.minecraft.screen.slot.Slot in project BleachHack by BleachDrinker420.
the class Peek method drawScreen.
@BleachSubscribe
public void drawScreen(EventRenderTooltip event) {
if (!(event.getScreen() instanceof HandledScreen)) {
return;
}
Slot slot = ((HandledScreen<?>) event.getScreen()).focusedSlot;
if (slot == null)
return;
if (slot.x != slotX || slot.y != slotY) {
pageCount = 0;
pages = null;
slotX = slot.x;
slotY = slot.y;
}
event.getMatrix().push();
event.getMatrix().translate(0, 0, 400);
if (getSetting(0).asToggle().getState()) {
List<TooltipComponent> components = drawShulkerToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
if (components != null) {
if (components.isEmpty()) {
event.setCancelled(true);
} else {
event.setComponents(components);
}
}
}
if (getSetting(1).asToggle().getState())
drawBookToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
if (getSetting(2).asToggle().getState())
drawMapToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
event.getMatrix().pop();
}
Aggregations