use of de.teamlapen.vampirism.player.tasks.req.ItemRequirement in project Vampirism by TeamLapen.
the class TaskManager method getStat.
private int getStat(@Nonnull ITaskInstance taskInstance, @Nonnull TaskRequirement.Requirement<?> requirement) {
Map<ResourceLocation, Integer> stats = taskInstance.getStats();
if (!taskInstance.isAccepted())
return 0;
int neededStat = 0;
int actualStat = 0;
switch(requirement.getType()) {
case STATS:
actualStat = this.player.getStats().getValue(Stats.CUSTOM.get((ResourceLocation) requirement.getStat(this.factionPlayer)));
neededStat = stats.get(requirement.getId()) + requirement.getAmount(this.factionPlayer);
break;
case ENTITY:
actualStat = this.player.getStats().getValue(Stats.ENTITY_KILLED.get((EntityType<?>) requirement.getStat(this.factionPlayer)));
neededStat = stats.get(requirement.getId()) + requirement.getAmount(this.factionPlayer);
break;
case ENTITY_TAG:
// noinspection unchecked
for (EntityType<?> type : ((ITag.INamedTag<EntityType<?>>) requirement.getStat(this.factionPlayer)).getValues()) {
actualStat += this.player.getStats().getValue(Stats.ENTITY_KILLED.get(type));
}
neededStat = stats.get(requirement.getId()) + requirement.getAmount(this.factionPlayer);
break;
case ITEMS:
ItemStack stack = ((ItemRequirement) requirement).getItemStack();
neededStat = stack.getCount();
actualStat = this.player.inventory.countItem(stack.getItem());
break;
case BOOLEAN:
if (!(Boolean) requirement.getStat(this.factionPlayer))
return 0;
return 1;
}
return Math.min(requirement.getAmount(this.factionPlayer) - (neededStat - actualStat), requirement.getAmount(this.factionPlayer));
}
use of de.teamlapen.vampirism.player.tasks.req.ItemRequirement in project Vampirism by TeamLapen.
the class TaskItem method renderDummy.
@Override
public void renderDummy(MatrixStack matrixStack, int x, int y, int listWidth, int listHeight, int itemHeight, int mouseX, int mouseY, float partialTicks, float zLevel) {
// render background
RenderSystem.enableDepthTest();
GuiUtils.drawContinuousTexturedBox(matrixStack, TASKMASTER_GUI_TEXTURE, x, y, 17, 208, listWidth, itemHeight, 136, 21, 3, 3, 3, 3, zLevel);
RenderSystem.disableDepthTest();
// render content
ITaskRewardInstance reward = this.item.getReward();
if (reward instanceof ItemRewardInstance) {
ItemStack stack = ((ItemRewardInstance) reward).getReward();
this.screen.getItemRenderer().renderAndDecorateItem(stack, x + 3 + 113 - 21, y + 2);
this.screen.getItemRenderer().renderGuiItemDecorations(this.screen.font, stack, x + 3 + 113 - 21, y + 2, "" + Math.min(stack.getCount(), stack.getMaxStackSize()));
} else {
this.screen.getItemRenderer().renderAndDecorateItem(PAPER, x + 3 + 113 - 21, y + 2);
}
List<TaskRequirement.Requirement<?>> requirements = this.item.getTask().getRequirement().getAll();
for (int i = 0; i < requirements.size(); i++) {
TaskRequirement.Requirement<?> requirement = requirements.get(i);
switch(requirement.getType()) {
case ITEMS:
ItemStack stack = ((ItemRequirement) requirement).getItemStack();
this.screen.getItemRenderer().renderAndDecorateItem(stack, x + 3 + 3 + i * 20, y + 2);
this.screen.getItemRenderer().renderGuiItemDecorations(this.screen.font, stack, x + 3 + 3 + i * 20, y + 2, "" + Math.min(stack.getCount(), stack.getMaxStackSize()));
break;
case ENTITY:
case ENTITY_TAG:
this.screen.getItemRenderer().renderAndDecorateItem(SKULL_ITEM, x + 3 + 3 + i * 20, y + 2);
this.screen.getItemRenderer().renderGuiItemDecorations(this.screen.font, SKULL_ITEM, x + 3 + 3 + i * 20, y + 2, "" + requirement.getAmount(factionPlayer));
break;
default:
this.screen.getItemRenderer().renderAndDecorateItem(PAPER, x + 3 + 3 + i * 20, y + 2);
break;
}
}
// render task button
this.taskButton.x = x + listWidth - 17;
this.taskButton.y = y + 4;
this.taskButton.render(matrixStack, mouseX, mouseY, partialTicks);
}
Aggregations