Search in sources :

Example 6 with Trophy

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);
}
Also used : Trophy(trofers.common.trophy.Trophy) TrophyBlock(trofers.common.block.TrophyBlock)

Example 7 with Trophy

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;
}
Also used : Trophy(trofers.common.trophy.Trophy) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack)

Example 8 with Trophy

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;
    }
}
Also used : Trophy(trofers.common.trophy.Trophy) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Trophy (trofers.common.trophy.Trophy)8 ResourceLocation (net.minecraft.util.ResourceLocation)3 ItemStack (net.minecraft.item.ItemStack)2 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 EntityType (net.minecraft.entity.EntityType)1 ILootCondition (net.minecraft.loot.conditions.ILootCondition)1 Direction (net.minecraft.util.Direction)1 ModLoadedCondition (net.minecraftforge.common.crafting.conditions.ModLoadedCondition)1 TrophyBlock (trofers.common.block.TrophyBlock)1 AddEntityTrophy (trofers.common.loot.AddEntityTrophy)1 EffectInfo (trofers.common.trophy.EffectInfo)1