use of net.minecraft.nbt.NbtCompound in project Skyblocker by LifeIsAParadox.
the class DungeonMap method render.
public static void render(MatrixStack matrices) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null && client.world == null)
return;
ItemStack item = client.player.getInventory().main.get(8);
NbtCompound tag = item.getNbt();
if (tag != null && tag.contains("map")) {
String tag2 = tag.asString();
tag2 = StringUtils.substringBetween(tag2, "map:", "}");
int mapid = Integer.parseInt(tag2);
VertexConsumerProvider.Immediate vertices = client.getBufferBuilders().getEffectVertexConsumers();
MapRenderer map = client.gameRenderer.getMapRenderer();
MapState state = FilledMapItem.getMapState(mapid, client.world);
if (state == null)
return;
matrices.push();
matrices.translate(2, 2, 0);
matrices.scale(1, 1, 0);
map.draw(matrices, vertices, mapid, state, false, 15728880);
vertices.draw();
matrices.pop();
}
}
use of net.minecraft.nbt.NbtCompound 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.nbt.NbtCompound in project MasaGadget by plusls.
the class BborProtocol method parse.
public static void parse(PacketByteBuf buf) {
Identifier dimensionId = buf.readIdentifier();
ModInfo.LOGGER.debug("dimensionId = {}", dimensionId.toString());
NbtCompound tag = BoundingBoxDeserializer.deserializeStructure(buf);
if (!structuresCache.containsKey(dimensionId)) {
structuresCache.put(dimensionId, new NbtList());
}
if (tag != null) {
structuresCache.get(dimensionId).add(tag);
if (enable && Configs.Minihud.COMPACT_BBOR_PROTOCOL.getBooleanValue() && MinecraftClient.getInstance().world != null) {
BborProtocol.lock.lock();
try {
DataStorage.getInstance().addOrUpdateStructuresFromServer(structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
} catch (Exception e) {
e.printStackTrace();
}
BborProtocol.lock.unlock();
}
}
}
use of net.minecraft.nbt.NbtCompound in project MasaGadget by plusls.
the class BoundingBoxDeserializer method deserializeStructure.
public static NbtCompound deserializeStructure(PacketByteBuf buf) {
NbtCompound tag = new NbtCompound();
deserializeStructureBox(buf, tag, true);
if (!tag.contains("BB")) {
return null;
}
NbtList childrenTagList = new NbtList();
while (buf.isReadable()) {
NbtCompound childrenTag = new NbtCompound();
deserializeStructureBox(buf, childrenTag, false);
childrenTagList.add(childrenTag);
}
tag.put("Children", childrenTagList);
return tag;
}
use of net.minecraft.nbt.NbtCompound in project MCDoom by AzureDoom.
the class DoomEquipmentUtils method onSendEquipmentBreakStatusImpl.
public static void onSendEquipmentBreakStatusImpl(ServerPlayerEntity serverPlayer, ItemStack breakingStack, boolean forceSet) {
for (Map.Entry<Item, Item> itemMap : DoomItems.getItemMap().entrySet()) {
if (isVanillaItemStackBreaking(breakingStack, itemMap.getValue())) {
// Directly copy over breaking Item's NBT, removing specific fields
ItemStack ruinedStack = new ItemStack(itemMap.getKey());
NbtCompound breakingNBT = breakingStack.getOrCreateNbt();
if (breakingNBT.contains("Damage"))
breakingNBT.remove("Damage");
if (breakingNBT.contains("RepairCost"))
breakingNBT.remove("RepairCost");
// Set enchantment NBT data
NbtCompound enchantTag = getNbtForEnchantments(breakingStack, ruinedStack);
if (enchantTag != null)
breakingNBT.copyFrom(enchantTag);
if (breakingNBT.contains("Enchantments"))
breakingNBT.remove("Enchantments");
ruinedStack.setNbt(breakingNBT);
serverPlayer.getInventory().offerOrDrop(ruinedStack);
}
}
}
Aggregations