Finish implementing heads
This commit is contained in:
parent
1e2186d62d
commit
be1f961175
6 changed files with 97 additions and 8 deletions
|
@ -0,0 +1,60 @@
|
|||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.BookItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.WrittenBookItem;
|
||||
import net.minecraft.world.scores.Team;
|
||||
|
||||
public class CreditsEntry {
|
||||
public HeadCacheItem player;
|
||||
public String name;
|
||||
public String role;
|
||||
public String description;
|
||||
|
||||
public CreditsEntry(HeadCacheItem item, String name, String role, String descript){
|
||||
player=item;
|
||||
this.name=name;
|
||||
this.role=role;
|
||||
this.description=descript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles all the information into the head item, then applies the Lore Entry with the role the person has played, and a description
|
||||
* @return
|
||||
*/
|
||||
public ItemStack compile()
|
||||
{
|
||||
ItemStack stack = player.getAsItem();
|
||||
stack.setHoverName(new TextComponent(name));
|
||||
LoreContainer contain = new LoreContainer(stack);
|
||||
LoreEntry entry = new LoreEntry();
|
||||
entry.text = ChatColor.doColors("!Dark_Purple!Role: "+role);
|
||||
entry.bold=true;
|
||||
entry.italic=true;
|
||||
contain.miscData.LoreData.add(entry);
|
||||
entry = new LoreEntry();
|
||||
entry.text = ChatColor.doColors("!White!About: !Dark_Green!"+description);
|
||||
entry.italic=true;
|
||||
contain.miscData.LoreData.add(entry);
|
||||
|
||||
contain.commitLore();
|
||||
|
||||
return stack;
|
||||
}
|
||||
/**
|
||||
* Generates a written book that can serve as an about-page about the person being creditted.
|
||||
* @return
|
||||
*/
|
||||
public ItemStack compileInfosBook()
|
||||
{
|
||||
// Will return a patchouli book
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntArrayTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -17,6 +18,7 @@ import net.minecraft.network.chat.TextComponent;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.PlayerHeadItem;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class HeadCache
|
||||
{
|
||||
|
@ -67,7 +69,7 @@ public class HeadCache
|
|||
skullOwner.put("Properties", properties);
|
||||
head.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, skullOwner);
|
||||
|
||||
TextComponent headname = ChatHelpers.macro("!Dark_red![0]'s Head", name);
|
||||
TextComponent headname = ChatHelpers.macro("[0]'s Head", name);
|
||||
head.setHoverName(headname);
|
||||
|
||||
return head;
|
||||
|
@ -98,6 +100,21 @@ public class HeadCache
|
|||
}else {
|
||||
CACHE.resetCache();
|
||||
}
|
||||
|
||||
|
||||
List<CreditsEntry> creds = new ArrayList<>();
|
||||
|
||||
creds.add(
|
||||
new CreditsEntry(HeadUtilities.cachedLookup("zontreck"), "Aria (zontreck)", "Developer", "Aria is the primary developer and project maintainer"));
|
||||
creds.add(
|
||||
new CreditsEntry(HeadUtilities.cachedLookup("PossumTheWarrior"), "PossumTheWarrior", "Tester", "Poss has helped to test the mods from very early on"));
|
||||
creds.add(
|
||||
new CreditsEntry(HeadUtilities.cachedLookup("GemMD"), "GemMD", "Adviser", "GemMD has provided advise on marketing and development decisions for various mods"));
|
||||
|
||||
CREDITS = creds;
|
||||
|
||||
|
||||
CACHE.compile();
|
||||
}
|
||||
|
||||
private void initFromCache(CompoundTag tag)
|
||||
|
@ -165,6 +182,17 @@ public class HeadCache
|
|||
HeadUtilities.get("GemMD");
|
||||
}
|
||||
|
||||
public List<ItemStack> compiled = new ArrayList<>();
|
||||
public static final List<CreditsEntry> CREDITS;
|
||||
public void compile()
|
||||
{
|
||||
compiled.clear();
|
||||
|
||||
for (CreditsEntry entry : CREDITS) {
|
||||
compiled.add(entry.compile());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHead(String playerName)
|
||||
{
|
||||
for (HeadCacheItem item : items) {
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
@ -8,14 +8,15 @@ import java.util.UUID;
|
|||
import com.google.gson.Gson;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.util.HeadCache.HeadCacheItem;
|
||||
import dev.zontreck.libzontreck.util.HttpHelper;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Added to showcase Patreon supporters and those who have helped test or provide feedback and suggestions!
|
||||
*/
|
||||
public class HeadUtilities {
|
||||
private static HeadCacheItem cachedLookup(String playerName)
|
||||
protected static HeadCacheItem cachedLookup(String playerName)
|
||||
{
|
||||
if(HeadCache.CACHE.hasHead(playerName))
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
package dev.zontreck.libzontreck.util.heads;
|
||||
|
||||
public class PlayerTextureContainer {
|
||||
public String name;
|
Reference in a new issue