use of net.minecraft.block.ShulkerBoxBlock in project MasaGadget by plusls.
the class MixinRenderUtils method modifyInv.
@ModifyVariable(method = "renderInventoryOverlay", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/util/GuiUtils;getScaledWindowWidth()I", ordinal = 0, remap = false), ordinal = 0)
private static Inventory modifyInv(Inventory inv) {
Inventory ret = inv;
Entity traceEntity = TraceUtil.getTraceEntity();
if (Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_SHULKER_BOX_ITEM_ENTITY.getBooleanValue() && ret == null && traceEntity instanceof ItemEntity) {
ItemStack itemStack = ((ItemEntity) traceEntity).getStack();
Item item = itemStack.getItem();
NbtCompound invNbt = itemStack.getSubNbt("BlockEntityTag");
DefaultedList<ItemStack> stacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof ShulkerBoxBlock) {
ret = new SimpleInventory(27);
if (invNbt != null) {
Inventories.readNbt(invNbt, stacks);
}
for (int i = 0; i < 27; ++i) {
ret.setStack(i, stacks.get(i));
}
}
}
return ret;
}
use of net.minecraft.block.ShulkerBoxBlock in project BleachHack by BleachDrinker420.
the class Peek method drawShulkerToolTip.
public List<TooltipComponent> drawShulkerToolTip(MatrixStack matrices, Slot slot, int mouseX, int mouseY) {
if (!(slot.getStack().getItem() instanceof BlockItem)) {
return null;
}
Block block = ((BlockItem) slot.getStack().getItem()).getBlock();
if (!(block instanceof ShulkerBoxBlock) && !(block instanceof ChestBlock) && !(block instanceof BarrelBlock) && !(block instanceof DispenserBlock) && !(block instanceof HopperBlock) && !(block instanceof AbstractFurnaceBlock)) {
return null;
}
List<ItemStack> items = ItemContentUtils.getItemsInContainer(slot.getStack());
if (items.stream().allMatch(ItemStack::isEmpty)) {
return null;
}
int mode = getSetting(0).asToggle().getChild(0).asMode().getMode();
int realY = mode == 2 ? mouseY + 24 : mouseY;
int tooltipWidth = block instanceof AbstractFurnaceBlock ? 47 : block instanceof HopperBlock ? 82 : 150;
int tooltipHeight = block instanceof AbstractFurnaceBlock || block instanceof HopperBlock || block instanceof DispenserBlock ? 13 : 47;
renderTooltipBox(matrices, mouseX, realY - tooltipHeight - 7, tooltipWidth, tooltipHeight, true);
int count = block instanceof HopperBlock || block instanceof DispenserBlock || block instanceof AbstractFurnaceBlock ? 18 : 0;
for (ItemStack i : items) {
if (count > 26) {
break;
}
int x = mouseX + 11 + 17 * (count % 9);
int y = realY - 67 + 17 * (count / 9);
mc.getItemRenderer().zOffset = 400;
mc.getItemRenderer().renderGuiItemIcon(i, x, y);
mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, null);
mc.getItemRenderer().zOffset = 300;
count++;
}
if (mode == 1) {
return Arrays.asList(TooltipComponent.of(slot.getStack().getName().asOrderedText()));
} else if (mode == 2) {
return List.of();
}
return null;
}
use of net.minecraft.block.ShulkerBoxBlock in project KiwiClient by TangyKiwi.
the class Tooltips method getShulkerColor.
public Color getShulkerColor(ItemStack shulkerItem) {
if (!(shulkerItem.getItem() instanceof BlockItem))
return Color.WHITE;
Block block = ((BlockItem) shulkerItem.getItem()).getBlock();
if (block == Blocks.ENDER_CHEST)
return new Color(0, 50, 50);
if (!(block instanceof ShulkerBoxBlock))
return Color.WHITE;
ShulkerBoxBlock shulkerBlock = (ShulkerBoxBlock) ShulkerBoxBlock.getBlockFromItem(shulkerItem.getItem());
DyeColor dye = shulkerBlock.getColor();
if (dye == null)
return Color.WHITE;
final float[] colors = dye.getColorComponents();
return new Color(colors[0], colors[1], colors[2], 1f);
}
use of net.minecraft.block.ShulkerBoxBlock in project KiwiClient by TangyKiwi.
the class Dupe method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
HitResult hr = MinecraftClient.getInstance().crosshairTarget;
if (hr instanceof BlockHitResult) {
BlockHitResult bhr = (BlockHitResult) hr;
BlockState bs = MinecraftClient.getInstance().world.getBlockState(bhr.getBlockPos());
if (bs.getBlock() instanceof ShulkerBoxBlock) {
MinecraftClient.getInstance().interactionManager.interactBlock(MinecraftClient.getInstance().player, MinecraftClient.getInstance().world, Hand.MAIN_HAND, bhr);
preDoDupe = true;
}
} else {
Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Please look at a shulker box"));
}
return SINGLE_SUCCESS;
});
}
use of net.minecraft.block.ShulkerBoxBlock in project Client by MatHax.
the class AutoMountBypassDupe method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
toggle();
mc.player.closeHandledScreen();
return;
}
if (timer <= 0)
timer = delay.get();
else {
timer--;
return;
}
int slots = getInvSize(mc.player.getVehicle());
for (Entity e : mc.world.getEntities()) {
if (e.distanceTo(mc.player) < 5 && e instanceof AbstractDonkeyEntity && ((AbstractDonkeyEntity) e).isTame())
entity = (AbstractDonkeyEntity) e;
}
if (entity == null)
return;
if (sneak) {
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
mc.player.setSneaking(false);
sneak = false;
return;
}
if (slots == -1) {
if (entity.hasChest() || mc.player.getMainHandStack().getItem() == Items.CHEST) {
mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
} else {
int slot = InvUtils.findInHotbar(Items.CHEST).slot();
if (!InvUtils.swap(slot, true)) {
error("Cannot find chest in your hotbar, disabling...");
toggle();
}
}
} else if (slots == 0) {
if (isDupeTime()) {
if (!slotsToThrow.isEmpty()) {
if (faceDown.get())
Rotations.rotate(mc.player.getYaw(), 90, 99, this::drop);
else
drop();
} else {
for (int i = 2; i < getDupeSize() + 1; i++) {
slotsToThrow.add(i);
}
}
} else {
mc.player.closeHandledScreen();
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
mc.player.setSneaking(true);
sneak = true;
}
} else if (!(mc.currentScreen instanceof HorseScreen))
mc.player.openRidingInventory();
else if (slots > 0) {
if (slotsToMove.isEmpty()) {
boolean empty = true;
for (int i = 2; i <= slots; i++) {
if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
empty = false;
break;
}
}
if (empty) {
for (int i = slots + 2; i < mc.player.currentScreenHandler.getStacks().size(); i++) {
if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
if (mc.player.currentScreenHandler.getSlot(i).getStack().getItem() == Items.CHEST)
continue;
if (!(mc.player.currentScreenHandler.getSlot(i).getStack().getItem() instanceof BlockItem && ((BlockItem) mc.player.currentScreenHandler.getSlot(i).getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && shulkersOnly.get())
continue;
slotsToMove.add(i);
if (slotsToMove.size() >= slots)
break;
}
}
} else {
noCancel = true;
mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
noCancel = false;
return;
}
}
if (!slotsToMove.isEmpty()) {
for (int i : slotsToMove) {
InvUtils.quickMove().from(i).to(0);
}
slotsToMove.clear();
}
}
}
Aggregations