From 5438138c936e20a59559ee83b3ab3b7694d4ccac Mon Sep 17 00:00:00 2001 From: Michael Brenan Date: Thu, 14 Jan 2016 22:44:54 -0600 Subject: [PATCH 01/10] Add preemptive bugfix - Swappers now threadsafe --- .../botania/common/item/ItemGrassSeeds.java | 32 +++++++++++++++---- .../tool/terrasteel/ItemTerraAxe.java | 26 ++++++++++++--- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java index 2400e5582..7a9c57617 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java @@ -11,11 +11,13 @@ package vazkii.botania.common.item; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -41,7 +43,11 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { - private static Map> blockSwappers = new HashMap(); + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new ConcurrentHashMap>(); private static final IslandType[] ISLAND_TYPES = { IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, @@ -169,25 +175,39 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { if(event.phase == Phase.END) { int dim = event.world.provider.dimensionId; if(blockSwappers.containsKey(dim)) { - List swappers = blockSwappers.get(dim); + Set swappers = blockSwappers.get(dim); - Iterator iter = swappers.listIterator(); + Iterator iter = swappers.iterator(); while(iter.hasNext()) { BlockSwapper next = iter.next(); - if(!next.tick()) + if(next == null || !next.tick()) iter.remove(); } } } } + /** + * Adds a grass seed block swapper to the world at the provided positiona + * and with the provided meta (which designates the type of the grass + * being spread). + * @param world The world the swapper will be in. + * @param x The x-position of the swapper. + * @param y The y-position of the swapper. + * @param z The z-position of the swapper. + * @param meta The meta value representing the type of block being swapped. + * @return The created block swapper. + */ private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); + // If a set for the dimension doesn't exist, create it. int dim = world.provider.dimensionId; if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, new ArrayList()); + blockSwappers.put(dim, Collections.newSetFromMap(new ConcurrentHashMap())); + + // Add the block swapper blockSwappers.get(dim).add(swapper); return swapper; diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java index 370081172..fc7f7f3f8 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java @@ -11,13 +11,14 @@ package vazkii.botania.common.item.equipment.tool.terrasteel; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -70,7 +71,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker */ private static final int MANA_PER_DAMAGE = 100; - private static Map> blockSwappers = new HashMap>(); + private static Map> blockSwappers = new ConcurrentHashMap>(); IIcon iconOn, iconOff; @@ -134,27 +135,42 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker if(event.phase == Phase.END) { int dim = event.world.provider.dimensionId; if(blockSwappers.containsKey(dim)) { - List swappers = blockSwappers.get(dim); + Set swappers = blockSwappers.get(dim); // Iterate through all of our swappers, removing any // which no longer need to tick. Iterator swapper = swappers.iterator(); while(swapper.hasNext()) { BlockSwapper next = swapper.next(); - if(!next.tick()) + + // If a null sneaks in or the swapper is done, remove it + if(next == null || !next.tick()) swapper.remove(); } } } } + /** + * Adds a new block swapper to the provided world as the provided player. + * @param world The world to add the swapper to. + * @param player The player who is responsible for this swapper. + * @param stack The Terra Truncator which caused this block swapper. + * @param origCoords The original coordinates the swapper should start at. + * @param steps The range of the block swapper, in blocks. + * @param leaves If true, will treat leaves specially (see the BlockSwapper + * documentation). + * @return The created block swapper. + */ private static BlockSwapper addBlockSwapper(World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); + // If the mapping for this dimension doesn't exist, create it. int dim = world.provider.dimensionId; if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, new ArrayList()); + blockSwappers.put(dim, Collections.newSetFromMap(new ConcurrentHashMap())); + // Add the swapper blockSwappers.get(dim).add(swapper); return swapper; From 54f1dd0478045855df9c21252bfb41113d9b21cf Mon Sep 17 00:00:00 2001 From: Michael Brenan Date: Fri, 15 Jan 2016 03:24:21 -0600 Subject: [PATCH 02/10] Fix #1749 - Mana Tablets no longer lose durability in storage drawer --- .../botania/common/item/ItemManaTablet.java | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java index 167ca07ad..f66cab2a8 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java @@ -49,13 +49,16 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP @Override public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - par3List.add(new ItemStack(par1, 1, 10000)); + // Empty tablet + par3List.add(new ItemStack(par1, 1)); - ItemStack fullPower = new ItemStack(par1, 1, 1); + // Full tablet + ItemStack fullPower = new ItemStack(par1, 1); setMana(fullPower, MAX_MANA); par3List.add(fullPower); - ItemStack creative = new ItemStack(par1, 1, 0); + // Creative Tablet + ItemStack creative = new ItemStack(par1, 1); setMana(creative, MAX_MANA); setStackCreative(creative); par3List.add(creative); @@ -69,13 +72,12 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP @Override public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int) (mana / MAX_MANA * 1000); - } + // Compatibility shim, so tablets from previous versions of botania + // stack right in barrels and so forth + if(super.getDamage(stack) != 0) + super.setDamage(stack, 0); - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); + return 0; } @Override @@ -168,4 +170,18 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP public float getManaFractionForDisplay(ItemStack stack) { return (float) getMana(stack) / (float) getMaxMana(stack); } + + + @Override + public boolean showDurabilityBar(ItemStack stack) { + // If the stack is not creative, show the durability bar. + return !isStackCreative(stack); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + // I believe Forge has their durability values swapped, hence the (1.0 -). + // This will probably be fixed soon. + return 1.0 - getManaFractionForDisplay(stack); + } } From 24cf30a29e95d427ba0dbc47979c0835aab230dc Mon Sep 17 00:00:00 2001 From: Michael Brenan Date: Fri, 15 Jan 2016 18:26:45 -0600 Subject: [PATCH 03/10] Bugfix followup - Block swappers use sidedness to control concurrency --- .../botania/common/item/ItemGrassSeeds.java | 20 +++++++++++--- .../tool/terrasteel/ItemTerraAxe.java | 27 ++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java index 7a9c57617..b63033154 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java @@ -11,13 +11,13 @@ package vazkii.botania.common.item; import java.util.ArrayList; -import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -47,7 +47,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { * Represents a map of dimension IDs to a set of all block swappers * active in that dimension. */ - private static Map> blockSwappers = new ConcurrentHashMap>(); + private static Map> blockSwappers = new HashMap>(); private static final IslandType[] ISLAND_TYPES = { IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, @@ -172,6 +172,10 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { @SubscribeEvent public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block swapper updates should only occur on the server + if(event.world.isRemote) + return; + if(event.phase == Phase.END) { int dim = event.world.provider.dimensionId; if(blockSwappers.containsKey(dim)) { @@ -192,6 +196,10 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { * Adds a grass seed block swapper to the world at the provided positiona * and with the provided meta (which designates the type of the grass * being spread). + * + * Block swappers are only actually created on the server, so a client + * calling this method will recieve a marker block swapper which contains + * the provided information but is not ticked. * @param world The world the swapper will be in. * @param x The x-position of the swapper. * @param y The y-position of the swapper. @@ -202,10 +210,14 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); + // Block swappers are only registered on the server + if(world.isRemote) + return swapper; + // If a set for the dimension doesn't exist, create it. int dim = world.provider.dimensionId; if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, Collections.newSetFromMap(new ConcurrentHashMap())); + blockSwappers.put(dim, new HashSet()); // Add the block swapper blockSwappers.get(dim).add(swapper); diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java index fc7f7f3f8..11ad6a5bf 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java @@ -11,14 +11,13 @@ package vazkii.botania.common.item.equipment.tool.terrasteel; import java.util.ArrayList; -import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -70,8 +69,12 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker * The amount of mana required to restore 1 point of damage. */ private static final int MANA_PER_DAMAGE = 100; - - private static Map> blockSwappers = new ConcurrentHashMap>(); + + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new HashMap>(); IIcon iconOn, iconOff; @@ -132,6 +135,10 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker @SubscribeEvent public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block Swapping ticking should only occur on the server + if(event.world.isRemote) + return; + if(event.phase == Phase.END) { int dim = event.world.provider.dimensionId; if(blockSwappers.containsKey(dim)) { @@ -153,6 +160,10 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker /** * Adds a new block swapper to the provided world as the provided player. + * Block swappers are only added on the server, and a marker instance + * which is not actually ticked but contains the proper passed in + * information will be returned to the client. + * * @param world The world to add the swapper to. * @param player The player who is responsible for this swapper. * @param stack The Terra Truncator which caused this block swapper. @@ -165,11 +176,15 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker private static BlockSwapper addBlockSwapper(World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); + // Block swapper registration should only occur on the server + if(world.isRemote) + return swapper; + // If the mapping for this dimension doesn't exist, create it. int dim = world.provider.dimensionId; if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, Collections.newSetFromMap(new ConcurrentHashMap())); - + blockSwappers.put(dim, new HashSet()); + // Add the swapper blockSwappers.get(dim).add(swapper); From c0e735319267a0b3a84631a721ae3ff9d8c4fa26 Mon Sep 17 00:00:00 2001 From: TheWhiteWolves Date: Sun, 17 Jan 2016 14:50:50 +0000 Subject: [PATCH 04/10] Move disposable blocks list to API and add hook and semi disposable list --- .../java/vazkii/botania/api/BotaniaAPI.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 69d32542a..eb0d0508c 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -65,6 +65,9 @@ public final class BotaniaAPI { public static Map knowledgeTypes = new HashMap(); public static Map brewMap = new LinkedHashMap(); + + public static List disposableBlocks = new ArrayList(); + public static List semiDisposableBlocks = new ArrayList(); public static List petalRecipes = new ArrayList(); public static List pureDaisyRecipes = new ArrayList(); @@ -236,6 +239,16 @@ public final class BotaniaAPI { registerPaintableBlock(Blocks.stained_hardened_clay); registerPaintableBlock(Blocks.wool); registerPaintableBlock(Blocks.carpet); + + registerDisposableBlock("dirt"); // Vanilla + registerDisposableBlock("sand"); // Vanilla + registerDisposableBlock("gravel"); // Vanilla + registerDisposableBlock("cobblestone"); // Vanilla + registerDisposableBlock("netherrack"); // Vanilla + registerSemiDisposableBlock("stoneAndesite"); // Botania + registerSemiDisposableBlock("stoneBasalt"); // Botania + registerSemiDisposableBlock("stoneDiorite"); // Botania + registerSemiDisposableBlock("stoneGranite"); // Botania } /** @@ -275,6 +288,21 @@ public final class BotaniaAPI { return fallbackBrew; } + /* + * Registers a Block as disposable using its Ore Dictionary Name. + */ + public static void registerDisposableBlock(String oreDictName) { + disposableBlocks.add(oreDictName); + } + + /* + * Registers a Block as semi disposable using its Ore Dictionary Name. + * This means it will not be trashed when sneaking. + */ + public static void registerSemiDisposableBlock(String oreDictName) { + semiDisposableBlocks.add(oreDictName); + } + /** * Registers a paintableBlock and returns it. */ From d431207eec81d164beeb0e3e61981f9c731cd2b5 Mon Sep 17 00:00:00 2001 From: TheWhiteWolves Date: Sun, 17 Jan 2016 14:51:39 +0000 Subject: [PATCH 05/10] Change to use API version of disposable blocks and implement semi-disposable --- .../tool/elementium/ItemElementiumPick.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java index 4ef76bb2a..bead2f8fc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java @@ -17,10 +17,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemElementiumPick extends ItemManasteelPick { - static final List validBlocks = Arrays.asList(new String[] { - "dirt", "sand", "gravel", "cobblestone", "netherrack" - }); - public ItemElementiumPick() { super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK); MinecraftForge.EVENT_BUS.register(this); @@ -30,24 +26,36 @@ public class ItemElementiumPick extends ItemManasteelPick { public void onHarvestDrops(HarvestDropsEvent event) { if(event.harvester != null) { ItemStack stack = event.harvester.getCurrentEquippedItem(); - if(stack != null && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) + if(stack != null && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { for(int i = 0; i < event.drops.size(); i++) { ItemStack drop = event.drops.get(i); if(drop != null) { Block block = Block.getBlockFromItem(drop.getItem()); - if(block != null && isDisposable(block)) - event.drops.remove(i); + if(block != null){ + if(isDisposable(block) || (isSemiDisposable(block) && !event.harvester.isSneaking())) + event.drops.remove(i); + } } } + } } } public static boolean isDisposable(Block block) { - for(int id : OreDictionary.getOreIDs(new ItemStack(block))) - if(validBlocks.contains(OreDictionary.getOreName(id))) + for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if(BotaniaAPI.disposableBlocks.contains(name)) return true; - + } + return false; + } + + public static boolean isSemiDisposable(Block block) { + for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if(BotaniaAPI.semiDisposableBlocks.contains(name)) + return true; + } return false; } - } From a6896f250f6e61afea98b2393af973acc4e330d4 Mon Sep 17 00:00:00 2001 From: TheWhiteWolves Date: Sun, 17 Jan 2016 14:51:51 +0000 Subject: [PATCH 06/10] bump API version --- src/main/java/vazkii/botania/api/package-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index afc095ad3..f5ba9c024 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Botania", apiVersion = "75", provides = "BotaniaAPI") +@API(owner = "Botania", apiVersion = "76", provides = "BotaniaAPI") package vazkii.botania.api; import cpw.mods.fml.common.API; From 2df3b356fd7d58c70ef67f722b21ba1e398953b6 Mon Sep 17 00:00:00 2001 From: Eladkay Date: Mon, 18 Jan 2016 15:00:17 +0200 Subject: [PATCH 07/10] Fixed license link in FAQ page. If issue is not obvious: https://gyazo.com/c4657c529a337f37a3c67925e8e5e61e --- web/module/faq.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/module/faq.php b/web/module/faq.php index a1071ddcf..5558d643d 100644 --- a/web/module/faq.php +++ b/web/module/faq.php @@ -6,7 +6,7 @@ \ No newline at end of file + From 177c5b1d1ba694235476b55088f73f58aa65be77 Mon Sep 17 00:00:00 2001 From: NatsuArashi Date: Tue, 19 Jan 2016 19:31:17 +0800 Subject: [PATCH 08/10] Update zh_TW.lang FIX SOMETHING...? --- .../resources/assets/botania/lang/zh_TW.lang | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/assets/botania/lang/zh_TW.lang b/src/main/resources/assets/botania/lang/zh_TW.lang index 3afa9cfe6..881efc4c9 100644 --- a/src/main/resources/assets/botania/lang/zh_TW.lang +++ b/src/main/resources/assets/botania/lang/zh_TW.lang @@ -34,15 +34,15 @@ botaniamisc.toolRank=%s&7 級 botaniamisc.edition=%s 版本 # ^ Leave this empty for no edition display botaniamisc.devEdition=作者的 -botaniamisc.lexiconcover0=在植物魔法中 -botaniamisc.lexiconcover1=你所需的指南 -botaniamisc.lexiconcover2=來自暢銷書作者 -botaniamisc.lexiconcover3=Lizbeth "Vazkii" Rika +botaniamisc.lexiconcover0=一本由 Lizbeth "Vazkii" +botaniamisc.lexiconcover1=Whitewood 所撰寫的 +botaniamisc.lexiconcover2=官方指引手冊,詳述 +botaniamisc.lexiconcover3=所有植物魔法所需知識 botaniamisc.lexiconcover4=由BevoLJ編輯 botaniamisc.lexiconcover5=由Saice編輯 botaniamisc.shiftinfo=按住&bSHIFT&7顯示更多 -botaniamisc.knowledgeTypesSingular=內含%s個世界的知識 -botaniamisc.knowledgeTypesPlural=內含%s個世界的知識 +botaniamisc.knowledgeTypesSingular=包含%s個世界的知識 +botaniamisc.knowledgeTypesPlural=包含%s個世界的知識 botaniamisc.bookmark=書籤 #%s botaniamisc.clickToSee=點擊閱讀 botaniamisc.shiftToRemove=Shift點擊移除 @@ -146,7 +146,7 @@ botaniamisc.badArena=只要你努力,信標就不會讓你白白犧牲。你 botaniamisc.tutorialText=Ingame botaniamisc.tutorialVideo=Video botaniamisc.shiftToStopSpin=(SHIFT以停止動畫) -botaniamisc.noVideo=&4視頻教程很快就有,抱歉 :( +botaniamisc.noVideo=&4視頻教程很快就有 ,抱歉 :( botaniamisc.adaptativeConfigChanges=Botania自調整系統為你調整了以下默認設定: botaniamisc.altarRefill0=用空手右擊 botaniamisc.altarRefill1=返回最後一個合成 @@ -1951,7 +1951,7 @@ botania.page.welcome0=&o什麼是和平?是沒有鬥爭?是 年復一年的待 botania.page.welcome1=&o和平是不需勞作就能獲得之 物-又或是難以獲得之物?
讓我們來簡單地說說-只需要 一會兒-和平其實就是無需工 作;可以過著被花朵所包圍的 和平日子. botania.page.welcome2=&o看著你的植物們如預期般的 完成各自的任務,就這樣感受 著時間的流逝,沒有嘈雜且汙 染四布的機器和電腦,也沒有 密佈的線纜和管道.
現在想像一下,我們所討論的 這一切都是可能實現的. botania.page.welcome3=&o想像下,經過你的一番努力- 對植物的精心培養,對瑪那的 使用,對於這個世界和紅石的 知識運用-你就能達到那種夢 寐以求的境界.想像下你所需 求的一切都能通過植物來實 現自動化.植物,加上些瑪那, 還有你的智慧. -botania.page.welcome4=&o有了這本書,你就能夢想成真 了.
書名只是表面的.儘管稱它植 物瑪那辭典,但它所涉及的可 不僅僅都是花.其中也涵蓋了 各種瑪那和近似科技的裝置. +botania.page.welcome4=&o有了這本書,你就能夢想成真 了.
書名只是表面的.儘管稱它植 物魔法辭典,但它所涉及的可 不僅僅都是花.其中也涵蓋了 各種魔法和近似科技的裝置. botania.page.welcome5=&o它裡面也蘊藏著精靈的秘密, 而精靈們卻早已帶著世界起 源的線索一同消失在了這個 世界上.對於每一個有著基礎 紅石知識並能將其投入實踐 的人而言,這本書為每一個人 們所知的問題給出了答案,有 了它你就再也不需要學習那 些不明所以的瑪那和機械知 識了. botania.page.welcome6=&o書的內容也包括了你所要進 行的每一項任務的解釋說明, 只需要用上書中的東西,確保 在Minecraft的世界裡可行, 然後動用你的聰明才智,難題 就都不是問題了.
試試看,你會吃驚於自己在沒 有外界干擾的情況下竟然可 以做到這麼多. From adc06dc6ce11dbbf8ebb31843f1ca5d53932a213 Mon Sep 17 00:00:00 2001 From: TheWhiteWolves Date: Thu, 21 Jan 2016 22:43:43 +0000 Subject: [PATCH 09/10] Added a blacklist to the Rod of the Shaded Mesa --- .../java/vazkii/botania/api/BotaniaAPI.java | 18 +++++ .../common/item/rod/ItemGravityRod.java | 70 +++++++++++-------- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index eb0d0508c..96acba8b5 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.Set; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; @@ -89,6 +90,7 @@ public final class BotaniaAPI { public static Set looniumBlacklist = new LinkedHashSet(); public static Set paintableBlocks = new LinkedHashSet(); public static Set magnetBlacklist = new LinkedHashSet(); + public static Set> gravityRodBlacklist = new LinkedHashSet>(); public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18); public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); @@ -311,6 +313,22 @@ public final class BotaniaAPI { return paintable; } + /* + * Blacklists an Entity from being affected by the Rod of the Shaded Mesa. + * Pass in the class for the Entity, e.g. EntityCow.class + */ + public static void blacklistEntityFromGravityRod(Class entity) { + gravityRodBlacklist.add(entity); + } + + /* + * Checks if the provided Entity is contained in the Blacklist. + * Pass in the class for the Entity, e.g. entity.getClass() + */ + public static boolean isEntityBlacklistedFromGravityRod(Class entity) { + return gravityRodBlacklist.contains(entity); + } + /** * Blacklists an item from being pulled by the Ring of Magnetization. * Short.MAX_VALUE can be used as the stack's damage for a wildcard. diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java index 34b254266..08e2b8f13 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java @@ -22,6 +22,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IManaProficiencyArmor; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -80,11 +81,12 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); + if(ticksCooldown == 0) { Entity item = null; if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { Entity taritem = player.worldObj.getEntityByID(targetID); - + boolean found = false; Vector3 target = Vector3.fromEntityCenter(player); List entities = new ArrayList(); @@ -123,38 +125,43 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { } } - if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true) && item != null) { - if(item instanceof EntityItem) - ((EntityItem)item).delayBeforeCanPickup = 5; + if(item != null) { + if(BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass())) + return stack; + + if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { + if(item instanceof EntityItem) + ((EntityItem)item).delayBeforeCanPickup = 5; - if(item instanceof EntityLivingBase) { - EntityLivingBase targetEntity = (EntityLivingBase)item; - targetEntity.fallDistance = 0.0F; - if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) - targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); + if(item instanceof EntityLivingBase) { + EntityLivingBase targetEntity = (EntityLivingBase)item; + targetEntity.fallDistance = 0.0F; + if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) + targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); + } + + Vector3 target3 = Vector3.fromEntityCenter(player); + target3.add(new Vector3(player.getLookVec()).multiply(length)); + target3.y += 0.5; + if(item instanceof EntityItem) + target3.y += 0.25; + + for(int i = 0; i < 4; i++) { + float r = 0.5F + (float) Math.random() * 0.5F; + float b = 0.5F + (float) Math.random() * 0.5F; + float s = 0.2F + (float) Math.random() * 0.1F; + float m = 0.1F; + float xm = ((float) Math.random() - 0.5F) * m; + float ym = ((float) Math.random() - 0.5F) * m; + float zm = ((float) Math.random() - 0.5F) * m; + Botania.proxy.wispFX(world, item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm); + } + + setEntityMotionFromVector(item, target3, 0.3333333F); + + ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); + ItemNBTHelper.setDouble(stack, TAG_DIST, length); } - - Vector3 target3 = Vector3.fromEntityCenter(player); - target3.add(new Vector3(player.getLookVec()).multiply(length)); - target3.y += 0.5; - if(item instanceof EntityItem) - target3.y += 0.25; - - for(int i = 0; i < 4; i++) { - float r = 0.5F + (float) Math.random() * 0.5F; - float b = 0.5F + (float) Math.random() * 0.5F; - float s = 0.2F + (float) Math.random() * 0.1F; - float m = 0.1F; - float xm = ((float) Math.random() - 0.5F) * m; - float ym = ((float) Math.random() - 0.5F) * m; - float zm = ((float) Math.random() - 0.5F) * m; - Botania.proxy.wispFX(world, item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm); - } - - setEntityMotionFromVector(item, target3, 0.3333333F); - - ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); - ItemNBTHelper.setDouble(stack, TAG_DIST, length); } if(item != null) @@ -186,6 +193,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); ItemNBTHelper.getDouble(stack, TAG_DIST, -1); Entity item = null; + if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { Entity taritem = player.worldObj.getEntityByID(targetID); From 275729d54ea783aba32929f0a91a7ac32107a4f2 Mon Sep 17 00:00:00 2001 From: TheWhiteWolves Date: Thu, 21 Jan 2016 23:13:41 +0000 Subject: [PATCH 10/10] Popped a null check in onEquipped() to ensure player isn't null, hopefully helps with Issue #1757 --- .../common/item/equipment/bauble/ItemBauble.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java index 77bd4604a..f8d75a891 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java @@ -129,14 +129,16 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt @Override public void onEquipped(ItemStack stack, EntityLivingBase player) { - if(!player.worldObj.isRemote) - player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); + if(player != null) { + if(!player.worldObj.isRemote) + player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); - if(player instanceof EntityPlayer) - ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); + if(player instanceof EntityPlayer) + ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } } public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {