diff --git a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java index 481f9d716..170331eeb 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java +++ b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java @@ -240,7 +240,7 @@ public class MiscellaneousIcons { } private void register(AtlasTexture map, String name) { - map.registerSprite(null, new ResourceLocation(LibMisc.MOD_ID, name)); + // todo 1.14 map.registerSprite(null, new ResourceLocation(LibMisc.MOD_ID, name)); } private TextureAtlasSprite get(AtlasTexture map, String name) { diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java index 5be6b2ca7..5b0141c73 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java @@ -16,14 +16,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.button.Button; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.InputMappings; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SharedConstants; import net.minecraft.util.text.ITextComponent; @@ -47,7 +44,7 @@ import vazkii.botania.client.gui.lexicon.button.GuiButtonChallengeInfo; import vazkii.botania.client.gui.lexicon.button.GuiButtonChallenges; import vazkii.botania.client.gui.lexicon.button.GuiButtonDoot; import vazkii.botania.client.gui.lexicon.button.GuiButtonHistory; -import vazkii.botania.client.gui.lexicon.button.GuiButtonInvisible; +import vazkii.botania.client.gui.lexicon.button.GuiButtonIndexEntry; import vazkii.botania.client.gui.lexicon.button.GuiButtonNotes; import vazkii.botania.client.gui.lexicon.button.GuiButtonOptions; import vazkii.botania.client.gui.lexicon.button.GuiButtonScaleChange; @@ -61,6 +58,7 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lexicon.page.PageText; import vazkii.botania.common.lib.LibMisc; +import javax.annotation.Nonnull; import java.time.LocalDateTime; import java.time.Month; import java.util.ArrayDeque; @@ -169,7 +167,6 @@ public class GuiLexicon extends Screen { lastTime = ClientTickHandler.ticksInGame; - title = ItemLexicon.getTitle(stackUsed); currentOpenLexicon = this; left = width / 2 - guiWidth / 2; @@ -180,7 +177,7 @@ public class GuiLexicon extends Screen { int x = 18; for(int i = 0; i < 12; i++) { int y = 16 + i * 12; - buttons.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); + buttons.add(new GuiButtonIndexEntry((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); } populateIndex(); } else if(isCategoryIndex()) { @@ -428,9 +425,10 @@ public class GuiLexicon extends Screen { return font.getStringWidth(b) + 15; } + @Nonnull @Override public ITextComponent getTitle() { - return title; + return ItemLexicon.getTitle(stackUsed); } String getSubtitle() { @@ -454,8 +452,8 @@ public class GuiLexicon extends Screen { } public static int getMaxAllowedScale() { - Minecraft mc = Minecraft.getInstance(); - return mc.mainWindow.getScaleFactor(0); + // Reference: AbstractOption.GUI_SCALE + return Minecraft.getInstance().mainWindow.calcGuiScale(0, Minecraft.getInstance().getForceUnicodeFont()); } void populateIndex() { @@ -463,7 +461,7 @@ public class GuiLexicon extends Screen { int shift = 2; for(int i = shift; i < 12; i++) { int i_ = i - shift; - GuiButtonInvisible button = (GuiButtonInvisible) buttons.get(i); + GuiButtonIndexEntry button = (GuiButtonIndexEntry) buttons.get(i); LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_); if(category != null) button.setMessage(I18n.format(category.getUnlocalizedName())); diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java index 635bbe9ea..a17f90b64 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java @@ -30,6 +30,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.material.ItemRune; import vazkii.botania.common.lexicon.page.PageText; +import javax.annotation.Nonnull; import java.io.IOException; public class GuiLexiconChallenge extends GuiLexicon implements IParented { @@ -125,10 +126,11 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented { return false; } + @Nonnull @Override public ITextComponent getTitle() { return challenge == null - ? new StringTextComponent("(null)") + ? super.getTitle() : new TranslationTextComponent(challenge.unlocalizedName); } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java index 5516f5798..970c5e7bc 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java @@ -12,15 +12,13 @@ package vazkii.botania.client.gui.lexicon; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; @@ -31,7 +29,7 @@ import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.gui.lexicon.button.GuiButtonBack; -import vazkii.botania.client.gui.lexicon.button.GuiButtonInvisible; +import vazkii.botania.client.gui.lexicon.button.GuiButtonIndexEntry; import vazkii.botania.client.gui.lexicon.button.GuiButtonPage; import vazkii.botania.common.lexicon.DogLexiconEntry; @@ -161,7 +159,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented { LexiconEntry tutEntry = !tutorial.isEmpty() ? tutorial.peek() : null; for(int i = page * 12; i < (page + 1) * 12; i++) { - GuiButtonInvisible button = (GuiButtonInvisible) buttons.get(i - page * 12); + GuiButtonIndexEntry button = (GuiButtonIndexEntry) buttons.get(i - page * 12); LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i); if(entry != null) { button.setMessage(entry.getKnowledgeType().color + "" + (entry.isPriority() ? TextFormatting.ITALIC : "") + I18n.format(entry.getUnlocalizedName())); @@ -175,10 +173,10 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented { } } - public void setHoveredButton(GuiButtonInvisible b) { + public void setHoveredButton(GuiButtonIndexEntry b) { if(b == null) currentEntry = null; - else currentEntry = entriesToDisplay.get(b.id + page * 12); + else currentEntry = entriesToDisplay.get(b.ordinal + page * 12); currentButton = b; } @@ -276,15 +274,18 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented { return; } - for(Button button : buttons) { - int id = button.id; - int index = id + page * 12; - if(index >= entriesToDisplay.size()) - continue; + for(Widget widget : buttons) { + if(widget instanceof GuiButtonIndexEntry) { + GuiButtonIndexEntry button = (GuiButtonIndexEntry) widget; + int id = button.ordinal; + int index = id + page * 12; + if(index >= entriesToDisplay.size()) + continue; - if(entry == entriesToDisplay.get(index)) { - orientTutorialArrowWithButton(id >= 12 ? rightButton : button); - break; + if(entry == entriesToDisplay.get(index)) { + orientTutorialArrowWithButton(id >= 12 ? rightButton : button); + break; + } } } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonIndexEntry.java similarity index 93% rename from src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java rename to src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonIndexEntry.java index 64ed5efa3..7dd2c7c60 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonIndexEntry.java @@ -24,13 +24,11 @@ import vazkii.botania.client.gui.lexicon.GuiLexiconIndex; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibMisc; -import javax.annotation.Nonnull; - -public class GuiButtonInvisible extends GuiButtonLexicon { +public class GuiButtonIndexEntry extends GuiButtonLexicon { private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); private static final IPressable ON_PRESS = b -> { - GuiButtonInvisible button = (GuiButtonInvisible) b; + GuiButtonIndexEntry button = (GuiButtonIndexEntry) b; if (button.dog) { button.enableDog = true; PersistentVariableHelper.dog = true; @@ -41,7 +39,7 @@ public class GuiButtonInvisible extends GuiButtonLexicon { } }; - private final int ordinal; + public final int ordinal; private final GuiLexiconIndex gui; public ItemStack displayStack = ItemStack.EMPTY; public boolean dog = false; @@ -50,7 +48,7 @@ public class GuiButtonInvisible extends GuiButtonLexicon { private boolean enableDog = false; private double dogPos = 0; - public GuiButtonInvisible(GuiLexiconIndex gui, int ordinal, int x, int y, int width, int height, String text) { + public GuiButtonIndexEntry(GuiLexiconIndex gui, int ordinal, int x, int y, int width, int height, String text) { super(x, y, width, height, text, ON_PRESS); this.ordinal = ordinal; this.gui = gui; diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index b0cc11517..c06b0f649 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -470,19 +470,19 @@ public final class ModBlocks { register(r, new BlockConjurationCatalyst(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.CONJURATION_CATALYST); register(r, new BlockBifrost(Block.Properties.create(Material.GLASS).hardnessAndResistance(-1, 0.3F).lightValue(15).sound(SoundType.GLASS)), LibBlockNames.BIFROST); - register(r, new BlockSolidVines(Block.Properties.create(Material.VINE).hardnessAndResistance(0.2F).sound(SoundType.PLANT)), LibBlockNames.SOLID_VINE); + register(r, new BlockSolidVines(Block.Properties.create(Material.TALL_PLANTS).hardnessAndResistance(0.2F).sound(SoundType.PLANT)), LibBlockNames.SOLID_VINE); builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT).lightValue(4); for(DyeColor color : DyeColor.values()) { register(r, new BlockBuriedPetals(color, builder), color.getName() + LibBlockNames.BURIED_PETALS_SUFFIX); } - builder = Block.Properties.create(Material.GROUND).hardnessAndResistance(0.5F).sound(SoundType.GROUND).lightValue(15); + builder = Block.Properties.create(Material.EARTH).hardnessAndResistance(0.5F).sound(SoundType.GROUND).lightValue(15); for(DyeColor color : DyeColor.values()) { register(r, new BlockFloatingFlower(color, builder), color.getName() + LibBlockNames.FLOATING_FLOWER_SUFFIX); } - register(r, new BlockTinyPotato(Block.Properties.create(Material.CLOTH).hardnessAndResistance(0.25F)), LibBlockNames.TINY_POTATO); + register(r, new BlockTinyPotato(Block.Properties.create(Material.WOOL).hardnessAndResistance(0.25F)), LibBlockNames.TINY_POTATO); register(r, new BlockSpawnerClaw(Block.Properties.create(Material.IRON).hardnessAndResistance(3)), LibBlockNames.SPAWNER_CLAW); builder = Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 5).sound(SoundType.STONE); @@ -506,9 +506,9 @@ public final class ModBlocks { register(r, new BlockRedStringComparator(builder), LibBlockNames.RED_STRING_COMPARATOR); register(r, new BlockRedStringRelay(builder), LibBlockNames.RED_STRING_RELAY); register(r, new BlockRedStringInterceptor(builder), LibBlockNames.RED_STRING_INTERCEPTOR); - register(r, new BlockManaFlame(Block.Properties.create(Material.CLOTH).sound(SoundType.CLOTH).lightValue(15).doesNotBlockMovement()), LibBlockNames.MANA_FLAME); + register(r, new BlockManaFlame(Block.Properties.create(Material.WOOL).sound(SoundType.CLOTH).lightValue(15).doesNotBlockMovement()), LibBlockNames.MANA_FLAME); register(r, new BlockPrism(Block.Properties.create(Material.GLASS).hardnessAndResistance(0.3F).sound(SoundType.GLASS).lightValue(15).doesNotBlockMovement()), LibBlockNames.PRISM); - register(r, new BlockEnchantedSoil(Block.Properties.create(Material.GRASS).hardnessAndResistance(0.6F).sound(SoundType.PLANT)), LibBlockNames.ENCHANTED_SOIL); + register(r, new BlockEnchantedSoil(Block.Properties.create(Material.ORGANIC).hardnessAndResistance(0.6F).sound(SoundType.PLANT)), LibBlockNames.ENCHANTED_SOIL); builder = Block.Properties.create(Material.PLANTS).hardnessAndResistance(0.4F).sound(SoundType.PLANT); for(DyeColor color : DyeColor.values()) { @@ -525,7 +525,7 @@ public final class ModBlocks { register(r, new BlockPump(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.PUMP); - builder = Block.Properties.create(Material.VINE).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT); + builder = Block.Properties.create(Material.TALL_PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT); for(DyeColor color : DyeColor.values()) { register(r, new BlockModDoubleFlower(color, builder), color.getName() + LibBlockNames.DOUBLE_FLOWER_SUFFIX); } @@ -536,11 +536,11 @@ public final class ModBlocks { register(r, new BlockCorporeaCrystalCube(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_CRYSTAL_CUBE); register(r, new BlockIncensePlate(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.INCENSE_PLATE); register(r, new BlockHourglass(Block.Properties.create(Material.IRON).hardnessAndResistance(2).sound(SoundType.METAL)), LibBlockNames.HOURGLASS); - register(r, new BlockGhostRail(Block.Properties.create(Material.CIRCUITS).doesNotBlockMovement().hardnessAndResistance(0.7F).sound(SoundType.METAL)), LibBlockNames.GHOST_RAIL); + register(r, new BlockGhostRail(Block.Properties.create(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0.7F).sound(SoundType.METAL)), LibBlockNames.GHOST_RAIL); register(r, new BlockSparkChanger(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.SPARK_CHANGER); register(r, new BlockRoot(Block.Properties.create(Material.PLANTS).hardnessAndResistance(1.2F).sound(SoundType.WOOD)), LibBlockNames.ROOT); register(r, new BlockFelPumpkin(Block.Properties.from(Blocks.CARVED_PUMPKIN)), LibBlockNames.FEL_PUMPKIN); - register(r, new BlockCocoon(Block.Properties.create(Material.CLOTH).hardnessAndResistance(3, 60).sound(SoundType.CLOTH)), LibBlockNames.COCOON); + register(r, new BlockCocoon(Block.Properties.create(Material.WOOL).hardnessAndResistance(3, 60).sound(SoundType.CLOTH)), LibBlockNames.COCOON); builder = Block.Properties.create(Material.GLASS).doesNotBlockMovement(); register(r, new BlockLightRelay(LuminizerVariant.DEFAULT, builder), LibBlockNames.LIGHT_RELAY); @@ -554,21 +554,21 @@ public final class ModBlocks { register(r, new BlockBellows(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.BELLOWS); register(r, new BlockBifrostPerm(Block.Properties.create(Material.GLASS).hardnessAndResistance(0.3F).lightValue(15).sound(SoundType.GLASS)), LibBlockNames.BIFROST_PERM); register(r, new BlockCell(Block.Properties.create(Material.GOURD).sound(SoundType.CLOTH)), LibBlockNames.CELL_BLOCK); - register(r, new BlockGaiaHeadWall(Block.Properties.create(Material.CIRCUITS).hardnessAndResistance(1)), LibBlockNames.GAIA_WALL_HEAD); - register(r, new BlockGaiaHead(Block.Properties.create(Material.CIRCUITS).hardnessAndResistance(1)), LibBlockNames.GAIA_HEAD); + register(r, new BlockGaiaHeadWall(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1)), LibBlockNames.GAIA_WALL_HEAD); + register(r, new BlockGaiaHead(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1)), LibBlockNames.GAIA_HEAD); register(r, new BlockCorporeaRetainer(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_RETAINER); - register(r, new BlockTeruTeruBozu(Block.Properties.create(Material.CLOTH)), LibBlockNames.TERU_TERU_BOZU); + register(r, new BlockTeruTeruBozu(Block.Properties.create(Material.WOOL)), LibBlockNames.TERU_TERU_BOZU); ILexiconable rainbowRod = (w, po, pl, st) -> LexiconData.rainbowRod; register(r, new BlockModLexiconable(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE), rainbowRod), LibBlockNames.SHIMMERROCK); register(r, new BlockModLexiconable(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD), rainbowRod), LibBlockNames.SHIMMERWOOD_PLANKS); register(r, new BlockAvatar(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.AVATAR); - builder = Block.Properties.create(Material.GRASS).hardnessAndResistance(0.6F).tickRandomly().sound(SoundType.PLANT); + builder = Block.Properties.create(Material.ORGANIC).hardnessAndResistance(0.6F).tickRandomly().sound(SoundType.PLANT); for(BlockAltGrass.Variant v : BlockAltGrass.Variant.values()) { register(r, new BlockAltGrass(v, builder), v.name().toLowerCase(Locale.ROOT) + LibBlockNames.ALT_GRASS_SUFFIX); } - register(r, new BlockAnimatedTorch(Block.Properties.create(Material.CIRCUITS).lightValue(7)), LibBlockNames.ANIMATED_TORCH); + register(r, new BlockAnimatedTorch(Block.Properties.create(Material.MISCELLANEOUS).lightValue(7)), LibBlockNames.ANIMATED_TORCH); } @SubscribeEvent diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java index ae096fe3f..0f4d22813 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java @@ -20,6 +20,7 @@ import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; @@ -38,8 +39,8 @@ public class ItemCrystalBow extends ItemLivingwoodBow { @Override boolean canFire(ItemStack stack, PlayerEntity player) { - int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack); - return player.abilities.isCreativeMode || ManaItemHandler.requestManaExactForTool(stack, player, ARROW_COST / (infinity + 1), false); + boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; + return player.abilities.isCreativeMode || ManaItemHandler.requestManaExactForTool(stack, player, ARROW_COST / (infinity ? 2 : 1), false); } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java index fd22b8376..e2d98a3e5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java @@ -40,8 +40,6 @@ import javax.annotation.Nonnull; import java.util.function.Predicate; public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { - - private static final Predicate AMMO_FUNC = s -> !s.isEmpty() && s.getItem() instanceof ArrowItem; public static final int MANA_PER_DAMAGE = 40; public ItemLivingwoodBow(Properties builder) { @@ -59,99 +57,88 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { }); } + // [VanillaCopy] super @Nonnull @Override - public ActionResult onItemRightClick(@Nonnull World world, PlayerEntity player, @Nonnull Hand hand) { - ItemStack stack = player.getHeldItem(hand); - // Copy from superclass with our own check - boolean flag = canFire(stack, player); - ActionResult ret = ForgeEventFactory.onArrowNock(stack, world, player, hand, flag); + public ActionResult onItemRightClick(@Nonnull World worldIn, PlayerEntity playerIn, @Nonnull Hand handIn) { + ItemStack itemstack = playerIn.getHeldItem(handIn); + boolean flag = canFire(itemstack, playerIn); // Botania - custom check + + ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, worldIn, playerIn, handIn, flag); if (ret != null) return ret; - if (!player.abilities.isCreativeMode && !flag) - { - return new ActionResult<>(ActionResultType.FAIL, stack); - } - else - { - player.setActiveHand(hand); - return new ActionResult<>(ActionResultType.SUCCESS, stack); + if (!playerIn.abilities.isCreativeMode && !flag) { + return flag ? new ActionResult<>(ActionResultType.PASS, itemstack) : new ActionResult<>(ActionResultType.FAIL, itemstack); + } else { + playerIn.setActiveHand(handIn); + return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } } + // [VanillaCopy] super @Override - public void onPlayerStoppedUsing(@Nonnull ItemStack stack, @Nonnull World world, LivingEntity shooter, int useTicks) { - PlayerEntity player = (PlayerEntity) shooter; + public void onPlayerStoppedUsing(@Nonnull ItemStack stack, @Nonnull World worldIn, LivingEntity entityLiving, int timeLeft) { + if (entityLiving instanceof PlayerEntity) { + PlayerEntity playerentity = (PlayerEntity)entityLiving; + boolean flag = canFire(stack, playerentity); // Botania - custom check + ItemStack itemstack = playerentity.func_213356_f(stack); - // Begin copy modified ItemBow.onPlayerStoppedUsing - boolean flag = canFire(stack, player); // Botania - Custom canFire check - ItemStack itemstack = getAmmo(player); + int i = (int) ((getUseDuration(stack) - timeLeft) * chargeVelocityMultiplier()); // Botania - velocity multiplier + i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, playerentity, i, !itemstack.isEmpty() || flag); + if (i < 0) return; - int i = (int) ((getUseDuration(stack) - useTicks) * chargeVelocityMultiplier()); // Botania - velocity multiplier - i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, world, player, i, !itemstack.isEmpty() || flag); - if (i < 0) return; - - if (!itemstack.isEmpty() || flag) - { - if (itemstack.isEmpty()) - { - itemstack = new ItemStack(Items.ARROW); - } - - float f = getArrowVelocity(i); - - if (f >= 0.1D) - { - boolean infinite = player.abilities.isCreativeMode || (itemstack.getItem() instanceof ArrowItem ? ((ArrowItem)itemstack.getItem()).isInfinite(itemstack, stack, player) : false); - - if (!world.isRemote) - { - ArrowItem itemarrow = (ArrowItem) (itemstack.getItem() instanceof ArrowItem ? itemstack.getItem() : Items.ARROW); - AbstractArrowEntity entityarrow = itemarrow.createArrow(world, itemstack, shooter); - entityarrow.shoot(shooter, shooter.rotationPitch, shooter.rotationYaw, 0.0F, f * 3.0F, 1.0F); - - if (f == 1.0F) - { - entityarrow.setIsCritical(true); - } - - int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); - - if (j > 0) - { - entityarrow.setDamage(entityarrow.getDamage() + j * 0.5D + 0.5D); - } - - int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - - if (k > 0) - { - entityarrow.setKnockbackStrength(k); - } - - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) - { - entityarrow.setFire(100); - } - - // Botania - move bow damage into onFire (below) - - if (infinite) - { - entityarrow.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY; - } - - world.addEntity(entityarrow); - onFire(stack, shooter, infinite, entityarrow); + if (!itemstack.isEmpty() || flag) { + if (itemstack.isEmpty()) { + itemstack = new ItemStack(Items.ARROW); } + float f = getArrowVelocity(i); + if (!((double)f < 0.1D)) { + boolean flag1 = playerentity.abilities.isCreativeMode || (itemstack.getItem() instanceof ArrowItem && ((ArrowItem)itemstack.getItem()).isInfinite(itemstack, stack, playerentity)); + if (!worldIn.isRemote) { + ArrowItem arrowitem = (ArrowItem)(itemstack.getItem() instanceof ArrowItem ? itemstack.getItem() : Items.ARROW); + AbstractArrowEntity abstractarrowentity = arrowitem.createArrow(worldIn, itemstack, playerentity); + abstractarrowentity = customeArrow(abstractarrowentity); + abstractarrowentity.shoot(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, f * 3.0F, 1.0F); + if (f == 1.0F) { + abstractarrowentity.setIsCritical(true); + } - world.playSound(null, shooter.posX, shooter.posY, shooter.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); + if (j > 0) { + abstractarrowentity.setDamage(abstractarrowentity.getDamage() + (double)j * 0.5D + 0.5D); + } - player.addStat(Stats.ITEM_USED.get(this)); + int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); + if (k > 0) { + abstractarrowentity.setKnockbackStrength(k); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { + abstractarrowentity.setFire(100); + } + + // Botania - move damage into onFire + onFire(stack, playerentity, flag1, abstractarrowentity); + if (flag1 || playerentity.abilities.isCreativeMode && (itemstack.getItem() == Items.SPECTRAL_ARROW || itemstack.getItem() == Items.TIPPED_ARROW)) { + abstractarrowentity.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY; + } + + worldIn.addEntity(abstractarrowentity); + } + + worldIn.playSound((PlayerEntity)null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + if (!flag1 && !playerentity.abilities.isCreativeMode) { + itemstack.shrink(1); + if (itemstack.isEmpty()) { + playerentity.inventory.deleteStack(itemstack); + } + } + + playerentity.addStat(Stats.ITEM_USED.get(this)); + } } } - // End modified ItemBow.onPlayerStoppedUsing } float chargeVelocityMultiplier() { @@ -159,16 +146,13 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { } boolean canFire(ItemStack stack, PlayerEntity player) { - return player.abilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0 || PlayerHelper.hasAmmo(player, AMMO_FUNC); + return player.abilities.isCreativeMode + || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0 + || !player.func_213356_f(stack).isEmpty(); } void onFire(ItemStack bow, LivingEntity living, boolean infinity, AbstractArrowEntity arrow) { - if(living instanceof ServerPlayerEntity) { - ToolCommons.damageItem(bow, 1, living, MANA_PER_DAMAGE); - - if(((ServerPlayerEntity) living).interactionManager.getGameType().isSurvivalOrAdventure() && !infinity) - PlayerHelper.consumeAmmo((ServerPlayerEntity) living, AMMO_FUNC); - } + ToolCommons.damageItem(bow, 1, living, MANA_PER_DAMAGE); } @Override @@ -186,19 +170,4 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { public boolean usesMana(ItemStack stack) { return true; } - - private ItemStack getAmmo(PlayerEntity player) { - if(isArrow(player.getHeldItem(Hand.OFF_HAND))) - return player.getHeldItem(Hand.OFF_HAND); - else if(isArrow(player.getHeldItem(Hand.MAIN_HAND))) - return player.getHeldItem(Hand.MAIN_HAND); - else for(int i = 0; i < player.inventory.getSizeInventory(); ++i) { - ItemStack itemstack = player.inventory.getStackInSlot(i); - - if (isArrow(itemstack)) - return itemstack; - } - - return ItemStack.EMPTY; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMine.java b/src/main/java/vazkii/botania/common/item/lens/LensMine.java index ae3fccbf0..75983bec2 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMine.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMine.java @@ -67,7 +67,6 @@ public class LensMine extends Lens { if(!burst.hasAlreadyCollidedAt(collidePos)) { if(!burst.isFake()) { List items = Block.getDrops(state, (ServerWorld) world, collidePos, tile); - float chance = net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, world, collidePos, state, 0, 1.0f, false, null); world.removeBlock(collidePos, false); if(ConfigHandler.COMMON.blockBreakParticles.get()) @@ -78,8 +77,7 @@ public class LensMine extends Lens { BlockPos dropCoord = doWarp ? source : collidePos; for(ItemStack stack_ : items) { - if(world.rand.nextFloat() <= chance) - Block.spawnAsEntity(world, dropCoord, stack_); + Block.spawnAsEntity(world, dropCoord, stack_); } burst.setMana(mana - 24); diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java index 7721dc694..c4f8cfc29 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java @@ -187,13 +187,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra BlockPos adjPos = pos_.offset(dir); BlockState adjState = world.getBlockState(adjPos); - // If the side of the adjacent block facing this block is - // _not_ solid, then this block is considered "visible" - // and should be replaced. - - // If there is a rendering-specific way to check for this, - // that should be placed in preference to this. - if(adjState.getBlockFaceShape(world, adjPos, dir.getOpposite()) != BlockFaceShape.SOLID) { + if(!Block.hasSolidSide(adjState, world, adjPos, dir.getOpposite())) { coordsList.add(pos_); break; }