use of trofers.common.trophy.Trophy in project trofers by ochotonida.
the class TrophyItemRenderer method renderTrophy.
private void renderTrophy(ItemStack stack, MatrixStack poseStack, IRenderTypeBuffer multiBufferSource, int light, int overlay) {
Trophy trophy = Trophy.getTrophy(stack);
if (trophy == null || Minecraft.getInstance().player == null) {
return;
}
float partialTicks = Minecraft.getInstance().getFrameTime() * (Minecraft.getInstance().isPaused() ? 0 : 1);
float ticks = (Minecraft.getInstance().player.tickCount + partialTicks);
int trophyHeight = ((TrophyBlock) ((BlockItem) stack.getItem()).getBlock()).getHeight();
TrophyBlockEntityRenderer.render(trophy, ticks, trophyHeight, poseStack, multiBufferSource, light, overlay);
}
use of trofers.common.trophy.Trophy in project trofers by ochotonida.
the class AddEntityTrophy method doApply.
@Override
public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
if (context.hasParam(LootParameters.THIS_ENTITY)) {
// noinspection ConstantConditions
ResourceLocation trophyId = trophies.get(context.getParamOrNull(LootParameters.THIS_ENTITY).getType());
if (trophyId != null) {
Trophy trophy = TrophyManager.get(trophyId);
if (trophy == null) {
Trofers.LOGGER.error("Failed to find trophy with invalid id '{}'", trophyId);
} else {
ItemStack stack = new ItemStack(trophyItem);
stack.getOrCreateTagElement("BlockEntityTag").putString("Trophy", trophyId.toString());
generatedLoot.add(stack);
}
}
}
return generatedLoot;
}
use of trofers.common.trophy.Trophy in project trofers by ochotonida.
the class TrophyScreen method setCurrentPage.
private void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
trophyButtons.forEach(button -> {
buttons.remove(button);
children.remove(button);
});
int index = currentPage * columns * rows;
for (int row = 0; row < rows; row++) {
for (int column = 0; column < columns; column++) {
if (index >= trophies.size()) {
break;
}
ItemStack stack = new ItemStack(trophyItem);
Trophy trophy = trophies.get(index++);
stack.getOrCreateTagElement("BlockEntityTag").putString("Trophy", trophy.id().toString());
int x = columnStart + column * (BUTTON_SIZE + BUTTON_SPACING);
int y = rowStart + row * (BUTTON_SIZE + BUTTON_SPACING);
trophyButtons.add(addButton(new ItemButton(x, y, BUTTON_SIZE, stack, button -> setTrophy(trophy))));
}
}
previousButton.active = nextButton.active = false;
if (index < trophies.size() - 1) {
nextButton.active = true;
}
if (currentPage > 0) {
previousButton.active = true;
}
}
Aggregations