Search in sources :

Example 1 with Trophy

use of trofers.common.trophy.Trophy in project trofers by ochotonida.

the class LootModifiers method start.

protected void start() {
    for (String modid : trophies.trophies.keySet()) {
        HashMap<EntityType<?>, ResourceLocation> trophyMap = new HashMap<>();
        for (Trophy trophy : trophies.trophies.get(modid)) {
            // noinspection ConstantConditions
            EntityType<?> entityType = trophy.entity().getType();
            trophyMap.put(entityType, trophy.id());
        }
        ILootCondition[] conditions = new ILootCondition[] { KilledByPlayer.killedByPlayer().build(), RandomTrophyChanceCondition.randomTrophyChance().build() };
        AddEntityTrophy modifier = new AddEntityTrophy(conditions, ModItems.SMALL_PLATE.get(), trophyMap);
        String name = Trofers.MODID.equals(modid) ? "vanilla" : modid;
        name = name + "_trophies";
        add(name, ModLootModifiers.ADD_ENTITY_TROPHY.get(), modifier);
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) AddEntityTrophy(trofers.common.loot.AddEntityTrophy) Trophy(trofers.common.trophy.Trophy) HashMap(java.util.HashMap) AddEntityTrophy(trofers.common.loot.AddEntityTrophy) ResourceLocation(net.minecraft.util.ResourceLocation) ILootCondition(net.minecraft.loot.conditions.ILootCondition)

Example 2 with Trophy

use of trofers.common.trophy.Trophy in project trofers by ochotonida.

the class Trophies method run.

@Override
public void run(DirectoryCache cache) {
    addTrophies();
    Path outputFolder = generator.getOutputFolder();
    Set<ResourceLocation> resourceLocations = Sets.newHashSet();
    for (String modid : trophies.keySet()) {
        for (Trophy trophy : trophies.get(modid)) {
            if (!resourceLocations.add(trophy.id())) {
                throw new IllegalStateException("Duplicate trophy " + trophy.id());
            } else {
                Path path = createPath(outputFolder, trophy);
                try {
                    JsonObject object;
                    if (Trofers.MODID.equals(modid)) {
                        object = trophy.toJson();
                    } else {
                        object = trophy.toJson(new ModLoadedCondition(modid));
                    }
                    IDataProvider.save(GSON, cache, object, path);
                } catch (IOException ioexception) {
                    Trofers.LOGGER.error("Couldn't save trophy {}", path, ioexception);
                }
            }
        }
    }
}
Also used : Path(java.nio.file.Path) Trophy(trofers.common.trophy.Trophy) ModLoadedCondition(net.minecraftforge.common.crafting.conditions.ModLoadedCondition) ResourceLocation(net.minecraft.util.ResourceLocation) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException)

Example 3 with Trophy

use of trofers.common.trophy.Trophy in project trofers by ochotonida.

the class TrophyBlock method appendHoverText.

@Override
public void appendHoverText(ItemStack stack, @Nullable IBlockReader level, List<ITextComponent> tooltip, ITooltipFlag flag) {
    super.appendHoverText(stack, level, tooltip, flag);
    Trophy trophy = Trophy.getTrophy(stack);
    if (trophy != null) {
        tooltip.addAll(trophy.tooltip());
    }
}
Also used : Trophy(trofers.common.trophy.Trophy)

Example 4 with Trophy

use of trofers.common.trophy.Trophy in project trofers by ochotonida.

the class TrophyBlockEntity method applyEffect.

public boolean applyEffect(PlayerEntity player, Hand hand) {
    Trophy trophy = getTrophy();
    if (trophy == null || level == null) {
        return false;
    }
    EffectInfo.RewardInfo rewards = trophy.effects().rewards();
    EffectInfo.SoundInfo sound = trophy.effects().sound();
    if (sound != null) {
        player.level.playSound(player, getBlockPos(), sound.soundEvent(), SoundCategory.BLOCKS, sound.volume(), sound.pitch());
    }
    giveRewards(rewards, player, hand);
    return sound != null || rewards.lootTable() != null || !rewards.statusEffect().isEmpty();
}
Also used : Trophy(trofers.common.trophy.Trophy) EffectInfo(trofers.common.trophy.EffectInfo)

Example 5 with Trophy

use of trofers.common.trophy.Trophy in project trofers by ochotonida.

the class TrophyBlockEntityRenderer method render.

@Override
public void render(TrophyBlockEntity blockEntity, float partialTicks, MatrixStack poseStack, IRenderTypeBuffer multiBufferSource, int light, int overlay) {
    poseStack.pushPose();
    poseStack.translate(0.5, 0, 0.5);
    Direction direction = blockEntity.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING).getOpposite();
    poseStack.mulPose(Vector3f.YP.rotationDegrees(-direction.toYRot()));
    Trophy trophy = blockEntity.getTrophy();
    if (trophy != null && Minecraft.getInstance().player != null) {
        float ticks = (Minecraft.getInstance().player.tickCount + partialTicks + blockEntity.getAnimationOffset());
        render(trophy, ticks, blockEntity.getTrophyHeight(), poseStack, multiBufferSource, light, overlay);
    }
    poseStack.popPose();
}
Also used : Trophy(trofers.common.trophy.Trophy) Direction(net.minecraft.util.Direction)

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