mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Added entry sharing.
This commit is contained in:
1 parent
28acdfbef7
commit
1ecd9b5996
11 files changed
+225
-16
No files matched your search
@@ -164,7 +164,7 @@ public final class HUDHandler {
|
||||
if(url != null && !url.isEmpty()) {
|
||||
String name = provider.getBlockName(mc.theWorld, pos);
|
||||
String wikiName = provider.getWikiName(mc.theWorld, pos);
|
||||
drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName;
|
||||
drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName;
|
||||
draw = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package vazkii.botania.client.gui.lexicon;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -25,6 +26,7 @@ import vazkii.botania.api.lexicon.LexiconPage;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonBackWithShift;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonPage;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonShare;
|
||||
|
||||
public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IParented {
|
||||
|
||||
@@ -34,7 +36,7 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
String title;
|
||||
String subtitle;
|
||||
|
||||
GuiButton leftButton, rightButton, backButton;
|
||||
GuiButton leftButton, rightButton, backButton, shareButton;
|
||||
|
||||
public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) {
|
||||
this.entry = entry;
|
||||
@@ -53,6 +55,7 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
buttonList.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
|
||||
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
|
||||
buttonList.add(shareButton = new GuiButtonShare(3, left + guiWidth / 2 + fontRendererObj.getStringWidth(title) / 2 + 12, top - 15));
|
||||
|
||||
updatePageButtons();
|
||||
}
|
||||
@@ -105,7 +108,15 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
page++;
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 3 :
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
String cmd = "/botania-share " + entry.unlocalizedName;
|
||||
|
||||
mc.ingameGUI.getChatGUI().addToSentMessages(cmd);
|
||||
mc.thePlayer.sendChatMessage(cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
updatePageButtons();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Sep 24, 2014, 3:49:21 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
|
||||
public class GuiButtonShare extends GuiButtonLexicon {
|
||||
|
||||
public GuiButtonShare(int par1, int par2, int par3) {
|
||||
super(par1, par2, par3, 10, 12, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
|
||||
int k = getHoverState(field_146123_n);
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 10 : 0 , 200, 10, 12);
|
||||
|
||||
List<String> tooltip = getTooltip();
|
||||
int tooltipY = (tooltip.size() - 1) * 10;
|
||||
if(k == 2)
|
||||
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
|
||||
}
|
||||
|
||||
public List<String> getTooltip() {
|
||||
return Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.clickToShare"));
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
@@ -183,7 +184,7 @@ public class TileAlfPortal extends TileMod {
|
||||
for(ItemStack stack : stacksIn) {
|
||||
if(stack.getItem() instanceof ILexicon) {
|
||||
((ILexicon) stack.getItem()).unlockKnowledge(stack, BotaniaAPI.elvenKnowledge);
|
||||
ItemLexicon.forceMessage(stack, true);
|
||||
ItemLexicon.setForcedPage(stack, LexiconData.elvenMessage.unlocalizedName);
|
||||
spawnItem(stack);
|
||||
stacksIn.remove(i);
|
||||
return;
|
||||
|
||||
+3
-1
@@ -9,8 +9,10 @@
|
||||
*
|
||||
* File Created @ [May 31, 2014, 11:43:13 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.version;
|
||||
package vazkii.botania.common.core.command;
|
||||
|
||||
import vazkii.botania.common.core.version.ThreadDownloadMod;
|
||||
import vazkii.botania.common.core.version.VersionChecker;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Sep 23, 2014, 9:50:14 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
|
||||
public class CommandOpen extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "botania-open";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender p_71518_1_) {
|
||||
return "<entry>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
if(sender instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() instanceof ItemLexicon) {
|
||||
ItemLexicon.setForcedPage(stack, args[0]);
|
||||
ItemLexicon.setQueueTicks(stack, 3);
|
||||
} else sender.addChatMessage(new ChatComponentTranslation("botaniamisc.noLexicon").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Sep 23, 2014, 8:06:49 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.command;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class CommandShare extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "botania-share";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender p_71518_1_) {
|
||||
return "<entry>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
String json = StatCollector.translateToLocal("botaniamisc.shareMsg");
|
||||
json = json.replaceAll("%name%", sender.getCommandSenderName());
|
||||
json = json.replaceAll("%entry%", args[0]);
|
||||
json = json.replaceAll("%entryname%", StatCollector.translateToLocal("botania.entry." + args[0]));
|
||||
|
||||
IChatComponent component = IChatComponent.Serializer.func_150699_a(json);
|
||||
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,9 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.command.CommandDownloadLatest;
|
||||
import vazkii.botania.common.core.command.CommandOpen;
|
||||
import vazkii.botania.common.core.command.CommandShare;
|
||||
import vazkii.botania.common.core.handler.BiomeDecorationHandler;
|
||||
import vazkii.botania.common.core.handler.ChestGenHandler;
|
||||
import vazkii.botania.common.core.handler.CommonTickHandler;
|
||||
@@ -32,7 +35,6 @@ import vazkii.botania.common.core.handler.PixieHandler;
|
||||
import vazkii.botania.common.core.handler.SheddingHandler;
|
||||
import vazkii.botania.common.core.handler.SpawnerChangingHandler;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.core.version.CommandDownloadLatest;
|
||||
import vazkii.botania.common.crafting.ModCrafingRecipes;
|
||||
import vazkii.botania.common.crafting.ModElvenTradeRecipes;
|
||||
import vazkii.botania.common.crafting.ModManaAlchemyRecipes;
|
||||
@@ -94,6 +96,8 @@ public class CommonProxy {
|
||||
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new CommandDownloadLatest());
|
||||
event.registerServerCommand(new CommandShare());
|
||||
event.registerServerCommand(new CommandOpen());
|
||||
}
|
||||
|
||||
public void setEntryToOpen(LexiconEntry entry) {
|
||||
|
||||
@@ -17,10 +17,13 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -44,7 +47,9 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
|
||||
|
||||
private static final String TAG_KNOWLEDGE_PREFIX = "knowledge.";
|
||||
private static final String TAG_FORCED_MESSAGE = "forcedMessage";
|
||||
|
||||
private static final String TAG_QUEUE_TICKS = "queueTicks";
|
||||
boolean skipSound = false;
|
||||
|
||||
public ItemLexicon() {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
@@ -122,15 +127,33 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if(isMessageForced(par1ItemStack)) {
|
||||
Botania.proxy.setEntryToOpen(LexiconData.elvenMessage);
|
||||
forceMessage(par1ItemStack, false);
|
||||
String force = getForcedPage(par1ItemStack);
|
||||
if(force != null && !force.isEmpty()) {
|
||||
LexiconEntry entry = getEntryFromForce(par1ItemStack);
|
||||
if(entry != null)
|
||||
Botania.proxy.setEntryToOpen(entry);
|
||||
else par3EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.cantOpen").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
setForcedPage(par1ItemStack, "");
|
||||
}
|
||||
|
||||
par3EntityPlayer.openGui(Botania.instance, LibGuiIDs.LEXICON, par2World, 0, 0, 0);
|
||||
if(!par2World.isRemote)
|
||||
if(!par2World.isRemote && !skipSound)
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "botania:lexiconOpen", 0.5F, 1F);
|
||||
skipSound = false;
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) {
|
||||
int ticks = getQueueTicks(stack);
|
||||
if(ticks > 0 && entity instanceof EntityPlayer) {
|
||||
skipSound = ticks < 3;
|
||||
onItemRightClick(stack, world, (EntityPlayer) entity);
|
||||
|
||||
setQueueTicks(stack, ticks - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack) {
|
||||
@@ -147,14 +170,33 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true);
|
||||
}
|
||||
|
||||
public static void forceMessage(ItemStack stack, boolean forced) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_FORCED_MESSAGE, forced);
|
||||
public static void setForcedPage(ItemStack stack, String forced) {
|
||||
ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced);
|
||||
}
|
||||
|
||||
public static boolean isMessageForced(ItemStack stack) {
|
||||
return ItemNBTHelper.getBoolean(stack, TAG_FORCED_MESSAGE, false);
|
||||
public static String getForcedPage(ItemStack stack) {
|
||||
return ItemNBTHelper.getString(stack, TAG_FORCED_MESSAGE, "");
|
||||
}
|
||||
|
||||
|
||||
private static LexiconEntry getEntryFromForce(ItemStack stack) {
|
||||
String force = getForcedPage(stack);
|
||||
|
||||
for(LexiconEntry entry : BotaniaAPI.getAllEntries())
|
||||
if(entry.unlocalizedName.equals(force))
|
||||
if(entry != null && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
|
||||
return entry;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getQueueTicks(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_QUEUE_TICKS, 0);
|
||||
}
|
||||
|
||||
public static void setQueueTicks(ItemStack stack, int ticks) {
|
||||
ItemNBTHelper.setInt(stack, TAG_QUEUE_TICKS, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isElvenItem(ItemStack stack) {
|
||||
return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge);
|
||||
|
||||
@@ -40,7 +40,7 @@ botaniamisc.knowledgeTypesPlural=Contains %s Schools of Knowledge
|
||||
botaniamisc.bookmark=Bookmark #%s
|
||||
botaniamisc.clickToSee=Click to read
|
||||
botaniamisc.shiftToRemove=Shift-click to remove
|
||||
botaniamisc.clickToAdd=Click to add a Bookmark here
|
||||
botaniamisc.clickToAdd=Add Bookmark
|
||||
botaniamisc.ratio=%s:1 Ratio
|
||||
botaniamisc.bottleTooltip=It has an acquired taste
|
||||
botaniamisc.coarseDirt0=Coarse Dirt, grass
|
||||
@@ -49,6 +49,10 @@ botaniamisc.spawnerTip=Tip: Use a Spawn Egg to change the mob
|
||||
botaniamisc.shardLevel=Shard Power %s
|
||||
botaniamisc.lexiconIndex=Lexicon Index
|
||||
botaniamisc.hasIvy=Has Timeless Ivy
|
||||
botaniamisc.shareMsg=[{"text":"%name%","color":"light_purple"},{"text":" has shared a ","color":"blue"},{"text":"Lexica Botania","color":"green","hoverEvent":{"action":"show_text","value":{"text":"You can make one using a Book and a Sapling!","color":"aqua"}}},{"text":" entry, click to see it: ","color":"blue"},{"text":"[%entryname%]","color":"green","clickEvent":{"action":"run_command","value":"/botania-open %entry%"},"hoverEvent":{"action":"show_text","value":{"text":"Click to read about this","color":"aqua"}}}]
|
||||
botaniamisc.noLexicon=You need a Lexica Botania in-hand to read this.
|
||||
botaniamisc.cantOpen=It doesn't seem like your Lexica Botania has this page. Perhaps it comes from an outside source...?
|
||||
botaniamisc.clickToShare=Share
|
||||
|
||||
# COLORS
|
||||
botania.color0=White
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Reference in new issue
Block a user