use of net.minecraft.nbt.NbtCompound in project FZMM-Mod by Zailer43.
the class DisplayUtils method setName.
public DisplayUtils setName(NbtString name) {
NbtCompound display = this.getDisplay();
display.put(ItemStack.NAME_KEY, name);
this.nbt.put(ItemStack.DISPLAY_KEY, display);
return this;
}
use of net.minecraft.nbt.NbtCompound in project FZMM-Mod by Zailer43.
the class EntityMixin method giveDyedArmor.
private void giveDyedArmor(Item item, EquipmentSlot slot, byte slotId) {
MinecraftClient mc = MinecraftClient.getInstance();
assert mc.player != null;
ItemStack stack = item.getDefaultStack();
NbtCompound display = new NbtCompound();
int averageColor = getAverageColor(skinPartBuffered);
if (mc.interactionManager == null) {
return;
}
display.putInt(DyeableItem.COLOR_KEY, averageColor);
stack.setSubNbt(DyeableItem.DISPLAY_KEY, display);
skinPartBuffered = new BufferedImage(40, 48, BufferedImage.TYPE_INT_ARGB);
g = skinPartBuffered.createGraphics();
mc.player.equipStack(slot, stack);
mc.interactionManager.clickCreativeStack(stack, slotId);
}
use of net.minecraft.nbt.NbtCompound in project FZMM-Mod by Zailer43.
the class ItemFrameEntityMixin method getPickBlockStack.
@Inject(method = "getPickBlockStack", at = @At(value = "HEAD"), cancellable = true)
public void getPickBlockStack(CallbackInfoReturnable<ItemStack> cir) {
if (Screen.hasControlDown()) {
ItemStack stack = this.getAsItemStack();
NbtCompound entityTag = new NbtCompound();
this.writeCustomDataToNbt(entityTag);
entityTag.remove("TileX");
entityTag.remove("TileY");
entityTag.remove("TileZ");
entityTag.remove("Facing");
stack.setSubNbt(EntityType.ENTITY_TAG_KEY, entityTag);
stack = new DisplayUtils(stack).addLore("(" + EntityType.ENTITY_TAG_KEY + ")", Configs.Colors.LORE_PICK_BLOCK.getColor()).get();
cir.setReturnValue(stack);
}
}
use of net.minecraft.nbt.NbtCompound in project KiwiClient by TangyKiwi.
the class Tooltips method appendTooltip.
@Subscribe
@AllowConcurrentEvents
public void appendTooltip(ItemStackTooltipEvent event) {
// Stew
if (getSetting(0).asToggle().state) {
if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtList effects = tag.getList("Effects", 10);
if (effects != null) {
for (int i = 0; i < effects.size(); i++) {
NbtCompound effectTag = effects.getCompound(i);
byte effectId = effectTag.getByte("EffectId");
int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160;
StatusEffectInstance effect = new StatusEffectInstance(StatusEffect.byRawId(effectId), effectDuration, 0);
event.list.add(1, getStatusText(effect));
}
}
}
} else if (event.itemStack.getItem().isFood()) {
FoodComponent food = event.itemStack.getItem().getFoodComponent();
if (food != null) {
food.getStatusEffects().forEach((e) -> {
StatusEffectInstance effect = e.getFirst();
event.list.add(1, getStatusText(effect));
});
}
}
}
// Bees
if (getSetting(1).asToggle().state) {
if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtCompound blockStateTag = tag.getCompound("BlockStateTag");
if (blockStateTag != null) {
int level = blockStateTag.getInt("honey_level");
event.list.add(1, new LiteralText(String.format("%sHoney Level: %s%d%s", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
}
NbtCompound blockEntityTag = tag.getCompound("BlockEntityTag");
if (blockEntityTag != null) {
NbtList beesTag = blockEntityTag.getList("Bees", 10);
event.list.add(1, new LiteralText(String.format("%sBees: %s%d%s", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY)));
}
}
}
}
// Fish handled in EntityBucketItemMixin
}
use of net.minecraft.nbt.NbtCompound in project KiwiClient by TangyKiwi.
the class Tooltips method getTooltipData.
@Subscribe
@AllowConcurrentEvents
public void getTooltipData(TooltipDataEvent event) {
// Shulker Box
if (hasItems(event.itemStack) && getSetting(3).asToggle().state) {
NbtCompound compoundTag = event.itemStack.getSubNbt("BlockEntityTag");
DefaultedList<ItemStack> itemStacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
Inventories.readNbt(compoundTag, itemStacks);
event.tooltipData = new ContainerTooltipComponent(itemStacks, getShulkerColor(event.itemStack));
} else // EChest
if (event.itemStack.getItem() == Items.ENDER_CHEST && getSetting(4).asToggle().state) {
event.tooltipData = new ContainerTooltipComponent(EChestMemory.ITEMS, new Color(0, 50, 50));
}
}
Aggregations