@Override
public void onUpdate()
{
IClientPlayerInteractionManager im = IMC.getInteractionManager();
PlayerInventory inventory = MC.player.inventory;
if(nextTickSlot != -1)
{
im.windowClick_PICKUP(nextTickSlot);
nextTickSlot = -1;
}
ItemStack offhandStack = inventory.getStack(40);
if(offhandStack.getItem() == Items.TOTEM_OF_UNDYING)
return;
if(MC.currentScreen instanceof HandledScreen
&& !(MC.currentScreen instanceof AbstractInventoryScreen))
return;
for(int slot = 0; slot <= 36; slot++)
{
if(inventory.getStack(slot).getItem() != Items.TOTEM_OF_UNDYING)
continue;
int newTotemSlot = slot < 9 ? slot + 36 : slot;
boolean offhandEmpty = offhandStack.isEmpty();
im.windowClick_PICKUP(newTotemSlot);
im.windowClick_PICKUP(45);
if(!offhandEmpty)
nextTickSlot = newTotemSlot;
break;
}
}
@Inject(at = @At("RETURN"), method = "render")
public void render(MatrixStack matrix, int mouseX, int mouseY, float delta, CallbackInfo info) {
EventDrawContainer event = new EventDrawContainer(
(HandledScreen<?>) MinecraftClient.getInstance().currentScreen, mouseX, mouseY, matrix); // hmm // hmm?
BleachHack.eventBus.post(event);
if (event.isCancelled()) info.cancel();
}
public EventDrawContainer(HandledScreen<?> screen, int mX, int mY, MatrixStack matrix) {
this.screen = screen;
this.mouseX = mX;
this.mouseY = mY;
this.matrix = matrix;
}