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);
}
}
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);
}
}
}
}
}
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());
}
}
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();
}
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();
}
Aggregations