diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 9136e13bf..fd56bda2e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -27,6 +27,7 @@ import de.ellpeck.actuallyadditions.mod.crafting.*; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.gen.OreGen; import de.ellpeck.actuallyadditions.mod.items.InitItems; +import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats; import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting; import de.ellpeck.actuallyadditions.mod.items.lens.LensMining; import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; @@ -209,7 +210,7 @@ public final class InitBooklet{ //No RF Using Items new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant(); - new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial(); + new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())).addTextReplacement("", ItemWingsOfTheBats.MAX_FLY_TIME/20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial(); new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText()); new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemLeafBlowerAdvanced), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant(); new BookletChapter("playerProbe", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemPlayerProbe), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipePlayerProbe).setNoText()).setSpecial(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java index 0f0c1d61c..1df3dceec 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java @@ -52,6 +52,7 @@ public final class PlayerData{ public boolean bookGottenAlready; public boolean didBookTutorial; public boolean hasBatWings; + public boolean shouldDisableBatWings; public int batWingsFlyTime; public IBookletPage[] bookmarks = new IBookletPage[12]; @@ -63,10 +64,11 @@ public final class PlayerData{ this.id = id; } - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound, boolean savingToFile){ this.displayTesla = compound.getBoolean("DisplayTesla"); this.bookGottenAlready = compound.getBoolean("BookGotten"); this.didBookTutorial = compound.getBoolean("DidTutorial"); + this.hasBatWings = compound.getBoolean("HasBatWings"); this.batWingsFlyTime = compound.getInteger("BatWingsFlyTime"); @@ -78,12 +80,17 @@ public final class PlayerData{ this.bookmarks[i] = page; } } + + if(!savingToFile){ + this.shouldDisableBatWings = compound.getBoolean("ShouldDisableWings"); + } } - public void writeToNBT(NBTTagCompound compound){ + public void writeToNBT(NBTTagCompound compound, boolean savingToFile){ compound.setBoolean("DisplayTesla", this.displayTesla); compound.setBoolean("BookGotten", this.bookGottenAlready); compound.setBoolean("DidTutorial", this.didBookTutorial); + compound.setBoolean("HasBatWings", this.hasBatWings); compound.setInteger("BatWingsFlyTime", this.batWingsFlyTime); @@ -92,6 +99,10 @@ public final class PlayerData{ bookmarks.appendTag(new NBTTagString(bookmark == null ? "" : bookmark.getIdentifier())); } compound.setTag("Bookmarks", bookmarks); + + if(!savingToFile){ + compound.setBoolean("ShouldDisableWings", this.shouldDisableBatWings); + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java index 29cada13b..ba91e625c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java @@ -149,7 +149,7 @@ public class WorldData{ NBTTagCompound data = player.getCompoundTag("Data"); PlayerSave save = new PlayerSave(id); - save.readFromNBT(data); + save.readFromNBT(data, true); this.playerSaveData.put(id, save); } } @@ -169,7 +169,7 @@ public class WorldData{ player.setUniqueId("UUID", save.id); NBTTagCompound data = new NBTTagCompound(); - save.writeToNBT(data); + save.writeToNBT(data, true); player.setTag("Data", data); playerList.appendTag(player); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java index 1f5a655d5..ea4750e9d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java @@ -16,11 +16,15 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.util.StackUtil; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDropsEvent; @@ -31,7 +35,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ItemWingsOfTheBats extends ItemBase{ - private static final int MAX_FLY_TIME = 800; + public static final int MAX_FLY_TIME = 800; public ItemWingsOfTheBats(String name){ super(name); @@ -107,7 +111,7 @@ public class ItemWingsOfTheBats extends ItemBase{ PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); if(!player.worldObj.isRemote){ - boolean shouldDeduct = false; + boolean tryDeduct = false; boolean shouldSend = false; boolean wingsEquipped = StackUtil.isValid(ItemWingsOfTheBats.getWingItem(player)); @@ -119,7 +123,7 @@ public class ItemWingsOfTheBats extends ItemBase{ } } else{ - shouldDeduct = true; + tryDeduct = true; } } else{ @@ -133,12 +137,12 @@ public class ItemWingsOfTheBats extends ItemBase{ shouldSend = true; } } - else{ - shouldDeduct = true; - } + + tryDeduct = true; } else{ data.hasBatWings = false; + data.shouldDisableBatWings = true; shouldSend = true; player.capabilities.allowFlying = false; @@ -147,25 +151,41 @@ public class ItemWingsOfTheBats extends ItemBase{ } } - if(shouldDeduct){ - if(data.batWingsFlyTime >= 0){ - data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime-5); + if(tryDeduct && data.batWingsFlyTime > 0){ + int deductTime = 0; + + if(!player.capabilities.isFlying){ + deductTime = 2; + } + else{ + BlockPos pos = new BlockPos(player.posX, player.posY+player.height, player.posZ); + IBlockState state = player.worldObj.getBlockState(pos); + if(state != null && state.isSideSolid(player.worldObj, pos, EnumFacing.DOWN)){ + deductTime = 10; + } } - if(player.worldObj.getTotalWorldTime()%10 == 0){ - shouldSend = true; + if(deductTime > 0){ + data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime-deductTime); + + if(player.worldObj.getTotalWorldTime()%10 == 0){ + shouldSend = true; + } } } if(shouldSend){ PacketHandlerHelper.sendPlayerDataPacket(player, false, true); + data.shouldDisableBatWings = false; //was set only temporarily to send it } } else{ if(data.hasBatWings){ player.capabilities.allowFlying = true; } - else{ + else if(data.shouldDisableBatWings){ //so that other modded flying won't be disabled + data.shouldDisableBatWings = false; + player.capabilities.allowFlying = false; player.capabilities.isFlying = false; player.capabilities.disableDamage = false; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index ad6436f08..32838dce3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -115,7 +115,7 @@ public final class PacketHandler{ public void handleData(NBTTagCompound compound){ NBTTagCompound data = compound.getCompoundTag("Data"); UUID id = compound.getUniqueId("UUID"); - PlayerData.getDataFromPlayer(id).readFromNBT(data); + PlayerData.getDataFromPlayer(id).readFromNBT(data, false); if(compound.getBoolean("Log")){ ModUtil.LOGGER.info("Receiving (new or changed) Player Data for player with UUID "+id+"."); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java index da0d5254f..9930a53d1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java @@ -38,7 +38,7 @@ public final class PacketHandlerHelper{ compound.setBoolean("Log", log); NBTTagCompound data = new NBTTagCompound(); - PlayerData.getDataFromPlayer(player).writeToNBT(data); + PlayerData.getDataFromPlayer(player).writeToNBT(data, false); compound.setTag("Data", data); if(toClient){ diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 960ff8e3e..400911806 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -887,7 +887,7 @@ booklet.actuallyadditions.chapter.canola.text.2=For starters, you can use a Oil Generator, it will keep the liquid inside. If you want to empty it out, just place it in the crafting grid and all of the fluid will be drained. booklet.actuallyadditions.chapter.wings.name=Wings Of The Bats -booklet.actuallyadditions.chapter.wings.text.1=Sometimes, bats will drop Wings. These wings can't really be used to fly, but that's just because they're not powerful enough. To make them more powerful, you can craft Wings Of The Bats. When you have these in your inventory, they will allow you to fly like in creative mode. +booklet.actuallyadditions.chapter.wings.text.1=Sometimes, bats will drop Wings. These wings can be used to make Wings Of The Bats, which allow you to fly in a creative way. However, after about seconds, your weight won't be supported anymore and you will drop to the ground. To remove exhaustion from your wings, either stand on the ground to remove exhaustion slowly, or hang on to the ceiling by flying up below a solid block like a bat while the wings aren't fully exhausted to remove exhaustion fast. booklet.actuallyadditions.chapter.foods.name=Foodstuffs