use of com.witchworks.api.item.IBrew in project Witchworks by Um-Mitternacht.
the class BrewUtils method createBrew.
public static ItemStack createBrew(Item item, BrewEffect... effects) {
ItemStack stack = new ItemStack(item);
NBTTagList list = addBrewData(stack);
for (BrewEffect effect : effects) {
NBTTagCompound tag = new NBTTagCompound();
IBrew brew = effect.getBrew();
tag.setInteger(BREW_ID, BrewRegistry.getBrewId(brew));
tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
tag.setInteger(BREW_DURATION, effect.getDuration());
list.appendTag(tag);
}
return stack;
}
use of com.witchworks.api.item.IBrew in project Witchworks by Um-Mitternacht.
the class BrewStorageHandler method addEntityBrewEffect.
/**
* Add a BrewEffect to the entity.
*
* @param entity The entity
* @param effect The effect
*/
public static void addEntityBrewEffect(EntityLivingBase entity, BrewEffect effect) {
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
if (optional.isPresent()) {
Map<IBrew, BrewEffect> effectMap = optional.get().getBrews();
BrewEffect out = effectMap.get(effect.getBrew());
if (out == null || effect.getDuration() > out.getDuration()) {
effectMap.put(effect.getBrew(), effect);
}
optional.get().setBrews(effectMap);
}
}
use of com.witchworks.api.item.IBrew in project Witchworks by Um-Mitternacht.
the class BrewHUD method renderOverlay.
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
if (!BREW_HUD.hide && event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(Minecraft.getMinecraft().player);
if (optional.isPresent()) {
ScaledResolution res = event.getResolution();
int x = res.getScaledWidth() - BREW_HUD.x;
int yOffset = BREW_HUD.y;
Minecraft mc = Minecraft.getMinecraft();
Set<IBrew> client = optional.get().getClient();
if (client == null)
return;
Iterator<IBrew> renders = client.iterator();
GlStateManager.pushMatrix();
while (renders.hasNext()) {
renders.next().renderHUD(x, yOffset, mc);
yOffset += 22;
}
GlStateManager.popMatrix();
}
}
}
use of com.witchworks.api.item.IBrew in project Witchworks by Um-Mitternacht.
the class ItemBrew method addInformation.
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
if (NBTHelper.hasTag(stack, BrewUtils.BREW_DESC)) {
tooltip.add(TextFormatting.ITALIC + I18n.format(NBTHelper.getString(stack, BrewUtils.BREW_DESC)));
}
if (GuiScreen.isShiftKeyDown()) {
tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + I18n.format("tooltip.brew.data"));
List<BrewEffect> brewsFromStack = BrewUtils.getBrewsFromStack(stack);
for (BrewEffect effect : brewsFromStack) {
if (effect == null)
break;
IBrew brew = effect.getBrew();
String info = " - " + TextFormatting.ITALIC + I18n.format(brew.getName()).replace(" Brew", "") + " ";
info += RomanNumber.getRoman(effect.getAmplifier() + 1) + " ";
info += "(" + StringUtils.ticksToElapsedTime(effect.getDuration()) + ")";
tooltip.add(TextFormatting.DARK_AQUA + info);
}
if (brewsFromStack.isEmpty()) {
tooltip.add("---");
} else
tooltip.add("");
BrewUtils.addPotionTooltip(stack, tooltip, 1.0F);
} else {
tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + I18n.format("tooltip.shift_for_info"));
}
}
use of com.witchworks.api.item.IBrew in project Witchworks by Um-Mitternacht.
the class BrewUtils method getBrewsFromStack.
public static List<BrewEffect> getBrewsFromStack(ItemStack stack) {
List<BrewEffect> effects = new ArrayList<>();
NBTTagList list = NBTHelper.getNBT(stack, BREW_DATA);
for (int i = 0, size = list.tagCount(); i < size; i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
IBrew brew = BrewRegistry.getBrewById(tag.getInteger(BREW_ID));
int duration = tag.getInteger(BREW_DURATION);
int amplifier = tag.getInteger(BREW_AMPLIFIER);
effects.add(new BrewEffect(brew, duration, amplifier));
}
return effects;
}
Aggregations