Remove open and share commands and their corresponding vestiges from lexicon files, remove word counter

This commit is contained in:
Vincent Lee committed 2019-10-18 14:31:29 -05:00
1 parent d69389a32e
commit 4fac487589
5 files changed
+3 -162

No files matched your search

@@ -45,8 +45,6 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.ModMultiblocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.brew.ModBrews;
import vazkii.botania.common.core.command.CommandOpen;
import vazkii.botania.common.core.command.CommandShare;
import vazkii.botania.common.core.command.CommandSkyblockSpread;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
@@ -97,6 +95,7 @@ public class Botania {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(IMCSender::enqueue);
FMLJavaModLoadingContext.get().getModEventBus().addListener(IMCHandler::handle);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigHandler.CLIENT_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.COMMON_SPEC);
MinecraftForge.EVENT_BUS.addListener(this::serverAboutToStart);
@@ -303,17 +302,7 @@ public class Botania {
}
*/
// todo 1.13 move everything here to where it belongs
private void loadComplete(FMLLoadCompleteEvent event) {
int words = 0;
for(LexiconEntry entry : BotaniaAPI.getAllEntries())
for(LexiconPage page : entry.pages) {
words += countWords(page.getUnlocalizedName());
if(page instanceof ITwoNamedPage)
words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName());
}
Botania.LOGGER.info("The Lexica Botania has {} words.", words);
finishedLoading = true;
}
@@ -332,8 +321,6 @@ public class Botania {
}
private void serverStarting(FMLServerStartingEvent event) {
CommandShare.register(event.getCommandDispatcher());
CommandOpen.register(event.getCommandDispatcher());
if(Botania.gardenOfGlassLoaded)
CommandSkyblockSpread.register(event.getCommandDispatcher());
}
@@ -342,12 +329,4 @@ public class Botania {
ManaNetworkHandler.instance.clear();
}
private int countWords(String s) {
/* todo 1.13
String s1 = I18n.translateToLocal(s);
return s1.split("\\s+").length;
*/
return 0;
}
}
@@ -1,49 +0,0 @@
/**
* 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 the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Sep 23, 2014, 9:50:14 PM (GMT)]
*/
package vazkii.botania.common.core.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TranslationTextComponent;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.item.ItemLexicon;
public class CommandOpen {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
dispatcher.register(
Commands.literal("botania-open")
.then(Commands.argument("entry", StringArgumentType.string())
.executes(CommandOpen::run))
);
}
private static int run(CommandContext<CommandSource> ctx) throws CommandSyntaxException {
ServerPlayerEntity player = ctx.getSource().asPlayer();
ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, ItemLexicon.class);
if(!stack.isEmpty()) {
ItemLexicon.setForcedPage(stack, StringArgumentType.getString(ctx, "entry"));
ItemLexicon.setQueueTicks(stack, 5);
return 1;
} else {
ctx.getSource().sendErrorMessage(new TranslationTextComponent("botaniamisc.noLexicon"));
return 0;
}
}
}
@@ -1,42 +0,0 @@
/**
* 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 the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Sep 23, 2014, 8:06:49 PM (GMT)]
*/
package vazkii.botania.common.core.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
public class CommandShare {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
dispatcher.register(
Commands.literal("botania-share")
.then(Commands.argument("entry", StringArgumentType.string())
.executes(CommandShare::run))
);
}
private static int run(CommandContext<CommandSource> ctx) {
// todo 1.13
/*
String json = I18n.translateToLocal("botaniamisc.shareMsg");
json = json.replaceAll("%name%", sender.getName());
json = json.replaceAll("%entry%", args[0]);
json = json.replaceAll("%entryname%", I18n.translateToLocal(StringArgumentType.getString(ctx, "entry")));
ITextComponent component = ITextComponent.Serializer.jsonToComponent(json);
ctx.getSource().getServer().getPlayerList().sendMessage(component);
*/
return 1;
}
}
@@ -72,9 +72,6 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
public static final String TAG_ELVEN_UNLOCK = "botania:elven_unlock";
private static final String TAG_KNOWLEDGE_PREFIX = "knowledge.";
private static final String TAG_FORCED_MESSAGE = "forcedMessage";
private static final String TAG_QUEUE_TICKS = "queueTicks";
private boolean skipSound = false;
public ItemLexicon(Properties props) {
super(props);
@@ -138,24 +135,6 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int idk, boolean something) {
int ticks = getQueueTicks(stack);
if(ticks > 0 && entity instanceof PlayerEntity) {
skipSound = ticks < 5;
if(ticks == 1)
onItemRightClick(world, (PlayerEntity) entity, Hand.MAIN_HAND);
setQueueTicks(stack, ticks - 1);
}
}
@Nonnull
@Override
public Rarity getRarity(ItemStack par1ItemStack) {
return Rarity.UNCOMMON;
}
@Override
public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge) {
return knowledge.autoUnlock || ItemNBTHelper.getBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, false);
@@ -166,33 +145,6 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true);
}
public static void setForcedPage(ItemStack stack, String forced) {
ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced);
}
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.getUnlocalizedName().equals(force))
if(((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);
}
public static ITextComponent getTitle(ItemStack stack) {
ITextComponent title = stack.getDisplayName();
@@ -17,6 +17,7 @@ import net.minecraft.item.DyeColor;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
@@ -464,7 +465,7 @@ public final class ModItems {
public static void registerItems(RegistryEvent.Register<Item> evt) {
IForgeRegistry<Item> r = evt.getRegistry();
register(r, new ItemLexicon(unstackable()), LibItemNames.LEXICON);
register(r, new ItemLexicon(unstackable().rarity(Rarity.UNCOMMON)), LibItemNames.LEXICON);
for(DyeColor color : DyeColor.values()) {
register(r, new ItemPetal(ModBlocks.getBuriedPetal(color), color, defaultBuilder()), color.getName() + LibItemNames.PETAL_SUFFIX);
register(r, new ItemDye(color, defaultBuilder()), color.getName() + LibItemNames.DYE_SUFFIX);